/** * Swiper 3.3.0 * Most modern mobile touch slider and framework with hardware accelerated transitions * * http://www.idangero.us/swiper/ * * Copyright 2016, Vladimir Kharlampidi * The iDangero.us * http://www.idangero.us/ * * Licensed under MIT * * Released on: January 10, 2016 */ !function(){"use strict";function e(e){e.fn.swiper=function(a){var i;return e(this).each(function(){var e=new t(this,a);i||(i=e)}),i}}var a,t=function(e,r){function s(e){return Math.floor(e)}function n(){b.autoplayTimeoutId=setTimeout(function(){b.params.loop?(b.fixLoop(),b._slideNext(),b.emit("onAutoplay",b)):b.isEnd?r.autoplayStopOnLast?b.stopAutoplay():(b._slideTo(0),b.emit("onAutoplay",b)):(b._slideNext(),b.emit("onAutoplay",b))},b.params.autoplay)}function o(e,t){var i=a(e.target);if(!i.is(t))if("string"==typeof t)i=i.parents(t);else if(t.nodeType){var r;return i.parents().each(function(e,a){a===t&&(r=t)}),r?t:void 0}if(0!==i.length)return i[0]}function l(e,a){a=a||{};var t=window.MutationObserver||window.WebkitMutationObserver,i=new t(function(e){e.forEach(function(e){b.onResize(!0),b.emit("onObserverUpdate",b,e)})});i.observe(e,{attributes:"undefined"==typeof a.attributes?!0:a.attributes,childList:"undefined"==typeof a.childList?!0:a.childList,characterData:"undefined"==typeof a.characterData?!0:a.characterData}),b.observers.push(i)}function p(e){e.originalEvent&&(e=e.originalEvent);var a=e.keyCode||e.charCode;if(!b.params.allowSwipeToNext&&(b.isHorizontal()&&39===a||!b.isHorizontal()&&40===a))return!1;if(!b.params.allowSwipeToPrev&&(b.isHorizontal()&&37===a||!b.isHorizontal()&&38===a))return!1;if(!(e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||document.activeElement&&document.activeElement.nodeName&&("input"===document.activeElement.nodeName.toLowerCase()||"textarea"===document.activeElement.nodeName.toLowerCase()))){if(37===a||39===a||38===a||40===a){var t=!1;if(b.container.parents(".swiper-slide").length>0&&0===b.container.parents(".swiper-slide-active").length)return;var i={left:window.pageXOffset,top:window.pageYOffset},r=window.innerWidth,s=window.innerHeight,n=b.container.offset();b.rtl&&(n.left=n.left-b.container[0].scrollLeft);for(var o=[[n.left,n.top],[n.left+b.width,n.top],[n.left,n.top+b.height],[n.left+b.width,n.top+b.height]],l=0;l=i.left&&p[0]<=i.left+r&&p[1]>=i.top&&p[1]<=i.top+s&&(t=!0)}if(!t)return}b.isHorizontal()?((37===a||39===a)&&(e.preventDefault?e.preventDefault():e.returnValue=!1),(39===a&&!b.rtl||37===a&&b.rtl)&&b.slideNext(),(37===a&&!b.rtl||39===a&&b.rtl)&&b.slidePrev()):((38===a||40===a)&&(e.preventDefault?e.preventDefault():e.returnValue=!1),40===a&&b.slideNext(),38===a&&b.slidePrev())}}function d(e){e.originalEvent&&(e=e.originalEvent);var a=b.mousewheel.event,t=0,i=b.rtl?-1:1;if(e.detail)t=-e.detail;else if("mousewheel"===a)if(b.params.mousewheelForceToAxis)if(b.isHorizontal()){if(!(Math.abs(e.wheelDeltaX)>Math.abs(e.wheelDeltaY)))return;t=e.wheelDeltaX*i}else{if(!(Math.abs(e.wheelDeltaY)>Math.abs(e.wheelDeltaX)))return;t=e.wheelDeltaY}else t=Math.abs(e.wheelDeltaX)>Math.abs(e.wheelDeltaY)?-e.wheelDeltaX*i:-e.wheelDeltaY;else if("DOMMouseScroll"===a)t=-e.detail;else if("wheel"===a)if(b.params.mousewheelForceToAxis)if(b.isHorizontal()){if(!(Math.abs(e.deltaX)>Math.abs(e.deltaY)))return;t=-e.deltaX*i}else{if(!(Math.abs(e.deltaY)>Math.abs(e.deltaX)))return;t=-e.deltaY}else t=Math.abs(e.deltaX)>Math.abs(e.deltaY)?-e.deltaX*i:-e.deltaY;if(0!==t){if(b.params.mousewheelInvert&&(t=-t),b.params.freeMode){var r=b.getWrapperTranslate()+t*b.params.mousewheelSensitivity,s=b.isBeginning,n=b.isEnd;if(r>=b.minTranslate()&&(r=b.minTranslate()),r<=b.maxTranslate()&&(r=b.maxTranslate()),b.setWrapperTransition(0),b.setWrapperTranslate(r),b.updateProgress(),b.updateActiveIndex(),(!s&&b.isBeginning||!n&&b.isEnd)&&b.updateClasses(),b.params.freeModeSticky?(clearTimeout(b.mousewheel.timeout),b.mousewheel.timeout=setTimeout(function(){b.slideReset()},300)):b.params.lazyLoading&&b.lazy&&b.lazy.load(),0===r||r===b.maxTranslate())return}else{if((new window.Date).getTime()-b.mousewheel.lastScrollTime>60)if(0>t)if(b.isEnd&&!b.params.loop||b.animating){if(b.params.mousewheelReleaseOnEdges)return!0}else b.slideNext();else if(b.isBeginning&&!b.params.loop||b.animating){if(b.params.mousewheelReleaseOnEdges)return!0}else b.slidePrev();b.mousewheel.lastScrollTime=(new window.Date).getTime()}return b.params.autoplay&&b.stopAutoplay(),e.preventDefault?e.preventDefault():e.returnValue=!1,!1}}function u(e,t){e=a(e);var i,r,s,n=b.rtl?-1:1;i=e.attr("data-swiper-parallax")||"0",r=e.attr("data-swiper-parallax-x"),s=e.attr("data-swiper-parallax-y"),r||s?(r=r||"0",s=s||"0"):b.isHorizontal()?(r=i,s="0"):(s=i,r="0"),r=r.indexOf("%")>=0?parseInt(r,10)*t*n+"%":r*t*n+"px",s=s.indexOf("%")>=0?parseInt(s,10)*t+"%":s*t+"px",e.transform("translate3d("+r+", "+s+",0px)")}function c(e){return 0!==e.indexOf("on")&&(e=e[0]!==e[0].toUpperCase()?"on"+e[0].toUpperCase()+e.substring(1):"on"+e),e}if(!(this instanceof t))return new t(e,r);var m={direction:"horizontal",touchEventsTarget:"container",initialSlide:0,speed:300,autoplay:!1,autoplayDisableOnInteraction:!0,autoplayStopOnLast:!1,iOSEdgeSwipeDetection:!1,iOSEdgeSwipeThreshold:20,freeMode:!1,freeModeMomentum:!0,freeModeMomentumRatio:1,freeModeMomentumBounce:!0,freeModeMomentumBounceRatio:1,freeModeSticky:!1,freeModeMinimumVelocity:.02,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",coverflow:{rotate:50,stretch:0,depth:100,modifier:1,slideShadows:!0},flip:{slideShadows:!0,limitRotation:!0},cube:{slideShadows:!0,shadow:!0,shadowOffset:20,shadowScale:.94},fade:{crossFade:!1},parallax:!1,scrollbar:null,scrollbarHide:!0,scrollbarDraggable:!1,scrollbarSnapOnRelease:!1,keyboardControl:!1,mousewheelControl:!1,mousewheelReleaseOnEdges:!1,mousewheelInvert:!1,mousewheelForceToAxis:!1,mousewheelSensitivity:1,hashnav:!1,breakpoints:void 0,spaceBetween:0,slidesPerView:1,slidesPerColumn:1,slidesPerColumnFill:"column",slidesPerGroup:1,centeredSlides:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,onlyExternal:!1,threshold:0,touchMoveStopPropagation:!0,pagination:null,paginationElement:"span",paginationClickable:!1,paginationHide:!1,paginationBulletRender:null,paginationProgressRender:null,paginationFractionRender:null,paginationCustomRender:null,paginationType:"bullets",resistance:!0,resistanceRatio:.85,nextButton:null,prevButton:null,watchSlidesProgress:!1,watchSlidesVisibility:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,lazyLoading:!1,lazyLoadingInPrevNext:!1,lazyLoadingInPrevNextAmount:1,lazyLoadingOnTransitionStart:!1,preloadImages:!0,updateOnImagesReady:!0,loop:!1,loopAdditionalSlides:0,loopedSlides:null,control:void 0,controlInverse:!1,controlBy:"slide",allowSwipeToPrev:!0,allowSwipeToNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",slideClass:"swiper-slide",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideDuplicateClass:"swiper-slide-duplicate",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",bulletClass:"swiper-pagination-bullet",bulletActiveClass:"swiper-pagination-bullet-active",buttonDisabledClass:"swiper-button-disabled",paginationCurrentClass:"swiper-pagination-current",paginationTotalClass:"swiper-pagination-total",paginationHiddenClass:"swiper-pagination-hidden",paginationProgressbarClass:"swiper-pagination-progressbar",observer:!1,observeParents:!1,a11y:!1,prevSlideMessage:"Previous slide",nextSlideMessage:"Next slide",firstSlideMessage:"This is the first slide",lastSlideMessage:"This is the last slide",paginationBulletMessage:"Go to slide {{index}}",runCallbacksOnInit:!0},f=r&&r.virtualTranslate;r=r||{};var h={};for(var g in r)if("object"!=typeof r[g]||null===r[g]||(r[g].nodeType||r[g]===window||r[g]===document||"undefined"!=typeof i&&r[g]instanceof i||"undefined"!=typeof jQuery&&r[g]instanceof jQuery))h[g]=r[g];else{h[g]={};for(var v in r[g])h[g][v]=r[g][v]}for(var w in m)if("undefined"==typeof r[w])r[w]=m[w];else if("object"==typeof r[w])for(var y in m[w])"undefined"==typeof r[w][y]&&(r[w][y]=m[w][y]);var b=this;if(b.params=r,b.originalParams=h,b.classNames=[],"undefined"!=typeof a&&"undefined"!=typeof i&&(a=i),("undefined"!=typeof a||(a="undefined"==typeof i?window.Dom7||window.Zepto||window.jQuery:i))&&(b.$=a,b.currentBreakpoint=void 0,b.getActiveBreakpoint=function(){if(!b.params.breakpoints)return!1;var e,a=!1,t=[];for(e in b.params.breakpoints)b.params.breakpoints.hasOwnProperty(e)&&t.push(e);t.sort(function(e,a){return parseInt(e,10)>parseInt(a,10)});for(var i=0;i=window.innerWidth&&!a&&(a=e);return a||"max"},b.setBreakpoint=function(){var e=b.getActiveBreakpoint();if(e&&b.currentBreakpoint!==e){var a=e in b.params.breakpoints?b.params.breakpoints[e]:b.originalParams;for(var t in a)b.params[t]=a[t];b.currentBreakpoint=e}},b.params.breakpoints&&b.setBreakpoint(),b.container=a(e),0!==b.container.length)){if(b.container.length>1)return void b.container.each(function(){new t(this,r)});b.container[0].swiper=b,b.container.data("swiper",b),b.classNames.push("swiper-container-"+b.params.direction),b.params.freeMode&&b.classNames.push("swiper-container-free-mode"),b.support.flexbox||(b.classNames.push("swiper-container-no-flexbox"),b.params.slidesPerColumn=1),b.params.autoHeight&&b.classNames.push("swiper-container-autoheight"),(b.params.parallax||b.params.watchSlidesVisibility)&&(b.params.watchSlidesProgress=!0),["cube","coverflow","flip"].indexOf(b.params.effect)>=0&&(b.support.transforms3d?(b.params.watchSlidesProgress=!0,b.classNames.push("swiper-container-3d")):b.params.effect="slide"),"slide"!==b.params.effect&&b.classNames.push("swiper-container-"+b.params.effect),"cube"===b.params.effect&&(b.params.resistanceRatio=0,b.params.slidesPerView=1,b.params.slidesPerColumn=1,b.params.slidesPerGroup=1,b.params.centeredSlides=!1,b.params.spaceBetween=0,b.params.virtualTranslate=!0,b.params.setWrapperSize=!1),("fade"===b.params.effect||"flip"===b.params.effect)&&(b.params.slidesPerView=1,b.params.slidesPerColumn=1,b.params.slidesPerGroup=1,b.params.watchSlidesProgress=!0,b.params.spaceBetween=0,b.params.setWrapperSize=!1,"undefined"==typeof f&&(b.params.virtualTranslate=!0)),b.params.grabCursor&&b.support.touch&&(b.params.grabCursor=!1),b.wrapper=b.container.children("."+b.params.wrapperClass),b.params.pagination&&(b.paginationContainer=a(b.params.pagination),"bullets"===b.params.paginationType&&b.params.paginationClickable?b.paginationContainer.addClass("swiper-pagination-clickable"):b.params.paginationClickable=!1,b.paginationContainer.addClass("swiper-pagination-"+b.params.paginationType)),b.isHorizontal=function(){return"horizontal"===b.params.direction},b.rtl=b.isHorizontal()&&("rtl"===b.container[0].dir.toLowerCase()||"rtl"===b.container.css("direction")),b.rtl&&b.classNames.push("swiper-container-rtl"),b.rtl&&(b.wrongRTL="-webkit-box"===b.wrapper.css("display")),b.params.slidesPerColumn>1&&b.classNames.push("swiper-container-multirow"),b.device.android&&b.classNames.push("swiper-container-android"),b.container.addClass(b.classNames.join(" ")),b.translate=0,b.progress=0,b.velocity=0,b.lockSwipeToNext=function(){b.params.allowSwipeToNext=!1},b.lockSwipeToPrev=function(){b.params.allowSwipeToPrev=!1},b.lockSwipes=function(){b.params.allowSwipeToNext=b.params.allowSwipeToPrev=!1},b.unlockSwipeToNext=function(){b.params.allowSwipeToNext=!0},b.unlockSwipeToPrev=function(){b.params.allowSwipeToPrev=!0},b.unlockSwipes=function(){b.params.allowSwipeToNext=b.params.allowSwipeToPrev=!0},b.params.grabCursor&&(b.container[0].style.cursor="move",b.container[0].style.cursor="-webkit-grab",b.container[0].style.cursor="-moz-grab",b.container[0].style.cursor="grab"),b.imagesToLoad=[],b.imagesLoaded=0,b.loadImage=function(e,a,t,i,r){function s(){r&&r()}var n;e.complete&&i?s():a?(n=new window.Image,n.onload=s,n.onerror=s,t&&(n.srcset=t),a&&(n.src=a)):s()},b.preloadImages=function(){function e(){"undefined"!=typeof b&&null!==b&&(void 0!==b.imagesLoaded&&b.imagesLoaded++,b.imagesLoaded===b.imagesToLoad.length&&(b.params.updateOnImagesReady&&b.update(),b.emit("onImagesReady",b)))}b.imagesToLoad=b.container.find("img");for(var a=0;a=0&&(a=parseFloat(a.replace("%",""))/100*b.size),b.virtualSize=-a,b.rtl?b.slides.css({marginLeft:"",marginTop:""}):b.slides.css({marginRight:"",marginBottom:""});var n;b.params.slidesPerColumn>1&&(n=Math.floor(b.slides.length/b.params.slidesPerColumn)===b.slides.length/b.params.slidesPerColumn?b.slides.length:Math.ceil(b.slides.length/b.params.slidesPerColumn)*b.params.slidesPerColumn,"auto"!==b.params.slidesPerView&&"row"===b.params.slidesPerColumnFill&&(n=Math.max(n,b.params.slidesPerView*b.params.slidesPerColumn)));var o,l=b.params.slidesPerColumn,p=n/l,d=p-(b.params.slidesPerColumn*p-b.slides.length);for(e=0;e1){var c,m,f;"column"===b.params.slidesPerColumnFill?(m=Math.floor(e/l),f=e-m*l,(m>d||m===d&&f===l-1)&&++f>=l&&(f=0,m++),c=m+f*n/l,u.css({"-webkit-box-ordinal-group":c,"-moz-box-ordinal-group":c,"-ms-flex-order":c,"-webkit-order":c,order:c})):(f=Math.floor(e/p),m=e-f*p),u.css({"margin-top":0!==f&&b.params.spaceBetween&&b.params.spaceBetween+"px"}).attr("data-swiper-column",m).attr("data-swiper-row",f)}"none"!==u.css("display")&&("auto"===b.params.slidesPerView?(o=b.isHorizontal()?u.outerWidth(!0):u.outerHeight(!0),b.params.roundLengths&&(o=s(o))):(o=(b.size-(b.params.slidesPerView-1)*a)/b.params.slidesPerView,b.params.roundLengths&&(o=s(o)),b.isHorizontal()?b.slides[e].style.width=o+"px":b.slides[e].style.height=o+"px"),b.slides[e].swiperSlideSize=o,b.slidesSizesGrid.push(o),b.params.centeredSlides?(t=t+o/2+i/2+a,0===e&&(t=t-b.size/2-a),Math.abs(t)<.001&&(t=0),r%b.params.slidesPerGroup===0&&b.snapGrid.push(t),b.slidesGrid.push(t)):(r%b.params.slidesPerGroup===0&&b.snapGrid.push(t),b.slidesGrid.push(t),t=t+o+a),b.virtualSize+=o+a,i=o,r++)}b.virtualSize=Math.max(b.virtualSize,b.size)+b.params.slidesOffsetAfter;var h;if(b.rtl&&b.wrongRTL&&("slide"===b.params.effect||"coverflow"===b.params.effect)&&b.wrapper.css({width:b.virtualSize+b.params.spaceBetween+"px"}),(!b.support.flexbox||b.params.setWrapperSize)&&(b.isHorizontal()?b.wrapper.css({width:b.virtualSize+b.params.spaceBetween+"px"}):b.wrapper.css({height:b.virtualSize+b.params.spaceBetween+"px"})),b.params.slidesPerColumn>1&&(b.virtualSize=(o+b.params.spaceBetween)*n,b.virtualSize=Math.ceil(b.virtualSize/b.params.slidesPerColumn)-b.params.spaceBetween,b.wrapper.css({width:b.virtualSize+b.params.spaceBetween+"px"}),b.params.centeredSlides)){for(h=[],e=0;eMath.floor(b.snapGrid[b.snapGrid.length-1])&&b.snapGrid.push(b.virtualSize-b.size)}0===b.snapGrid.length&&(b.snapGrid=[0]),0!==b.params.spaceBetween&&(b.isHorizontal()?b.rtl?b.slides.css({marginLeft:a+"px"}):b.slides.css({marginRight:a+"px"}):b.slides.css({marginBottom:a+"px"})),b.params.watchSlidesProgress&&b.updateSlidesOffset()},b.updateSlidesOffset=function(){for(var e=0;e=0&&s0&&n<=b.size||0>=s&&n>=b.size;o&&b.slides.eq(t).addClass(b.params.slideVisibleClass)}i.progress=b.rtl?-r:r}}},b.updateProgress=function(e){"undefined"==typeof e&&(e=b.translate||0);var a=b.maxTranslate()-b.minTranslate(),t=b.isBeginning,i=b.isEnd;0===a?(b.progress=0,b.isBeginning=b.isEnd=!0):(b.progress=(e-b.minTranslate())/a,b.isBeginning=b.progress<=0,b.isEnd=b.progress>=1),b.isBeginning&&!t&&b.emit("onReachBeginning",b),b.isEnd&&!i&&b.emit("onReachEnd",b),b.params.watchSlidesProgress&&b.updateSlidesProgress(e),b.emit("onProgress",b,b.progress)},b.updateActiveIndex=function(){var e,a,t,i=b.rtl?b.translate:-b.translate;for(a=0;a=b.slidesGrid[a]&&i=b.slidesGrid[a]&&i=b.slidesGrid[a]&&(e=a);(0>e||"undefined"==typeof e)&&(e=0),t=Math.floor(e/b.params.slidesPerGroup),t>=b.snapGrid.length&&(t=b.snapGrid.length-1),e!==b.activeIndex&&(b.snapIndex=t,b.previousIndex=b.activeIndex,b.activeIndex=e,b.updateClasses())},b.updateClasses=function(){b.slides.removeClass(b.params.slideActiveClass+" "+b.params.slideNextClass+" "+b.params.slidePrevClass);var e=b.slides.eq(b.activeIndex);if(e.addClass(b.params.slideActiveClass),e.next("."+b.params.slideClass).addClass(b.params.slideNextClass),e.prev("."+b.params.slideClass).addClass(b.params.slidePrevClass),b.paginationContainer&&b.paginationContainer.length>0){var t,i=b.params.loop?Math.ceil((b.slides.length-2*b.loopedSlides)/b.params.slidesPerGroup):b.snapGrid.length;if(b.params.loop?(t=Math.ceil(b.activeIndex-b.loopedSlides)/b.params.slidesPerGroup,t>b.slides.length-1-2*b.loopedSlides&&(t-=b.slides.length-2*b.loopedSlides),t>i-1&&(t-=i),0>t&&"bullets"!==b.params.paginationType&&(t=i+t)):t="undefined"!=typeof b.snapIndex?b.snapIndex:b.activeIndex||0,"bullets"===b.params.paginationType&&b.bullets&&b.bullets.length>0&&(b.bullets.removeClass(b.params.bulletActiveClass),b.paginationContainer.length>1?b.bullets.each(function(){a(this).index()===t&&a(this).addClass(b.params.bulletActiveClass)}):b.bullets.eq(t).addClass(b.params.bulletActiveClass)),"fraction"===b.params.paginationType&&(b.paginationContainer.find("."+b.params.paginationCurrentClass).text(t+1),b.paginationContainer.find("."+b.params.paginationTotalClass).text(i)),"progress"===b.params.paginationType){var r=(t+1)/i,s=r,n=1;b.isHorizontal()||(n=r,s=1),b.paginationContainer.find("."+b.params.paginationProgressbarClass).transform("translate3d(0,0,0) scaleX("+s+") scaleY("+n+")").transition(b.params.speed)}"custom"===b.params.paginationType&&b.params.paginationCustomRender&&b.paginationContainer.html(b.params.paginationCustomRender(b,t+1,i))}b.params.loop||(b.params.prevButton&&(b.isBeginning?(a(b.params.prevButton).addClass(b.params.buttonDisabledClass),b.params.a11y&&b.a11y&&b.a11y.disable(a(b.params.prevButton))):(a(b.params.prevButton).removeClass(b.params.buttonDisabledClass),b.params.a11y&&b.a11y&&b.a11y.enable(a(b.params.prevButton)))),b.params.nextButton&&(b.isEnd?(a(b.params.nextButton).addClass(b.params.buttonDisabledClass),b.params.a11y&&b.a11y&&b.a11y.disable(a(b.params.nextButton))):(a(b.params.nextButton).removeClass(b.params.buttonDisabledClass),b.params.a11y&&b.a11y&&b.a11y.enable(a(b.params.nextButton)))))},b.updatePagination=function(){if(b.params.pagination&&b.paginationContainer&&b.paginationContainer.length>0){var e="";if("bullets"===b.params.paginationType){for(var a=b.params.loop?Math.ceil((b.slides.length-2*b.loopedSlides)/b.params.slidesPerGroup):b.snapGrid.length,t=0;a>t;t++)e+=b.params.paginationBulletRender?b.params.paginationBulletRender(t,b.params.bulletClass):"<"+b.params.paginationElement+' class="'+b.params.bulletClass+'">";b.paginationContainer.html(e),b.bullets=b.paginationContainer.find("."+b.params.bulletClass),b.params.paginationClickable&&b.params.a11y&&b.a11y&&b.a11y.initPagination()}"fraction"===b.params.paginationType&&(e=b.params.paginationFractionRender?b.params.paginationFractionRender(b,b.params.paginationCurrentClass,b.params.paginationTotalClass):' / ',b.paginationContainer.html(e)),"progress"===b.params.paginationType&&(e=b.params.paginationProgressRender?b.params.paginationProgressRender(b,b.params.paginationProgressbarClass):'',b.paginationContainer.html(e))}},b.update=function(e){function a(){i=Math.min(Math.max(b.translate,b.maxTranslate()),b.minTranslate()),b.setWrapperTranslate(i),b.updateActiveIndex(),b.updateClasses()}if(b.updateContainerSize(),b.updateSlidesSize(),b.updateProgress(),b.updatePagination(),b.updateClasses(),b.params.scrollbar&&b.scrollbar&&b.scrollbar.set(),e){var t,i;b.controller&&b.controller.spline&&(b.controller.spline=void 0),b.params.freeMode?(a(),b.params.autoHeight&&b.updateAutoHeight()):(t=("auto"===b.params.slidesPerView||b.params.slidesPerView>1)&&b.isEnd&&!b.params.centeredSlides?b.slideTo(b.slides.length-1,0,!1,!0):b.slideTo(b.activeIndex,0,!1,!0),t||a())}else b.params.autoHeight&&b.updateAutoHeight()},b.onResize=function(e){b.params.breakpoints&&b.setBreakpoint();var a=b.params.allowSwipeToPrev,t=b.params.allowSwipeToNext;if(b.params.allowSwipeToPrev=b.params.allowSwipeToNext=!0,b.updateContainerSize(),b.updateSlidesSize(),("auto"===b.params.slidesPerView||b.params.freeMode||e)&&b.updatePagination(),b.params.scrollbar&&b.scrollbar&&b.scrollbar.set(),b.controller&&b.controller.spline&&(b.controller.spline=void 0),b.params.freeMode){var i=Math.min(Math.max(b.translate,b.maxTranslate()),b.minTranslate());b.setWrapperTranslate(i),b.updateActiveIndex(),b.updateClasses(),b.params.autoHeight&&b.updateAutoHeight()}else b.updateClasses(),("auto"===b.params.slidesPerView||b.params.slidesPerView>1)&&b.isEnd&&!b.params.centeredSlides?b.slideTo(b.slides.length-1,0,!1,!0):b.slideTo(b.activeIndex,0,!1,!0);b.params.allowSwipeToPrev=a,b.params.allowSwipeToNext=t};var T=["mousedown","mousemove","mouseup"];window.navigator.pointerEnabled?T=["pointerdown","pointermove","pointerup"]:window.navigator.msPointerEnabled&&(T=["MSPointerDown","MSPointerMove","MSPointerUp"]),b.touchEvents={start:b.support.touch||!b.params.simulateTouch?"touchstart":T[0],move:b.support.touch||!b.params.simulateTouch?"touchmove":T[1],end:b.support.touch||!b.params.simulateTouch?"touchend":T[2]},(window.navigator.pointerEnabled||window.navigator.msPointerEnabled)&&("container"===b.params.touchEventsTarget?b.container:b.wrapper).addClass("swiper-wp8-"+b.params.direction),b.initEvents=function(e){var t=e?"off":"on",i=e?"removeEventListener":"addEventListener",s="container"===b.params.touchEventsTarget?b.container[0]:b.wrapper[0],n=b.support.touch?s:document,o=b.params.nested?!0:!1;b.browser.ie?(s[i](b.touchEvents.start,b.onTouchStart,!1),n[i](b.touchEvents.move,b.onTouchMove,o),n[i](b.touchEvents.end,b.onTouchEnd,!1)):(b.support.touch&&(s[i](b.touchEvents.start,b.onTouchStart,!1),s[i](b.touchEvents.move,b.onTouchMove,o),s[i](b.touchEvents.end,b.onTouchEnd,!1)),!r.simulateTouch||b.device.ios||b.device.android||(s[i]("mousedown",b.onTouchStart,!1),document[i]("mousemove",b.onTouchMove,o),document[i]("mouseup",b.onTouchEnd,!1))),window[i]("resize",b.onResize),b.params.nextButton&&(a(b.params.nextButton)[t]("click",b.onClickNext),b.params.a11y&&b.a11y&&a(b.params.nextButton)[t]("keydown",b.a11y.onEnterKey)),b.params.prevButton&&(a(b.params.prevButton)[t]("click",b.onClickPrev),b.params.a11y&&b.a11y&&a(b.params.prevButton)[t]("keydown",b.a11y.onEnterKey)),b.params.pagination&&b.params.paginationClickable&&(a(b.paginationContainer)[t]("click","."+b.params.bulletClass,b.onClickIndex),b.params.a11y&&b.a11y&&a(b.paginationContainer)[t]("keydown","."+b.params.bulletClass,b.a11y.onEnterKey)),(b.params.preventClicks||b.params.preventClicksPropagation)&&s[i]("click",b.preventClicks,!0)},b.attachEvents=function(e){b.initEvents()},b.detachEvents=function(){b.initEvents(!0)},b.allowClick=!0,b.preventClicks=function(e){b.allowClick||(b.params.preventClicks&&e.preventDefault(),b.params.preventClicksPropagation&&b.animating&&(e.stopPropagation(),e.stopImmediatePropagation()))},b.onClickNext=function(e){e.preventDefault(),(!b.isEnd||b.params.loop)&&b.slideNext()},b.onClickPrev=function(e){e.preventDefault(),(!b.isBeginning||b.params.loop)&&b.slidePrev()},b.onClickIndex=function(e){e.preventDefault();var t=a(this).index()*b.params.slidesPerGroup;b.params.loop&&(t+=b.loopedSlides),b.slideTo(t)},b.updateClickedSlide=function(e){var t=o(e,"."+b.params.slideClass),i=!1;if(t)for(var r=0;rb.slides.length-b.loopedSlides+b.params.slidesPerView/2?(b.fixLoop(),n=b.wrapper.children("."+b.params.slideClass+'[data-swiper-slide-index="'+s+'"]:not(.swiper-slide-duplicate)').eq(0).index(),setTimeout(function(){b.slideTo(n)},0)):b.slideTo(n):n>b.slides.length-b.params.slidesPerView?(b.fixLoop(),n=b.wrapper.children("."+b.params.slideClass+'[data-swiper-slide-index="'+s+'"]:not(.swiper-slide-duplicate)').eq(0).index(),setTimeout(function(){b.slideTo(n)},0)):b.slideTo(n)}else b.slideTo(n)}};var x,S,C,z,M,P,E,k,I,L,D="input, select, textarea, button",H=Date.now(),B=[];b.animating=!1,b.touches={startX:0,startY:0,currentX:0,currentY:0,diff:0};var A,G;if(b.onTouchStart=function(e){if(e.originalEvent&&(e=e.originalEvent),A="touchstart"===e.type,A||!("which"in e)||3!==e.which){if(b.params.noSwiping&&o(e,"."+b.params.noSwipingClass))return void(b.allowClick=!0);if(!b.params.swipeHandler||o(e,b.params.swipeHandler)){var t=b.touches.currentX="touchstart"===e.type?e.targetTouches[0].pageX:e.pageX,i=b.touches.currentY="touchstart"===e.type?e.targetTouches[0].pageY:e.pageY;if(!(b.device.ios&&b.params.iOSEdgeSwipeDetection&&t<=b.params.iOSEdgeSwipeThreshold)){if(x=!0,S=!1,C=!0,M=void 0,G=void 0,b.touches.startX=t,b.touches.startY=i,z=Date.now(),b.allowClick=!0,b.updateContainerSize(),b.swipeDirection=void 0,b.params.threshold>0&&(k=!1),"touchstart"!==e.type){var r=!0;a(e.target).is(D)&&(r=!1),document.activeElement&&a(document.activeElement).is(D)&&document.activeElement.blur(),r&&e.preventDefault()}b.emit("onTouchStart",b,e)}}}},b.onTouchMove=function(e){if(e.originalEvent&&(e=e.originalEvent),!(A&&"mousemove"===e.type||e.preventedByNestedSwiper)){if(b.params.onlyExternal)return b.allowClick=!1,void(x&&(b.touches.startX=b.touches.currentX="touchmove"===e.type?e.targetTouches[0].pageX:e.pageX,b.touches.startY=b.touches.currentY="touchmove"===e.type?e.targetTouches[0].pageY:e.pageY,z=Date.now()));if(A&&document.activeElement&&e.target===document.activeElement&&a(e.target).is(D))return S=!0,void(b.allowClick=!1);if(C&&b.emit("onTouchMove",b,e),!(e.targetTouches&&e.targetTouches.length>1)){if(b.touches.currentX="touchmove"===e.type?e.targetTouches[0].pageX:e.pageX,b.touches.currentY="touchmove"===e.type?e.targetTouches[0].pageY:e.pageY,"undefined"==typeof M){var t=180*Math.atan2(Math.abs(b.touches.currentY-b.touches.startY),Math.abs(b.touches.currentX-b.touches.startX))/Math.PI;M=b.isHorizontal()?t>b.params.touchAngle:90-t>b.params.touchAngle}if(M&&b.emit("onTouchMoveOpposite",b,e),"undefined"==typeof G&&b.browser.ieTouch&&(b.touches.currentX!==b.touches.startX||b.touches.currentY!==b.touches.startY)&&(G=!0),x){if(M)return void(x=!1);if(G||!b.browser.ieTouch){b.allowClick=!1,b.emit("onSliderMove",b,e),e.preventDefault(),b.params.touchMoveStopPropagation&&!b.params.nested&&e.stopPropagation(),S||(r.loop&&b.fixLoop(),E=b.getWrapperTranslate(),b.setWrapperTransition(0),b.animating&&b.wrapper.trigger("webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd msTransitionEnd"),b.params.autoplay&&b.autoplaying&&(b.params.autoplayDisableOnInteraction?b.stopAutoplay():b.pauseAutoplay()),L=!1,b.params.grabCursor&&(b.container[0].style.cursor="move",b.container[0].style.cursor="-webkit-grabbing",b.container[0].style.cursor="-moz-grabbin",b.container[0].style.cursor="grabbing")),S=!0;var i=b.touches.diff=b.isHorizontal()?b.touches.currentX-b.touches.startX:b.touches.currentY-b.touches.startY;i*=b.params.touchRatio,b.rtl&&(i=-i),b.swipeDirection=i>0?"prev":"next",P=i+E;var s=!0;if(i>0&&P>b.minTranslate()?(s=!1,b.params.resistance&&(P=b.minTranslate()-1+Math.pow(-b.minTranslate()+E+i,b.params.resistanceRatio))):0>i&&PP&&(P=E),!b.params.allowSwipeToPrev&&"prev"===b.swipeDirection&&P>E&&(P=E),b.params.followFinger){if(b.params.threshold>0){if(!(Math.abs(i)>b.params.threshold||k))return void(P=E);if(!k)return k=!0,b.touches.startX=b.touches.currentX,b.touches.startY=b.touches.currentY,P=E,void(b.touches.diff=b.isHorizontal()?b.touches.currentX-b.touches.startX:b.touches.currentY-b.touches.startY)}(b.params.freeMode||b.params.watchSlidesProgress)&&b.updateActiveIndex(),b.params.freeMode&&(0===B.length&&B.push({position:b.touches[b.isHorizontal()?"startX":"startY"],time:z}),B.push({position:b.touches[b.isHorizontal()?"currentX":"currentY"],time:(new window.Date).getTime()})),b.updateProgress(P),b.setWrapperTranslate(P)}}}}}},b.onTouchEnd=function(e){if(e.originalEvent&&(e=e.originalEvent),C&&b.emit("onTouchEnd",b,e),C=!1,x){b.params.grabCursor&&S&&x&&(b.container[0].style.cursor="move",b.container[0].style.cursor="-webkit-grab",b.container[0].style.cursor="-moz-grab",b.container[0].style.cursor="grab");var t=Date.now(),i=t-z;if(b.allowClick&&(b.updateClickedSlide(e),b.emit("onTap",b,e),300>i&&t-H>300&&(I&&clearTimeout(I),I=setTimeout(function(){b&&(b.params.paginationHide&&b.paginationContainer.length>0&&!a(e.target).hasClass(b.params.bulletClass)&&b.paginationContainer.toggleClass(b.params.paginationHiddenClass), b.emit("onClick",b,e))},300)),300>i&&300>t-H&&(I&&clearTimeout(I),b.emit("onDoubleTap",b,e))),H=Date.now(),setTimeout(function(){b&&(b.allowClick=!0)},0),!x||!S||!b.swipeDirection||0===b.touches.diff||P===E)return void(x=S=!1);x=S=!1;var r;if(r=b.params.followFinger?b.rtl?b.translate:-b.translate:-P,b.params.freeMode){if(r<-b.minTranslate())return void b.slideTo(b.activeIndex);if(r>-b.maxTranslate())return void(b.slides.length1){var s=B.pop(),n=B.pop(),o=s.position-n.position,l=s.time-n.time;b.velocity=o/l,b.velocity=b.velocity/2,Math.abs(b.velocity)150||(new window.Date).getTime()-s.time>300)&&(b.velocity=0)}else b.velocity=0;B.length=0;var p=1e3*b.params.freeModeMomentumRatio,d=b.velocity*p,u=b.translate+d;b.rtl&&(u=-u);var c,m=!1,f=20*Math.abs(b.velocity)*b.params.freeModeMomentumBounceRatio;if(ub.minTranslate())b.params.freeModeMomentumBounce?(u-b.minTranslate()>f&&(u=b.minTranslate()+f),c=b.minTranslate(),m=!0,L=!0):u=b.minTranslate();else if(b.params.freeModeSticky){var h,g=0;for(g=0;g-u){h=g;break}u=Math.abs(b.snapGrid[h]-u)=b.params.longSwipesMs)&&(b.updateProgress(),b.updateActiveIndex()))}var v,w=0,y=b.slidesSizesGrid[0];for(v=0;v=b.slidesGrid[v]&&r=b.slidesGrid[v]&&(w=v,y=b.slidesGrid[b.slidesGrid.length-1]-b.slidesGrid[b.slidesGrid.length-2]);var T=(r-b.slidesGrid[w])/y;if(i>b.params.longSwipesMs){if(!b.params.longSwipes)return void b.slideTo(b.activeIndex);"next"===b.swipeDirection&&(T>=b.params.longSwipesRatio?b.slideTo(w+b.params.slidesPerGroup):b.slideTo(w)),"prev"===b.swipeDirection&&(T>1-b.params.longSwipesRatio?b.slideTo(w+b.params.slidesPerGroup):b.slideTo(w))}else{if(!b.params.shortSwipes)return void b.slideTo(b.activeIndex);"next"===b.swipeDirection&&b.slideTo(w+b.params.slidesPerGroup),"prev"===b.swipeDirection&&b.slideTo(w)}}},b._slideTo=function(e,a){return b.slideTo(e,a,!0,!0)},b.slideTo=function(e,a,t,i){"undefined"==typeof t&&(t=!0),"undefined"==typeof e&&(e=0),0>e&&(e=0),b.snapIndex=Math.floor(e/b.params.slidesPerGroup),b.snapIndex>=b.snapGrid.length&&(b.snapIndex=b.snapGrid.length-1);var r=-b.snapGrid[b.snapIndex];b.params.autoplay&&b.autoplaying&&(i||!b.params.autoplayDisableOnInteraction?b.pauseAutoplay(a):b.stopAutoplay()),b.updateProgress(r);for(var s=0;s=Math.floor(100*b.slidesGrid[s])&&(e=s);return!b.params.allowSwipeToNext&&rb.translate&&r>b.maxTranslate()&&(b.activeIndex||0)!==e?!1:("undefined"==typeof a&&(a=b.params.speed),b.previousIndex=b.activeIndex||0,b.activeIndex=e,b.rtl&&-r===b.translate||!b.rtl&&r===b.translate?(b.params.autoHeight&&b.updateAutoHeight(),b.updateClasses(),"slide"!==b.params.effect&&b.setWrapperTranslate(r),!1):(b.updateClasses(),b.onTransitionStart(t),0===a?(b.setWrapperTranslate(r),b.setWrapperTransition(0),b.onTransitionEnd(t)):(b.setWrapperTranslate(r),b.setWrapperTransition(a),b.animating||(b.animating=!0,b.wrapper.transitionEnd(function(){b&&b.onTransitionEnd(t)}))),!0))},b.onTransitionStart=function(e){"undefined"==typeof e&&(e=!0),b.params.autoHeight&&b.updateAutoHeight(),b.lazy&&b.lazy.onTransitionStart(),e&&(b.emit("onTransitionStart",b),b.activeIndex!==b.previousIndex&&(b.emit("onSlideChangeStart",b),b.activeIndex>b.previousIndex?b.emit("onSlideNextStart",b):b.emit("onSlidePrevStart",b)))},b.onTransitionEnd=function(e){b.animating=!1,b.setWrapperTransition(0),"undefined"==typeof e&&(e=!0),b.lazy&&b.lazy.onTransitionEnd(),e&&(b.emit("onTransitionEnd",b),b.activeIndex!==b.previousIndex&&(b.emit("onSlideChangeEnd",b),b.activeIndex>b.previousIndex?b.emit("onSlideNextEnd",b):b.emit("onSlidePrevEnd",b))),b.params.hashnav&&b.hashnav&&b.hashnav.setHash()},b.slideNext=function(e,a,t){if(b.params.loop){if(b.animating)return!1;b.fixLoop();b.container[0].clientLeft;return b.slideTo(b.activeIndex+b.params.slidesPerGroup,a,e,t)}return b.slideTo(b.activeIndex+b.params.slidesPerGroup,a,e,t)},b._slideNext=function(e){return b.slideNext(!0,e,!0)},b.slidePrev=function(e,a,t){if(b.params.loop){if(b.animating)return!1;b.fixLoop();b.container[0].clientLeft;return b.slideTo(b.activeIndex-1,a,e,t)}return b.slideTo(b.activeIndex-1,a,e,t)},b._slidePrev=function(e){return b.slidePrev(!0,e,!0)},b.slideReset=function(e,a,t){return b.slideTo(b.activeIndex,a,e)},b.setWrapperTransition=function(e,a){b.wrapper.transition(e),"slide"!==b.params.effect&&b.effects[b.params.effect]&&b.effects[b.params.effect].setTransition(e),b.params.parallax&&b.parallax&&b.parallax.setTransition(e),b.params.scrollbar&&b.scrollbar&&b.scrollbar.setTransition(e),b.params.control&&b.controller&&b.controller.setTransition(e,a),b.emit("onSetTransition",b,e)},b.setWrapperTranslate=function(e,a,t){var i=0,r=0,n=0;b.isHorizontal()?i=b.rtl?-e:e:r=e,b.params.roundLengths&&(i=s(i),r=s(r)),b.params.virtualTranslate||(b.support.transforms3d?b.wrapper.transform("translate3d("+i+"px, "+r+"px, "+n+"px)"):b.wrapper.transform("translate("+i+"px, "+r+"px)")),b.translate=b.isHorizontal()?i:r;var o,l=b.maxTranslate()-b.minTranslate();o=0===l?0:(e-b.minTranslate())/l,o!==b.progress&&b.updateProgress(e),a&&b.updateActiveIndex(),"slide"!==b.params.effect&&b.effects[b.params.effect]&&b.effects[b.params.effect].setTranslate(b.translate),b.params.parallax&&b.parallax&&b.parallax.setTranslate(b.translate),b.params.scrollbar&&b.scrollbar&&b.scrollbar.setTranslate(b.translate),b.params.control&&b.controller&&b.controller.setTranslate(b.translate,t),b.emit("onSetTranslate",b,b.translate)},b.getTranslate=function(e,a){var t,i,r,s;return"undefined"==typeof a&&(a="x"),b.params.virtualTranslate?b.rtl?-b.translate:b.translate:(r=window.getComputedStyle(e,null),window.WebKitCSSMatrix?(i=r.transform||r.webkitTransform,i.split(",").length>6&&(i=i.split(", ").map(function(e){return e.replace(",",".")}).join(", ")),s=new window.WebKitCSSMatrix("none"===i?"":i)):(s=r.MozTransform||r.OTransform||r.MsTransform||r.msTransform||r.transform||r.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),t=s.toString().split(",")),"x"===a&&(i=window.WebKitCSSMatrix?s.m41:16===t.length?parseFloat(t[12]):parseFloat(t[4])),"y"===a&&(i=window.WebKitCSSMatrix?s.m42:16===t.length?parseFloat(t[13]):parseFloat(t[5])),b.rtl&&i&&(i=-i),i||0)},b.getWrapperTranslate=function(e){return"undefined"==typeof e&&(e=b.isHorizontal()?"x":"y"),b.getTranslate(b.wrapper[0],e)},b.observers=[],b.initObservers=function(){if(b.params.observeParents)for(var e=b.container.parents(),a=0;ae.length&&(b.loopedSlides=e.length);var t,i=[],r=[];for(e.each(function(t,s){var n=a(this);t=e.length-b.loopedSlides&&i.push(s),n.attr("data-swiper-slide-index",t)}),t=0;t=0;t--)b.wrapper.prepend(a(i[t].cloneNode(!0)).addClass(b.params.slideDuplicateClass))},b.destroyLoop=function(){b.wrapper.children("."+b.params.slideClass+"."+b.params.slideDuplicateClass).remove(),b.slides.removeAttr("data-swiper-slide-index")},b.fixLoop=function(){var e;b.activeIndex=2*b.loopedSlides||b.activeIndex>b.slides.length-2*b.params.slidesPerView)&&(e=-b.slides.length+b.activeIndex+b.loopedSlides,e+=b.loopedSlides,b.slideTo(e,0,!1,!0))},b.appendSlide=function(e){if(b.params.loop&&b.destroyLoop(),"object"==typeof e&&e.length)for(var a=0;aa&&t--;t=Math.max(t,0)}else a=e,b.slides[a]&&b.slides.eq(a).remove(),t>a&&t--,t=Math.max(t,0);b.params.loop&&b.createLoop(),b.params.observer&&b.support.observer||b.update(!0),b.params.loop?b.slideTo(t+b.loopedSlides,0,!1):b.slideTo(t,0,!1)},b.removeAllSlides=function(){for(var e=[],a=0;a'),t.append(d)),0===u.length&&(u=a('
'),t.append(u)),d.length&&(d[0].style.opacity=Math.max(-i,0)),u.length&&(u[0].style.opacity=Math.max(i,0))}t.transform("translate3d("+l+"px, "+p+"px, 0px) rotateX("+o+"deg) rotateY("+n+"deg)")}},setTransition:function(e){if(b.slides.transition(e).find(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").transition(e),b.params.virtualTranslate&&0!==e){var t=!1;b.slides.eq(b.activeIndex).transitionEnd(function(){if(!t&&b&&a(this).hasClass(b.params.slideActiveClass)){t=!0,b.animating=!1;for(var e=["webkitTransitionEnd","transitionend","oTransitionEnd","MSTransitionEnd","msTransitionEnd"],i=0;i'),b.wrapper.append(e)),e.css({height:b.width+"px"})):(e=b.container.find(".swiper-cube-shadow"),0===e.length&&(e=a('
'),b.container.append(e))));for(var i=0;i=o&&o>-1&&(t=90*i+90*o,b.rtl&&(t=90*-i-90*o)),r.transform(u),b.params.cube.slideShadows){var c=b.isHorizontal()?r.find(".swiper-slide-shadow-left"):r.find(".swiper-slide-shadow-top"),m=b.isHorizontal()?r.find(".swiper-slide-shadow-right"):r.find(".swiper-slide-shadow-bottom");0===c.length&&(c=a('
'),r.append(c)),0===m.length&&(m=a('
'),r.append(m)),c.length&&(c[0].style.opacity=Math.max(-o,0)),m.length&&(m[0].style.opacity=Math.max(o,0))}}if(b.wrapper.css({"-webkit-transform-origin":"50% 50% -"+b.size/2+"px","-moz-transform-origin":"50% 50% -"+b.size/2+"px","-ms-transform-origin":"50% 50% -"+b.size/2+"px","transform-origin":"50% 50% -"+b.size/2+"px"}),b.params.cube.shadow)if(b.isHorizontal())e.transform("translate3d(0px, "+(b.width/2+b.params.cube.shadowOffset)+"px, "+-b.width/2+"px) rotateX(90deg) rotateZ(0deg) scale("+b.params.cube.shadowScale+")");else{var f=Math.abs(t)-90*Math.floor(Math.abs(t)/90),h=1.5-(Math.sin(2*f*Math.PI/360)/2+Math.cos(2*f*Math.PI/360)/2),g=b.params.cube.shadowScale,v=b.params.cube.shadowScale/h,w=b.params.cube.shadowOffset;e.transform("scale3d("+g+", 1, "+v+") translate3d(0px, "+(b.height/2+w)+"px, "+-b.height/2/v+"px) rotateX(-90deg)")}var y=b.isSafari||b.isUiWebView?-b.size/2:0;b.wrapper.transform("translate3d(0px,0,"+y+"px) rotateX("+(b.isHorizontal()?0:t)+"deg) rotateY("+(b.isHorizontal()?-t:0)+"deg)")},setTransition:function(e){b.slides.transition(e).find(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").transition(e),b.params.cube.shadow&&!b.isHorizontal()&&b.container.find(".swiper-cube-shadow").transition(e)}},coverflow:{setTranslate:function(){for(var e=b.translate,t=b.isHorizontal()?-e+b.width/2:-e+b.height/2,i=b.isHorizontal()?b.params.coverflow.rotate:-b.params.coverflow.rotate,r=b.params.coverflow.depth,s=0,n=b.slides.length;n>s;s++){var o=b.slides.eq(s),l=b.slidesSizesGrid[s],p=o[0].swiperSlideOffset,d=(t-p-l/2)/l*b.params.coverflow.modifier,u=b.isHorizontal()?i*d:0,c=b.isHorizontal()?0:i*d,m=-r*Math.abs(d),f=b.isHorizontal()?0:b.params.coverflow.stretch*d,h=b.isHorizontal()?b.params.coverflow.stretch*d:0;Math.abs(h)<.001&&(h=0),Math.abs(f)<.001&&(f=0),Math.abs(m)<.001&&(m=0),Math.abs(u)<.001&&(u=0),Math.abs(c)<.001&&(c=0);var g="translate3d("+h+"px,"+f+"px,"+m+"px) rotateX("+c+"deg) rotateY("+u+"deg)";if(o.transform(g),o[0].style.zIndex=-Math.abs(Math.round(d))+1,b.params.coverflow.slideShadows){var v=b.isHorizontal()?o.find(".swiper-slide-shadow-left"):o.find(".swiper-slide-shadow-top"),w=b.isHorizontal()?o.find(".swiper-slide-shadow-right"):o.find(".swiper-slide-shadow-bottom");0===v.length&&(v=a('
'),o.append(v)),0===w.length&&(w=a('
'),o.append(w)),v.length&&(v[0].style.opacity=d>0?d:0),w.length&&(w[0].style.opacity=-d>0?-d:0)}}if(b.browser.ie){var y=b.wrapper[0].style;y.perspectiveOrigin=t+"px 50%"}},setTransition:function(e){b.slides.transition(e).find(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").transition(e)}}},b.lazy={initialImageLoaded:!1,loadImageInSlide:function(e,t){if("undefined"!=typeof e&&("undefined"==typeof t&&(t=!0),0!==b.slides.length)){var i=b.slides.eq(e),r=i.find(".swiper-lazy:not(.swiper-lazy-loaded):not(.swiper-lazy-loading)");!i.hasClass("swiper-lazy")||i.hasClass("swiper-lazy-loaded")||i.hasClass("swiper-lazy-loading")||(r=r.add(i[0])),0!==r.length&&r.each(function(){var e=a(this);e.addClass("swiper-lazy-loading");var r=e.attr("data-background"),s=e.attr("data-src"),n=e.attr("data-srcset");b.loadImage(e[0],s||r,n,!1,function(){if(r?(e.css("background-image","url("+r+")"),e.removeAttr("data-background")):(n&&(e.attr("srcset",n),e.removeAttr("data-srcset")),s&&(e.attr("src",s),e.removeAttr("data-src"))),e.addClass("swiper-lazy-loaded").removeClass("swiper-lazy-loading"),i.find(".swiper-lazy-preloader, .preloader").remove(),b.params.loop&&t){var a=i.attr("data-swiper-slide-index");if(i.hasClass(b.params.slideDuplicateClass)){var o=b.wrapper.children('[data-swiper-slide-index="'+a+'"]:not(.'+b.params.slideDuplicateClass+")");b.lazy.loadImageInSlide(o.index(),!1)}else{var l=b.wrapper.children("."+b.params.slideDuplicateClass+'[data-swiper-slide-index="'+a+'"]');b.lazy.loadImageInSlide(l.index(),!1)}}b.emit("onLazyImageReady",b,i[0],e[0])}),b.emit("onLazyImageLoad",b,i[0],e[0])})}},load:function(){var e;if(b.params.watchSlidesVisibility)b.wrapper.children("."+b.params.slideVisibleClass).each(function(){b.lazy.loadImageInSlide(a(this).index())});else if(b.params.slidesPerView>1)for(e=b.activeIndex;e1||b.params.lazyLoadingInPrevNextAmount&&b.params.lazyLoadingInPrevNextAmount>1){var t=b.params.lazyLoadingInPrevNextAmount,i=b.params.slidesPerView,r=Math.min(b.activeIndex+i+Math.max(t,i),b.slides.length),s=Math.max(b.activeIndex-Math.max(i,t),0);for(e=b.activeIndex+b.params.slidesPerView;r>e;e++)b.slides[e]&&b.lazy.loadImageInSlide(e);for(e=s;e0&&b.lazy.loadImageInSlide(n.index());var o=b.wrapper.children("."+b.params.slidePrevClass);o.length>0&&b.lazy.loadImageInSlide(o.index())}},onTransitionStart:function(){b.params.lazyLoading&&(b.params.lazyLoadingOnTransitionStart||!b.params.lazyLoadingOnTransitionStart&&!b.lazy.initialImageLoaded)&&b.lazy.load()},onTransitionEnd:function(){b.params.lazyLoading&&!b.params.lazyLoadingOnTransitionStart&&b.lazy.load()}},b.scrollbar={isTouched:!1,setDragPosition:function(e){var a=b.scrollbar,t=b.isHorizontal()?"touchstart"===e.type||"touchmove"===e.type?e.targetTouches[0].pageX:e.pageX||e.clientX:"touchstart"===e.type||"touchmove"===e.type?e.targetTouches[0].pageY:e.pageY||e.clientY,i=t-a.track.offset()[b.isHorizontal()?"left":"top"]-a.dragSize/2,r=-b.minTranslate()*a.moveDivider,s=-b.maxTranslate()*a.moveDivider;r>i?i=r:i>s&&(i=s),i=-i/a.moveDivider,b.updateProgress(i),b.setWrapperTranslate(i,!0)},dragStart:function(e){var a=b.scrollbar;a.isTouched=!0,e.preventDefault(),e.stopPropagation(),a.setDragPosition(e),clearTimeout(a.dragTimeout),a.track.transition(0),b.params.scrollbarHide&&a.track.css("opacity",1),b.wrapper.transition(100),a.drag.transition(100),b.emit("onScrollbarDragStart",b)},dragMove:function(e){var a=b.scrollbar;a.isTouched&&(e.preventDefault?e.preventDefault():e.returnValue=!1,a.setDragPosition(e),b.wrapper.transition(0),a.track.transition(0),a.drag.transition(0),b.emit("onScrollbarDragMove",b))},dragEnd:function(e){var a=b.scrollbar;a.isTouched&&(a.isTouched=!1,b.params.scrollbarHide&&(clearTimeout(a.dragTimeout),a.dragTimeout=setTimeout(function(){a.track.css("opacity",0),a.track.transition(400)},1e3)),b.emit("onScrollbarDragEnd",b),b.params.scrollbarSnapOnRelease&&b.slideReset())},enableDraggable:function(){var e=b.scrollbar,t=b.support.touch?e.track:document;a(e.track).on(b.touchEvents.start,e.dragStart),a(t).on(b.touchEvents.move,e.dragMove),a(t).on(b.touchEvents.end,e.dragEnd)},disableDraggable:function(){var e=b.scrollbar,t=b.support.touch?e.track:document;a(e.track).off(b.touchEvents.start,e.dragStart),a(t).off(b.touchEvents.move,e.dragMove),a(t).off(b.touchEvents.end,e.dragEnd)},set:function(){if(b.params.scrollbar){var e=b.scrollbar;e.track=a(b.params.scrollbar),e.drag=e.track.find(".swiper-scrollbar-drag"),0===e.drag.length&&(e.drag=a('
'),e.track.append(e.drag)),e.drag[0].style.width="",e.drag[0].style.height="",e.trackSize=b.isHorizontal()?e.track[0].offsetWidth:e.track[0].offsetHeight,e.divider=b.size/b.virtualSize,e.moveDivider=e.divider*(e.trackSize/b.size),e.dragSize=e.trackSize*e.divider,b.isHorizontal()?e.drag[0].style.width=e.dragSize+"px":e.drag[0].style.height=e.dragSize+"px",e.divider>=1?e.track[0].style.display="none":e.track[0].style.display="",b.params.scrollbarHide&&(e.track[0].style.opacity=0)}},setTranslate:function(){if(b.params.scrollbar){var e,a=b.scrollbar,t=(b.translate||0,a.dragSize);e=(a.trackSize-a.dragSize)*b.progress,b.rtl&&b.isHorizontal()?(e=-e,e>0?(t=a.dragSize-e,e=0):-e+a.dragSize>a.trackSize&&(t=a.trackSize+e)):0>e?(t=a.dragSize+e,e=0):e+a.dragSize>a.trackSize&&(t=a.trackSize-e),b.isHorizontal()?(b.support.transforms3d?a.drag.transform("translate3d("+e+"px, 0, 0)"):a.drag.transform("translateX("+e+"px)"),a.drag[0].style.width=t+"px"):(b.support.transforms3d?a.drag.transform("translate3d(0px, "+e+"px, 0)"):a.drag.transform("translateY("+e+"px)"),a.drag[0].style.height=t+"px"),b.params.scrollbarHide&&(clearTimeout(a.timeout),a.track[0].style.opacity=1,a.timeout=setTimeout(function(){a.track[0].style.opacity=0,a.track.transition(400)},1e3))}},setTransition:function(e){b.params.scrollbar&&b.scrollbar.drag.transition(e)}},b.controller={LinearSpline:function(e,a){this.x=e,this.y=a,this.lastIndex=e.length-1;var t,i;this.x.length;this.interpolate=function(e){return e?(i=r(this.x,e),t=i-1,(e-this.x[t])*(this.y[i]-this.y[t])/(this.x[i]-this.x[t])+this.y[t]):0};var r=function(){var e,a,t;return function(i,r){for(a=-1,e=i.length;e-a>1;)i[t=e+a>>1]<=r?a=t:e=t;return e}}()},getInterpolateFunction:function(e){b.controller.spline||(b.controller.spline=b.params.loop?new b.controller.LinearSpline(b.slidesGrid,e.slidesGrid):new b.controller.LinearSpline(b.snapGrid,e.snapGrid))},setTranslate:function(e,a){function i(a){e=a.rtl&&"horizontal"===a.params.direction?-b.translate:b.translate,"slide"===b.params.controlBy&&(b.controller.getInterpolateFunction(a),s=-b.controller.spline.interpolate(-e)),s&&"container"!==b.params.controlBy||(r=(a.maxTranslate()-a.minTranslate())/(b.maxTranslate()-b.minTranslate()),s=(e-b.minTranslate())*r+a.minTranslate()),b.params.controlInverse&&(s=a.maxTranslate()-s),a.updateProgress(s),a.setWrapperTranslate(s,!1,b),a.updateActiveIndex()}var r,s,n=b.params.control;if(b.isArray(n))for(var o=0;ot;t++){var r=b.slides.eq(t),s=r.attr("data-hash");if(s===e&&!r.hasClass(b.params.slideDuplicateClass)){var n=r.index();b.slideTo(n,a,b.params.runCallbacksOnInit,!0)}}}},setHash:function(){b.hashnav.initialized&&b.params.hashnav&&(document.location.hash=b.slides.eq(b.activeIndex).attr("data-hash")||"")}},b.disableKeyboardControl=function(){b.params.keyboardControl=!1,a(document).off("keydown",p)},b.enableKeyboardControl=function(){b.params.keyboardControl=!0,a(document).on("keydown",p)},b.mousewheel={event:!1,lastScrollTime:(new window.Date).getTime()},b.params.mousewheelControl){try{new window.WheelEvent("wheel"),b.mousewheel.event="wheel"}catch(O){}b.mousewheel.event||void 0===document.onmousewheel||(b.mousewheel.event="mousewheel"),b.mousewheel.event||(b.mousewheel.event="DOMMouseScroll")}b.disableMousewheelControl=function(){return b.mousewheel.event?(b.container.off(b.mousewheel.event,d),!0):!1},b.enableMousewheelControl=function(){return b.mousewheel.event?(b.container.on(b.mousewheel.event,d),!0):!1},b.parallax={setTranslate:function(){b.container.children("[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]").each(function(){u(this,b.progress)}),b.slides.each(function(){var e=a(this);e.find("[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]").each(function(){var a=Math.min(Math.max(e[0].progress,-1),1);u(this,a)})})},setTransition:function(e){"undefined"==typeof e&&(e=b.params.speed),b.container.find("[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]").each(function(){var t=a(this),i=parseInt(t.attr("data-swiper-parallax-duration"),10)||e;0===e&&(i=0),t.transition(i)})}},b._plugins=[];for(var N in b.plugins){var R=b.plugins[N](b,b.params[N]);R&&b._plugins.push(R)}return b.callPlugins=function(e){for(var a=0;a'),notify:function(e){var a=b.a11y.liveRegion;0!==a.length&&(a.html(""),a.html(e))},init:function(){if(b.params.nextButton){var e=a(b.params.nextButton);b.a11y.makeFocusable(e),b.a11y.addRole(e,"button"),b.a11y.addLabel(e,b.params.nextSlideMessage)}if(b.params.prevButton){var t=a(b.params.prevButton);b.a11y.makeFocusable(t),b.a11y.addRole(t,"button"),b.a11y.addLabel(t,b.params.prevSlideMessage)}a(b.container).append(b.a11y.liveRegion)},initPagination:function(){b.params.pagination&&b.params.paginationClickable&&b.bullets&&b.bullets.length&&b.bullets.each(function(){var e=a(this);b.a11y.makeFocusable(e),b.a11y.addRole(e,"button"),b.a11y.addLabel(e,b.params.paginationBulletMessage.replace(/{{index}}/,e.index()+1))})},destroy:function(){b.a11y.liveRegion&&b.a11y.liveRegion.length>0&&b.a11y.liveRegion.remove()}},b.init=function(){b.params.loop&&b.createLoop(),b.updateContainerSize(),b.updateSlidesSize(),b.updatePagination(),b.params.scrollbar&&b.scrollbar&&(b.scrollbar.set(),b.params.scrollbarDraggable&&b.scrollbar.enableDraggable()),"slide"!==b.params.effect&&b.effects[b.params.effect]&&(b.params.loop||b.updateProgress(),b.effects[b.params.effect].setTranslate()),b.params.loop?b.slideTo(b.params.initialSlide+b.loopedSlides,0,b.params.runCallbacksOnInit):(b.slideTo(b.params.initialSlide,0,b.params.runCallbacksOnInit),0===b.params.initialSlide&&(b.parallax&&b.params.parallax&&b.parallax.setTranslate(),b.lazy&&b.params.lazyLoading&&(b.lazy.load(),b.lazy.initialImageLoaded=!0))),b.attachEvents(),b.params.observer&&b.support.observer&&b.initObservers(),b.params.preloadImages&&!b.params.lazyLoading&&b.preloadImages(),b.params.autoplay&&b.startAutoplay(),b.params.keyboardControl&&b.enableKeyboardControl&&b.enableKeyboardControl(),b.params.mousewheelControl&&b.enableMousewheelControl&&b.enableMousewheelControl(),b.params.hashnav&&b.hashnav&&b.hashnav.init(),b.params.a11y&&b.a11y&&b.a11y.init(),b.emit("onInit",b)},b.cleanupStyles=function(){b.container.removeClass(b.classNames.join(" ")).removeAttr("style"),b.wrapper.removeAttr("style"),b.slides&&b.slides.length&&b.slides.removeClass([b.params.slideVisibleClass,b.params.slideActiveClass,b.params.slideNextClass,b.params.slidePrevClass].join(" ")).removeAttr("style").removeAttr("data-swiper-column").removeAttr("data-swiper-row"),b.paginationContainer&&b.paginationContainer.length&&b.paginationContainer.removeClass(b.params.paginationHiddenClass),b.bullets&&b.bullets.length&&b.bullets.removeClass(b.params.bulletActiveClass),b.params.prevButton&&a(b.params.prevButton).removeClass(b.params.buttonDisabledClass),b.params.nextButton&&a(b.params.nextButton).removeClass(b.params.buttonDisabledClass),b.params.scrollbar&&b.scrollbar&&(b.scrollbar.track&&b.scrollbar.track.length&&b.scrollbar.track.removeAttr("style"),b.scrollbar.drag&&b.scrollbar.drag.length&&b.scrollbar.drag.removeAttr("style"))},b.destroy=function(e,a){b.detachEvents(),b.stopAutoplay(),b.params.scrollbar&&b.scrollbar&&b.params.scrollbarDraggable&&b.scrollbar.disableDraggable(),b.params.loop&&b.destroyLoop(),a&&b.cleanupStyles(),b.disconnectObservers(),b.params.keyboardControl&&b.disableKeyboardControl&&b.disableKeyboardControl(),b.params.mousewheelControl&&b.disableMousewheelControl&&b.disableMousewheelControl(),b.params.a11y&&b.a11y&&b.a11y.destroy(),b.emit("onDestroy"),e!==!1&&(b=null)},b.init(),b}};t.prototype={isSafari:function(){var e=navigator.userAgent.toLowerCase();return e.indexOf("safari")>=0&&e.indexOf("chrome")<0&&e.indexOf("android")<0}(),isUiWebView:/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent),isArray:function(e){return"[object Array]"===Object.prototype.toString.apply(e)},browser:{ie:window.navigator.pointerEnabled||window.navigator.msPointerEnabled, ieTouch:window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints>1||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>1},device:function(){var e=navigator.userAgent,a=e.match(/(Android);?[\s\/]+([\d.]+)?/),t=e.match(/(iPad).*OS\s([\d_]+)/),i=e.match(/(iPod)(.*OS\s([\d_]+))?/),r=!t&&e.match(/(iPhone\sOS)\s([\d_]+)/);return{ios:t||r||i,android:a}}(),support:{touch:window.Modernizr&&Modernizr.touch===!0||function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)}(),transforms3d:window.Modernizr&&Modernizr.csstransforms3d===!0||function(){var e=document.createElement("div").style;return"webkitPerspective"in e||"MozPerspective"in e||"OPerspective"in e||"MsPerspective"in e||"perspective"in e}(),flexbox:function(){for(var e=document.createElement("div").style,a="alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient".split(" "),t=0;t=0&&o.indexOf(">")>=0){var l="div";for(0===o.indexOf(":~]/)?(t||document).querySelectorAll(a):[document.getElementById(a.split("#")[1])],r=0;r0&&a[0].nodeType)for(r=0;r0?parseFloat(this.css("width")):null},outerWidth:function(e){return this.length>0?e?this[0].offsetWidth+parseFloat(this.css("margin-right"))+parseFloat(this.css("margin-left")):this[0].offsetWidth:null},height:function(){return this[0]===window?window.innerHeight:this.length>0?parseFloat(this.css("height")):null},outerHeight:function(e){return this.length>0?e?this[0].offsetHeight+parseFloat(this.css("margin-top"))+parseFloat(this.css("margin-bottom")):this[0].offsetHeight:null},offset:function(){if(this.length>0){var e=this[0],a=e.getBoundingClientRect(),t=document.body,i=e.clientTop||t.clientTop||0,r=e.clientLeft||t.clientLeft||0,s=window.pageYOffset||e.scrollTop,n=window.pageXOffset||e.scrollLeft;return{top:a.top+s-i,left:a.left+n-r}}return null},css:function(e,a){var t;if(1===arguments.length){if("string"!=typeof e){for(t=0;ti-1?new e([]):0>a?(t=i+a,new e(0>t?[]:[this[t]])):new e([this[a]])},append:function(a){var t,i;for(t=0;t=0;i--)this[t].insertBefore(r.childNodes[i],this[t].childNodes[0])}else if(a instanceof e)for(i=0;i1)for(var r=0;r1)for(var r=0;r0?t?this[0].nextElementSibling&&a(this[0].nextElementSibling).is(t)?[this[0].nextElementSibling]:[]:this[0].nextElementSibling?[this[0].nextElementSibling]:[]:[])},nextAll:function(t){var i=[],r=this[0];if(!r)return new e([]);for(;r.nextElementSibling;){var s=r.nextElementSibling;t?a(s).is(t)&&i.push(s):i.push(s),r=s}return new e(i)},prev:function(t){return new e(this.length>0?t?this[0].previousElementSibling&&a(this[0].previousElementSibling).is(t)?[this[0].previousElementSibling]:[]:this[0].previousElementSibling?[this[0].previousElementSibling]:[]:[])},prevAll:function(t){var i=[],r=this[0];if(!r)return new e([]);for(;r.previousElementSibling;){var s=r.previousElementSibling;t?a(s).is(t)&&i.push(s):i.push(s),r=s}return new e(i)},parent:function(e){for(var t=[],i=0;i= 200 || document.body.scrollTop >= 100 ) { removeClass(document.querySelector('.sun-header--wrap'), 'open'); removeClass(sunHeaderNav, 'open'); removeClass(document.querySelector('.sun-newsuk'), 'open'); removeClass(document.querySelector('.sun-newsuk__button'), 'open'); if(subNav) { removeClass(subNav, 'open'); } } if( document.documentElement.scrollTop >= 250 || document.body.scrollTop >= 250 ) { removeClass(sunHeaderNav, 'sun-header__mini-remove'); removeClass(sunHeaderNavBg, 'scrolling-remove'); addClass(sunHeaderNav, 'sun-header__mini'); addClass(sunHeaderNavBg, 'scrolling'); } else { addClass(sunHeaderNav, 'sun-header__mini-remove'); addClass(sunHeaderNavBg, 'scrolling-remove'); setTimeout(function () { removeClass(sunHeaderNav, 'sun-header__mini'); removeClass(sunHeaderNavBg, 'scrolling'); }, 100) } } function miniNavScrollEvent () { window.addEventListener('scroll', debounce(miniNav, 10)); } // POPUP BOX function popupBox () { var openPopup = document.querySelectorAll('.open-popup-box'); addEventListenerList(openPopup, 'click', function (ev) { ev.preventDefault(); var allBoxes = document.querySelectorAll('.popup-box'); var allOpenBoxes = document.querySelectorAll('.open-popup-box'); for (var i = 0, len = allBoxes.length; i < len; i++) { removeClass(allBoxes[i], 'open'); removeClass(allOpenBoxes[i], 'open'); } var targetElement = ev.target || ev.srcElement; if ( hasClass(targetElement, 'place-inner') ) { targetElement = targetElement.parentNode; } if ( hasClass(targetElement, 'icon-search') ) { targetElement = targetElement.parentNode; } var box = targetElement.nextSibling.nextSibling; addClass(targetElement, 'open'); addClass(box, 'open'); if (box.querySelector('input')) { box.querySelector('input').focus(); } }); popupBoxClose(); } // CLOSE POPUP BOX function popupBoxClose () { var closePopup = document.querySelectorAll('.popup-box--close'); addEventListenerList(closePopup, 'click', function (ev) { ev.preventDefault(); var targetElement = ev.target || ev.srcElement; var box = targetElement.parentNode; var popupButton = targetElement.parentNode.previousSibling.previousSibling; removeClass(box, 'open'); removeClass(popupButton, 'open'); }) } function createSwiper () { var allSwiper = document.querySelectorAll('.rail .swiper-container'); for (var i = 0, len = allSwiper.length; i < len; i++) { var groupNum = allSwiper[i].parentNode.getAttribute("data-slide-count"); var groupNumTablet = allSwiper[i].parentNode.getAttribute("data-slide-count-tablet"); var groupNumMobile = 2; if ( hasClass(allSwiper[i], 'swiper-container-gallery') ) { groupNumTablet, groupNumMobile = 1; } var swiper = new Swiper(allSwiper[i], { slidesPerView: 'auto', slidesPerGroup: groupNum * 1, simulateTouch: false, prevButton: allSwiper[i].querySelector('.swiper-button-prev'), nextButton: allSwiper[i].querySelector('.swiper-button-next'), pagination: allSwiper[i].querySelector('.swiper-pagination'), paginationClickable: true, breakpoints: { 980: { slidesPerGroup: groupNumTablet * 1 }, 675: { slidesPerGroup: groupNumMobile, paginationType: 'fraction' } }, onInit: function ( swiper ) { var pagination = swiper.paginationContainer[0]; if ( pagination.querySelectorAll('.swiper-pagination-bullet').length == 1 ) { pagination.remove(); } } }); } } function createSwiperSubNav (sel) { var selSwiper = sel+' .swiper-container'; if (document.querySelector(sel)) { var index = 0; var isActive = false; var lis = document.querySelectorAll(selSwiper+' .swiper-slide'); for (var len = lis.length; index < len; ++index) { if (lis[index].className.match(/\bactive\b/)) { isActive = true; break; } } if ( !isActive ) { index = 0; } var subSwiper = new Swiper(selSwiper, { slidesPerView: 'auto', freeMode: true, prevButton: sel+' .swiper-button-prev', nextButton: sel+' .swiper-button-next', initialSlide: index, onInit: function (swiper) { if ( sel != '.club-nav--mobile' && swiper.translate < 0 ) { swiper.setWrapperTranslate(swiper.translate); } if ( sel == '.club-nav--mobile' && swiper.translate < 0 ) { swiper.setWrapperTranslate(swiper.translate + 20); } } }); setTimeout(function () { subSwiper.update(true); }, 1) } } // FIND PARENT IF HAS SPECIFIED CLASS function findAncestor (el, cls) { while ((el = el.parentElement) && !el.classList.contains(cls)); return el; } // GALLERY function openGallery () { if( window.location.hash == '#gallery' && !isMobile() ) { addClass(document.querySelector('.gallery-popup'), 'open'); createGallery('hash'); } addEventListenerList(document.querySelectorAll('.open-gallery'), 'click', function (ev) { ev.preventDefault(ev); var targetElement = ev.target || ev.srcElement; var parent; if ( targetElement.tagName == 'IMG' ) { parent = findAncestor(targetElement, 'open-gallery'); } if ( targetElement.tagName == 'SPAN' ) { parent = findAncestor(targetElement, 'open-gallery'); } if ( targetElement.tagName == 'DIV' ) { parent = findAncestor(targetElement, 'open-gallery'); } addClass(document.querySelector('.gallery-popup'), 'open'); createGallery(parent); }); } function createGallery (elem) { addClass(document.querySelector('html'), 'galleryOpen'); var galleryObj = galleryData; var swiperWrapper = document.querySelector('.gallery-popup .swiper-wrapper'); var swiperCaption = document.querySelector('.gallery-popup .swiper-caption-list'); var swiperCaptionWrap = document.querySelector('.gallery-popup .swiper-caption'); var captionHeight = []; for (var i = 0, len = galleryObj.length; i < len; i++) { var gallerySlide = document.createElement( 'div' ); gallerySlide.setAttribute( 'class', 'swiper-slide' ); gallerySlide.setAttribute( 'data-hash', 'image-'+(i+1) ); var gallerySlideImageWrap = document.createElement( 'div' ); gallerySlideImageWrap.setAttribute( 'class', 'gallery-image-wrap' ); var gallerySlideImage = document.createElement( 'img' ); gallerySlideImage.setAttribute( 'src', galleryObj[i].img ); gallerySlideImage.setAttribute( 'alt', galleryObj[i].caption ); gallerySlideImageWrap.appendChild( gallerySlideImage ); gallerySlide.appendChild( gallerySlideImageWrap ); swiperWrapper.appendChild( gallerySlide ); var gallerycredit = ''; if ( 'undefined' !== typeof galleryObj[i] && '' !== galleryObj[i].credit ) { gallerycredit = document.createElement( 'span' ); gallerycredit.setAttribute( 'class', 'credit' ); var creditText = document.createTextNode( 'Image: ' + galleryObj[i].credit ); gallerycredit.appendChild( creditText ); } var gallerycaption = document.createElement( 'p' ); gallerycaption.setAttribute( 'class', 'cap cap' + i ); var captionText = document.createTextNode( galleryObj[i].caption ); gallerycaption.appendChild( captionText ); if ( '' !== gallerycredit ) { gallerycaption.appendChild( gallerycredit ); } swiperCaption.appendChild( gallerycaption ); captionHeight[i] = gallerycaption.offsetHeight; } var index; if (elem == 'hash') { index = 0; } else { index = elem.getAttribute('data-index'); } if ( isMobile() ) { captionHeight.sort(function(a,b){return b - a}); swiperCaption.style.height = captionHeight[0] + 10 + 'px'; swiperCaptionWrap.style.bottom = -(captionHeight[0]+32) + 'px'; } createSwiperGallery(index) } function closeGallery (swiper) { addEventListenerList(document.querySelectorAll('.close-gallery'), 'click', function (ev) { var shareEmail; ev.preventDefault(ev); shareEmail = document.getElementById('sharing_email'); if ( shareEmail ) { shareEmail.style.display = 'none'; } removeClass(document.querySelector('html'), 'galleryOpen'); removeClass(document.querySelector('.gallery-popup'), 'open'); removeClass( document.querySelector('.gallery-image-load-cover'), 'loaded'); var slides = document.querySelectorAll('.gallery-popup .swiper-wrapper .swiper-slide'); var captions = document.querySelectorAll('.gallery-popup .swiper-caption-list .cap'); for (var i = 0, len = slides.length; i < len; i++) { slides[i].parentNode.removeChild(slides[i]); captions[i].parentNode.removeChild(captions[i]); }; swiper.destroy(true, true); }); } function createSwiperGallery (elemIndex) { var imageCount = 0; var swiper = new Swiper('.gallery-popup .swiper-container', { initialSlide: elemIndex, slidesPerView: 'auto', centeredSlides: true, simulateTouch: false, preloadImages: true, updateOnImagesReady: true, nextButton: '.gallery-popup .swiper-button-next', prevButton: '.gallery-popup .swiper-button-prev', pagination: '.gallery-popup .swiper-pagination', paginationType: 'fraction', onInit: function (swiper) { removeClass(document.querySelector('.gallery-popup .cap'), 'show') addClass(document.querySelector('.gallery-popup .cap.cap'+elemIndex), 'show') }, onSlideNextStart: function (swiper) { var activeIndex = swiper.activeIndex; removeClass(document.querySelector('.gallery-popup .cap.cap'+(swiper.slides.length-1)), 'show') removeClass(document.querySelector('.gallery-popup .cap.cap'+(activeIndex-1)), 'show') addClass(document.querySelector('.gallery-popup .cap.cap'+activeIndex), 'show') }, onSlidePrevStart: function (swiper) { var activeIndex = swiper.activeIndex; removeClass(document.querySelector('.gallery-popup .cap.cap'+(swiper.slides.length-1)), 'show') removeClass(document.querySelector('.gallery-popup .cap.cap'+(activeIndex+1)), 'show') addClass(document.querySelector('.gallery-popup .cap.cap'+activeIndex), 'show') }, onImagesReady: function (swiper) { swiper.update(true); swiper.slideTo(elemIndex, 1); addClass(document.querySelector('.gallery-image-load-cover'), 'loaded'); } }); closeGallery(swiper); } function toggleCaption () { addEventListenerList(document.querySelectorAll('.swiper-caption-toggle'), 'click', function (ev) { ev.preventDefault(ev); var swiperCaption = document.querySelector('.swiper-caption'); if (hasClass(swiperCaption, 'open')) { removeClass(swiperCaption, 'open'); } else { addClass(swiperCaption, 'open'); } }); } // TOGGLE SEARCH ON MOBILE function toggleSearchMobile () { addEventListenerList(document.querySelectorAll('.toggle-mobile-search'), 'click', function (ev) { ev.preventDefault(ev); if (hasClass(document.querySelector('.sun-header--search'), 'open')) { closeSearchMobile(); } else { if(hasClass(document.querySelector('.sun-newsuk'), 'open')) { closeNewsuk('open'); setTimeout(openSearchMobile, 400); } else { openSearchMobile(); } } }); } function closeSearchMobile () { removeClass(document.querySelector('.toggle-mobile-search'), 'open'); removeClass(document.querySelector('.sun-header--search'), 'open'); removeClass(document.querySelector('.sun-header--nav'), 'open'); removeClass(document.querySelector('.sub-nav__mobile-head'), 'moveDown'); removeClass(document.querySelector('.sub-nav__container'), 'moveDown'); removeClass(document.querySelector('.main-content-wrap'), 'open'); } function openSearchMobile () { addClass(document.querySelector('.toggle-mobile-search'), 'open'); addClass(document.querySelector('.sun-header--search'), 'open'); addClass(document.querySelector('.sun-header--nav'), 'open'); addClass(document.querySelector('.sub-nav__mobile-head'), 'moveDown'); addClass(document.querySelector('.sub-nav__container'), 'moveDown'); addClass(document.querySelector('.main-content-wrap'), 'open'); } // TOGGLES SECTION SUBNAV function subnavToggle () { addEventListenerList(document.querySelectorAll('.sub-nav__mobile-head'), 'click', function () { if (hasClass(document.querySelectorAll('.sub-nav__container')[0], 'open')) { removeClass(document.querySelector('html'), 'newsuk-open'); removeClass(this, 'open') removeClass(document.querySelectorAll('.sub-nav__container')[0], 'open') } else { addClass(document.querySelector('html'), 'newsuk-open'); addClass(this, 'open') addClass(document.querySelectorAll('.sub-nav__container')[0], 'open') } }); } function teaserShareCount () { var teasers = document.querySelectorAll('.teaser-item .article-data__share'); } function scrollWindow () { window.oldScrollPos = 0; window.addEventListener('scroll', function(ev) { scrollMobileNav(ev) // topTeaserImage(ev) }); } function scrollMobileNav (ev) { var nav = document.querySelector('.sun-header--nav'); var scrollPos = window.pageYOffset | document.body.scrollTop; if (scrollPos > 200) { addClass(nav, 'fixed'); } else { removeClass(nav, 'fixed'); removeClass(nav, 'show'); } if (scrollPos > 200 && window.oldScrollPos > scrollPos) { addClass(nav, 'show') } else { removeClass(nav, 'show') } window.oldScrollPos = scrollPos; } function swapActiveSubnav () { var subNavHeadText = document.querySelector('.sub-nav__mobile-head-text'); var subNavItem = document.querySelector('.sub-nav__item.active'); if (subNavHeadText) { subNavHeadText.textContent = subNavItem.querySelector('a').textContent; addClass(subNavHeadText, 'show'); } } // Load Facebook SDK (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.8"; js.onload = function(){ var ev = d.createEvent('Event'); ev.initEvent('fbSDKLoaded', true, true); d.dispatchEvent(ev) }; fjs.parentNode.insertBefore(js, fjs); } (document, 'script', 'facebook-jssdk')); // See `thesun_setup()` for image sizes if ( isMobile() ) { var offset = 300; var thesun_imager_landscape = new Imager( document.querySelectorAll( '.delayed-image-load-mobile' ), { availableWidths: { 300: '300x192' }, lazyload: true, lazyloadOffset: offset } ); var thesun_imager_hero = new Imager( document.querySelectorAll( '.delayed-image-load-mobile' ), { availableWidths: { 300: '300x192' }, lazyload: true, lazyloadOffset: offset } ); var thesun_imager_portrait = new Imager( document.querySelectorAll( '.delayed-image-load-mobile' ), { onResize: false, availableWidths: { 300: '300x192' }, lazyload: true, lazyloadOffset: offset } ); } else { var offset = 500; var thesun_imager_landscape = new Imager( document.querySelectorAll( '.delayed-image-load-landscape' ), { availableWidths: { 150: '150x100', 300: '300x192', 360: '620x413', 620: '620x413' }, lazyload: true, lazyloadOffset: offset } ); var thesun_imager_hero = new Imager( document.querySelectorAll( '.delayed-image-load-hero' ), { availableWidths: { 300: '300x192', // switches to landscape ratio at this small size 360: '620x413', 620: '620x295', 940: '940x447' }, lazyload: true, lazyloadOffset: offset } ); var thesun_imager_portrait = new Imager( document.querySelectorAll( '.delayed-image-load-portrait' ), { onResize: true, availableWidths: { 300: '300x450', 360: '620x413', 620: '620x413' }, lazyload: true, lazyloadOffset: offset } ); } /** * Function to split the lines into multiple elements. * Ellipsis can be applied to the HTML elements through CSS style but it will work with only single lines. * The code will split the contents into two line to make it compatible with CSS style Ellipsis. * * @param teaserLeadEl The HTML element. */ function splitLinesToMultipleElements(teaserLeadEl) { var elText = teaserLeadEl.textContent, el = teaserLeadEl.cloneNode(true), parentElement = teaserLeadEl.parentNode, wordArray = elText.split(' '), firstText = []; if (elText) { elText = elText.trim(); } // Apply additional styles for manipulating. el.style.height = teaserLeadEl.clientHeight / 2 + 'px'; el.style.width = teaserLeadEl.clientWidth + 'px'; el.style.overflow = 'hidden'; el.style.visibility = 'hidden'; el.style.position = 'absolute'; el.style.left = '-9999px'; el.textContent = ''; parentElement.appendChild(el); while (!(el.clientHeight < el.scrollHeight)) { if (wordArray.length <= 1) { break; } else { firstText.push(wordArray.shift()); el.textContent = firstText.join(' '); } } if ( firstText.length ) { firstText.pop(); firstText = firstText.join(' '); elText = elText.replace(firstText, ''); var firstChild = document.createElement('span'); var lastChild = document.createElement('span'); firstChild.className = 'teaser__lead_first_line'; lastChild.className = 'teaser__lead_last_line'; firstChild.textContent = firstText; lastChild.textContent = elText; teaserLeadEl.textContent = ''; teaserLeadEl.appendChild(firstChild); teaserLeadEl.appendChild(lastChild); } parentElement.removeChild(el); } /** * Loops through all the teaser lead elements and apply the Ellipsis. */ function teaserLeadEllipsis() { var ua = navigator.userAgent.toLowerCase(); var isSafari = (ua.indexOf('safari') !== -1 && ua.indexOf('chrome') === -1 ); var teaserLeads = document.getElementsByClassName('teaser__lead'); if (teaserLeads.length) { for (var i = 0; i < teaserLeads.length; i++) { if (isSafari) { addClass(teaserLeads[i], 'teaser__lead_line_clamp'); } else { splitLinesToMultipleElements(teaserLeads[i]); } } } } /** * Iframe Resize function. * Listens to the child frame and auto resize. * * @param e */ function frameHeight ( e ) { var isMobile = window.matchMedia( '(max-width: 530px)' ).matches; var height = parseInt( e.height ); var viewPortOffsetHeight = ( height * 70 ) / window.innerWidth; viewPortOffsetHeight = Math.round( viewPortOffsetHeight ) + 20; if ( isMobile && window.innerWidth > 530 ){ isMobile = false; } if ( !isMobile ){ viewPortOffsetHeight = 5; } e.height = height + viewPortOffsetHeight; } /** * Sun Login link. * @returns {string} */ function thesun_login_link() { let domainPrefixName, domainName, envi, nonProd, enviPrefix, loginLink = ( thesun_main_settings.loginlink ) ? thesun_main_settings.loginlink : 'https://login.thesun.co.uk'; if ( 'thesuncom' !== thesun_main_settings.stylesheet ) { return loginLink; } domainPrefixName = 'home'; domainName = 'thesun.co.uk'; envi = ( thesun_main_settings.envi ) ? thesun_main_settings.envi : ''; if ( ! readCookie( 'acs_ngn' ) ) { domainPrefixName = 'login'; domainName = 'the-sun.com'; } nonProd = [ 'uat', 'staging' ]; enviPrefix = ''; if ( nonProd.indexOf( envi ) !== -1 ) { enviPrefix = envi + '-'; } return 'https://' + domainPrefixName + '.' + enviPrefix + domainName; } ; // Function to get the browser width and return if it's // mobile, tablet or desktop for analytics ////////////////////////////////// function getBrowserWidth() { if ( isMobile() ) { return 'mobile'; } else if ( isTablet() ) { return 'tablet'; } else { return 'desktop'; } } /** * Converts undefined values into a string for teamium. */ function isUndefined(str) { if (str == undefined || typeof str == undefined) str = ''; if (typeof str == "string") { str = str.replace(/\'/g, ''); str = str.replace(/\"/g, ''); str = str.replace(/\#/g, ''); str = str.replace('#8230;','...'); } return str; } function isOoyala(e) { try { return e.className.indexOf('oo-player') >=0 || e.className.indexOf('ooyala-player') >= 0; } catch (e) { return undefined; } } /** * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1 * @param obj1 * @param obj2 * @returns obj3 a new object based on obj1 and obj2 * For joining two object arrays */ function mergeArray(obj1,obj2){ var obj3 = {}; for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; } for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; } return obj3; } /** * Send utag link data to tealium for tracking events * Get the array "data" which is the data specific to this event * and append it to the default data we pass to the utag object * @param data */ function gsaSendUtagData(data) { // set up array of default values ///////////////////////////////////// var conData = { 'page_site_name' : isUndefined( utag_data.page_site_name ), 'page_site_region' : isUndefined( utag_data.page_site_region ), 'page_name' : isUndefined( utag_data.page_name ), 'page_section' : isUndefined( utag_data.page_section ), 'page_section_2' : isUndefined( utag_data.page_section_2 ), 'page_type' : isUndefined( utag_data.page_type ), 'article_id' : isUndefined( utag_data.article_id ), 'article_id_type' : isUndefined( utag_data.article_id_type ), 'article_name' : isUndefined( utag_data.article_name ), 'article_name_latest' : isUndefined( utag_data.article_name_latest ), 'article_publish_timestamp' : isUndefined( utag_data.article_publish_timestamp ), 'article_publish_latest' : isUndefined( utag_data.article_publish_latest ), 'article_author' : isUndefined( utag_data.article_author ), 'article_kicker_name' : isUndefined( utag_data.article_kicker_name ), 'article_tag_name' : isUndefined( utag_data.article_tag_name ), 'page_number' : isUndefined( utag_data.page_number ), 'template_name' : isUndefined( utag_data.template_name ), 'page_restrictions' : isUndefined( utag_data.page_restrictions ), 'page_tags' : isUndefined( utag_data.page_tags ) }; // merge the two arrays var finalData = mergeArray(data,conData); utag.link(finalData); // send data to tealium } /*************************** START VIDEO STATS TRACKING NEW DATA ***************************/ // // function to convert video duration time from the default (seconds). // It serves two functions. // // duration :: the duration in seconds. // outputTime :: true/false. // if true :: output the value as HH:MM:SS // if false :: output the value as a percentage of the total time // in to hours, minutes and seconds // for tracking. The desired result is: HH:MM:SS function getVideoDuration(time, outputTime, totalDuration) { if (outputTime == true) { var hrs = ~~(time / 3600); var mins = ~~((time % 3600) / 60); var secs = Math.round(time % 60); hrs += ""; mins += ""; secs += ""; if (hrs.length == 1) hrs = "0" + hrs; if (mins.length == 1) mins = "0" + mins; if (secs.length == 1) secs = "0" + secs; return hrs + ":" + mins + ":" + secs; } else { var percentageTime = time / totalDuration * 100; percentageTime = Math.round(percentageTime); // no reutn pre specified range based on exact percentage: if (percentageTime <= 25) return "0-25"; else if (percentageTime <= 50) return "26-50" else if (percentageTime <= 75) return "51-75" else return "76-100" } } // set milestone markers to false so they can later be set true // to stop them fireing more than once var milestoneSet = []; function gsa_reset_milestone_flags() { milestoneSet["25"] = false; milestoneSet["50"] = false; milestoneSet["75"] = false; } // START: // VIDEO STATS // START: // VIDEO PLAY AND CHANGE STATE gsa_reset_milestone_flags(); // set the flags to false until we call on them var gsa_start_play = false; /** * Bind events for videos in the page. * * @param videoElementId Video element id in the DOM. * @param videoId Video id in the backlot. */ function bindVideoEvents(videoElementId, videoId) { // firstly get all the videos that have loaded on the page var videoObject = document.getElementById(videoElementId); if (gsaVideos = videoObject.querySelectorAll(".video")) { for (i=0; i < gsaVideos.length;i++ ) { // get the video's data to pass to utag var mediaTitle, mediaCategory, mediaPubTime; var mediaID = videoId; // get the video's content ID // now get the videos details which is in a class with attribute of the same data-content-id as above if (gsaVideoDetails = document.getElementById('sun-video-details-' + videoId)) { if (gsaVideoDetails.getAttribute("data-content-id") == mediaID) { // ignore if the content is different - for multiple players on one page mediaTitle = gsaVideoDetails.getAttribute("data-content-title") + ": " + gsaVideoDetails.getAttribute("data-content-details"); mediaCategory = gsaVideoDetails.getAttribute("data-video-section"); mediaPubTime = gsaVideoDetails.getAttribute("data-video-published"); } } gsaVideos[i].addEventListener('loadedmetadata', function() { // if playing for the first time gsa_start_play = true; var utagArray = { 'event_media_action':'media play', 'media_player':'ooyala', 'media_id':isUndefined(mediaID), 'media_name':isUndefined(mediaTitle), 'media_category':isUndefined(mediaCategory), 'media_publish_timestamp':isUndefined(mediaPubTime), 'media_type':'video', 'media_duration':getVideoDuration(this.duration, true), 'media_segment':getVideoDuration(this.currentTime, false, this.duration), 'media_offset':getVideoDuration(this.currentTime, true), }; gsaSendUtagData(utagArray); // send data to tealium }); // if press play gsaVideos[i].onplay = function() { // make sure milestone flags are reset gsa_reset_milestone_flags(); if (gsa_start_play == true || this.readyState == 4) { // if users pauses then plays again var utagArray = { 'event_media_action':'media play', 'media_player':'ooyala', 'media_id':isUndefined(mediaID), 'media_name':isUndefined(mediaTitle), 'media_category':isUndefined(mediaCategory), 'media_publish_timestamp':isUndefined(mediaPubTime), 'media_type':'video', 'media_duration':getVideoDuration(this.duration, true), 'media_segment':getVideoDuration(this.currentTime, false, this.duration), 'media_offset':getVideoDuration(this.currentTime, true), }; gsaSendUtagData(utagArray); // send data to tealium } }; // if 100% complete gsaVideos[i].onended = function() { // reset milestones for next video gsa_reset_milestone_flags(); var utagArray = { 'event_media_action':'media complete', 'media_player':'ooyala', 'media_id':isUndefined(mediaID), 'media_name':isUndefined(mediaTitle), 'media_category':isUndefined(mediaCategory), 'media_publish_timestamp':isUndefined(mediaPubTime), 'media_type':'video', 'media_duration':getVideoDuration(this.duration, true), 'media_milestone':"100", 'media_segment':"76-100", 'media_offset':getVideoDuration(this.duration, true), }; gsaSendUtagData(utagArray); // send data to tealium }; // log if 25%, 50% and 75% complete gsaVideos[i].ontimeupdate = function() { // check time as a percentage var percentageTime = this.currentTime / this.duration * 100; percentageTime = Math.round(percentageTime); var milestone, segment; if (percentageTime == 25) { milestone = "25"; segment = "0-25"; } else if (percentageTime == 50) { milestone = "50"; segment = "26-50"; } else if (percentageTime == 75) { milestone = "75"; segment = "51-75"; } if (milestone && milestoneSet[milestone] == false) { milestoneSet[milestone] = true; // make sure we only fire this once per milestone setTimeout( gsa_reset_milestone_flags() , 1000); // reset all the milestone flags after 1 second. var utagArray = { 'event_media_action':'media milestone', 'media_player':'ooyala', 'media_id':isUndefined(mediaID), 'media_name':isUndefined(mediaTitle), 'media_category':isUndefined(mediaCategory), 'media_publish_timestamp':isUndefined(mediaPubTime), 'media_type':'video', 'media_duration':getVideoDuration(this.duration, true), 'media_milestone':milestone, 'media_segment':segment, 'media_offset':getVideoDuration(this.currentTime, true), }; gsaSendUtagData(utagArray); // send data to tealium } }; } } // END: // VIDEO PLAY AND CHANGE STATE } document.addEventListener('DOMContentLoaded', function () { // START: // LOGO CLICK document.getElementById("logo").onclick = function () { var utagArray = { 'event_navigation_action': 'navigation', 'event_navigation_name': 'the sun logo', 'event_navigation_browsing_method':'click' }; gsaSendUtagData(utagArray); // send data to tealium }; // END: // LOGO CLICK // START: // CHANGE EDITION SELECTION if (gsaEdition = document.querySelectorAll(".edition a")) { for(i = 0; i < gsaEdition.length; i++) { gsaEdition[i].addEventListener('click', function(){ var gsaEditionName = this.innerHTML.trim(); var utagArray = { 'event_navigation_action':'navigation', 'event_navigation_name':'sun edition:selection', 'event_navigation_browsing_method':'click', 'article_parent_name':'sun edition:' + gsaEditionName, }; gsaSendUtagData(utagArray); // send data to tealium }, false); } } // END: // CHANGE EDITION SELECTION // START: // CLICK SEARCH BOX if (gsaSearch = document.querySelector(".search-bar a")) { gsaSearch.addEventListener('click', function(){ var utagArray = { 'event_engagement_action':'engagement', 'event_engagement_name':'site search:expose', 'event_engagement_browsing_method':'click', }; gsaSendUtagData(utagArray); // send data to tealium }, false); } // END: // CLICK SEARCH BOX // START: // CLICK SEARCH BUTTON if (gsaSearch = document.querySelector(".search-bar")) { gsaSearch = gsaSearch.getElementsByTagName("input"); for(i = 0; i < gsaSearch.length; i++) { if (gsaSearch[i].type == "submit") { gsaSearch[i].addEventListener('click', function(){ // get the input value var gsaSearchValue = document.querySelector(".search-bar input").value; var utagArray = { 'event_navigation_action':'navigation', 'event_navigation_name':'site search:confirm', 'event_navigation_browsing_method':'click', 'internal_search_term':gsaSearchValue, 'internal_search_type':'site search:free text' }; gsaSendUtagData(utagArray); // send data to tealium }, false); } } } // END: // CLICK SEARCH BUTTON // START: // CLICK ON NAVIGATION WITHIN THE MAIN MENU if (gsaTopNav = document.querySelectorAll("#sun-menu li a")) { for (j = 0;j < gsaTopNav.length; j++) { gsaTopNav[j].addEventListener('click', function(){ var utagArray = { 'event_navigation_action':'navigation', 'event_navigation_name':'section:selection', 'event_navigation_browsing_method':'click', 'article_parent_name':'section:'+this.textContent.trim() }; gsaSendUtagData(utagArray); // send data to tealium }, false); } } // END: // CLICK ON NAVIGATION WITHIN THE MAIN MENU // START: // CLICK ON SUB NAVIGATION if ( gsaSubNav = document.querySelectorAll(".sub-nav__list a") ) { for (i = 0;i < gsaSubNav.length; i++) { gsaSubNav[i].addEventListener('click', function(){ var utagArray = { 'event_navigation_action':'navigation', 'event_navigation_name':'subsection:selection', 'event_navigation_browsing_method':'click', 'article_parent_name':'subsection:' + isUndefined(utag_data.page_section) + ':'+this.textContent.trim() }; gsaSendUtagData(utagArray); // send data to tealium }, false); } } // END: // CLICK ON SUB NAVIGATION // START: // CLICK ON A TAG FROM A TOPIC PAGE if ( gsaTagName = document.querySelectorAll(".tags--topic a") ) { for (i = 0;i < gsaTagName.length; i++) { gsaTagName[i].addEventListener('click', function(){ var utagArray = { 'event_navigation_action':'navigation', 'event_navigation_name':'tag:selection', 'event_navigation_browsing_method':'click', 'article_parent_name':'tag:' + this.textContent.trim() }; gsaSendUtagData(utagArray); // send data to tealium }, false); } } // END: // CLICK ON A TAG FROM A TOPIC PAGE // START: // CLICK ON A TAG FROM AN ARTICLE PAGE if ( gsaTagName = document.querySelectorAll(".tags--article a") ) { for (i = 0;i < gsaTagName.length; i++) { gsaTagName[i].addEventListener('click', function(){ var utagArray = { 'event_navigation_action':'navigation', 'event_navigation_name':'topic:selection', 'event_navigation_browsing_method':'click', 'article_parent_name':'topic:' + this.textContent.trim() }; gsaSendUtagData(utagArray); // send data to tealium }, false); } } // END: // CLICK ON A TAG FROM AN ARTICLE PAGE // START: // CLICK ON ANY TEASER // THIS HAS BEEN MODIFIED FROM THE OLD CODE // Adding a condition to check that it is not a single-post page, // as we are having a separate tracking implementation for single-post page. if ( null === document.querySelector( '.single.single-post' ) ) { if ( gsaTeasers = document.querySelectorAll(".teaser-item a") ) { for (i=0; i < gsaTeasers.length; i++) { gsaTeasers[i].addEventListener('click', function(){ var wName = "article"; // normal teaser if (this.parentNode.parentNode.className.indexOf("teaser__extra-large") > 0) { // hero teaser wName = "hero"; } var teaserKicker = ""; if (this.parentNode.parentNode.querySelector(".teaser__headline")) { teaserKicker = this.parentNode.parentNode.querySelector(".teaser__headline").textContent.trim(); } var teaserTag = ""; if (this.parentNode.parentNode.querySelector(".teaser-slug__copy")) { teaserTag = this.parentNode.parentNode.querySelector(".teaser-slug__copy").textContent.trim(); } var teaserHeadline = this.parentNode.parentNode.querySelector(".teaser__subdeck").textContent.trim(); var teaserSection = this.parentNode.parentNode.querySelector(".article-data__tag a").textContent.trim(); var utagArray = { 'event_navigation_action':'navigation', 'event_navigation_name':'widget:'+wName, 'event_navigation_browsing_method':'click', 'widget_kicker':teaserKicker, 'widget_tag':teaserTag, 'widget_headline':teaserHeadline, 'widget_section':teaserSection, 'widget_type':'widget:'+wName }; gsaSendUtagData(utagArray); // send data to tealium }, false); } } } // END: // CLICK ON ANY TEASER // START: // Click on Rail interaction // Adding a condition to check that it is not a single-post page, // as we are having a separate tracking implementation for single-post page. if ( null === document.querySelector( '.single.single-post' ) ) { if ( gsaRail = document.querySelectorAll(".rail") ) { for (i=0; i < gsaRail.length; i++ ) { var gsaRailContainer = gsaRail[i].querySelector('.swiper-container'); var gsaRailSwiper = gsaRailContainer.swiper; // Add Swiper js callback Event for Navigation event. On bullet button click and nav next-previous button click event. gsaRailSwiper.on('onSlideChangeEnd', function ( gsaRailSwiper ) { var currentPage, totalPage, gsaRailSwiperContainer, utagArray, gsaRailTitle = ''; gsaRailSwiperContainer = gsaRailSwiper.container[0]; if ( gsaRailSwiperContainer.querySelector( '.rail__title' ) ) { gsaRailTitle = gsaRailSwiperContainer.querySelector( '.rail__title' ).textContent.trim(); } currentPage = gsaRailSwiper.snapIndex + 1; // Index start from 0. totalPage = gsaRailSwiper.snapGrid.length; utagArray = { 'event_engagement_action':'engagement', 'event_engagement_name':'rail:show segment', 'event_engagement_browsing_method':'click', 'article_parent_name':'rail:' + gsaRailTitle, 'widget_segment':'segment:' + currentPage + ' of ' + totalPage, }; gsaSendUtagData( utagArray ); // Send data to tealium. }); // START: // Click a teaser within a rail // Adding a condition to check that it is not a single-post page, // as we are having a separate tracking implementation for single-post page. var gsaTeasers = gsaRailContainer.querySelectorAll( '.rail__item' ); for ( var j = 0; j < gsaTeasers.length; j++ ) { // get rail items's kicker text and headline text if ( gsaTeasers[j].parentNode.parentNode.querySelector(".rail__title") ) { gsaTeasers[j].gsaParentTitle = gsaTeasers[j].parentNode.parentNode.querySelector(".rail__title").textContent.trim(); } if ( gsaTeasers[j].querySelector(".rail__item-headline") ) { gsaTeasers[j].gsaTeaserKickerText = gsaTeasers[j].querySelector(".rail__item-headline").textContent.trim(); } if ( gsaTeasers[j].querySelector(".rail__item-sub") ) { gsaTeasers[j].gsaTeaserTitleText = gsaTeasers[j].querySelector(".rail__item-sub").textContent.trim(); } gsaTeasers[j].addEventListener( 'click', function(){ var utagArray = { 'event_navigation_action':'navigation', 'event_navigation_name':'rail:selection:article', 'event_navigation_browsing_method':'click', 'article_parent_name':'rail:' + this.gsaParentTitle, 'widget_kicker':this.gsaTeaserKickerText, 'widget_tag':'', // This isn't coming through yet so can't be passed. 'widget_headline':this.gsaTeaserTitleText, 'widget_section':this.gsaParentTitle, 'widget_segment':'', // segment:x of t 'widget_type':'rail:' + this.gsaParentTitle }; gsaSendUtagData(utagArray); // send data to tealium }, false ); } // END: // Click a teaser within a rail } } } // END: // Click on Rail interaction // START: // Jetpack sharing button click if ( gsaSharing = document.querySelectorAll(".sd-button") ) { for (var i=0; i < gsaSharing.length; i++ ) { gsaSharing[i].addEventListener('click', function(e){ // detect if we are on a video page or not var gsaPageType; var isVideoPage = document.getElementsByClassName('social--video'); if (isVideoPage.length > 0) { gsaPageType = "video"; } else { gsaPageType = "article"; } // sharing buttons have the first class as 'share-[network]'. var network = e.target.classList.item(0).substr(6,e.target.classList.item(0).length); if ( 'share-jetpack-whatsapp' === e.target.classList.item(0)) { // whatsapp has inconsistent naming convention. network = e.target.classList.item(0).substr(14,e.target.classList.item(0).length); } var utagArray = { 'event_navigation_action':'navigation', 'event_navigation_name':gsaPageType + ':social share:' + network, 'event_navigation_browsing_method':'click', 'event_social_action':'share start', 'social_platform': network, }; gsaSendUtagData(utagArray); }, false); } } // END: // Jetpack sharing button click // START: // Click footer sharing buttons if ( gsaSharingFooter = document.querySelectorAll("footer .follow-sun a") ) { for (i=0; i < gsaSharingFooter.length; i++ ) { gsaSharingFooter[i].addEventListener('click', function(){ var gsaSharingName = this.getAttribute("class").replace('follow-',''); var utagArray = { 'event_navigation_action': 'navigation', 'event_navigation_name':"footer:social share:" + gsaSharingName, 'event_navigation_browsing_method':'click', 'event_social_action':'share start', 'social_platform':gsaSharingName }; gsaSendUtagData(utagArray); }, false); } } // END: // Click footer sharing buttons // START: // VIDEO FULL SCREEN CHANGE function fullscreenHandler (e) { var state = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen; var event = state ? 'fullscreen' : 'fullscreen closed'; var targetElement = e.target; if ( !isOoyala(targetElement) ) { return; } var parentElement = e.target.parentNode; var mediaID = parentElement.getAttribute("data-content-id"); var videoID = parentElement.querySelector("video"); // If no video is found (e.g. coming from an AD in an iFrame), then we don't want to interfere. if (!videoID) return; // LOOP THROUGH ALL sun-video-details CLASS'S AND GET THE ONE THAT MATCHES THIS CURRENT data-content-id with mediaID var mediaTitle, mediaCategory, mediaPubTime; // now get the videos details which is in a class with attribute of the same data-content-id as above if (gsaVideoDetails = document.getElementById('sun-video-details-' + mediaID)) { if (gsaVideoDetails.getAttribute("data-content-id") == mediaID) { // ignore if the content is different - for multiple players on one page mediaTitle = gsaVideoDetails.getAttribute("data-content-title") + ": " + gsaVideoDetails.getAttribute("data-content-details"); mediaCategory = gsaVideoDetails.getAttribute("data-video-section"); mediaPubTime = gsaVideoDetails.getAttribute("data-video-published"); } } var utagArray = { 'event_media_action':'media ' + event, 'media_player':'ooyala', 'media_id':isUndefined(mediaID), 'media_name':isUndefined(mediaTitle), 'media_category':isUndefined(mediaCategory), 'media_publish_timestamp':isUndefined(mediaPubTime), 'media_type':'video', 'media_duration':getVideoDuration(videoID.duration, true), 'media_segment':getVideoDuration(videoID.currentTime, false, videoID.duration), 'media_offset':getVideoDuration(videoID.currentTime, true) }; gsaSendUtagData(utagArray); // send data to tealium } document.addEventListener('fullscreenchange', fullscreenHandler, false); document.addEventListener("webkitfullscreenchange", fullscreenHandler, false); document.addEventListener("mozfullscreenchange", fullscreenHandler, false); // END: // VIDEO FULL SCREEN CHANGE // END: // VIDEO STATS // START: // CLICKING ON ARTICLE FROM SIDE RAIL var gsaSideRail = document.querySelectorAll( '.sidebar__section .teaser-item' ); if ( gsaSideRail.length > 0 ) { for ( var i = 0; i < gsaSideRail.length; i++ ) { gsaSideRail[i].addEventListener( 'click', gsa_side_rail ); } } // Implementing the GSA analytics for Side Rail. function gsa_side_rail() { var kicker = '', slug = '', headline = '', section = '', gsaRailTitle = 'no title', utagArray, position, gsaSideRail; if ( this.parentNode.querySelector( '.sidebar__title' ) ) { gsaRailTitle = this.parentNode.querySelector( '.sidebar__title' ).textContent.trim(); } if ( this.querySelector( '.teaser__headline' ) ) { kicker = this.querySelector( '.teaser__headline' ).textContent.trim(); } if ( this.querySelector( '.teaser-slug__copy' ) ) { slug = this.querySelector( '.teaser-slug__copy' ).textContent.trim(); } if ( this.querySelector( '.teaser__subdeck' ) ) { headline = this.querySelector( '.teaser__subdeck' ).textContent.trim(); } if ( this.querySelector( '.article-data__tag a' ) ) { section = this.querySelector( '.article-data__tag a' ).textContent.trim(); } gsaSideRail = document.querySelectorAll( '.sidebar__section .teaser-item' ); for ( var i = 0; i < gsaSideRail.length; i++ ) { if ( this == gsaSideRail[ i ] ) { position = i + 1; break; } } utagArray = { 'event_navigation_action': 'navigation', 'event_navigation_name': 'side rail:selection:article', 'event_navigation_browsing_method': 'click', 'article_parent_name': 'side rail:' + gsaRailTitle, 'widget_kicker': kicker, 'widget_tag': slug, 'widget_headline': headline, 'widget_section': section, 'widget_type': 'side rail:' + gsaRailTitle, 'widget_segment': 'position:' + position }; gsaSendUtagData( utagArray ); // Send data to tealium. } // END: // CLICKING ON ARTICLE FROM SIDE RAIL // START: // CLICKING ON IN-BODY RAIL var gsaInBodyRail = document.querySelectorAll( '.article__content .rail' ); if ( gsaInBodyRail.length > 0 ) { for ( i = 0; i < gsaInBodyRail.length; i++ ) { var swiperContainer = gsaInBodyRail[i].querySelector('.swiper-container'); var swiper = swiperContainer.swiper; // Add Swiper js callback Event for Navigation event. On bullet button click and nav next-previous button click event. swiper.on('onSlideChangeEnd', function (swiper) { var currentPage, totalPage, swiperContainer, utagArray, gsaRailTitle = ''; swiperContainer = swiper.container[0]; if ( swiperContainer.querySelector( '.rail__title' ) ) { gsaRailTitle = swiperContainer.querySelector( '.rail__title' ).textContent.trim(); } currentPage = swiper.snapIndex + 1; // Index start from 0. totalPage = swiper.snapGrid.length; utagArray = { 'event_engagement_action': 'engagement', 'event_engagement_name': 'in body-rail:show segment', 'event_engagement_browsing_method': 'click', 'article_parent_name': 'in-body rail:' + gsaRailTitle, 'widget_segment': 'segment:' + currentPage + ' of ' + totalPage, 'widget_type': 'in-body rail:' + gsaRailTitle }; gsaSendUtagData( utagArray ); // Send data to tealium. }); // Implementing analytics for rail item click. var gsaInBodyRailItem = swiperContainer.querySelectorAll( '.rail__item' ); for ( var j = 0; j < gsaInBodyRailItem.length; j++ ) { gsaInBodyRailItem[ j ].addEventListener( 'click', gsa_rail_item ); } } } // Implementing the GSA analytics for In-Body rail item click. function gsa_rail_item() { var kicker = '', headline = '', gsaRailTitle = '', utagArray, position, gsaRailItem; if ( this.parentNode.parentNode.querySelector( '.rail__title' ) ) { gsaRailTitle = this.parentNode.parentNode.querySelector( '.rail__title' ).textContent.trim(); } if ( this.querySelector( '.rail__item-headline' ) ) { kicker = this.querySelector( '.rail__item-headline' ).textContent.trim(); } if ( this.querySelector( '.rail__item-sub' ) ) { headline = this.querySelector( '.rail__item-sub' ).textContent.trim(); } gsaRailItem = this.parentNode.querySelectorAll( '.rail__item' ); for ( var i = 0; i < gsaRailItem.length; i++ ) { if ( this == gsaRailItem[ i ] ) { position = i + 1; break; } } utagArray = { 'event_navigation_action': 'navigation', 'event_navigation_name': 'in-body rail:selection:article', 'event_navigation_browsing_method': 'click', 'article_parent_name': 'in-body rail:' + gsaRailTitle, 'widget_kicker': kicker, 'widget_tag': "", 'widget_headline': headline, 'widget_section': "", 'widget_type': 'in-body rail:' + gsaRailTitle, 'widget_segment': 'position:' + position }; gsaSendUtagData( utagArray ); // Send data to tealium. } // Implementing the GSA analytics for In-Body rail view change. function gsa_rail_navigation() { var x, y, parent, utagArray, gsaRailTitle = ''; parent = this.parentNode; if ( this.parentNode.parentNode.querySelector( '.rail__title' ) ) { gsaRailTitle = this.parentNode.parentNode.querySelector( '.rail__title' ).textContent.trim(); } if ( parent.getElementsByClassName( 'swiper-pagination-current' ).length ) { x = parent.getElementsByClassName( 'swiper-pagination-current' )[0].textContent.trim(); y = parent.getElementsByClassName( 'swiper-pagination-total' )[0].textContent.trim(); } else if ( x = parent.getElementsByClassName( 'swiper-pagination-bullet' ) ) { y = x.length; for ( var z = 0; z < x.length; z++ ) { if ( x[ z ].className.split(' ').indexOf( 'swiper-pagination-bullet-active' ) > -1 ) { x = z + 1; break; } } } utagArray = { 'event_engagement_action': 'engagement', 'event_engagement_name': 'in body-rail:show segment', 'event_engagement_browsing_method': 'click', 'article_parent_name': 'in-body rail:' + gsaRailTitle, 'widget_segment': 'segment:' + x + ' of ' + y, 'widget_type': 'in-body rail:' + gsaRailTitle }; gsaSendUtagData( utagArray ); // Send data to tealium. } // END: // CLICKING ON IN-BODY RAIL // START: // CLICKING ON RAIL TITLE var gsaRailWidgetTitle = document.getElementsByClassName( 'rail__header--anchor' ); if ( gsaRailWidgetTitle.length ) { for ( i = 0; i < gsaRailWidgetTitle.length; i++ ) { gsaRailWidgetTitle[ i ].addEventListener( 'click', function() { var title = this.parentNode.getElementsByClassName('rail__title')[0].textContent.trim(); var utagArray = { 'event_navigation_action': 'navigation', 'event_navigation_name': 'rail:selection:title', 'event_navigation_browsing_method': 'click', 'article_parent_name': 'rail:' + title, 'widget_type': 'rail:' + title }; gsaSendUtagData( utagArray ); // Send data to tealium. }); } } // END: // CLICKING ON RAIL TITLE }); ;