jQuery.noConflict(); jQuery(function($) { var smallonly = window.innerWidth <= 640; var $subscribeModal = $('#subscribeModal'), $dynamicModal = $('#dynamicModal'), $autoAlert = $('#autoAlert'); $('li.menu-item.subscribe a, footer .fbox.cta a.button').on({ 'click': function(e) { e.preventDefault(); $subscribeModal.data('opened','manual').foundation('reveal','open','/modal/subscribe/'); } }); visitorLocation = new geolocate('visitorLocation'); var geocallback = function() { var excludes = []; excludes.push('/blt/'); excludes.push('/clamp/'); excludes.push('/germany/'); excludes.push('/preorder/'); excludes.push('/2017/01/urb-e-sport-pre-order-begins-today/'); excludes.push('/2017/02/urb-e-pandora-activation/'); excludes.push('/2017/01/urb-e-press-reel-ces-detroit-auto-show-2017/'); excludes.push('/2017/02/facebook-live-session-february-8/'); excludes.push('/2017/02/presidents/'); excludes.push('/metrolink/'); excludes.push('/sxsw-2017-urb-e/'); excludes.push('/2017/03/urb-e-featured-cnbc/'); excludes.push('/2017/04/urb-e-austin-texas-saving-time-money-commuting/'); excludes.push('/2017/04/eddy-mobile-power-source-urb-e-sport/'); excludes.push('/2017/04/urb-e-san-francisco-video/'); excludes.push('/2017/04/urb-e-cheddar-com-live-madison-square-park/'); excludes.push('/2017/04/urb-e-new-2018-audi-q5-commercial/'); excludes.push('/letsfly/'); excludes.push('/2017/04/urb-e-fox-news-new-york-city/'); excludes.push('/2017/04/urb-e-pro-gt-casey-neistat-sean-avery-new-york-city/'); excludes.push('/2017/04/urb-e-celebrating-earth-day-via-cbs-san-diego/'); excludes.push('/2017/04/bestproducts-com-featured-urb-e-new-york-city/'); excludes.push('/2017/05/may-the-4th-be-with-you/'); excludes.push('/2017/05/urb-e-sport-launch-party-video/'); excludes.push('/2017/06/urb-e-testimonial-15-hours-research-paul/'); excludes.push('/2017/06/urb-e-testimonial-saving-money-la-casey/'); excludes.push('/2017/06/urb-e-testimonial-saving-time-nyc-saraswati/'); var excluded = excludes.indexOf(window.location.pathname) > -1; if (excluded) return; var showModal = 'subscribe'; var $autoModal = $subscribeModal; var delay = smallonly ? 35000 : 20000; var expiryMinutes = 240; var hasCityRide = Cookies.get('cmlcridess1') == '1'; var modalTimer; if (!hasCityRide && ('New York' == visitorLocation.getField('city') && 'NY' == visitorLocation.getField('region_code'))) { showModal = 'nycrides20160628'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('Dallas' == visitorLocation.getField('city') && 'TX' == visitorLocation.getField('region_code'))) { showModal = 'dallasrides20161113'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('Houston' == visitorLocation.getField('city') && 'TX' == visitorLocation.getField('region_code'))) { showModal = 'houstonrides20161113'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('Detroit' == visitorLocation.getField('city') && 'MI' == visitorLocation.getField('region_code'))) { showModal = 'detroit20170207'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('515' == visitorLocation.getField('metro_code'))) { showModal = 'cincinnati20160916'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('751' == visitorLocation.getField('metro_code'))) { showModal = 'denver20160916'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('506' == visitorLocation.getField('metro_code'))) { showModal = 'boston20160916'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('528' == visitorLocation.getField('metro_code'))) { showModal = 'miami20160916'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('511' == visitorLocation.getField('metro_code'))) { showModal = 'washingtondc20160916'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('807' == visitorLocation.getField('metro_code'))) { showModal = 'sanfranrides20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('803' == visitorLocation.getField('metro_code'))) { showModal = 'larides20160627'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('602' == visitorLocation.getField('metro_code'))) { showModal = 'chicagorides20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('635' == visitorLocation.getField('metro_code'))) { showModal = 'austinrides20160706'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('819' == visitorLocation.getField('metro_code'))) { showModal = 'seattlerides20160628'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if (!hasCityRide && ('804' == visitorLocation.getField('metro_code'))) { showModal = 'palmsprings20161004'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 240; } else if ('HI' == visitorLocation.getField('region_code')) { showModal = 'hawaiiship20160622'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('AUS' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'ausship20160729'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('AUT' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'austship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('BEL' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'belship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('BGR' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'bgrship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('CAN' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'canship20160729'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('HRV' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'hrvship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('CZE' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'czeship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('DNK' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'dnkship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('EST' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'estship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('FIN' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'finship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('FRA' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'fraship20160630'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('DEU' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'deuship20160624'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('GRC' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'grcship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('HUN' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'hunship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('IRL' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'irlship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('ITA' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'itaship20160701'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('LVA' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'lvaship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('LTU' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'ltuship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('LUX' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'luxship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('MLT' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'mltship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('NLD' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'nldship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('PRT' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'prtship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('POL' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'polship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('CYP' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'cypship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('ROU' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'rouship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('SVK' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'svkship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('SVN' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'svnship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('ESP' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'espship20160624'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('SWE' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'sweship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('CHE' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'cheship20160715'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('GBR' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'ukship20160621'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('NZL' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'newzealandship20161110'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } else if ('ISR' == visitorLocation.getField('country_code_iso3166alpha3')) { showModal = 'israelship20161110'; $autoModal = $dynamicModal; delay = smallonly ? 35000 : 20000; expiryMinutes = 720; } var hasSubscribed = Cookies.get('cmlsubss1') == '1'; var defaultModal = $autoModal.is($subscribeModal); var skipModal = ((hasSubscribed || ('/newsletter/' == window.location.pathname)) && defaultModal); var ignoredModal = Cookies.get('cmlignoremodal1'); var useAlert = (!defaultModal && (ignoredModal == showModal)); $autoModal.data('opened','manual'); $autoModal.bind('closed.fndtn.reveal', function () { console.log('autoModal ['+showModal+'] dismissed - from ' + $autoModal.data('opened')); dataLayer.push({ 'event': 'gaTriggerEvent', 'gaEventCategory': 'Modal', 'gaEventAction': 'dismissed ('+$autoModal.data('opened')+')', 'gaEventLabel': showModal }); $autoModal.removeData('opened'); }); $autoModal.bind('open.fndtn.reveal', function() { console.log('autoModal ['+showModal+'] open - from ' + $autoModal.data('opened')); clearTimeout(modalTimer); Cookies.set('cmlignoremodal1', showModal, { expires: expiryMinutes/60/24 }); dataLayer.push({ 'event': 'gaTriggerEvent', 'gaEventCategory': 'Modal', 'gaEventAction': 'opened ('+$autoModal.data('opened')+')', 'gaEventLabel': showModal }); }); if (!defaultModal) { $autoAlert.on('click', function () { $autoAlert.removeClass('active'); $autoModal.data('opened','alert').foundation('reveal','open','/modal/'+showModal+'/'); }); $autoModal.bind('closed.fndtn.reveal', function () { $autoAlert.addClass('active'); }); } if (ignoredModal !== showModal) { if (!skipModal) { modalTimer = setTimeout(function() { $autoModal.data('opened','timer '+delay).foundation('reveal','open','/modal/'+showModal+'/'); }, delay); } } else { if (useAlert) { $autoAlert.addClass('active'); } } }; visitorLocation.checkcookie(geocallback); });