/** * v1.0 - Copyright 2014 Madden Media - All rights reserved. * * Advanced Google Analytics tracking script that tracks starting reading, 25%, * 50%, 75% and completion. This is otherwise a duplicate of: * * madden-ga-track-start-end-v1.0.js * * This duplication is in place to reduce configuration work for callers. * * Requires Google Analytics and jQuery. This script will determine which analytics * object (universal, legacy, etc.) seems to be present and will adjust tracking * calls based on this. */ // safe console log if (typeof console == "undefined"){console={};console.log = function(){return;}} jQuery(function($) { // Debug flags var debugMode = false; var logOutput = false; // Default time delay before checking location var callBackTime = 100; // percent of the page where reader events fire // at (use decimals < 1 - i.e. .25) - use .0001 for "start of page" var readerLocationPercents = [.0001, .25, .5, .75]; // # px before tracking a reader (will be assigned based on readerLocationPercents) var readerLocations = [ ]; // how far have they made it (this will be managed by the script) var readerLastPassed = 0; // Set some flags for tracking & execution var timer = 0; var isScrolling = false; var endContent = false; var didComplete = false; // Set some time variables to calculate reading time var startTime = new Date(); var beginning = startTime.getTime(); var totalTime = 0; // Check the location and track user function trackLocation () { // positions var curWinBottom = ($(window).height() + $(window).scrollTop()); var height = $(document).height(); // figure out scroll time var currentTime = new Date(); var timeToScroll = Math.round((currentTime.getTime() - beginning) / 1000); // If user starts to scroll send an event (if it's at a tracking point) for (i=readerLastPassed; i < readerLocations.length; i++) { // run location test if ( (curWinBottom >= readerLocations[i]) && (timeToScroll > 0) ) { // set label var label = makeReadingEventLabel(readerLocationPercents[i]); // send the event sendEvent('Reading', label, timeToScroll, location.pathname); // log it log('READING: ' + readerLocations[i] + " / " + label + " / " + timeToScroll); // note what they've tracked readerLastPassed = (i + 1); } } // if user has hit the bottom of page send an event if ( (curWinBottom >= height) && (! didComplete) ) { currentTime = new Date(); // figure out scroll time var currentTime = new Date(); var timeToScroll = Math.round((currentTime.getTime() - beginning) / 1000); // set label var label = makeReadingEventLabel(1); // send the event sendEvent('Reading', label, timeToScroll, location.pathname); // log it log('READING: ' + label + " / " + timeToScroll); didComplete = true; } } // figure out how tall our page is and adjust reader location to be a percent of that function adjustReaderLocation (percent) { var docHeight = $(document).height(); var adjHeight = Math.floor(docHeight * percent); return adjHeight; } // util function to make a pretty reading label string function makeReadingEventLabel (raw) { var lbl = ""; if (raw < .001) { lbl = "StartReading"; } else if (raw == 1) { lbl = "ContentBottom"; } else { lbl = ("Reading " + (raw * 100) + "%"); } return lbl; } // a log wrapper to check if we want it logged first function log (msg) { if (logOutput) { console.log(msg); } } // sends the event to whichever object we seem to have found function sendEvent (eventCategory, eventAction, eventValue, page) { if (debugMode) { // MAY EXIT THIS BLOCK return; } // test for any given analytics type if (typeof _gaq != "undefined") { // legacy analytics if (typeof pageTracker != "undefined") { // "traditional syntax" pageTracker._trackEvent(eventCategory, eventAction, page, eventValue); } else { // "asynchronous syntax" _gaq.push(['_trackEvent', eventCategory, eventAction, page, eventValue]); _gaq.push(['pageTracker._trackEvent', eventCategory, eventAction, page, eventValue]); } } else if (typeof ga != "undefined") { // universal analytics ga('send', { 'hitType': 'event', 'eventCategory': eventCategory, 'eventAction': eventAction, 'eventLabel': page, 'eventValue': eventValue }); } } // determine reader % locations function determineReaderLocations () { for (i=0; i < readerLocationPercents.length; i++) { readerLocations[i] = adjustReaderLocation(readerLocationPercents[i]); // log it log('LOCATION: ' + readerLocationPercents[i] + ' (' + readerLocations[i] + ' / ' + $(document).height() + ')'); } } // assign all percent sizes based on height of page $(window).load(function() { determineReaderLocations(); }); // reassign all percent sizes based on height of page $(window).resize(function() { determineReaderLocations(); }); // Track the scrolling and track location $(window).scroll(function() { if (timer) { clearTimeout(timer); } // Use a buffer so we don't call trackLocation too often. timer = setTimeout(trackLocation, callBackTime); }); }); /* * v1.0 * * Automatically track outbound links in Google Analytics. Any link that you do not want tracked * can be assigned a "noGA" class and it will not be skipped here. * * CREDIT: http://www.sitepoint.com/track-outbound-links-google-analytics/ * * Modified to support ability for links to open in new window w/o triggering a popup warning */ // just logging this to console for developers to see if (typeof console != "undefined") { console.log("%c NOTICE: madden-ga-exit-track-v1.0.js is deprecated - please use the latest version.", "background:orange; color:black"); } (function($) { "use strict"; // default no tracking class var defaultNoTrackClass = "noGA"; // current page host var baseURI = window.location.host; // click event on body $("body").on("click", function(e) { // abandon if link already aborted or analytics is not available if (e.isDefaultPrevented() || typeof ga !== "function") return; // abandon if no active link or link within domain var link = $(e.target).closest("a"); if (link.length != 1 || baseURI == link[0].host) return; // check the link to see if it should not be tracked if ( (link.attr("class") == undefined) || (link.attr("class").indexOf(defaultNoTrackClass) != -1) ) { return; } // cancel event and record outbound link e.preventDefault(); var href = link[0].href; var target = link[0].target; if (target != "") { // gets us around popup blocking $(link[0]).on("click", function(){ var w = window.open(href, target); trackEvent(href, false); return false; }); $(link[0]).click(); } else { trackEvent(href, true); // in case hit callback bogs down setTimeout(function() { self.location.href = href; }, 1000); } // track the event function trackEvent (href, runHitCallback) { ga('send', { 'hitType': 'event', 'eventCategory': 'outbound', 'eventAction': 'link', 'eventLabel': href, 'hitCallback': (runHitCallback) ? function() { self.location.href = href; } : function() { return false; } }); } }); })(jQuery); /** * v1.2 - Copyright 2015 Madden Media - All rights reserved. * * A set of parallax design functionality. */ !function(a){"use strict";a.fn.parallaxBG=function(b){var c=a(window).height(),d=0,e=a(window).scrollTop(),f=0,g=0,h=a.extend({adjustX:0,adjustY:0,bgXOffset:0,bgYOffset:0,bgXPosition:"100%",bgYPosition:"100%"},b);return this.each(function(){var b=a(this);a(window).scroll(function(){var i=h.bgXAdjust,j=b.css("backgroundPosition").split(" ");parseInt(j[0]);if(e=a(window).scrollTop(),f=b.offset().top,g=b.outerHeight(),e=e+c)){var l=0==h.adjustX?h.bgXPosition:Math.round((f-e)*h.adjustX)+0+h.bgXOffset+"px",m=0==h.adjustY?h.bgYPosition:Math.round((f-e)*h.adjustY)+0+h.bgYOffset+"px";b.css("background-position",l+" "+m)}})})},a.fn.parallaxLockElement=function(b){var c=!1,d=a.extend({parentEl:"",offsetTop:0,additionalCSS:void 0,onLock:void 0,onRelease:void 0},b);return this.each(function(){var b=a(this),e=a(d.parentEl);a(window).scroll(function(){var f=parseInt(e.offset().top-a(window).scrollTop()-d.offsetTop),g=e.offset().top+e.outerHeight(),i=(parseInt(b.outerHeight()),e.offset().top+e.outerHeight()-(b.offset().top+b.outerHeight()));f<=0?g+i<=a(window).scrollTop()+a(window).innerHeight()?c&&(c=!1,b.css({position:"absolute",top:"inherit",bottom:i+"px"}),"function"==typeof d.onRelease&&d.onRelease(this)):(b.css({position:"fixed",top:d.offsetTop+"px",bottom:"auto"}),"function"==typeof d.onLock&&d.onLock(this),c=!0):(b.css({position:"relative",top:"auto"}),"function"==typeof d.onRelease&&d.onRelease(this),c=!1),void 0!=d.additionalCSS&&b.css(d.additionalCSS)})})},a.fn.parallaxAnimateElement=function(b){var c=new Array,d=0,e=0,f=!1,g=a.extend({frames:1,elementClass:"floatingElement",elementFrameClassRoot:"frame",startOffset:null,endOffset:null,showWhenCentered:!1,centerOffsetAnimationRange:null,lock:!1,parentEl:"",offsetTop:0,additionalCSS:void 0,onLock:void 0,onRelease:void 0},b);g.lock?a(this).parallaxLockElement({parentEl:g.parentEl,offsetTop:g.offsetTop,additionalCSS:g.additionalCSS,onLock:g.onLock,onRelease:g.onRelease}):f=!0;var h=parseInt(a(this).parent().height());if(g.showWhenCentered)null==g.centerOffsetAnimationRange?g.centerOffsetAnimationRange=1:g.centerOffsetAnimationRange.indexOf("%")!=-1?g.centerOffsetAnimationRange=parseInt(g.centerOffsetAnimationRange)/100:g.centerOffsetAnimationRange=1;else{if(null!=g.startOffset)if(g.startOffset.indexOf("%")!=-1){var i=parseInt(g.startOffset)/100;d=Math.floor(h*i)}else{var i=parseInt(g.startOffset);d=i}if(null!=g.endOffset)if(g.endOffset.indexOf("%")!=-1){var i=parseInt(g.endOffset)/100;e=Math.floor(h-h*i)}else{var i=parseInt(g.endOffset);e=i}0==d&&0==e||(h=h-e-d);for(var j=h/g.frames,k=1;k<=g.frames;k++)c.push(Math.floor(d+j*k));f&&void 0!=g.additionalCSS&&a(this).css(g.additionalCSS)}return this.each(function(){var b=a(this),d=c.length,e=g.showWhenCentered?a(this).height()*g.centerOffsetAnimationRange:a(this).height();a(window).scroll(function(){var f=b.offset().top,h=!(f+b.outerHeight()<=a(window).scrollTop()||f>=a(window).scrollTop()+a(window).height());if(h){if(g.showWhenCentered){var i=parseInt(b.offset().top-a(window).scrollTop()),j=parseInt(i+e/2),k=parseInt(a(window).innerHeight()/2),l=parseInt(j-e),m=parseInt(j+e);if(k=l&&k<=m){var n=Math.max(0,Math.min(1,1-(l+(j-k))/j));d=Math.ceil(g.frames*n)}else d=g.frames}else for(var o=parseInt(b.parent().offset().top-a(window).scrollTop()),p=o*-1+e/2,q=0;q * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * @author: Kevin Thompson * @link: https://github.com/kevinthompson/jquery.sticky.js * @version: 2.0.0 **/ (function(e){e.fn.sticky=function(t){var n={offset:20,mode:"fixed",stopper:"",speed:500,classes:{element:"jquery-sticky-element",start:"jquery-sticky-start",sticky:"jquery-sticky-sticky",stopped:"jquery-sticky-stopped",placeholder:"jquery-sticky-placeholder"},onStick:"",onStart:"",onStop:""};this.each(function(){if(t)e.extend(n,t);if(e(this).parent().hasClass(n.classes.element))return;var r={init:function(t){r.element=t.wrap('
').parent();r.units={start:r.element.offset().top};n.states=[n.classes.start,n.classes.sticky,n.classes.stopped].join(" ");if(n.stopper!=""){var s=e(n.stopper),o;if(s.length>0){for(i=0;ir.element.offset().top+r.element.outerHeight(false)){r.stopper=e(s[i])}}}if(typeof r.stopper!="undefined"&&r.stopper.length>0){o=parseInt(r.stopper.css("margin-top"))||0;r.units.stop=r.stopper.offset().top-o}}r.placeholder=r.element.clone().empty().attr("class",n.classes.placeholder).css({opacity:0,height:r.element.height()}).insertBefore(r.element);r.element.appendTo("body").css({width:r.placeholder.width(),left:r.placeholder.offset().left,top:r.placeholder.offset().top,"margin-bottom":"0px",position:"absolute","z-index":"999"});e(window).bind("resize scroll",function(){r.update()});r.update()},update:function(){var t;r.element.css({width:r.placeholder.width(),left:r.placeholder.offset().left});r.placeholder.css("height",r.element.height());r.units.start=r.placeholder.offset().top;if(r.element.outerHeight(false)+n.offset0){t=parseInt(r.stopper.css("margin-top"))||0;r.units.stop=r.stopper.offset().top-t}if(!r.element.hasClass(n.classes.stopped)&&typeof r.stopper!="undefined"&&r.stopper.length>0&&r.units.doctop+n.offset+r.element.outerHeight(false)>=r.units.stop){r.stop(r.units.stop-r.element.outerHeight(false),"stop");if(typeof n.onStop=="function")n.onStop()}else if(!r.element.hasClass(n.classes.sticky)&&r.units.doctop>r.units.start-n.offset&&(typeof r.stopper=="undefined"||r.stopper.length==0||r.stopper.length>0&&r.units.doctop+n.offset+r.element.outerHeight(false)=r.units.stop){e=r.units.stop-r.element.outerHeight(false)}else if(e<=r.units.start){e=r.units.start}r.element.stop().animate({top:e},n.speed)},100)},stick:function(e){r.element.removeClass(n.states).addClass(n.classes.sticky);if(n.mode=="fixed"){r.element.css({top:e,position:"fixed"})}},stop:function(e,t){r.element.removeClass(n.states).addClass(t=="start"?n.classes.start:n.classes.stopped);if(n.mode=="fixed"){r.element.css({top:e,position:"absolute"})}else{r.animate(t=="start"?r.units.start:r.units.stop-r.element.outerHeight(false))}}};r.init(e(this))})}})(jQuery) /** * v1.2 - Copyright 2014 Madden Media - All rights reserved. * * Global frameworks functions for all content. */ "undefined"!=typeof console&&console.log("%c NOTICE: madden-content-frameworks-v1.2.js is deprecated - please use the latest version.","background:orange; color:black");var _stickyTopBarHeight=0,_stickyTopBarOffset=0,_chapterTops=new Array,_onChapter=0,_setChapterLinkCallback,_chapterSetCompleteCallback,_stickyTopBarEl="#topBar",_stickyTopBarProgressBarEl,_mobileMenuEl="#mobileMenu",_socialMenuTriggerEl="#socialLinksTrigger",_topAndMobileMenuControl="#controlsTrigger",_chapterEl=".chapter",_chapterLinkEl=".chapterLink",_chapterElPrefix="#c",_multiSizeImageEl=".multiSize",_readMoreEl=void 0,DEFAULT_MOBILE_TEST_EL="#isMobile",DEFAULT_TABLET_TEST_EL="#isTablet",DEFAULT_PARALLAX_TEST_EL="#doParallax",IS_RESPONSIVE=document.addEventListener,_isMobile=!1,_isTablet=!1,_doParallax=!1;frameworksOnReady=function(a,b,c){initViewTypes(),initLayout(a,b,c)},frameworksOnScroll=function(){adjustScrollProgress()},frameworksOnTouchMove=function(){adjustScrollProgress()},frameworksOnResize=function(){initViewTypes(),adjustLayoutAfterResize()},initViewTypes=function(){_isMobile=0!=$(DEFAULT_MOBILE_TEST_EL).length&&"none"!=$(DEFAULT_MOBILE_TEST_EL).css("float"),_isTablet=0!=$(DEFAULT_TABLET_TEST_EL).length&&"none"!=$(DEFAULT_TABLET_TEST_EL).css("float"),_doParallax=0!=$(DEFAULT_PARALLAX_TEST_EL).length&&"none"!=$(DEFAULT_PARALLAX_TEST_EL).css("float")},initLayout=function(a,b,c){if(void 0!=a&&(_setChapterLinkCallback=a.setChapterLinkCallback||_setChapterLinkCallback,_chapterSetCompleteCallback=a.chapterSetCompleteCallback||_chapterSetCompleteCallback),void 0!=b&&(_stickyTopBarEl=b.topBar||_stickyTopBarEl,_mobileMenuEl=b.mobileMenuEl||_mobileMenuEl,_socialMenuTriggerEl=b.socialMenuTriggerEl||_socialMenuTriggerEl,_topAndMobileMenuControl=b.topAndMobileMenuControl||_topAndMobileMenuControl,_chapterEl=b.chapterEl||_chapterEl,_chapterLinkEl=b.chapterLinkEl||_chapterLinkEl,_chapterElPrefix=b.chapterElPrefix||_chapterElPrefix,_multiSizeImageEl=b.multiSizeImageEl||_multiSizeImageEl,_readMoreEl=b.readMoreEl||_readMoreEl),$(_mobileMenuEl).length){var d=$(_mobileMenuEl),e=d.data("chapters"),f=d.data("top-link"),g=d.data("close-trigger");try{$(g).click(function(){toggleMobileMenu(_mobileMenuEl,_topAndMobileMenuControl)}),$(f).click(function(){toTop(),toggleMobileMenu(_mobileMenuEl,_topAndMobileMenuControl)}),$(e).children("div").each(function(a){$(this).click(function(){toggleMobileMenu(_mobileMenuEl,_topAndMobileMenuControl),goToChapter(a+1)})})}catch(a){console.log(a)}}if($(_socialMenuTriggerEl).length){var h=$(_socialMenuTriggerEl),i=h.data("social-links"),j=h.data("social-links-class-off"),k=h.data("social-links-class-on"),l=h.data("trigger-class-off"),m=h.data("trigger-class-on");try{var n=$(i);getIsDesktop()?n.on("mouseenter",function(a){h.attr("class",m)}).on("mouseleave",function(a){h.attr("class",l)}):$(document).on("touchstart",i,function(a){n.attr("class",k),h.attr("class",m)}).on("touchend",function(){n.attr("class",j),h.attr("class",l)}).on("touchcancel",function(){n.attr("class",j),h.attr("class",l)})}catch(a){console.log(a)}}$(_stickyTopBarEl).length&&(_stickyTopBarHeight=$(_stickyTopBarEl).height(),void 0!=$(_stickyTopBarEl).data("offset-el")&&0!=$($(_stickyTopBarEl).data("offset-el")).length&&(_stickyTopBarOffset=$($(_stickyTopBarEl).data("offset-el")).offset().top),void 0!=$(_stickyTopBarEl).data("progress-bar-el")&&0!=$($(_stickyTopBarEl).data("progress-bar-el")).length&&(_stickyTopBarProgressBarEl=$(_stickyTopBarEl).data("progress-bar-el"))),void 0!=_readMoreEl&&($.isArray(_readMoreEl)||(_readMoreEl=[_readMoreEl]),$.each(_readMoreEl,function(a,b){$(b).click(function(){var a=0;void 0!=$(b).data("offset-el")&&0!=$($(b).data("offset-el")).length&&(a=$($(b).data("offset-el")).offset().top),$("html, body").animate({scrollTop:a-_stickyTopBarHeight},300)})})),adjustMultiSizedImages(),c&&initChapterTops(!0),$(_chapterLinkEl).click(function(){$(this.hash);return goToChapter(this.hash.substr(1)),!1})},initChapterTops=function(a){var b=new Array;$(_chapterEl).each(function(a){b[a]=Math.floor($(this).offset().top-_stickyTopBarHeight)}),_chapterTops=b,a&&adjustScrollProgress()},getCurrentChapter=function(){return _onChapter},getVisibleViewport=function(a){return a?window.innerHeight-_stickyTopBarHeight+"px":parseInt(window.innerHeight-_stickyTopBarHeight)},getViewportOffset=function(a,b){return b?$(a).offset().top-$(window).scrollTop()-_stickyTopBarHeight+"px":parseInt($(a).offset().top-$(window).scrollTop()-_stickyTopBarHeight)},getItemInViewport=function(a){var b=$(a).offset().top;return!(b+$(a).outerHeight()<=$(window).scrollTop()||b>=$(window).scrollTop()+$(window).height())},getItemInViewportCenter=function(a,b){var c=$(a).offset().top,d=$(window).height()/2;return b=b||0,!(c>=$(window).scrollTop()+d+b||c<=$(window).scrollTop()+d-b)},getStickyTopBarHeight=function(){return _stickyTopBarHeight},getIsMobile=function(){return _isMobile},getIsTablet=function(){return _isTablet},getDoParallax=function(){return _doParallax},getIsDesktop=function(){return!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},getIsIPad=function(){return navigator.userAgent.match(/iPad;.*CPU.*OS/i)},getIsResponsive=function(){return IS_RESPONSIVE},adjustLayoutAfterResize=function(){initChapterTops(!0),adjustMultiSizedImages()},adjustChapterLinksArtHeight=function(a,b){$(a).css("height",$(b).outerHeight())},adjustSizeToParentAndViewport=function(a,b){$(a).css("height",getVisibleViewport(!0)),$(a).css("width",$(b).width())},adjustScrollProgress=function(){if(0!=$(_stickyTopBarProgressBarEl).length){var e,a=-1,b=$(document).height(),c=$("body").height(),d=b-c-_stickyTopBarOffset;e=Math.round(($(document).scrollTop()-_stickyTopBarOffset)/d*100),$(_stickyTopBarProgressBarEl).css("width",e+"%");for(var f=_chapterTops.length-1;f>=0;f--)if($(document).scrollTop()>=_chapterTops[f]){a=f+1;break}return a!=-1&&adjustChapterLinks(a),a}},adjustChapterLinks=function(a){$(_chapterLinkEl).each(function(){$(this).attr("href")!="#"+a?"function"==typeof _setChapterLinkCallback&&_setChapterLinkCallback(this,!1):("function"==typeof _setChapterLinkCallback&&_setChapterLinkCallback(this,!0),_onChapter=a)})},adjustMultiSizedImages=function(){var a=$(_multiSizeImageEl);a.length&&a.each(function(){getIsResponsive()||void 0==$(this).data("src-legacy")?getIsMobile()&&void 0!=$(this).data("src-small")?$(this).attr("src",$(this).data("src-small")):getIsTablet()&&void 0!=$(this).data("src-medium")?$(this).attr("src",$(this).data("src-medium")):void 0!=$(this).data("src")&&$(this).attr("src",$(this).data("src")):$(this).attr("src",$(this).data("src-legacy"))})},toTop=function(){$("html, body").animate({scrollTop:0},600)},runTopMenuControl=function(){getIsMobile()?toggleMobileMenu(_mobileMenuEl,_topAndMobileMenuControl):toTop()},toggleMobileMenu=function(a,b){getIsMobile()&&($(a).toggle("fast"),$(b).toggle("fast"))},goToChapter=function(a){var b=$(_chapterElPrefix+a),c=b.offset().top-_stickyTopBarHeight+1,d=_onChapter>a?_onChapter-a:a-_onChapter,e=Math.floor(1e3/(_chapterTops.length-(_chapterTops.length-d)));$("html, body").animate({scrollTop:c},e,function(){adjustChapterLinks(a),"function"==typeof _chapterSetCompleteCallback&&_chapterSetCompleteCallback(a)}),_onChapter=a},animateOverflowContent=function(a,b,c,d,e){if(e==_onChapter){var f=$(a).css("background-position").split(" "),g=isNaN(b)?b:b+parseInt(f[0])+"px",h=isNaN(c)?c:c+parseInt(f[1])+"px";$(a).css({"background-position":g+" "+h})}window.setTimeout(function(){animateOverflowContent(a,b,c,d,e)},d)},cycleImages=function(a,b){var c=$(a+" .active"),d=c.next().length>0?c.next():$(a+" img:first");d.css("z-index",2),c.fadeOut(b,function(){c.css("z-index",1).show().removeClass("active"),d.css("z-index",3).addClass("active")})}; /** * v1.0 - Copyright 2015 Madden Media - All rights reserved. * * Content-specific layout functionality. These functions * make many assumptions about content contained in the page. * * NOTE: Assumes that madden-content-frameworks-v1.0.js has been loaded and * that the initial view types (mobile, tablet, etc.) have been defined. */ // mobile can call resize during scroll - we can cache width // and check if an actual resize happens var _winWidth = 0; // for the timer var TOTAL_TIMER_SECONDS_START = 3599; var TOTAL_TIMER_SECONDS_END = 480; var TIMER_DELAY = 1000; var timerOffsetFromTop = 200; var changeTimerEvery = 0; var timerTiming = false; var timerTop; var timerBottom; var timerWindow; var currentTimerTime = TOTAL_TIMER_SECONDS_START; var timerChangeUnderEl; var timerTimeMinCharOne; var timerTimeMinCharTwo; var timerTimeSecCharOne; var timerTimeSecCharTwo; var timerTimout; var adjustedTimer = false; ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // STOCK EVENT FUNCTIONS ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // // Called on document ready // contentOnReady = function () { // set the window width _winWidth = $(window).width(); // parallax effects if (getDoParallax()) { // parallax scroll a few backgrounds $("#ci0").parallaxBG({ adjustY: .08, bgXPosition: 'center' }); $("#ci0Hands").parallaxBG({ adjustY: .16, bgXPosition: 'center', bgYOffset: 100 }); $("#ci0Table").parallaxBG({ adjustY: .12, bgXPosition: 'center', bgYOffset: 100 }); $("#ci4Diners1").parallaxBG({ adjustX: .08, bgYPosition: 'bottom', bgXOffset: -60 }); $("#ci4Diners2").parallaxBG({ adjustX: .08, bgYPosition: 'bottom' }); $("#ci4Guitar").parallaxBG({ adjustX: -.16, bgYPosition: 'bottom' }); $("#ci4Fiddle").parallaxBG({ adjustX: .12, bgYPosition: 'bottom' }); // fade in the scrolling cta $("#scrollCTA").delay(1500).fadeIn(500); } // assign the timer objects if ( (! getIsMobile()) && (getIsResponsive()) ) { timerTimeMinCharOne = $("#tn01"); timerTimeMinCharTwo = $("#tn02"); timerTimeSecCharOne = $("#tn03"); timerTimeSecCharTwo = $("#tn04"); timerChangeUnderEl = $("#ci4"); } // if mobile, swap out the title image if (getIsMobile()) { $(".sponsorLogo").attr("src", $(".centerLogo").attr("src")); } customAdjustLayout(true); // add the complete class to the loader $("#loading").addClass("complete"); // for tablet and mobile, start the intro fade if ( (getIsTablet()) || (getIsMobile()) ) { $("#ci0Lede").delay(1000).fadeIn(1000).delay(3000).fadeOut(600, function() { $("#ci0Title").fadeIn(1000); }); } // 26.feb: client has a broken link - listen here and catch it $(".footerConquer").click(function () { self.location.href = "http://www.visitamarillo.com/listings/Big-Texan-Steak-Ranch-and-Microbrewery/475/?source=Madden&utm_medium=StoryPg&utm_content=Food&utm_campaign=DMTXAM15"; return false; }); } // // Called on document scroll // contentOnScroll = function () { var scrollTop = $(document).scrollTop(); if (getDoParallax()) { // lock the title if scrolled to a certain point if ($(window).scrollTop() > 600) { // $("#ci0Title").css("margin-top", ($(window).scrollTop() - 375)); $("#ci0Title").addClass("locked"); } else { $("#ci0Title").removeClass("locked"); } // hide the fixed title if need be $("#ci0Title").css("display", ((getItemInViewport("#ci0")) ? "block" : "none")); } // countdodwn timer logic if ( (! getIsMobile()) && (getIsResponsive()) ) { if (scrollTop >= ($("#timerStart").offset().top - timerOffsetFromTop)) { // beneath where the lock starts - adjust position to fix if (! timerDone()) { // $("#timer").css("top", (scrollTop + timerOffsetFromTop)); $("#timer").addClass("locked"); } // kick off timer? if ( (! timerDone()) && (! timerTiming) ) { countdownTimer(currentTimerTime); } timerTiming = true; } if ((scrollTop + timerOffsetFromTop) > $("#timerStop").offset().top) { // beneath the ending lock point // $("#timer").css("top", $("#timerStop").offset().top); $("#timer").removeClass("locked"); timerTiming = false; adjustedTimer = false; window.clearTimeout(timerTimout); setTimerMin(); } // if the clock just emerged from under the 4th chapter image, drop the time for effect if ( (! timerDone()) && (timerTiming) && (! adjustedTimer) && (scrollTop >= timerChangeUnderEl.offset().top) ) { window.clearTimeout(timerTimout); currentTimerTime = (TOTAL_TIMER_SECONDS_END + 3); countdownTimer(currentTimerTime); adjustedTimer = true; } } } // // Called on a touch move on mobile // contentOnTouchMove = function () { } // // Called on document resize // contentOnResize = function () { customAdjustLayout(); } ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // CUSTOM FUNCTIONS ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // // The frameworks was given this function to handle setting chapter buttons // when the chapter is set // // chapterEl: The chapter link DOM element // on: Is it being turned on? (true|false) // customChapterLinkAdjust = function (chapterEl, on) { $(chapterEl).attr("class", ((on) ? "navLink chapterLink noGA on" : "navLink chapterLink noGA")); } // // Adjust this specific layout after a load or resize event // // isLoad: Is this being called by a load or resize event? // customAdjustLayout = function (isLoad) { var localNotJustTouchScroll = isLoad; // is it really a resize? if ($(window).width() != _winWidth) { // yes localNotJustTouchScroll = true; _winWidth = $(window).width(); } if (localNotJustTouchScroll) { // resize footer links to be equal height of the tallest one equalizeRelatedLlinks(); if ( (! getIsMobile()) && (getIsResponsive()) ) { // timer start/stop points timerTop = $("#timerStart").offset().top; timerBottom = $("#timerStop").offset().top; timerWindow = (timerTop - timerBottom); // seconds to count down and how often to change them changeTimerEvery = ((timerBottom - timerTop) / TOTAL_TIMER_SECONDS_START); // move the timer down to the related text // $("#timer").css("top", (timerTop + "px")); } // adjust the width of the pull quotes to the width of the related content var pWidth = $("#c1Text > p:first-of-type").css("width"); $(".pullQuote").css("width", pWidth); } } // // adjusts the heights for the bottom related content divs // equalizeRelatedLlinks = function () { var h1 = $("#fLink1").height(); var h2 = $("#fLink2").height(); var h3 = $("#fLink3").height(); var max = h1; max = (h2 > max) ? h2 : max; max = (h3 > max) ? h3 : max; // set all to max $(".alsoLikeLink").css("height", (max + "px")); } // // counts down the timer // countdownTimer = function (totalSeconds) { if (totalSeconds < TOTAL_TIMER_SECONDS_END) { // stop timerTiming = false; window.clearTimeout(timerTimout); currentTimerTime = TOTAL_TIMER_SECONDS_END; return; } // get the pretty values for layout var timeVals = convertSecondsToMinutes(totalSeconds); // adjust the countdown totalSeconds--; currentTimerTime = totalSeconds; setTimerImage(timerTimeMinCharOne, timeVals[0]); setTimerImage(timerTimeMinCharTwo, timeVals[1]); setTimerImage(timerTimeSecCharOne, timeVals[2]); setTimerImage(timerTimeSecCharTwo, timeVals[3]); timerTimout = window.setTimeout(function () { countdownTimer(totalSeconds); }, TIMER_DELAY); } // // converts seconds to minutes:seconds and returns values // convertSecondsToMinutes = function (totalSeconds) { var minutesInt = Math.floor(totalSeconds / 60); var secondsInt = Math.floor(totalSeconds - (minutesInt * 60)); // now stringify var minutesStr = minutesInt.toString(); var secondsStr = secondsInt.toString(); var p1 = (minutesInt < 10) ? 0 : minutesStr.charAt(0); var p2 = (minutesInt < 10) ? minutesStr.charAt(0) : minutesStr.charAt(1); var p3 = (secondsInt < 10) ? 0 : secondsStr.charAt(0); var p4 = (secondsInt < 10) ? secondsStr.charAt(0) : secondsStr.charAt(1); return new Array(p1, p2, p3, p4); } // // utility to set timer image // setTimerImage = function (tEl, num) { tEl.attr("src", ("//maddencdn.com/content/images/2015/amarillo/timer/numbers-" + num + ".png")); // a bit hacky, but we can "flash" the seconds if (tEl.attr("id") == "tn04") { var src = $("#timerBG").attr("src"); if ((num % 2) == 0) { $("#timerBG").attr("src", src.replace("_timer_no_sec.png", "_timer.png")); } else { $("#timerBG").attr("src", src.replace("_timer.png", "_timer_no_sec.png")); } } } // // utilty to set timer to min time // setTimerMin = function () { var timeVals = convertSecondsToMinutes(TOTAL_TIMER_SECONDS_END); setTimerImage(timerTimeMinCharOne, timeVals[0]); setTimerImage(timerTimeMinCharTwo, timeVals[1]); setTimerImage(timerTimeSecCharOne, timeVals[2]); setTimerImage(timerTimeSecCharTwo, timeVals[3]); } // // is the timer done? // timerDone = function () { return (currentTimerTime == TOTAL_TIMER_SECONDS_END); }