1 2// jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ 3jQuery.easing.jswing=jQuery.easing.swing; 4jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,a,c,b,d){return jQuery.easing[jQuery.easing.def](e,a,c,b,d)},easeInQuad:function(e,a,c,b,d){return b*(a/=d)*a+c},easeOutQuad:function(e,a,c,b,d){return-b*(a/=d)*(a-2)+c},easeInOutQuad:function(e,a,c,b,d){return 1>(a/=d/2)?b/2*a*a+c:-b/2*(--a*(a-2)-1)+c},easeInCubic:function(e,a,c,b,d){return b*(a/=d)*a*a+c},easeOutCubic:function(e,a,c,b,d){return b*((a=a/d-1)*a*a+1)+c},easeInOutCubic:function(e,a,c,b,d){return 1>(a/=d/2)?b/2*a*a*a+c: 5 b/2*((a-=2)*a*a+2)+c},easeInQuart:function(e,a,c,b,d){return b*(a/=d)*a*a*a+c},easeOutQuart:function(e,a,c,b,d){return-b*((a=a/d-1)*a*a*a-1)+c},easeInOutQuart:function(e,a,c,b,d){return 1>(a/=d/2)?b/2*a*a*a*a+c:-b/2*((a-=2)*a*a*a-2)+c},easeInQuint:function(e,a,c,b,d){return b*(a/=d)*a*a*a*a+c},easeOutQuint:function(e,a,c,b,d){return b*((a=a/d-1)*a*a*a*a+1)+c},easeInOutQuint:function(e,a,c,b,d){return 1>(a/=d/2)?b/2*a*a*a*a*a+c:b/2*((a-=2)*a*a*a*a+2)+c},easeInSine:function(e,a,c,b,d){return-b*Math.cos(a/ 6 d*(Math.PI/2))+b+c},easeOutSine:function(e,a,c,b,d){return b*Math.sin(a/d*(Math.PI/2))+c},easeInOutSine:function(e,a,c,b,d){return-b/2*(Math.cos(Math.PI*a/d)-1)+c},easeInExpo:function(e,a,c,b,d){return 0==a?c:b*Math.pow(2,10*(a/d-1))+c},easeOutExpo:function(e,a,c,b,d){return a==d?c+b:b*(-Math.pow(2,-10*a/d)+1)+c},easeInOutExpo:function(e,a,c,b,d){return 0==a?c:a==d?c+b:1>(a/=d/2)?b/2*Math.pow(2,10*(a-1))+c:b/2*(-Math.pow(2,-10*--a)+2)+c},easeInCirc:function(e,a,c,b,d){return-b*(Math.sqrt(1-(a/=d)* 7 a)-1)+c},easeOutCirc:function(e,a,c,b,d){return b*Math.sqrt(1-(a=a/d-1)*a)+c},easeInOutCirc:function(e,a,c,b,d){return 1>(a/=d/2)?-b/2*(Math.sqrt(1-a*a)-1)+c:b/2*(Math.sqrt(1-(a-=2)*a)+1)+c},easeInElastic:function(e,a,c,b,d){e=1.70158;var f=0,g=b;if(0==a)return c;if(1==(a/=d))return c+b;f||(f=0.3*d);g<Math.abs(b)?(g=b,e=f/4):e=f/(2*Math.PI)*Math.asin(b/g);return-(g*Math.pow(2,10*(a-=1))*Math.sin((a*d-e)*2*Math.PI/f))+c},easeOutElastic:function(e,a,c,b,d){e=1.70158;var f=0,g=b;if(0==a)return c;if(1== 8 (a/=d))return c+b;f||(f=0.3*d);g<Math.abs(b)?(g=b,e=f/4):e=f/(2*Math.PI)*Math.asin(b/g);return g*Math.pow(2,-10*a)*Math.sin((a*d-e)*2*Math.PI/f)+b+c},easeInOutElastic:function(e,a,c,b,d){e=1.70158;var f=0,g=b;if(0==a)return c;if(2==(a/=d/2))return c+b;f||(f=d*0.3*1.5);g<Math.abs(b)?(g=b,e=f/4):e=f/(2*Math.PI)*Math.asin(b/g);return 1>a?-0.5*g*Math.pow(2,10*(a-=1))*Math.sin((a*d-e)*2*Math.PI/f)+c:0.5*g*Math.pow(2,-10*(a-=1))*Math.sin((a*d-e)*2*Math.PI/f)+b+c},easeInBack:function(e,a,c,b,d,f){void 0== 9 f&&(f=1.70158);return b*(a/=d)*a*((f+1)*a-f)+c},easeOutBack:function(e,a,c,b,d,f){void 0==f&&(f=1.70158);return b*((a=a/d-1)*a*((f+1)*a+f)+1)+c},easeInOutBack:function(e,a,c,b,d,f){void 0==f&&(f=1.70158);return 1>(a/=d/2)?b/2*a*a*(((f*=1.525)+1)*a-f)+c:b/2*((a-=2)*a*(((f*=1.525)+1)*a+f)+2)+c},easeInBounce:function(e,a,c,b,d){return b-jQuery.easing.easeOutBounce(e,d-a,0,b,d)+c},easeOutBounce:function(e,a,c,b,d){return(a/=d)<1/2.75?b*7.5625*a*a+c:a<2/2.75?b*(7.5625*(a-=1.5/2.75)*a+0.75)+c:a<2.5/2.75? 10 b*(7.5625*(a-=2.25/2.75)*a+0.9375)+c:b*(7.5625*(a-=2.625/2.75)*a+0.984375)+c},easeInOutBounce:function(e,a,c,b,d){return a<d/2?0.5*jQuery.easing.easeInBounce(e,2*a,0,b,d)+c:0.5*jQuery.easing.easeOutBounce(e,2*a-d,0,b,d)+0.5*b+c}}); 11 12 13 14/* 15 * v0.2b - jQuery plugin 16 * Copyright (c) 2008 Joel Birch 17 * Dual licensed under the MIT and GPL licenses: 18 * http://www.opensource.org/licenses/mit-license.php 19 * http://www.gnu.org/licenses/gpl.html 20 */ 21(function(a){a.fn.supersubs=function(h){var f=a.extend({},a.fn.supersubs.defaults,h);return this.each(function(){var c=a(this),d=a.meta?a.extend({},f,c.data()):f,h=a('<li id="menu-fontsize">—</li>').css({padding:0,position:"absolute",top:"-999em",width:"auto"}).appendTo(c).width();a("#menu-fontsize").remove();$ULs=c.find("ul");$ULs.each(function(e){e=$ULs.eq(e);var g=e.children(),c=g.children("a"),f=g.css("white-space","nowrap").css("float"),b=e.add(g).add(c).css({"float":"none",width:"auto"}).end().end()[0].clientWidth/ 22 h,b=b+d.extraWidth;b>d.maxWidth?b=d.maxWidth:b<d.minWidth&&(b=d.minWidth);b+="em";e.css("width",b);g.css({"float":f,width:"100%","white-space":"normal"}).each(function(){var c=a(">ul",this),d=void 0!==c.css("left")?"left":"right";c.css(d,b)})})})};a.fn.supersubs.defaults={minWidth:9,maxWidth:25,extraWidth:0}})(jQuery); 23 24 25 26/** 27 * hoverIntent is similar to jQuery's built-in "hover" method except that 28 * instead of firing the handlerIn function immediately, hoverIntent checks 29 * to see if the user's mouse has slowed down (beneath the sensitivity 30 * threshold) before firing the event. The handlerOut function is only 31 * called after a matching handlerIn. 32 * 33 * hoverIntent r7 // 2013.03.11 // jQuery 1.9.1+ 34 * http://cherne.net/brian/resources/jquery.hoverIntent.html 35 */ 36(function(e){e.fn.hoverIntent=function(a,f,n){var b={interval:100,sensitivity:7,timeout:0},b="object"===typeof a?e.extend(b,a):e.isFunction(f)?e.extend(b,{over:a,out:f,selector:n}):e.extend(b,{over:a,out:a,selector:f}),g,h,j,k,l=function(b){g=b.pageX;h=b.pageY},m=function(a,d){d.hoverIntent_t=clearTimeout(d.hoverIntent_t);if(Math.abs(j-g)+Math.abs(k-h)<b.sensitivity)return e(d).off("mousemove.hoverIntent",l),d.hoverIntent_s=1,b.over.apply(d,[a]);j=g;k=h;d.hoverIntent_t=setTimeout(function(){m(a,d)}, 37 b.interval)};a=function(a){var d=jQuery.extend({},a),c=this;c.hoverIntent_t&&(c.hoverIntent_t=clearTimeout(c.hoverIntent_t));
37"mouseenter"==a.type?(j=d.pageX,k=d.pageY,e(c).on("mousemove.hoverIntent",l),1!=c.hoverIntent_s&&(c.hoverIntent_t=setTimeout(function(){m(d,c)},b.interval))):(e(c).off("mousemove.hoverIntent",l),1==c.hoverIntent_s&&(c.hoverIntent_t=setTimeout(function(){c.hoverIntent_t=clearTimeout(c.hoverIntent_t);c.hoverIntent_s=0;b.out.apply(c,[d])},b.timeout)))};return this.on({"mouseenter.hoverIntent":a, 38 "mouseleave.hoverIntent":a},b.selector)}})(jQuery); 39 40/* 41 * Superfish v1.5.13 - jQuery menu widget 42 * Copyright (c) 2013 Joel Birch 43 * 44 * Dual licensed under the MIT and GPL licenses: 45 * http://www.opensource.org/licenses/mit-license.php 46 * http://www.gnu.org/licenses/gpl.html 47 * 48 */ 49(function(c){c.fn.superfish=function(d){var f=c.fn.superfish,a=f.c,g=c('<i class="'+a.arrowClass+'"></i>'),h=function(){var e=c(this),b=l(e);clearTimeout(b.sfTimer);e.showSuperfishUl().siblings().hideSuperfishUl()},j=function(e){var b=c(this),d=l(b),a=f.op,g=function(){a.retainPath=-1<c.inArray(b[0],a.$path);b.hideSuperfishUl();a.$path.length&&1>b.parents("li."+a.hoverClass).length&&(a.onIdle.call(),c.proxy(h,a.$path,e)())};"click"===e.type?g():(clearTimeout(d.sfTimer),d.sfTimer=setTimeout(g, 50 a.delay))},l=function(e){e.hasClass(a.menuClass)&&c.error("Superfish requires you to update to a version of hoverIntent that supports event-delegation, such as this one: https://github.com/joeldbirch/onHoverIntent");e=e.closest("."+a.menuClass)[0];f.op=f.o[e.serial];return e},n=function(e){var b=c(this),a=b.siblings("ul");if(0<a.length&&!a.is(":visible")&&(b.data("follow",!1),"MSPointerDown"===e.type))return b.trigger("focus"),!1},p=function(a){var b=c(this),d=b.siblings("ul"),g=!1===b.data("follow")? 51 !1:!0;if(d.length&&(f.op.useClick||!g))a.preventDefault(),d.is(":visible")?f.op.useClick&&g&&c.proxy(j,b.parent("li"),a)():c.proxy(h,b.parent("li"))()};return this.addClass(a.menuClass).each(function(){var e=this.serial=f.o.length,b=c.extend({},f.defaults,d),k=c(this),l=k.find("li:has(ul)");b.$path=k.find("li."+b.pathClass).slice(0,b.pathLevels).each(function(){c(this).addClass(b.hoverClass+" "+a.bcClass).filter("li:has(ul)").removeClass(b.pathClass)});f.o[e]=f.op=b;b.autoArrows&&l.children("a").each(function(){c(this).addClass(a.anchorClass).append(g.clone())}); 52 k.css("ms-touch-action","none");if(!f.op.useClick)if(c.fn.hoverIntent&&!f.op.disableHI)k.hoverIntent(h,j,"li:has(ul)");else k.on("mouseenter","li:has(ul)",h).on("mouseleave","li:has(ul)",j);e="MSPointerDown";navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad)/)||(e+=" touchstart");k.on("focusin","li",h).on("focusout","li",j).on("click","a",p).on(e,"a",n);l.not("."+a.bcClass).children("ul").show().hide();b.onInit.call(this)})};var g=c.fn.superfish;g.o=[];g.op={};g.c={bcClass:"sf-breadcrumb", 53 menuClass:"sf-js-enabled",anchorClass:"sf-with-ul",arrowClass:"td-icon-menu-down"};g.defaults={hoverClass:"sfHover",pathClass:"overideThisToUse",pathLevels:1,delay:800,animation:{opacity:"show"},animationOut:{opacity:"hide"},speed:"normal",speedOut:"fast",autoArrows:!0,disableHI:!1,useClick:!1,onInit:function(){},onBeforeShow:function(){},onShow:function(){},onHide:function(){},onIdle:function(){}};c.fn.extend({hideSuperfishUl:function(){var d=g.op,f=this,a=!0===d.retainPath?d.$path:"";d.retainPath= 54 !1;c("li."+d.hoverClass,this).add(this).not(a).children("ul").stop(!0,!0).animate(d.animationOut,d.speedOut,function(){$ul=c(this);$ul.parent().removeClass(d.hoverClass);d.onHide.call($ul);g.op.useClick&&f.children("a").data("follow",!1)});return this},showSuperfishUl:function(){var d=g.op,f=this,a=this.children("ul");f.addClass(d.hoverClass);d.onBeforeShow.call(a);a.stop(!0,!0).animate(d.animation,d.speed,function(){d.onShow.call(a);f.children("a").data("follow",!0)});var m=c(window).width(),h=this.children("ul").first(); 55 if(0<h.length){var j=this.children("ul").first().offset().left+h.width();j>m&&(h.parent().parent().hasClass("sf-menu")?h.css("left","-"+(j-m)+"px"):h.addClass("reversed").css("left","-"+(h.width()+0)+"px"))}return this}})})(jQuery); 56 57 58 59/* 60 * iosSlider - http://iosscripts.com/iosslider/ 61 */ 62(function(b){var oa=0,X=0,fa=0,T=0,Ca="ontouchstart"in window||0<navigator.msMaxTouchPoints,Da="onorientationchange"in window,ga=!1,aa=!1,Y=!1,pa=!1,ia=!1,ba="pointer",ua="pointer",ja=[],J=[],va=[],$=[],z=[],ca=[],B=[],m=[],s=[],wa=[],da=[],e={showScrollbar:function(a,e){a.scrollbarHide&&b("."+e).css({opacity:a.scrollbarOpacity,filter:"alpha(opacity:"+100*a.scrollbarOpacity+")"})},hideScrollbar:function(b,g,c,f,h,d,m,s,B,z){if(b.scrollbar&&b.scrollbarHide)for(var t=c;t<c+25;t++)g[g.length]=e.hideScrollbarIntervalTimer(10* t,f[c],(c+24-t)/24,h,d,m,s,B,z,b)},hideScrollbarInterval:function(a,g,c,f,h,d,m,B,z){T=-1*a/s[B]*(h-d-m-f);e.setSliderOffset("."+c,T);b("."+c).css({opacity:z.scrollbarOpacity*g,filter:"alpha(opacity:"+z.scrollbarOpacity*g*100+")"})},slowScrollHorizontalInterval:function(a,g,c,f,h,d,N,O,L,K,t,w,x,y,v,q,G,p,n){if
62(n.infiniteSlider){if(c<=-1*s[q]){var r=b(a).width();if(c<=-1*wa[q]){var u=-1*t[0];b(g).each(function(c){e.setSliderOffset(b(g)[c],u+G);c<w.length&&(w[c]=-1*u);u+=v[c]});c+=-1*w[0];m[q]=-1* w[0]+G;s[q]=m[q]+r-d;B[q]=0}else{var k=0,E=e.getSliderOffset(b(g[0]),"x");b(g).each(function(b){e.getSliderOffset(this,"x")<E&&(E=e.getSliderOffset(this,"x"),k=b)});x=m[q]+r;e.setSliderOffset(b(g)[k],x);m[q]=-1*w[1]+G;s[q]=m[q]+r-d;w.splice(0,1);w.splice(w.length,0,-1*x+G);B[q]++}}if(c>=-1*m[q]||0<=c){r=b(a).width();if(0<c)for(u=-1*t[0],b(g).each(function(c){e.setSliderOffset(b(g)[c],u+G);c<w.length&&(w[c]=-1*u);u+=v[c]}),c-=-1*w[0],m[q]=-1*w[0]+G,s[q]=m[q]+r-d,B[q]=y;0<-1*w[0]-r+G;){var A=0,I=e.getSliderOffset(b(g[0]), "x");b(g).each(function(b){e.getSliderOffset(this,"x")>I&&(I=e.getSliderOffset(this,"x"),A=b)});x=m[q]-v[A];e.setSliderOffset(b(g)[A],x);w.splice(0,0,-1*x+G);w.splice(w.length-1,1);m[q]=-1*w[0]+G;s[q]=m[q]+r-d;B[q]--;z[q]++}0>c&&(A=0,I=e.getSliderOffset(b(g[0]),"x"),b(g).each(function(b){e.getSliderOffset(this,"x")>I&&(I=e.getSliderOffset(this,"x"),A=b)}),x=m[q]-v[A],e.setSliderOffset(b(g)[A],x),w.splice(0,0,-1*x+G),w.splice(w.length-1,1),m[q]=-1*w[0]+G,s[q]=m[q]+r-d,B[q]--)}}t=!1;d=e.calcActiveOffset(n, c,w,d,B[q],y,K,q);x=(d+B[q]+y)%y;n.infiniteSlider?x!=ca[q]&&(t=!0):d!=z[q]&&(t=!0);if(t&&(y=new e.args("change",n,a,b(a).children(":eq("+x+")"),x,p),b(a).parent().data("args",y),""!=n.onSlideChange))n.onSlideChange(y);z[q]=d;ca[q]=x;c=Math.floor(c);e.setSliderOffset(a,c);n.scrollbar&&(T=Math.floor((-1*c-m[q]+G)/(s[q]-m[q]+G)*(N-O-h)),a=h-L,c>=-1*m[q]+G?(a=h-L- -1*T,e.setSliderOffset(b("."+f),0)):(c<=-1*s[q]+1&&(a=N-O-L-T),e.setSliderOffset(b("."+f),T)),b("."+f).css({width:a+"px"}))},slowScrollHorizontal:function(a, g,c,f,h,d,N,O,L,K,t,w,x,y,v,q,G,p,n,r,u){var k=e.getSliderOffset(a,"x");d=[];var E=0,A=25/1024*O;frictionCoefficient=u.frictionCoefficient;elasticFrictionCoefficient=u.elasticFrictionCoefficient;snapFrictionCoefficient=u.snapFrictionCoefficient;h>u.snapVelocityThreshold&&u.snapToChildren&&!n?E=1:h<-1*u.snapVelocityThreshold&&u.snapToChildren&&!n&&(E=-1);h<-1*A?h=-1*A:h>A&&(h=A);b(a)[0]!==b(p)[0]&&(E*=-1,h*=-2);p=B[v];if(u.infiniteSlider)var I=m[v],l=s[v];n=[];for(var A=[],F=0;F<x.length;F++)n[F]= x[F],F<g.length&&(A[F]=e.getSliderOffset(b(g[F]),"x"));for(;1<h||-1>h;){h*=frictionCoefficient;k+=h;(k>-1*m[v]||k<-1*s[v])&&!u.infiniteSlider&&(h*=elasticFrictionCoefficient,k+=h);if(u.infiniteSlider){if(k<=-1*l){for(var l=b(a).width(),J=0,P=A[0],F=0;F<A.length;F++)A[F]<P&&(P=A[F],J=F);F=I+l;A[J]=F;I=-1*n[1]+r;l=I+l-O;n.splice(0,1);n.splice(n.length,0,-1*F+r);p++}if(k>=-1*I){l=b(a).width();J=0;P=A[0];for(F=0;F<A.length;F++)A[F]>P&&(P=A[F],J=F);F=I-y[J];A[J]=F;n.splice(0,0,-1*F+r);n.splice(n.length- 1,1);I=-1*n[0]+r;l=I+l-O;p--}}d[d.length]=k}A=!1;h=e.calcActiveOffset(u,k,n,O,p,G,z[v],v);I=(h+p+G)%G;u.snapToChildren&&(u.infiniteSlider?I!=ca[v]&&(A=!0):h!=z[v]&&(A=!0),0>E&&!A?(h++,h>=x.length&&!u.infiniteSlider&&(h=x.length-1)):0<E&&!A&&(h--,0>h&&!u.infiniteSlider&&(h=0)));if(u.snapToChildren||(k>-1*m[v]||k<-1*s[v])&&!u.infiniteSlider){(k>-1*m[v]||k<-1*s[v])&&!u.infiniteSlider?d.splice(0,d.length):(d.splice(0.1*d.length,d.length),k=0<d.length?d[d.length-1]:k);for(;k<n[h]-0.5||k>n[h]+0.5;)k=(k- n[h])*snapFrictionCoefficient+n[h],d[d.length]=k;d[d.length]=n[h]}E=1;0!=d.length%2&&(E=0);for(k=0;k<c.length;k++)clearTimeout(c[k]);p=(h+p+G)%G;I=0;for(k=E;k<d.length;k+=2)if(k==E||1<Math.abs(d[k]-I)||k>=d.length-2)I=d[k],c[c.length]=e.slowScrollHorizontalIntervalTimer(10*k,a,g,d[k],f,N,O,L,K,t,h,w,x,q,G,y,v,r,p,u);I=(h+B[v]+G)%G;""!=u.onSlideComplete&&1<d.length&&(c[c.length]=e.onSlideCompleteTimer(10*(k+1),u,a,b(a).children(":eq("+I+")"),p,v));$[v]=c;e.hideScrollbar(u,c,k,d,f,N,O,K,t,v)},onSlideComplete:function(a, g,c,f,h){c=new e.args("complete",a,b(g),c,f,f);b(g).parent().data("args",c);if(""!=a.onSlideComplete)a.onSlideComplete(c)},getSliderOffset:function(a,e){var c=0;e="x"==e?4:5;if(!ga||aa||Y)c=parseInt(b(a).css("left"),10);else{for(var c=["-webkit-transform","-moz-transform","transform"],f,h=0;h<c.length;h++)if(void 0!=b(a).css(c[h])&&0<b(a).css(c[h]).length){f=b(a).css(c[h]).split(",");break}c=void 0==f[e]?0:parseInt(f[e],10)}return c},setSliderOffset:function(a,e){e=parseInt(e,10);!ga||aa||Y?b(a).css({left:e+ "px"}
62):b(a).css({msTransform:"matrix(1,0,0,1,"+e+",0)",webkitTransform:"matrix(1,0,0,1,"+e+",0)",MozTransform:"matrix(1,0,0,1,"+e+",0)",transform:"matrix(1,0,0,1,"+e+",0)"})},setBrowserInfo:function(){null!=navigator.userAgent.match("WebKit")?(ba="-webkit-grab",ua="-webkit-grabbing"):null!=navigator.userAgent.match("Gecko")?(ia=!0,ba="move",ua="-moz-grabbing"):null!=navigator.userAgent.match("MSIE 7")?pa=aa=!0:null!=navigator.userAgent.match("MSIE 8")?pa=Y=!0:null!=navigator.userAgent.match("MSIE 9")&& (pa=!0)},has3DTransform:function(){var a=!1,e=b("<div />").css({msTransform:"matrix(1,1,1,1,1,1)",webkitTransform:"matrix(1,1,1,1,1,1)",MozTransform:"matrix(1,1,1,1,1,1)",transform:"matrix(1,1,1,1,1,1)"});""==e.attr("style")?a=!1:ia&&21<=parseInt(navigator.userAgent.split("/")[3],10)?a=!1:void 0!=e.attr("style")&&(a=!0);return a},getSlideNumber:function(b,e,c){return(b-B[e]+c)%c},calcActiveOffset:function(b,e,c,f,h,d,m,s){h=!1;b=[];var z;e>c[0]&&(z=0);e<c[c.length-1]&&(z=d-1);for(d=0;d<c.length;d++)c[d]<= e&&c[d]>e-f&&(h||c[d]==e||(b[b.length]=c[d-1]),b[b.length]=c[d],h=!0);0==b.length&&(b[0]=c[c.length-1]);for(d=h=0;d<b.length;d++)m=Math.abs(e-b[d]),m<f&&(h=b[d],f=m);for(d=0;d<c.length;d++)h==c[d]&&(z=d);return z},changeSlide:function(a,g,c,f,h,d,m,s,L,K,t,w,x,y,v,q,G,p){e.autoSlidePause(y);for(var n=0;n<f.length;n++)clearTimeout(f[n]);var r=Math.ceil(p.autoSlideTransTimer/10)+1,u=e.getSliderOffset(g,"x"),k=w[a],E=k-u;if(p.infiniteSlider)for(a=(a-B[y]+2*q)%q,n=!1,0==a&&2==q&&(a=q,w[a]=w[a-1]-b(c).eq(0).outerWidth(!0), n=!0),k=w[a],E=k-u,k=[w[a]-b(g).width(),w[a]+b(g).width()],n&&w.splice(w.length-1,1),n=0;n<k.length;n++)Math.abs(k[n]-u)<Math.abs(E)&&(E=k[n]-u);var k=[],A;e.showScrollbar(p,h);for(n=0;n<=r;n++)A=n,A/=r,A--,A=u+E*(Math.pow(A,5)+1),k[k.length]=A;r=(a+B[y]+q)%q;for(n=u=0;n<k.length;n++){if(0==n||1<Math.abs(k[n]-u)||n>=k.length-2)u=k[n],f[n]=e.slowScrollHorizontalIntervalTimer(10*(n+1),g,c,k[n],h,d,m,s,L,K,a,t,w,v,q,x,y,G,r,p);0==n&&""!=p.onSlideStart&&(E=(z[y]+B[y]+q)%q,p.onSlideStart(new e.args("start", p,g,b(g).children(":eq("+E+")"),E,a)))}u=!1;p.infiniteSlider?r!=ca[y]&&(u=!0):a!=z[y]&&(u=!0);u&&""!=p.onSlideComplete&&(f[f.length]=e.onSlideCompleteTimer(10*(n+1),p,g,b(g).children(":eq("+r+")"),r,y));$[y]=f;e.hideScrollbar(p,f,n,k,h,d,m,L,K,y);e.autoSlide(g,c,f,h,d,m,s,L,K,t,w,x,y,v,q,G,p)},autoSlide:function(b,g,c,f,h,d,m,s,L,K,t,w,x,y,v,q,G){if(!J[x].autoSlide)return!1;e.autoSlidePause(x);ja[x]=setTimeout(function(){!G.infiniteSlider&&z[x]>t.length-1&&(z[x]-=v);e.changeSlide((z[x]+B[x]+t.length+ 1)%t.length,b,g,c,f,h,d,m,s,L,K,t,w,x,y,v,q,G);e.autoSlide(b,g,c,f,h,d,m,s,L,K,t,w,x,y,v,q,G)},G.autoSlideTimer+G.autoSlideTransTimer)},autoSlidePause:function(b){clearTimeout(ja[b])},isUnselectable:function(a,e){return""!=e.unselectableSelector&&1==b(a).closest(e.unselectableSelector).length?!0:!1},slowScrollHorizontalIntervalTimer:function(b,g,c,f,h,d,m,s,z,B,t,w,x,y,v,q,G,p,n,r){return setTimeout(function(){e.slowScrollHorizontalInterval(g,c,f,h,d,m,s,z,B,t,w,x,y,v,q,G,p,n,r)},b)},onSlideCompleteTimer:function(b, g,c,f,h,d){return setTimeout(function(){e.onSlideComplete(g,c,f,h,d)},b)},hideScrollbarIntervalTimer:function(b,g,c,f,h,d,m,s,z,B){return setTimeout(function(){e.hideScrollbarInterval(g,c,f,h,d,m,s,z,B)},b)},args:function(a,g,c,f,h,d){this.prevSlideNumber=void 0==b(c).parent().data("args")?void 0:b(c).parent().data("args").prevSlideNumber;this.prevSlideObject=void 0==b(c).parent().data("args")?void 0:b(c).parent().data("args").prevSlideObject;this.targetSlideNumber=d+1;this.targetSlideObject=b(c).children(":eq("+ d+")");this.slideChanged=!1;"load"==a?this.targetSlideObject=this.targetSlideNumber=void 0:"start"==a?this.targetSlideObject=this.targetSlideNumber=void 0:"change"==a?(this.slideChanged=!0,this.prevSlideNumber=void 0==b(c).parent().data("args")?g.startAtSlide:b(c).parent().data("args").currentSlideNumber,this.prevSlideObject=b(c).children(":eq("+this.prevSlideNumber+")")):"complete"==a&&(this.slideChanged=b(c).parent().data("args").slideChanged);this.settings=g;this.data=b(c).parent().data("iosslider"); this.sliderObject=c;this.sliderContainerObject=b(c).parent();this.currentSlideObject=f;this.currentSlideNumber=h+1;this.currentSliderOffset=-1*e.getSliderOffset(c,"x")},preventDrag:function(b){b.preventDefault()},preventClick:function(b){b.stopImmediatePropagation();return!1},enableClick:function(){return!0}};e.setBrowserInfo();var V={init:function(a,g){ga=e.has3DTransform();var c=b.extend(!0,{elasticPullResistance:0.6,frictionCoefficient:0.92,elasticFrictionCoefficient:0.6,snapFrictionCoefficient:0.92, snapToChildren:!1,snapSlideCenter:!1,startAtSlide:1,scrollbar:!1,scrollbarDrag:!1,scrollbarHide:!0,scrollbarLocation:"top",scrollbarContainer:"",scrollbarOpacity:0.4,scrollbarHeight:"4px",scrollbarBorder:"0",scrollbarMargin:"5px",scrollbarBackgroun
62d:"#000",scrollbarBorderRadius:"100px",scrollbarShadow:"0 0 0 #000",scrollbarElasticPullResistance:0.9,desktopClickDrag:!1,keyboardControls:!1,tabToAdvance:!1,responsiveSlideContainer:!0,responsiveSlides:!0,navSlideSelector:"",navPrevSelector:"",navNextSelector:"", autoSlideToggleSelector:"",autoSlide:!1,autoSlideTimer:5E3,autoSlideTransTimer:750,autoSlideHoverPause:!0,infiniteSlider:!1,snapVelocityThreshold:5,slideStartVelocityThreshold:0,horizontalSlideLockThreshold:5,verticalSlideLockThreshold:3,stageCSS:{position:"relative",top:"0",left:"0",overflow:"hidden",zIndex:1},unselectableSelector:"",onSliderLoaded:"",onSliderUpdate:"",onSliderResize:"",onSlideStart:"",onSlideChange:"",onSlideComplete:""},a);void 0==g&&(g=this);return b(g).each(function(a){function g(){e.autoSlidePause(d); xa=b(C).find("a");ja=b(C).find("[onclick]");qa=b(C).find("*");b(n).css("width","");b(n).css("height","");b(C).css("width","");D=b(C).children().not("script").get();ha=[];M=[];c.responsiveSlides&&b(D).css("width","");s[d]=0;l=[];q=b(n).parent().width();r=b(n).outerWidth(!0);c.responsiveSlideContainer&&(r=b(n).outerWidth(!0)>q?q:b(n).width());
62b(n).css({position:c.stageCSS.position,top:c.stageCSS.top,left:c.stageCSS.left,overflow:c.stageCSS.overflow,zIndex:c.stageCSS.zIndex,webkitPerspective:1E3,webkitBackfaceVisibility:"hidden", msTouchAction:"pan-y",width:r});b(c.unselectableSelector).css({cursor:"default"});for(var a=0;a<D.length;a++){ha[a]=b(D[a]).width();M[a]=b(D[a]).outerWidth(!0);var h=M[a];c.responsiveSlides&&(M[a]>r?(h=r+-1*(M[a]-ha[a]),ha[a]=h,M[a]=r):h=ha[a],b(D[a]).css({width:h}));b(D[a]).css({webkitBackfaceVisibility:"hidden",overflow:"hidden",position:"absolute"});l[a]=-1*s[d];s[d]=s[d]+h+(M[a]-ha[a])}c.snapSlideCenter&&(p=0.5*(r-M[0]),c.responsiveSlides&&M[0]>r&&(p=0));wa[d]=2*s[d];for(a=0;a<D.length;a++)e.setSliderOffset(b(D[a]), -1*l[a]+s[d]+p),l[a]-=s[d];if(!c.infiniteSlider&&!c.snapSlideCenter){for(a=0;a<l.length&&!(l[a]<=-1*(2*s[d]-r));a++)ia=a;l.splice(ia+1,l.length);l[l.length]=-1*(2*s[d]-r)}for(a=0;a<l.length;a++)F[a]=l[a];I&&(J[d].startAtSlide=J[d].startAtSlide>l.length?l.length:J[d].startAtSlide,c.infiniteSlider?(J[d].startAtSlide=(J[d].startAtSlide-1+H)%H,z[d]=J[d].startAtSlide):(J[d].startAtSlide=0>J[d].startAtSlide-1?l.length-1:J[d].startAtSlide,z[d]=J[d].startAtSlide-1),ca[d]=z[d]);m[d]=s[d]+p;b(C).css({position:"relative", cursor:ba,webkitPerspective:"0",webkitBackfaceVisibility:"hidden",width:s[d]+"px"});R=s[d];s[d]=2*s[d]-r+2*p;(W=R+p<r||0==r?!0:!1)&&b(C).css({cursor:"default"});G=b(n).parent().outerHeight(!0);u=b(n).height();c.responsiveSlideContainer&&(u=u>G?G:u);b(n).css({height:u});e.setSliderOffset(C,l[z[d]]);if(c.infiniteSlider&&!W){a=e.getSliderOffset(b(C),"x");for(h=(B[d]+H)%H*-1;0>h;){var f=0,A=e.getSliderOffset(b(D[0]),"x");b(D).each(function(b){e.getSliderOffset(this,"x")<A&&(A=e.getSliderOffset(this,"x"), f=b)});var L=m[d]+R;e.setSliderOffset(b(D)[f],L);m[d]=-1*l[1]+p;s[d]=m[d]+R-r;l.splice(0,1);l.splice(l.length,0,-1*L+p);h++}for(;0<-1*l[0]-R+p&&c.snapSlideCenter&&I;){var O=0,P=e.getSliderOffset(b(D[0]),"x");b(D).each(function(b){e.getSliderOffset(this,"x")>P&&(P=e.getSliderOffset(this,"x"),O=b)});L=m[d]-M[O];e.setSliderOffset(b(D)[O],L);l.splice(0,0,-1*L+p);l.splice(l.length-1,1);m[d]=-1*l[0]+p;s[d]=m[d]+R-r;B[d]--;z[d]++}for(;a<=-1*s[d];)f=0,A=e.getSliderOffset(b(D[0]),"x"),b(D).each(function(b){e.getSliderOffset(this, "x")<A&&(A=e.getSliderOffset(this,"x"),f=b)}),L=m[d]+R,e.setSliderOffset(b(D)[f],L),m[d]=-1*l[1]+p,s[d]=m[d]+R-r,l.splice(0,1),l.splice(l.length,0,-1*L+p),B[d]++,z[d]--}e.setSliderOffset(C,l[z[d]]);c.desktopClickDrag||b(C).css({cursor:"default"});c.scrollbar&&(b("."+K).css({margin:c.scrollbarMargin,overflow:"hidden",display:"none"}),b("."+K+" ."+t).css({border:c.scrollbarBorder}),k=parseInt(b("."+K).css("marginLeft"))+parseInt(b("."+K).css("marginRight")),E=parseInt(b("."+K+" ."+t).css("borderLeftWidth"), 10)+parseInt(b("."+K+" ."+t).css("borderRightWidth"),10),y=""!=c.scrollbarContainer?b(c.scrollbarContainer).width():r,v=r/R*(y-k),c.scrollbarHide||(V=c.scrollbarOpacity),b("."+K).css({position:"absolute",left:0,width:y-k+"px",margin:c.scrollbarMargin}),"top"==c.scrollbarLocation?b("."+K).css("top","0"):b("."+K).css("bottom","0"),b("."+K+" ."+t).css({borderRadius:c.scrollbarBorderRadius,background:c.scrollbarBackground,height:c.scrollbarHeight,width:v-E+"px",minWidth:c.scrollbarHeight,border:c.scrollbarBorder, webkitPerspective:1E3,webkitBackfaceVisibility:"hidden",position:"relative",opacity:V,filter:"alpha(opacity:"+100*V+")",boxShadow:c.scrollbarShadow}),e.setSliderOffset(b("."+K+" ."+t),Math.floor((-1*l[z[d]]-m[d]+p)/(s[d]-m[d]+p)*(y-k-v))),b("."+K).css({display:"block"}),w=b("."+K+" ."+t),x=b("."+K));c.scrollbarDrag&&!W&&b("."+K+" ."+t).css({cursor:ba});c.infiniteSlider&&(S=(s[d]+r)/3);""!=c.navSlideSelector&&b(c.navSlideSelector).each(function(a){b(this).css({cursor:"pointer"});b(this).unbind(Q).bind(Q, function(g){"touchstart"==g.type?b(this).unbind("click.iosSliderEvent"):b(this).unbind("touchstart.iosSliderEvent");Q=g.type+".iosSliderEvent";e.changeSlide(a,C,D,N,t,v,r,y,k,E,F,l,M,d,S,H,p,c)})});""!=c.navPrevSelector&&(b(c.navPrevSelector).css({cursor:"pointer"}),b(c.navPrevSelector).unbind(Q).bind(Q,function(a){"touchstart"==a.type?b(this).unbind("click.iosSliderEvent"):b(this).unbind("touchstart.iosSliderEvent");Q=a.type+".iosSliderEvent";
62a=(z[d]+B[d]+H)%H;(0<a||c.infiniteSlider)&&e.changeSlide(a- 1,C,D,N,t,v,r,y,k,E,F,l,M,d,S,H,p,c)}));""!=c.navNextSelector&&(b(c.navNextSelector).css({cursor:"pointer"}),b(c.navNextSelector).unbind(Q).bind(Q,function(a){"touchstart"==a.type?b(this).unbind("click.iosSliderEvent"):b(this).unbind("touchstart.iosSliderEvent");Q=a.type+".iosSliderEvent";a=(z[d]+B[d]+H)%H;(a<l.length-1||c.infiniteSlider)&&e.changeSlide(a+1,C,D,N,t,v,r,y,k,E,F,l,M,d,S,H,p,c)}));c.autoSlide&&!W&&""!=c.autoSlideToggleSelector&&(b(c.autoSlideToggleSelector).css({cursor:"pointer"}),b(c.autoSlideToggleSelector).unbind(Q).bind(Q, function(a){"touchstart"==a.type?b(this).unbind("click.iosSliderEvent"):b(this).unbind("touchstart.iosSliderEvent");Q=a.type+".iosSliderEvent";ka?(e.autoSlide(C,D,N,t,v,r,y,k,E,F,l,M,d,S,H,p,c),ka=!1,b(c.autoSlideToggleSelector).removeClass("on")):(e.autoSlidePause(d),ka=!0,b(c.autoSlideToggleSelector).addClass("on"))}));e.autoSlide(C,D,N,t,v,r,y,k,E,F,l,M,d,S,H,p,c);b(n).bind("mouseleave.iosSliderEvent",function(){if(ka)return!0;e.autoSlide(C,D,N,t,v,r,y,k,E,F,l,M,d,S,H,p,c)});b(n).bind("touchend.iosSliderEvent", function(){if(ka)return!0;e.autoSlide(C,D,N,t,v,r,y,k,E,F,l,M,d,S,H,p,c)});c.autoSlideHoverPause&&b(n).bind("mouseenter.iosSliderEvent",function(){e.autoSlidePause(d)});b(n).data("iosslider",{obj:Ba,settings:c,scrollerNode:C,slideNodes:D,numberOfSlides:H,centeredSlideOffset:p,sliderNumber:d,originalOffsets:F,childrenOffsets:l,sliderMax:s[d],scrollbarClass:t,scrollbarWidth:v,scrollbarStageWidth:y,stageWidth:r,scrollMargin:k,scrollBorder:E,infiniteSliderOffset:B[d],infiniteSliderWidth:S,slideNodeOuterWidths:M, shortContent:W});I=!1;return!0}oa++;var d=oa,N=[];J[d]=b.extend({},c);m[d]=0;s[d]=0;var O=[0,0],L=[0,0],K="scrollbarBlock"+oa,t="scrollbar"+oa,w,x,y,v,q,G,p=0,n=b(this),r,u,k,E,A,I=!0;a=-1;var l,F=[],V=0,P=0,ga=0,C=b(this).children(":first-child"),D,ha,M,H=b(C).children().not("script").length,U=!1,ia=0,ya=!1,ra=void 0,S;B[d]=0;var W=!1,ka=!1;va[d]=!1;var Z,sa=!1,la=!1,Q="touchstart.iosSliderEvent click.iosSliderEvent",R,xa,ja,qa;da[d]=!1;$[d]=[];c.scrollbarDrag&&(c.scrollbar=!0,c.scrollbarHide=!1); var Ba=b(this);if(void 0!=Ba.data("iosslider"))return!0;var ma="".split(""),na=Math.floor(12317*Math.random());b(C).parent().append("<i class = 'i"+na+"'></i>").append("<i class = 'i"+na+"'></i>");b(".i"+na).css({position:"absolute",right:"10px",bottom:"10px",zIndex:1E3,fontStyle:"normal",background:"#fff",opacity:0.2}).eq(1).css({bottom:"auto",right:"auto",top:"10px",left:"10px"});for(a=0;a<ma.length;a++)b(".i"+na).html(b(".i"+na).html()+ma[a]);14.2<=parseInt(b().jquery.split(".").join(""), 10)?b(this).delegate("img","dragstart.iosSliderEvent",function(b){b.preventDefault()}):b(this).find("img").bind("dragstart.iosSliderEvent",function(b){b.preventDefault()});c.infiniteSlider&&(c.scrollbar=!1);c.infiniteSlider&&1==H&&(c.infiniteSlider=!1);c.scrollbar&&(""!=c.scrollbarContainer?b(c.scrollbarContainer).append("<div class = '"+K+"'><div class = '"+t+"'></div></div>"):b(C).parent().append("<div class = '"+K+"'><div class = '"+t+"'></div></div>"));if(!g())return!0;b(this).find("a").bind("mousedown", e.preventDrag);b(this).find("[onclick]").bind("click",e.preventDrag).each(function(){b(this).data("onclick",this.onclick)});a=e.calcActiveOffset(c,e.getSliderOffset(b(C),"x"),l,r,B[d],H,void 0,d);a=(a+B[d]+H)%H;a=new e.args("load",c,C,b(C).children(":eq("+a+")"),a,a);b(n).data("args",a);if(""!=c.onSliderLoaded)c.onSliderLoaded(a);if(J[d].responsiveSlides||J[d].responsiveSlideContainer)a=Da?"orientationchange":"resize",b(window).bind(a+".iosSliderEvent-"+d,function(){if(!g())return!0;var a=b(n).data("args"); if(""!=c.onSliderResize)c.onSliderResize(a)});!c.keyboardControls&&!c.tabToAdvance||W||b(document).bind("keydown.iosSliderEvent",function(b){aa||Y||(b=b.originalEvent);if(da[d])return!0;if(37==b.keyCode&&c.keyboardControls)b.preventDefault(),b=(z[d]+B[d]+H)%H,(0<b||c.infiniteSlider)&&e.changeSlide(b-1,C,D,N,t,v,r,y,k,E,F,l,M,d,S,H,p,c);else if(39==b.keyCode&&c.keyboardControls||9==b.keyCode&&c.tabToAdvance)b.preventDefault(),b=(z[d]+B[d]+H)%
62H,(b<l.length-1||c.infiniteSlider)&&e.changeSlide(b+1,C, D,N,t,v,r,y,k,E,F,l,M,d,S,H,p,c)});if(Ca||c.desktopClickDrag){var ea=!1,za=!1;a=b(C);var ta=b(C),Aa=!1;c.scrollbarDrag&&(a=a.add(w),ta=ta.add(x));b(a).bind("mousedown.iosSliderEvent touchstart.iosSliderEvent",function(a){if(ea)return!0;ea=!0;za=!1;"touchstart"==a.type?b(ta).unbind("mousedown.iosSliderEvent"):b(ta).unbind("touchstart.iosSliderEvent");if(da[d]||W||(Aa=e.isUnselectable(a.target,c)))return U=ea=!1,!0;Z=b(this)[0]===b(w)[0]?w:C;aa||Y||(a=a.originalEvent);e.autoSlidePause(d);qa.unbind(".disableClick"); if("touchstart"==a.type)eventX=a.touches[0].pageX,eventY=a.touches[0].pageY;else{if(window.getSelection)window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges();else if(document.selection)if(Y)try{document.selection.empty()}catch(g){}else document.selection.empty();eventX=a.pageX;eventY=a.pageY;ya=!0;ra=C;b(this).css({cursor:ua})}O=[0,0];L=[0,0];X=0;U=!1;for(a=0;a<N.length;a++)clearTimeout(N[a]);a=e.getSliderOffset(C, "x");a>-1*m[d]+p+R?(a=-1*m[d]+p+R,e.setSliderOffset(b("."+t),a),b("."+t).css({width:v-E+"px"})):a<-1*s[d]&&(e.setSliderOffset(b("."+t),y-k-v),b("."+t).css({width:v-E+"px"}));a=b(this)[0]===b(w)[0]?m[d]:0;P=-1*(e.getSliderOffset(this,"x")-eventX-a);e.getSliderOffset(this,"y");O[1]=eventX;L[1]=eventY;la=!1});b(document).bind("touchmove.iosSliderEvent mousemove.iosSliderEvent",function(a){aa||Y||(a=a.originalEvent);if(da[d]||W||Aa||!ea)return!0;var g=0;if("touchmove"==a.type)eventX=a.touches[0].pageX, eventY=a.touches[0].pageY;else{if(window.getSelection)window.getSelection().empty||window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges();else if(document.selection)if(Y)try{document.selection.empty()}catch(h){}else document.selection.empty();eventX=a.pageX;eventY=a.pageY;if(!ya||!pa&&("undefined"!=typeof a.webkitMovementX||"undefined"!=typeof a.webkitMovementY)&&0===a.webkitMovementY&&0===a.webkitMovementX)return!0}O[0]=O[1];O[1]=eventX;X=(O[1]-O[0])/2;L[0]=L[1];L[1]=eventY; fa=(L[1]-L[0])/2;if(!U){var f=(z[d]+B[d]+H)%H,f=new e.args("start",c,C,b(C).children(":eq("+f+")"),f,void 0);b(n).data("args",f);if(""!=c.onSlideStart)c.onSlideStart(f)}(fa>c.verticalSlideLockThreshold||fa<-1*c.verticalSlideLockThreshold)&&"touchmove"==a.type&&!U&&(sa=!0);(X>c.horizontalSlideLockThreshold||X<-1*c.horizontalSlideLockThreshold)&&"touchmove"==a.type&&a.preventDefault();if(X>c.slideStartVelocityThreshold||X<-1*c.slideStartVelocityThreshold)U=!0;if(U&&!sa){var f=e.getSliderOffset(C,"x"), q=b(Z)[0]===b(w)[0]?m[d]:p,u=b(Z)[0]===b(w)[0]?(m[d]-s[d]-p)/(y-k-v):1,x=b(Z)[0]===b(w)[0]?c.scrollbarElasticPullResistance:c.elasticPullResistance,G=c.snapSlideCenter&&b(Z)[0]===b(w)[0]?0:p,K=c.snapSlideCenter&&b(Z)[0]===b(w)[0]?p:0;"touchmove"==a.type&&(ga!=a.touches.length&&(P=-1*f+eventX),ga=a.touches.length);if(c.infiniteSlider){if(f<=-1*s[d]){var I=b(C).width();if(f<=-1*wa[d]){var J=-1*F[0];b(D).each(function(a){e.setSliderOffset(b(D)[a],J+p);a<l.length&&(l[a]=-1*J);J+=M[a]});P-=-1*l[0];m[d]= -1*l[0]+p;s[d]=m[d]+I-r;B[d]=0}else{var N=0,S=e.getSliderOffset(b(D[0]),"x");b(D).each(function(b){e.getSliderOffset(this,"x")<S&&(S=e.getSliderOffset(this,"x"),N=b)});x=m[d]+I;e.setSliderOffset(b(D)[N],x);m[d]=-1*l[1]+p;s[d]=m[d]+I-r;l.splice(0,1);l.splice(l.length,0,-1*x+p);B[d]++}}if(f>=-1*m[d]||0<=f)if(I=b(C).width(),0<=f)for(J=-1*F[0],b(D).each(function(a){e.setSliderOffset(b(D)[a],J+p);a<l.length&&(l[a]=-1*J);J+=M[a]}),P+=-1*l[0],m[d]=-1*l[0]+p,s[d]=m[d]+I-r,B[d]=H;0<-1*l[0]-I+p;){var Q=0,R= e.getSliderOffset(b(D[0]),"x");b(D).each(function(b){e.getSliderOffset(this,"x")>R&&(R=e.getSliderOffset(this,"x"),Q=b)});x=m[d]-M[Q];e.setSliderOffset(b(D)[Q],x);l.splice(0,0,-1*x+p);l.splice(l.length-1,1);m[d]=-1*l[0]+p;s[d]=m[d]+I-r;B[d]--;z[d]++}else Q=0,R=e.getSliderOffset(b(D[0]),"x"),b(D).each(function(b){e.getSliderOffset(this,"x")>R&&(R=e.getSliderOffset(this,"x"),Q=b)}),x=m[d]-M[Q],e.setSliderOffset(b(D)[Q],x),l.splice(0,0,-1*x+p),l.splice(l.length-1,1),m[d]=-1*l[0]+p,s[d]=m[d]+I-r,B[d]--}else I= b(C).width(),f>-1*m[d]+p&&(g=(m[d]+-1*(P-q-eventX+G)*u-q)*x*-1/u),f<-1*s[d]&&(g=(s[d]+K+-1*(P-q-eventX)*u-q)*x*-1/u);e.setSliderOffset(C,-1*(P-q-eventX-g)*u-q+K);c.scrollbar&&(e.showScrollbar(c,t),T=Math.floor((P-eventX-g-m[d]+G)/(s[d]-m[d]+p)*(y-k-v)*u),f=v,0>=T?(f=v-E- -1*T,e.setSliderOffset(b("."+t),0),b("."+t).css({width:f+"px"})):T>=y-k-E-v?(f=y-k-E-T,e.setSliderOffset(b("."+t),T),b("."+t).css({width:f+"px"})):e.setSliderOffset(b("."+t),T));"touchmove"==a.type&&(A=a.touches[0].pageX);a=!1;g= e.calcActiveOffset(c,-1*(P-eventX-g),l,r,B[d],H,void 0,d);
62f=(g+B[d]+H)%H;c.infiniteSlider?f!=ca[d]&&(a=!0):g!=z[d]&&(a=!0);if(a&&(z[d]=g,ca[d]=f,la=!0,f=new e.args("change",c,C,b(C).children(":eq("+f+")"),f,f),b(n).data("args",f),""!=c.onSlideChange))c.onSlideChange(f)}});ma=b(window);if(Y||aa)ma=b(document);b(a).bind("touchcancel.iosSliderEvent touchend.iosSliderEvent",function(b){b=b.originalEvent;if(za)return!1;za=!0;if(da[d]||W||Aa)return!0;if(0!=b.touches.length)for(var a=0;a<b.touches.length;a++)b.touches[a].pageX== A&&e.slowScrollHorizontal(C,D,N,t,X,fa,v,r,y,k,E,F,l,M,d,S,H,Z,la,p,c);else e.slowScrollHorizontal(C,D,N,t,X,fa,v,r,y,k,E,F,l,M,d,S,H,Z,la,p,c);ea=sa=!1;return!0});b(ma).bind("mouseup.iosSliderEvent-"+d,function(a){U?xa.unbind("click.disableClick").bind("click.disableClick",e.preventClick):xa.unbind("click.disableClick").bind("click.disableClick",e.enableClick);ja.each(function(){this.onclick=function(a){if(U)return!1;b(this).data("onclick")&&b(this).data("onclick").call(this,a||window.event)};this.onclick= b(this).data("onclick")});1.8<=parseFloat(b().jquery)?qa.each(function(){var a=b._data(this,"events");if(void 0!=a&&void 0!=a.click&&"iosSliderEvent"!=a.click[0].namespace){if(!U)return!1;b(this).one("click.disableClick",e.preventClick);var a=b._data(this,"events").click,c=a.pop();a.splice(0,0,c)}}):1.6<=parseFloat(b().jquery)&&qa.each(function(){var a=b(this).data("events");if(void 0!=a&&void 0!=a.click&&"iosSliderEvent"!=a.click[0].namespace){if(!U)return!1;b(this).one("click.disableClick",e.preventClick); var a=b(this).data("events").click,c=a.pop();a.splice(0,0,c)}});if(!va[d]){if(W)return!0;c.desktopClickDrag&&b(C).css({cursor:ba});c.scrollbarDrag&&b(w).css({cursor:ba});ya=!1;if(void 0==ra)return!0;e.slowScrollHorizontal(ra,D,N,t,X,fa,v,r,y,k,E,F,l,M,d,S,H,Z,la,p,c);ra=void 0}ea=sa=!1})}})},destroy:function(a,g){void 0==g&&(g=this);return b(g).each(function(){var c=b(this),f=c.data("iosslider");if(void 0==f)return!1;void 0==a&&(a=!0);e.autoSlidePause(f.sliderNumber);va[f.sliderNumber]=!0;b(window).unbind(".iosSliderEvent-"+ f.sliderNumber);b(document).unbind(".iosSliderEvent-"+f.sliderNumber);b(document).unbind("keydown.iosSliderEvent");b(this).unbind(".iosSliderEvent");b(this).children(":first-child").unbind(".iosSliderEvent");b(this).children(":first-child").children().unbind(".iosSliderEvent");a&&(b(this).attr("style",""),b(this).children(":first-child").attr("style",""),b(this).children(":first-child").children().attr("style",""),b(f.settings.navSlideSelector).attr("style",""),b(f.settings.navPrevSelector).attr("style", ""),b(f.settings.navNextSelector).attr("style",""),b(f.settings.autoSlideToggleSelector).attr("style",""),b(f.settings.unselectableSelector).attr("style",""));f.settings.scrollbar&&b(".scrollbarBlock"+f.sliderNumber).remove();for(var f=$[f.sliderNumber],g=0;g<f.length;g++)clearTimeout(f[g]);c.removeData("iosslider");c.removeData("args")})},update:function(a){void 0==a&&(a=this);return b(a).each(function(){var a=b(this),c=a.data("iosslider");if(void 0==c)return!1;c.settings.startAtSlide=a.data("args").currentSlideNumber; V.destroy(!1,this);1!=c.numberOfSlides&&c.settings.infiniteSlider&&(c.settings.startAtSlide=(z[c.sliderNumber]+1+B[c.sliderNumber]+c.numberOfSlides)%c.numberOfSlides);V.init(c.settings,this);a=new e.args("update",c.settings,c.scrollerNode,b(c.scrollerNode).children(":eq("+(c.settings.startAtSlide-1)+")"),c.settings.startAtSlide-1,c.settings.startAtSlide-1);b(c.stageNode).data("args",a);if(""!=c.settings.onSliderUpdate)c.settings.onSliderUpdate(a)})},addSlide:function(a,e){return this.each(function(){var c= b(this),f=c.data("iosslider");if(void 0==f)return!1;0==b(f.scrollerNode).children().length?(b(f.scrollerNode).append(a),c.data("args").currentSlideNumber=1):f.settings.infiniteSlider?(1==e?b(f.scrollerNode).children(":eq(0)").before(a):b(f.scrollerNode).children(":eq("+(e-2)+")").after(a),-1>B[f.sliderNumber]&&z[f.sliderNumber]--,c.data("args").currentSlideNumber>=e&&z[f.sliderNumber]++):(e<=f.numberOfSlides?b(f.scrollerNode).children(":eq("+(e-1)+")").before(a):b(f.scrollerNode).children(":eq("+ (e-2)+")").after(a),c.data("args").currentSlideNumber>=e&&c.data("args").currentSlideNumber++);c.data("iosslider").numberOfSlides++;V.update(this)})},removeSlide:function(a){return this.each(function(){var e=b(this),c=e.data("iosslider");if(void 0==c)return!1;b(c.scrollerNode).children(":eq("+(a-1)+")").remove();z[c.sliderNumber]>a-1&&z[c.sliderNumber]--;e.data("iosslider").numberOfSlides--;V.update(this)})},goToSlide:function(a,g){void 0==g&&(g=this);return b(g).each(function(){var c=b(this).data("iosslider"); if(void 0==c||c.shortContent)return!1;a=a>c.childrenOffsets.length?c.childrenOffsets.length-1:a-1;
62e.changeSlide(a,b(c.scrollerNode),b(c.slideNodes),$[c.sliderNumber],c.scrollbarClass,c.scrollbarWidth,c.stageWidth,c.scrollbarStageWidth,c.scrollMargin,c.scrollBorder,c.originalOffsets,c.childrenOffsets,c.slideNodeOuterWidths,c.sliderNumber,c.infiniteSliderWidth,c.numberOfSlides,c.centeredSlideOffset,c.settings)})},prevSlide:function(){return this.each(function(){var a=b(this).data("iosslider");if(void 0== a||a.shortContent)return!1;var g=(z[a.sliderNumber]+B[a.sliderNumber]+a.numberOfSlides)%a.numberOfSlides;(0<g||a.settings.infiniteSlider)&&e.changeSlide(g-1,b(a.scrollerNode),b(a.slideNodes),$[a.sliderNumber],a.scrollbarClass,a.scrollbarWidth,a.stageWidth,a.scrollbarStageWidth,a.scrollMargin,a.scrollBorder,a.originalOffsets,a.childrenOffsets,a.slideNodeOuterWidths,a.sliderNumber,a.infiniteSliderWidth,a.numberOfSlides,a.centeredSlideOffset,a.settings);z[a.sliderNumber]=g})},nextSlide:function(){return this.each(function(){var a= b(this).data("iosslider");if(void 0==a||a.shortContent)return!1;var g=(z[a.sliderNumber]+B[a.sliderNumber]+a.numberOfSlides)%a.numberOfSlides;(g<a.childrenOffsets.length-1||a.settings.infiniteSlider)&&e.changeSlide(g+1,b(a.scrollerNode),b(a.slideNodes),$[a.sliderNumber],a.scrollbarClass,a.scrollbarWidth,a.stageWidth,a.scrollbarStageWidth,a.scrollMargin,a.scrollBorder,a.originalOffsets,a.childrenOffsets,a.slideNodeOuterWidths,a.sliderNumber,a.infiniteSliderWidth,a.numberOfSlides,a.centeredSlideOffset, a.settings);z[a.sliderNumber]=g})},lock:function(){return this.each(function(){var a=b(this).data("iosslider");if(void 0==a||a.shortContent)return!1;b(a.scrollerNode).css({cursor:"default"});da[a.sliderNumber]=!0})},unlock:function(){return this.each(function(){var a=b(this).data("iosslider");if(void 0==a||a.shortContent)return!1;b(a.scrollerNode).css({cursor:ba});da[a.sliderNumber]=!1})},getData:function(){return this.each(function(){var a=b(this).data("iosslider");return void 0==a||a.shortContent? !1:a})},autoSlidePause:function(){return this.each(function(){var a=b(this).data("iosslider");if(void 0==a||a.shortContent)return!1;J[a.sliderNumber].autoSlide=!1;e.autoSlidePause(a.sliderNumber);return a})},autoSlidePlay:function(){return this.each(function(){var a=b(this).data("iosslider");if(void 0==a||a.shortContent)return!1;J[a.sliderNumber].autoSlide=!0;e.autoSlide(b(a.scrollerNode),b(a.slideNodes),$[a.sliderNumber],a.scrollbarClass,a.scrollbarWidth,a.stageWidth,a.scrollbarStageWidth,a.scrollMargin, a.scrollBorder,a.originalOffsets,a.childrenOffsets,a.slideNodeOuterWidths,a.sliderNumber,a.infiniteSliderWidth,a.numberOfSlides,a.centeredSlideOffset,a.settings);return a})}};b.fn.iosSlider=function(a){if(V[a])return V[a].apply(this,Array.prototype.slice.call(arguments,1));if("object"!==typeof a&&a)b.error("invalid method call!");else return V.init.apply(this,arguments)}})(jQuery); 63 64 65 66/*! Magnific Popup - v0.9.9 - 2013-12-27 67 * http://dimsemenov.com/plugins/magnific-popup/ 68 * Copyright (c) 2013 Dmitry Semenov; */ 69(function(e){var t,n,i,o,r,a,s,l="Close",c="BeforeClose",d="AfterClose",u="BeforeAppend",p="MarkupParse",f="Open",m="Change",g="mfp",h="."+g,v="mfp-ready",C="mfp-removing",y="mfp-prevent-close",w=function(){},b=!!window.jQuery,I=e(window),x=function(e,n){t.ev.on(g+e+h,n)},k=function(t,n,i,o){var r=document.createElement("div");return r.className="mfp-"+t,i&&(r.innerHTML=i),o?n&&n.appendChild(r):(r=e(r),n&&r.appendTo(n)),r},T=function(n,i){t.ev.triggerHandler(g+n,i),t.st.callbacks&&(n=n.charAt(0).toLowerCase()+n.slice(1),t.st.callbacks[n]&&t.st.callbacks[n].apply(t,e.isArray(i)?i:[i]))},E=function(n){return n===s&&t.currTemplate.closeBtn||(t.currTemplate.closeBtn=e(t.st.closeMarkup.replace("%title%",t.st.tClose)),s=n),t.currTemplate.closeBtn},_=function(){e.magnificPopup.instance||(t=new w,t.init(),e.magnificPopup.instance=t)},S=function(){var e=document.createElement("p").style,t=["ms","O","Moz","Webkit"];if(void 0!==e.transition)return!0;for(;t.length;)if(t.pop()+"Transition"in e)return!0;return!1};w.prototype={constructor:w,init:function(){var n=navigator.appVersion;t.isIE7=-1!==n.indexOf("MSIE 7."),t.isIE8=-1!==n.indexOf("MSIE 8."),t.isLowIE=t.isIE7||t.isIE8,t.isAndroid=/android/gi.test(n),t.isIOS=/iphone|ipad|ipod/gi.test(n),t.supportsTransition=S(),t.probablyMobile=t.isAndroid||t.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),o=e(document),t.popupsCache={}},open:function(n){i||(i=e(document.body));var r;if(n.isObj===!1){t.items=n.items.toArray(),t.index=0;var s,l=n.items;for(r=0;l.length>r;r++)if(s=l[r],s.parsed&&(s=s.el[0]),s===n.el[0]){t.index=r;break}}else t.items=e.isArray(n.items)?n.items:[n.items],t.index=n.index||0;if(t.isOpen)return t.updateItemHTML(),void 0;t.types=[],a="",t.ev=n.mainEl&&n.mainEl.length?n.mainEl.eq(0):o,n.key?(t.popupsCache[n.key]||(t.popupsCache[n.key]={}),t.currTemplate=t.popupsCache[n.key]):t.currTemplate={},t.st=e.extend(!0,{},e.magnificPopup.defaults,n),t.fixedContentPos="auto"===t.st.fixedContentPos?!t.probablyMobile:t.st.fixedContentPos,t.st.modal&&(t.st.closeOnContentClick=!1,t.st.closeOnBgClick=!1,t.st.showCloseBtn=!1,t.st.enableEscapeKey=!1),t.bgOverlay||(t.bgOverlay=k("bg").on("click"+h,function(){t.close()}),t.wrap=k("wrap").attr("tabindex",-1).on("click"+h,function(e){t._checkIfClose(e.target)&&t.close()}),t.container=k("container",t.wrap)),t.contentContainer=k("content"),t.st.preloader&&(t.preloader=k("preloader",t.container,t.st.tLoading));var c=e.magnificPopup.modules;for(r=0;c.length>r;r++){var d=c[r];d=d.charAt(0).toUpperCase()+d.slice(1),t["init"+d].call(t)}T("BeforeOpen"),t.st.showCloseBtn&&(t.st.closeBtnInside?(x(p,function(e,t,n,i){n.close_replaceWith=E(i.type)}),a+=" mfp-close-btn-in"):t.wrap.append(E())),t.st.alignTop&&(a+=" mfp-align-top"),t.fixedContentPos?t.wrap.css({overflow:t.st.overflowY,overflowX:"hidden",overflowY:t.st.overflowY}):t.wrap.css({top:I.scrollTop(),position:"absolute"}),(t.st.fixedBgPos===!1||"auto"===t.st.fixedBgPos&&!t.fixedContentPos)&&t.bgOverlay.css({height:o.height(),position:"absolute"}
69),t.st.enableEscapeKey&&o.on("keyup"+h,function(e){27===e.keyCode&&t.close()}),I.on("resize"+h,function(){t.updateSize()}),t.st.closeOnContentClick||(a+=" mfp-auto-cursor"),a&&t.wrap.addClass(a);var u=t.wH=I.height(),m={};if(t.fixedContentPos&&t._hasScrollBar(u)){var g=t._getScrollbarSize();g&&(m.marginRight=g)}t.fixedContentPos&&(t.isIE7?e("body, html").css("overflow","hidden"):m.overflow="hidden");var C=t.st.mainClass;return t.isIE7&&(C+=" mfp-ie7"),C&&t._addClassToMFP(C),t.updateItemHTML(),T("BuildControls"),e("html").css(m),t.bgOverlay.add(t.wrap).prependTo(t.st.prependTo||i),t._lastFocusedEl=document.activeElement,setTimeout(function(){t.content?(t._addClassToMFP(v),t._setFocus()):t.bgOverlay.addClass(v),o.on("focusin"+h,t._onFocusIn)},16),t.isOpen=!0,t.updateSize(u),T(f),n},close:function(){t.isOpen&&(T(c),t.isOpen=!1,t.st.removalDelay&&!t.isLowIE&&t.supportsTransition?(t._addClassToMFP(C),setTimeout(function(){t._close()},t.st.removalDelay)):t._close())},_close:function(){T(l);var n=C+" "+v+" ";if(t.bgOverlay.detach(),t.wrap.detach(),t.container.empty(),t.st.mainClass&&(n+=t.st.mainClass+" "),t._removeClassFromMFP(n),t.fixedContentPos){var i={marginRight:""};t.isIE7?e("body, html").css("overflow",""):i.overflow="",e("html").css(i)}o.off("keyup"+h+" focusin"+h),t.ev.off(h),t.wrap.attr("class","mfp-wrap").removeAttr("style"),t.bgOverlay.attr("class","mfp-bg"),t.container.attr("class","mfp-container"),!t.st.showCloseBtn||t.st.closeBtnInside&&t.currTemplate[t.currItem.type]!==!0||t.currTemplate.closeBtn&&t.currTemplate.closeBtn.detach(),t._lastFocusedEl&&e(t._lastFocusedEl).focus(),t.currItem=null,t.content=null,t.currTemplate=null,t.prevHeight=0,T(d)},updateSize:function(e){if(t.isIOS){var n=document.documentElement.clientWidth/window.innerWidth,i=window.innerHeight*n;t.wrap.css("height",i),t.wH=i}else t.wH=e||I.height();t.fixedContentPos||t.wrap.css("height",t.wH),T("Resize")},updateItemHTML:function(){var n=t.items[t.index];t.contentContainer.detach(),t.content&&t.content.detach(),n.parsed||(n=t.parseEl(t.index));var i=n.type;if(T("BeforeChange",[t.currItem?t.currItem.type:"",i]),t.currItem=n,!t.currTemplate[i]){var o=t.st[i]?t.st[i].markup:!1;T("FirstMarkupParse",o),t.currTemplate[i]=o?e(o):!0}r&&r!==n.type&&t.container.removeClass("mfp-"+r+"-holder");var a=t["get"+i.charAt(0).toUpperCase()+i.slice(1)](n,t.currTemplate[i]);t.appendContent(a,i),n.preloaded=!0,T(m,n),r=n.type,t.container.prepend(t.contentContainer),T("AfterChange")},appendContent:function(e,n){t.content=e,e?t.st.showCloseBtn&&t.st.closeBtnInside&&t.currTemplate[n]===!0?t.content.find(".mfp-close").length||t.content.append(E()):t.content=e:t.content="",T(u),t.container.addClass("mfp-"+n+"-holder"),t.contentContainer.append(t.content)},parseEl:function(n){var i,o=t.items[n];if(o.tagName?o={el:e(o)}:(i=o.type,o={data:o,src:o.src}),o.el){for(var r=t.types,a=0;r.length>a;a++)if(o.el.hasClass("mfp-"+r[a])){i=r[a];break}o.src=o.el.attr("data-mfp-src"),o.src||(o.src=o.el.attr("href"))}return o.type=i||t.st.type||"inline",o.index=n,o.parsed=!0,t.items[n]=o,T("ElementParse",o),t.items[n]},addGroup:function(e,n){var i=function(i){i.mfpEl=this,t._openClick(i,e,n)};n||(n={});var o="click.magnificPopup";n.mainEl=e,n.items?(n.isObj=!0,e.off(o).on(o,i)):(n.isObj=!1,n.delegate?e.off(o).on(o,n.delegate,i):(n.items=e,e.off(o).on(o,i)))},_openClick:function(n,i,o){var r=void 0!==o.midClick?o.midClick:e.magnificPopup.defaults.midClick;if(r||2!==n.which&&!n.ctrlKey&&!n.metaKey){var a=void 0!==o.disableOn?o.disableOn:e.magnificPopup.defaults.disableOn;if(a)if(e.isFunction(a)){if(!a.call(t))return!0}else if(a>I.width())return!0;n.type&&(n.preventDefault(),t.isOpen&&n.stopPropagation()),o.el=e(n.mfpEl),o.delegate&&(o.items=i.find(o.delegate)),t.open(o)}},updateStatus:function(e,i){if(t.preloader){n!==e&&t.container.removeClass("mfp-s-"+n),i||"loading"!==e||(i=t.st.tLoading);var o={status:e,text:i};T("UpdateStatus",o),e=o.status,i=o.text,t.preloader.html(i),t.preloader.find("a").on("click",function(e){e.stopImmediatePropagation()}),t.container.addClass("mfp-s-"+e),n=e}},_checkIfClose:function(n){if(!e(n).hasClass(y)){var i=t.st.closeOnContentClick,o=t.st.closeOnBgClick;if(i&&o)return!0;
69if(!t.content||e(n).hasClass("mfp-close")||t.preloader&&n===t.preloader[0])return!0;if(n===t.content[0]||e.contains(t.content[0],n)){if(i)return!0}else if(o&&e.contains(document,n))return!0;return!1}},_addClassToMFP:function(e){t.bgOverlay.addClass(e),t.wrap.addClass(e)},_removeClassFromMFP:function(e){this.bgOverlay.removeClass(e),t.wrap.removeClass(e)},_hasScrollBar:function(e){return(t.isIE7?o.height():document.body.scrollHeight)>(e||I.height())},_setFocus:function(){(t.st.focus?t.content.find(t.st.focus).eq(0):t.wrap).focus()},_onFocusIn:function(n){return n.target===t.wrap[0]||e.contains(t.wrap[0],n.target)?void 0:(t._setFocus(),!1)},_parseMarkup:function(t,n,i){var o;i.data&&(n=e.extend(i.data,n)),T(p,[t,n,i]),e.each(n,function(e,n){if(void 0===n||n===!1)return!0;if(o=e.split("_"),o.length>1){var i=t.find(h+"-"+o[0]);if(i.length>0){var r=o[1];"replaceWith"===r?i[0]!==n[0]&&i.replaceWith(n):"img"===r?i.is("img")?i.attr("src",n):i.replaceWith('<img src="'+n+'" class="'+i.attr("class")+'" />'):i.attr(o[1],n)}}else t.find(h+"-"+e).html(n)})},_getScrollbarSize:function(){if(void 0===t.scrollbarSize){var e=document.createElement("div");e.id="mfp-sbm",e.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(e),t.scrollbarSize=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return t.scrollbarSize}},e.magnificPopup={instance:null,proto:w.prototype,modules:[],open:function(t,n){return _(),t=t?e.extend(!0,{},t):{},t.isObj=!0,t.index=n||0,this.instance.open(t)},close:function(){return e.magnificPopup.instance&&e.magnificPopup.instance.close()},registerModule:function(t,n){n.options&&(e.magnificPopup.defaults[t]=n.options),e.extend(this.proto,n.proto),this.modules.push(t)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">×</button>',tClose:"Close (Esc)",tLoading:"Loading..."}},e.fn.magnificPopup=function(n){_();var i=e(this);if("string"==typeof n)if("open"===n){var o,r=b?i.data("magnificPopup"):i[0].magnificPopup,a=parseInt(arguments[1],10)||0;r.items?o=r.items[a]:(o=i,r.delegate&&(o=o.find(r.delegate)),o=o.eq(a)),t._openClick({mfpEl:o},i,r)}else t.isOpen&&t[n].apply(t,Array.prototype.slice.call(arguments,1));else n=e.extend(!0,{},n),b?i.data("magnificPopup",n):i[0].magnificPopup=n,t.addGroup(i,n);return i};var P,O,z,M="inline",B=function(){z&&(O.after(z.addClass(P)).detach(),z=null)};e.magnificPopup.registerModule(M,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){t.types.push(M),x(l+"."+M,function(){B()})},getInline:function(n,i){if(B(),n.src){var o=t.st.inline,r=e(n.src);if(r.length){var a=r[0].parentNode;a&&a.tagName&&(O||(P=o.hiddenClass,O=k(P),P="mfp-"+P),z=r.after(O).detach().removeClass(P)),t.updateStatus("ready")}else t.updateStatus("error",o.tNotFound),r=e("<div>");return n.inlineElement=r,r}return t.updateStatus("ready"),t._parseMarkup(i,{},n),i}}});var F,H="ajax",L=function(){F&&i.removeClass(F)},A=function(){L(),t.req&&t.req.abort()};e.magnificPopup.registerModule(H,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){t.types.push(H),F=t.st.ajax.cursor,x(l+"."+H,A),x("BeforeChange."+H,A)},getAjax:function(n){F&&i.addClass(F),t.updateStatus("loading");var o=e.extend({url:n.src,success:function(i,o,r){var a={data:i,xhr:r};T("ParseAjax",a),t.appendContent(e(a.data),H),n.finished=!0,L(),t._setFocus(),setTimeout(function(){t.wrap.addClass(v)},16),t.updateStatus("ready"),T("AjaxContentAdded")},error:function(){L(),n.finished=n.loadError=!0,t.updateStatus("error",t.st.ajax.tError.replace("%url%",n.src))}},t.st.ajax.settings);return t.req=e.ajax(o),""}}});var j,N=function(n){if(n.data&&void 0!==n.data.title)return n.data.title;
69var i=t.st.image.titleSrc;if(i){if(e.isFunction(i))return i.call(t,n);if(n.el)return n.el.attr(i)||""}return""};e.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var e=t.st.image,n=".image";t.types.push("image"),x(f+n,function(){"image"===t.currItem.type&&e.cursor&&i.addClass(e.cursor)}),x(l+n,function(){e.cursor&&i.removeClass(e.cursor),I.off("resize"+h)}),x("Resize"+n,t.resizeImage),t.isLowIE&&x("AfterChange",t.resizeImage)},resizeImage:function(){var e=t.currItem;if(e&&e.img&&t.st.image.verticalFit){var n=0;t.isLowIE&&(n=parseInt(e.img.css("padding-top"),10)+parseInt(e.img.css("padding-bottom"),10)),e.img.css("max-height",t.wH-n)}},_onImageHasSize:function(e){e.img&&(e.hasSize=!0,j&&clearInterval(j),e.isCheckingImgSize=!1,T("ImageHasSize",e),e.imgHidden&&(t.content&&t.content.removeClass("mfp-loading"),e.imgHidden=!1))},findImageSize:function(e){var n=0,i=e.img[0],o=function(r){j&&clearInterval(j),j=setInterval(function(){return i.naturalWidth>0?(t._onImageHasSize(e),void 0):(n>200&&clearInterval(j),n++,3===n?o(10):40===n?o(50):100===n&&o(500),void 0)},r)};o(1)},getImage:function(n,i){var o=0,r=function(){n&&(n.img[0].complete?(n.img.off(".mfploader"),n===t.currItem&&(t._onImageHasSize(n),t.updateStatus("ready")),n.hasSize=!0,n.loaded=!0,T("ImageLoadComplete")):(o++,200>o?setTimeout(r,100):a()))},a=function(){n&&(n.img.off(".mfploader"),n===t.currItem&&(t._onImageHasSize(n),t.updateStatus("error",s.tError.replace("%url%",n.src))),n.hasSize=!0,n.loaded=!0,n.loadError=!0)},s=t.st.image,l=i.find(".mfp-img");if(l.length){var c=document.createElement("img");c.className="mfp-img",n.img=e(c).on("load.mfploader",r).on("error.mfploader",a),c.src=n.src,l.is("img")&&(n.img=n.img.clone()),c=n.img[0],c.naturalWidth>0?n.hasSize=!0:c.width||(n.hasSize=!1)}return t._parseMarkup(i,{title:N(n),img_replaceWith:n.img},n),t.resizeImage(),n.hasSize?(j&&clearInterval(j),n.loadError?(i.addClass("mfp-loading"),t.updateStatus("error",s.tError.replace("%url%",n.src))):(i.removeClass("mfp-loading"),t.updateStatus("ready")),i):(t.updateStatus("loading"),n.loading=!0,n.hasSize||(n.imgHidden=!0,i.addClass("mfp-loading"),t.findImageSize(n)),i)}}});var W,R=function(){return void 0===W&&(W=void 0!==document.createElement("p").style.MozTransform),W};e.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(e){return e.is("img")?e:e.find("img")}},proto:{initZoom:function(){var e,n=t.st.zoom,i=".zoom";if(n.enabled&&t.supportsTransition){var o,r,a=n.duration,s=function(e){var t=e.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),i="all "+n.duration/1e3+"s "+n.easing,o={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},r="transition";return o["-webkit-"+r]=o["-moz-"+r]=o["-o-"+r]=o[r]=i,t.css(o),t},d=function(){t.content.css("visibility","visible")};x("BuildControls"+i,function(){if(t._allowZoom()){if(clearTimeout(o),t.content.css("visibility","hidden"),e=t._getItemToZoom(),!e)return d(),void 0;r=s(e),r.css(t._getOffset()),t.wrap.append(r),o=setTimeout(function(){r.css(t._getOffset(!0)),o=setTimeout(function(){d(),setTimeout(function(){r.remove(),e=r=null,T("ZoomAnimationEnded")},16)},a)},16)}}),x(c+i,function(){if(t._allowZoom()){if(clearTimeout(o),t.st.removalDelay=a,!e){if(e=t._getItemToZoom(),!e)return;r=s(e)}r.css(t._getOffset(!0)),t.wrap.append(r),t.content.css("visibility","hidden"),setTimeout(function(){r.css(t._getOffset())},16)}}),x(l+i,function(){t._allowZoom()&&(d(),r&&r.remove(),e=null)})}},_allowZoom:function(){return"image"===t.currItem.type},_getItemToZoom:function(){return t.currItem.hasSize?t.currItem.img:!1},_getOffset:function(n){var i;i=n?t.currItem.img:t.st.zoom.opener(t.currItem.el||t.currItem);var o=i.offset(),r=parseInt(i.css("padding-top"),10),a=parseInt(i.css("padding-bottom"),10);o.top-=e(window).scrollTop()-r;var s={width:i.width(),height:(b?i.innerHeight():i[0].offsetHeight)-a-r};return R()?s["-moz-transform"]=s.transform="translate("+o.left+"px,"+o.top+"px)":(s.left=o.left,s.top=o.top),s}}});var Z="iframe",q="//about:blank",D=function(e){if(t.currTemplate[Z]){var n=t.currTemplate[Z].find("iframe");n.length&&(e||(n[0].src=q),t.isIE8&&n.css("display",e?"block":"none"))}};e.magnificPopup.registerModule(Z,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){t.types.push(Z),x("BeforeChange",function(e,t,n){t!==n&&(t===Z?D():n===Z&&D(!0))}),x(l+"."+Z,function(){D()})},getIframe:function(n,i){var o=n.src,r=t.st.iframe;e.each(r.patterns,function(){return o.indexOf(this.index)>-1?(this.id&&(o="string"==typeof this.id?o.substr(o.lastIndexOf(this.id
69)+this.id.length,o.length):this.id.call(this,o)),o=this.src.replace("%id%",o),!1):void 0});var a={};return r.srcAction&&(a[r.srcAction]=o),t._parseMarkup(i,a,n),t.updateStatus("ready"),i}}});var K=function(e){var n=t.items.length;return e>n-1?e-n:0>e?n+e:e},Y=function(e,t,n){return e.replace(/%curr%/gi,t+1).replace(/%total%/gi,n)};e.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var n=t.st.gallery,i=".mfp-gallery",r=Boolean(e.fn.mfpFastClick);return t.direction=!0,n&&n.enabled?(a+=" mfp-gallery",x(f+i,function(){n.navigateByImgClick&&t.wrap.on("click"+i,".mfp-img",function(){return t.items.length>1?(t.next(),!1):void 0}),o.on("keydown"+i,function(e){37===e.keyCode?t.prev():39===e.keyCode&&t.next()})}),x("UpdateStatus"+i,function(e,n){n.text&&(n.text=Y(n.text,t.currItem.index,t.items.length))}),x(p+i,function(e,i,o,r){var a=t.items.length;o.counter=a>1?Y(n.tCounter,r.index,a):""}),x("BuildControls"+i,function(){if(t.items.length>1&&n.arrows&&!t.arrowLeft){var i=n.arrowMarkup,o=t.arrowLeft=e(i.replace(/%title%/gi,n.tPrev).replace(/%dir%/gi,"left")).addClass(y),a=t.arrowRight=e(i.replace(/%title%/gi,n.tNext).replace(/%dir%/gi,"right")).addClass(y),s=r?"mfpFastClick":"click";o[s](function(){t.prev()}),a[s](function(){t.next()}),t.isIE7&&(k("b",o[0],!1,!0),k("a",o[0],!1,!0),k("b",a[0],!1,!0),k("a",a[0],!1,!0)),t.container.append(o.add(a))}}),x(m+i,function(){t._preloadTimeout&&clearTimeout(t._preloadTimeout),t._preloadTimeout=setTimeout(function(){t.preloadNearbyImages(),t._preloadTimeout=null},16)}),x(l+i,function(){o.off(i),t.wrap.off("click"+i),t.arrowLeft&&r&&t.arrowLeft.add(t.arrowRight).destroyMfpFastClick(),t.arrowRight=t.arrowLeft=null}),void 0):!1},next:function(){t.direction=!0,t.index=K(t.index+1),t.updateItemHTML()},prev:function(){t.direction=!1,t.index=K(t.index-1),t.updateItemHTML()},goTo:function(e){t.direction=e>=t.index,t.index=e,t.updateItemHTML()},preloadNearbyImages:function(){var e,n=t.st.gallery.preload,i=Math.min(n[0],t.items.length),o=Math.min(n[1],t.items.length);for(e=1;(t.direction?o:i)>=e;e++)t._preloadItem(t.index+e);for(e=1;(t.direction?i:o)>=e;e++)t._preloadItem(t.index-e)},_preloadItem:function(n){if(n=K(n),!t.items[n].preloaded){var i=t.items[n];i.parsed||(i=t.parseEl(n)),T("LazyLoad",i),"image"===i.type&&(i.img=e('<img class="mfp-img" />').on("load.mfploader",function(){i.hasSize=!0}).on("error.mfploader",function(){i.hasSize=!0,i.loadError=!0,T("LazyLoadError",i)}).attr("src",i.src)),i.preloaded=!0}}}});var U="retina";e.magnificPopup.registerModule(U,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var e=t.st.retina,n=e.ratio;n=isNaN(n)?n():n,n>1&&(x("ImageHasSize."+U,function(e,t){t.img.css({"max-width":t.img[0].naturalWidth/n,width:"100%"})}),x("ElementParse."+U,function(t,i){i.src=e.replaceSrc(i,n)}))}}}}),function(){var t=1e3,n="ontouchstart"in window,i=function(){I.off("touchmove"+r+" touchend"+r)},o="mfpFastClick",r="."+o;e.fn.mfpFastClick=function(o){return e(this).each(function(){var a,s=e(this);if(n){var l,c,d,u,p,f;s.on("touchstart"+r,function(e){u=!1,f=1,p=e.originalEvent?e.originalEvent.touches[0]:e.touches[0],c=p.clientX,d=p.clientY,I.on("touchmove"+r,function(e){p=e.originalEvent?e.originalEvent.touches:e.touches,f=p.length,p=p[0],(Math.abs(p.clientX-c)>10||Math.abs(p.clientY-d)>10)&&(u=!0,i())}).on("touchend"+r,function(e){i(),u||f>1||(a=!0,e.preventDefault(),clearTimeout(l),l=setTimeout(function(){a=!1},t),o())})})}s.on("click"+r,function(){a||o()})})},e.fn.destroyMfpFastClick=function(){e(this).off("touchstart"+r+" click"+r),n&&I.off("touchmove"+r+" touchend"+r)}}(),_()})(window.jQuery||window.Zepto); 70 71 72/** 73 * placeholder 74 */ 75(function(q,f,d){function r(b){var a={},c=/^jQuery\d+$/;d.each(b.attributes,function(b,d){d.specified&&!c.test(d.name)&&(a[d.name]=d.value)});return a}function g(b,a){var c=d(this);if(this.value==c.attr("placeholder")&&c.hasClass("placeholder"))if(c.data("placeholder-password")){c=c.hide().next().show().attr("id",c.removeAttr("id").data("placeholder-id"));if(!0===b)return c[0].value=a;c.focus()}else this.value="",c.removeClass("placeholder"),this==m()&&this.select()}function k(){var b,a=d(this),c= 76 this.id;if(""==this.value){if("password"==this.type){if(!a.data("placeholder-textinput")){try{b=a.clone().attr({type:"text"})}catch(e){b=d("<input>").attr(d.extend(r(this),{type:"text"}))}b.removeAttr("name").data({"placeholder-password":a,"placeholder-id":c}).bind("focus.placeholder",g);a.data({"placeholder-textinput":b,"placeholder-id":c}).before(b)}a=a.removeAttr("id").hide().prev().attr("id",c).show()}a.addClass("placeholder");a[0].value=a.attr("placeholder")}else a.removeClass("placeholder")} 77 function m(){try{return f.activeElement}catch(b){}}var h="placeholder"in f.createElement("input"),l="placeholder"in f.createElement("textarea"),e=d.fn,n=d.valHooks,p=d.propHooks;h&&l?(e=e.placeholder=function(){return this},e.input=e.textarea=!0):(e=e.placeholder=function(){this.filter((h?"textarea":":input")+"[placeholder]").not(".placeholder").bind({"focus.placeholder":g,"blur.placeholder":k}).data("placeholder-enabled",!0).trigger("blur.placeholder");return this},e.input=h,e.textarea=l,e={get:function(b){var a= 78 d(b),c=a.data("placeholder-password");return c?c[0].value:a.data("placeholder-enabled")&&a.hasClass("placeholder")?"":b.value},set:function(b,a){var c=d(b),e=c.data("placeholder-password");if(e)return e[0].value=a;if(!c.data("placeholder-enabled"))return b.value=a;""==a?(b.value=a,b!=m()&&k.call(b)):c.hasClass("placeholder")?g.call(b,!0,a)||(b.value=a):b.value=a;return c}},h||(n.input=e,p.value=e),l||(n.textarea=e,p.value=e),d(function(){d(f).delegate("form","submit.placeholder",function(){var b= 79 d(".placeholder",this).each(g);setTimeout(function(){b.each(k)},10)})}),d(q).bind("beforeunload.placeholder",function(){d(".placeholder").each(function(){this.value=""})}))})(this,document,jQuery); 80 81 82 83// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel 84// MIT license
85(function(){for(var e=0,b=["ms","moz","webkit","o"],a=0;a<b.length&&!window.requestAnimationFrame;++a)window.requestAnimationFrame=window[b[a]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[a]+"CancelAnimationFrame"]||window[b[a]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(a,b){var c=(new Date).getTime(),d=Math.max(0,16-(c-e)),f=window.setTimeout(function(){a(c+d)},d);e=c+d;return f});window.cancelAnimationFrame||(window.cancelAnimationFrame= 86 function(a){clearTimeout(a)})})(); 87 88 89function td_smooth_scroll() { 90 // SmoothScroll v1.2.1 91 // Licensed under the terms of the MIT license. 92 93 // People involved 94 // - Balazs Galambosi (maintainer) 95 // - Patrick Brunner (original idea) 96 // - Michael Herf (Pulse Algorithm) 97 98 var defaultOptions={frameRate:150,animationTime:600,stepSize:120,pulseAlgorithm:!0,pulseScale:8,pulseNormalize:1,accelerationDelta:20,accelerationMax:1,keyboardSupport:!0,arrowScroll:50,touchpadSupport:!0,fixedBackground:!0,excluded:""},options=defaultOptions,isExcluded=!1,isFrame=!1,direction={x:0,y:0},initDone=!1,root=document.documentElement,activeElement,observer,deltaBuffer=[120,120,120],key={left:37,up:38,right:39,down:40,spacebar:32,pageup:33,pagedown:34,end:35,home:36}; 99 "undefined"!==typeof chrome&&"undefined"!==typeof chrome.storage&&chrome.storage.sync.get(defaultOptions,function(a){options=a;initTest()}); 100 function initTest(){var a=!1;-1<document.URL.indexOf("google.com/reader/view")&&(a=!0);if(options.excluded){var b=options.excluded.split(/[,\n] ?/);b.push("mail.google.com");for(var c=b.length;c--;)if(-1<document.URL.indexOf(b[c])){observer&&observer.disconnect();removeEvent("mousewheel",wheel);isExcluded=a=!0;break}}a&&removeEvent("keydown",keydown);options.keyboardSupport&&!a&&addEvent("keydown",keydown)} 101 function init(){if(document.body){var a=document.body,b=document.documentElement,c=window.innerHeight,d=a.scrollHeight;root=0<=document.compatMode.indexOf("CSS")?b:a;activeElement=a;initTest();initDone=!0;if(top!=self)isFrame=!0;else if(d>c&&(a.offsetHeight<=c||b.offsetHeight<=c)){var e=!1,d=function(){e||b.scrollHeight==document.height||(e=!0,setTimeout(function(){b.style.height=document.height+"px";e=!1},500))};b.style.height="auto";setTimeout(d,10);observer=new MutationObserver(d);observer.observe(a, 102 {attributes:!0,childList:!0,characterData:!1});root.offsetHeight<=c&&(c=document.createElement("div"),c.style.clear="both",a.appendChild(c))}-1<document.URL.indexOf("mail.google.com")?(c=document.createElement("style"),c.innerHTML=".iu { visibility: hidden }",(document.getElementsByTagName("head")[0]||b).appendChild(c)):-1<document.URL.indexOf("www.facebook.com")&&(c=document.getElementById("home_stream"))&&(c.style.webkitTransform="translateZ(0)");options.fixedBackground||isExcluded||(a.style.backgroundAttachment= 103 "scroll",b.style.backgroundAttachment="scroll")}}var que=[],pending=!1,lastScroll=+new Date; 104 function scrollArray(a,b,c,d){d||(d=1E3);directionCheck(b,c);if(1!=options.accelerationMax){var e=+new Date-lastScroll;e<options.accelerationDelta&&(e=(1+30/e)/2,1<e&&(e=Math.min(e,options.accelerationMax),b*=e,c*=e));lastScroll=+new Date}que.push({x:b,y:c,lastX:0>b?.99:-.99,lastY:0>c?.99:-.99,start:+new Date});if(!pending){var q=a===document.body,p=function(e){e=+new Date;for(var h=0,k=0,l=0;l<que.length;l++){var f=que[l],m=e-f.start,n=m>=options.animationTime,g=n?1:m/options.animationTime;options.pulseAlgorithm&& 105 (g=pulse(g));m=f.x*g-f.lastX>>0;g=f.y*g-f.lastY>>0;h+=m;k+=g;f.lastX+=m;f.lastY+=g;n&&(que.splice(l,1),l--)}q?window.scrollBy(h,k):(h&&(a.scrollLeft+=h),k&&(a.scrollTop+=k));b||c||(que=[]);que.length?requestFrame(p,a,d/options.frameRate+1):pending=!1};requestFrame(p,a,0);pending=!0}} 106 function wheel(a){initDone||init();var b=a.target,c=overflowingAncestor(b);if(!c||a.defaultPrevented||isNodeName(activeElement,"embed")||isNodeName(b,"embed")&&/\.pdf/i.test(b.src))return!0;var b=a.wheelDeltaX||0,d=a.wheelDeltaY||0;b||d||(d=a.wheelDelta||0);if(!options.touchpadSupport&&isTouchpad(d))return!0;1.2<Math.abs(b)&&(b*=options.stepSize/120);1.2<Math.abs(d)&&(d*=options.stepSize/120);scrollArray(c,-b,-d);a.preventDefault()} 107 function keydown(a){var b=a.target,c=a.ctrlKey||a.altKey||a.metaKey||a.shiftKey&&a.keyCode!==key.spacebar;
107if(/input|textarea|select|embed/i.test(b.nodeName)||b.isContentEditable||a.defaultPrevented||c||isNodeName(b,"button")&&a.keyCode===key.spacebar)return!0;var d;d=b=0;var c=overflowingAncestor(activeElement),e=c.clientHeight;c==document.body&&(e=window.innerHeight);switch(a.keyCode){case key.up:d=-options.arrowScroll;break;case key.down:d=options.arrowScroll;break;case key.spacebar:d=a.shiftKey? 108 1:-1;d=-d*e*.9;break;case key.pageup:d=.9*-e;break;case key.pagedown:d=.9*e;break;case key.home:d=-c.scrollTop;break;case key.end:e=c.scrollHeight-c.scrollTop-e;d=0<e?e+10:0;break;case key.left:b=-options.arrowScroll;break;case key.right:b=options.arrowScroll;break;default:return!0}scrollArray(c,b,d);a.preventDefault()}function mousedown(a){activeElement=a.target}var cache={};setInterval(function(){cache={}},1E4);var uniqueID=function(){var a=0;return function(b){return b.uniqueID||(b.uniqueID=a++)}}(); 109 function setCache(a,b){for(var c=a.length;c--;)cache[uniqueID(a[c])]=b;return b}function overflowingAncestor(a){var b=[],c=root.scrollHeight;do{var d=cache[uniqueID(a)];if(d)return setCache(b,d);b.push(a);if(c===a.scrollHeight){if(!isFrame||root.clientHeight+10<c)return setCache(b,document.body)}else if(a.clientHeight+10<a.scrollHeight&&(overflow=getComputedStyle(a,"").getPropertyValue("overflow-y"),"scroll"===overflow||"auto"===overflow))return setCache(b,a)}while(a=a.parentNode)} 110 function addEvent(a,b,c){window.addEventListener(a,b,c||!1)}function removeEvent(a,b,c){window.removeEventListener(a,b,c||!1)}function isNodeName(a,b){return(a.nodeName||"").toLowerCase()===b.toLowerCase()}function directionCheck(a,b){a=0<a?1:-1;b=0<b?1:-1;if(direction.x!==a||direction.y!==b)direction.x=a,direction.y=b,que=[],lastScroll=0}var deltaBufferTimer; 111 function isTouchpad(a){if(a){a=Math.abs(a);deltaBuffer.push(a);deltaBuffer.shift();clearTimeout(deltaBufferTimer);deltaBufferTimer=setTimeout(function(){chrome.storage.local.set({deltaBuffer:deltaBuffer})},1E3);a=deltaBuffer[0]==deltaBuffer[1]&&deltaBuffer[1]==deltaBuffer[2];var b=isDivisible(deltaBuffer[0],120)&&isDivisible(deltaBuffer[1],120)&&isDivisible(deltaBuffer[2],120);return!(a||b)}}function isDivisible(a,b){return Math.floor(a/b)==a/b} 112 "undefined"!==typeof chrome&&"undefined"!==typeof chrome.storage&&chrome.storage.local.get("deltaBuffer",function(a){a.deltaBuffer&&(deltaBuffer=a.deltaBuffer)});var requestFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(a,b,c){window.setTimeout(a,c||1E3/60)}}(),MutationObserver=window.MutationObserver||window.WebKitMutationObserver; 113 function pulse_(a){var b;a*=options.pulseScale;1>a?b=a-(1-Math.exp(-a)):(b=Math.exp(-1),--a,a=1-Math.exp(-a),b+=a*(1-b));return b*options.pulseNormalize}function pulse(a){if(1<=a)return 1;if(0>=a)return 0;1==options.pulseNormalize&&(options.pulseNormalize/=pulse_(1));return pulse_(a)}addEvent("mousedown",mousedown);addEvent("mousewheel",wheel);addEvent("load",init); 114} //end smooth scroll 115/** 116 * ___________________________________________ 117 * | __ _ ___ _ _ __ __ __ __ __ | 118 * | | \| | __|| | | |/' _/| V |/ \ / _] | 119 * | | | ' | _| | 'V' |`._`.| \_/ | /\ | [/\ | 120 * | |_|\__|___|!_/ \_!|___/|_| |_|_||_|\__/ | 121 * |___________________________________________| 122 * 123 * Our portfolio: http://themeforest.net/user/tagDiv/portfolio 124 * by tagDiv 2014 125 * Thanks for your interest in our theme! :) 126 * 127 * 128 */ 129/* global jQuery:false */ 130 131 132var tdDetect = {}; 133 134( function(){ 135 "use strict"; 136 tdDetect = { 137 isIe8: false, 138 isIe9 : false, 139 isIe10 : false, 140 isIe11 : false, 141 isIe : false, 142 isSafari : false, 143 isChrome : false, 144 isIpad : false, 145 isTouchDevice : false, 146 hasHistory : false, 147 isPhoneScreen : false, 148 isIos : false, 149 isAndroid : false, 150 isOsx : false, 151 isFirefox : false, 152 isWinOs : false, 153 isMobileDevice:false, 154 htmlJqueryObj:null, //here we keep the jQuery object for the HTML element 155 156 /** 157 * function to check the phone screen 158 * @see tdEvents 159 * The jQuery windows width is not reliable cross browser! 160 */ 161 runIsPhoneScreen: function () { 162 if ( (jQuery(window).width() < 768 || jQuery(window).height() < 768) && false === tdDetect.isIpad ) { 163 tdDetect.isPhoneScreen = true; 164 165 } else { 166 tdDetect.isPhoneScreen = false; 167 } 168 }, 169 170 171 set: function (detector_name, value) { 172 tdDetect[detector_name] = value; 173 //alert('tdDetect: ' + detector_name + ': ' + value); 174 } 175 }; 176 177 178 tdDetect.htmlJqueryObj = jQuery('html'); 179 180 181 // is touch device ? 182 if ( -1 !== navigator.appVersion.indexOf("Win") ) { 183 tdDetect.set('isWinOs', true); 184 } 185 186 // it looks like it has to have ontouchstart in window and NOT be windows OS. Why? we don't know. 187 if ( !!('ontouchstart' in window) && !tdDetect.isWinOs ) { 188 tdDetect.set('isTouchDevice', true); 189 } 190 191 192 // detect ie8 193 if ( tdDetect.htmlJqueryObj.is('.ie8') ) { 194 tdDetect.set('isIe8', true); 195 tdDetect.set('isIe', true); 196 } 197 198 // detect ie9 199 if ( tdDetect.htmlJqueryObj.is('.ie9') ) { 200 tdDetect.set('isIe9', true); 201 tdDetect.set('isIe', true); 202 } 203 204 // detect ie10 - also adds the ie10 class //it also detects windows mobile IE as IE10 205 if( navigator.userAgent.indexOf("MSIE 10.0") > -1 ){ 206 tdDetect.set('isIe10', true); 207 tdDetect.set('isIe', true); 208 } 209 210 //ie 11 check - also adds the ie11 class - it may detect ie on windows mobile 211 if ( !!navigator.userAgent.match(/Trident.*rv\:11\./) ){ 212 tdDetect.set('isIe11', true); 213 //this.isIe = true; //do not flag ie11 as isIe
214 } 215 216 217 //do we have html5 history support? 218 if (window.history && window.history.pushState) { 219 tdDetect.set('hasHistory', true); 220 } 221 222 //check for safary 223 if ( -1 !== navigator.userAgent.indexOf('Safari') && -1 === navigator.userAgent.indexOf('Chrome') ) { 224 tdDetect.set('isSafari', true); 225 } 226 227 //chrome and chrome-ium check 228 if (/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())) { 229 tdDetect.set('isChrome', true); 230 } 231 232 if ( null !== navigator.userAgent.match(/iPad/i)) { 233 tdDetect.set('isIpad', true); 234 } 235 236 237 if (/(iPad|iPhone|iPod)/g.test( navigator.userAgent )) { 238 tdDetect.set('isIos', true); 239 } 240 241 242 //detect if we run on a mobile device - ipad included - used by the modal / scroll to @see scrollIntoView 243 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { 244 tdDetect.set('isMobileDevice', true); 245 } 246 247 tdDetect.runIsPhoneScreen(); 248 249 //test for android 250 var user_agent = navigator.userAgent.toLowerCase(); 251 if ( user_agent.indexOf("android") > -1 ) { 252 tdDetect.set('isAndroid', true); 253 } 254 255 256 if ( -1 !== navigator.userAgent.indexOf('Mac OS X') ) { 257 tdDetect.set('isOsx', true); 258 } 259 260 if ( -1 !== navigator.userAgent.indexOf('Firefox') ) { 261 tdDetect.set('isFirefox', true); 262 } 263 264})(); 265 266/** 267 * Created by tagdiv on 13.05.2015. 268 */ 269 270/* global tdDetect: {} */ 271/* global jQuery: {} */ 272 273var tdViewport = {}; 274 275(function(){ 276 277 "use strict"; 278 279 tdViewport = { 280 281 /** 282 * - initial (default) value of the _currentIntervalIndex 283 * - it's used by third part libraries 284 * - it used just as constant value 285 */ 286 INTERVAL_INITIAL_INDEX: -1, 287 288 289 290 /** 291 * - keep the current interval index 292 * - it should be modified/taken just by setter/getter methods 293 * - after computing, it should not be a negative value 294 */ 295 _currentIntervalIndex : tdViewport.INTERVAL_INITIAL_INDEX, 296 297 298 299 /** 300 * - it keeps the interval index 301 * - it should be modified/taken just by setter/getter methods 302 * - it must be a crescendo positive values 303 */ 304 _intervalList : [], 305 306 307 308 /** 309 * 310 */ 311 init: function() { 312 if (('undefined' !== typeof window.td_viewport_interval_list) && (Array === window.td_viewport_interval_list.constructor)) { 313 314 for (var i = 0; i < window.td_viewport_interval_list.length; i++) { 315 var item = new tdViewport.item(); 316 317 var currentVal = window.td_viewport_interval_list[i]; 318 319 // the check is done to be sure that the intervals are well formatted 320 if (!currentVal.hasOwnProperty('limitBottom') || !currentVal.hasOwnProperty('sidebarWidth')) { 321 break; 322 } 323 324 item.limitBottom = currentVal.limitBottom; 325 item.sidebarWidth = currentVal.sidebarWidth; 326 327 tdViewport._items.push(item); 328 } 329 330 tdViewport.detectChanges(); 331 } 332 }, 333 334 335 336 /** 337 * - getter of the _currentIntervalIndex 338 * - it should be used by outsiders libraries 339 * @returns {*} 340 */ 341 getCurrentIntervalIndex : function() { 342 return tdViewport._currentIntervalIndex; 343 }, 344 345 346 347 /** 348 * - setter of the _intervalList 349 - it should be used by outsiders libraries 350 * @param value 351 */ 352 setIntervalList : function(value) { 353 tdViewport._intervalList = value; 354 }, 355 356 357 358 /** 359 * - getter of the _intervalList 360 * - it should be used by outsiders libraries 361 * @returns {*} 362 */ 363 getIntervalList : function() { 364 return tdViewport._intervalList; 365 }, 366 367 368 369 /** 370 * - getter of the tdViewport current item 371 * - it should be used by outsiders libraries 372 * @returns {*} 373 */ 374 getCurrentIntervalItem : function() { 375 376 if ((tdViewport.INTERVAL_INITIAL_INDEX === tdViewport._currentIntervalIndex) || (0 === tdViewport._currentIntervalIndex)) { 377 return null; 378 } 379 return tdViewport._items[tdViewport._currentIntervalIndex - 1]; 380 }, 381 382 383 384 _items : [], 385 386 387 388 item : function() { 389 this.limitBottom = undefined; 390 this.sidebarWidth = undefined; 391 }, 392 393 394 395 396 397 /**
398 * - detect view port changes 399 * - it returns true if the change view port has changed, false otherwise 400 * - it also sets the _currentIntervalIndex 401 * @returns {boolean} True when viewport has changed 402 */ 403 detectChanges: function() { 404 var result = false; 405 406 var realViewPortWidth = 0; 407 var localCurrentIntervalIndex = 0; 408 409 if (true === tdDetect.isSafari) { 410 realViewPortWidth = this._safariWiewPortWidth.getRealWidth(); 411 } else { 412 realViewPortWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 413 } 414 415 for (var i = 0; i < tdViewport._items.length; i++) { 416 417 if (realViewPortWidth <= tdViewport._items[i].limitBottom) { 418 419 if (localCurrentIntervalIndex !== tdViewport._currentIntervalIndex) { 420 tdViewport._currentIntervalIndex = localCurrentIntervalIndex; 421 result = true; 422 423 tdViewport.log('changing viewport ' + tdViewport._currentIntervalIndex + ' ~ ' + realViewPortWidth); 424 } 425 break; 426 } 427 localCurrentIntervalIndex++; 428 } 429 430 if ((false === result) && (localCurrentIntervalIndex !== tdViewport._currentIntervalIndex)) { 431 tdViewport._currentIntervalIndex = localCurrentIntervalIndex; 432 result = true; 433 434 tdViewport.log('changing viewport ' + tdViewport._currentIntervalIndex + ' ~ ' + realViewPortWidth); 435 } 436 return result; 437 }, 438 439 440 /** 441 * get the real view port width on safari 442 * @type {{divAdded: boolean, divJqueryObject: string, getRealWidth: Function}} 443 */ 444 _safariWiewPortWidth : { 445 divAdded : false, 446 divJqueryObject : '', 447 448 getRealWidth : function() { 449 if (false === this.divAdded) { 450 // we don't have a div present 451 this.divJqueryObject = jQuery('<div>') 452 .css({ 453 "height": "1px", 454 "position": "absolute", 455 "top": "-1px", 456 "left": "0", 457 "right": "0", 458 "visibility": "hidden", 459 "z-index": "-1" 460 }); 461 this.divJqueryObject.appendTo('body'); 462 this.divAdded = true; 463 } 464 return this.divJqueryObject.width(); 465 } 466 }, 467 468 469 470 log: function log(msg) { 471 //console.log(msg); 472 } 473 }; 474 475 tdViewport.init(); 476 477})(); 478 479/* ---------------------------------------------------------------------------- 480 Menu script 481 */ 482 483/* global jQuery:{} */ 484/* global tdDetect:{} */ 485 486 487(function(){ 488 'use strict'; 489 490 // top menu 491 492 if (tdDetect.isTouchDevice) { 493 //touch 494 jQuery('.td-header-sp-top-menu .top-header-menu').superfish({ 495 delay:300, 496 speed:'fast', 497 useClick:true 498 }); 499 500 } else { 501 502 //not touch 503 jQuery('.td-header-sp-top-menu .top-header-menu').superfish({ 504 delay:600, 505 speed:200, 506 useClick:false 507 }); 508 } 509 510/* ---------------------------------------------------------------------------- 511 On load 512 */ 513 514 // header menu 515 jQuery('#td-header-menu .sf-menu').supersubs({ 516 minWidth: 10, // minimum width of sub-menus in em units 517 maxWidth: 40, // maximum width of sub-menus in em units 518 extraWidth: 1 // extra width can ensure lines don't sometimes turn over 519 }); 520 521 522 523 if (tdDetect.isTouchDevice) { 524 //touch 525 jQuery('#td-header-menu .sf-menu').superfish({ 526 delay:300, 527 speed:'fast', 528 useClick:true 529 }); 530 531 } else { 532 533 //not touch 534 jQuery('#td-header-menu .sf-menu').superfish({ 535 delay:600, 536 speed:200, 537 useClick:false 538 }); 539 } 540})(); 541 542 543 544 545 546 547 548/* 549 td_util.js 550 v2.0 551 */ 552/* global jQuery:false */ 553/* global tdDetect:false */ 554/* global td`ScrollingAnimation:false */ 555/* jshint -W020 */ 556 557var tdUtil = {}; 558 559( function() { 560 "use strict"; 561 562 tdUtil = { 563 564 565 /** 566 * stop propagation of an event - we should check this if we can remove window.event.cancelBubble - possible 567 * a windows mobile issue 568 * @param event 569 */ 570 stopBubble: function( event ) { 571 if ( event && event.stopPropagation ) { 572 event.stopPropagation(); 573 } else { 574 window.event.cancelBubble=true; 575 } 576 }, 577 578 /** 579 * utility function, used by td_post_images.js 580 * @param classSelector 581 */ 582 imageMoveClassToFigure: function ( classSelector ) { 583 jQuery('figure .' + classSelector).each( function() { 584 jQuery(this).parent().parent().addClass(classSelector); 585 jQuery(this).removeClass(classSelector); 586 }); 587 }, 588 589 590 591 /** 592 * safe function to read variables passed by the theme via the js buffer. If by some kind of error the variable is missing from the global scope, this function will return false 593 * @param variableName 594 * @returns {*} 595 */ 596 getBackendVar: function ( variableName ) { 597 if ( typeof window[variableName] === 'undefined' ) { 598 return ''; 599 } 600 return window[variableName]; 601 }, 602 603 604 /** 605 * is a given variable undefined? - this is the underscore method of checking this 606 * @param obj 607 * @returns {boolean} 608 */ 609 isUndefined : function ( obj ) { 610 return obj === void 0; 611 }, 612 613 614 615 616 /** 617 * scrolls to a dom element 618 * @param domElement 619 */ 620 scrollToElement: function( domElement, duration ) { 621 tdIsScrollingAnimation = true; 622 jQuery("html, body").stop(); 623 624 625 var dest; 626 627 //calculate destination place 628 if ( domElement.offset().top > jQuery(document).height() - jQuery(window).height() ) { 629 dest = jQuery(document).height() - jQuery(window).height(); 630 } else { 631 dest = domElement.offset().top; 632 } 633 //go to destination 634 jQuery("html, body").animate( 635 { scrollTop: dest }, 636 { 637 duration: duration, 638 easing:'easeInOutQuart', 639 complete: function(){ 640 tdIsScrollingAnimation = false; 641 } 642 } 643 ); 644 }, 645 646 647 /** 648 * scrolls to a dom element - the element will be close to the center of the screen 649 * !!! compensates for long distances !!! 650 */ 651 scrollIntoView: function ( domElement ) { 652 653 tdIsScrollingAnimation = true; 654 655 if ( tdDetect.isMobileDevice === true ) { 656 return; //do not run on any mobile device 657 } 658 659 jQuery("html, body").stop(); 660 661 662 var destination = domElement.offset().top; 663 destination = destination - 150; 664 665 var distance = Math.abs( jQuery(window).scrollTop() - destination ); 666 var computed_time = distance / 5; 667 //console.log(distance + ' -> ' + computed_time + ' -> ' + (1100+computed_time)); 668 669 //go to destination 670 jQuery("html, body").animate( 671 { scrollTop: destination }, 672 { 673 duration: 1100 + computed_time, 674 easing:'easeInOutQuart', 675 complete: function(){ 676 tdIsScrollingAnimation = false; 677 } 678 } 679 ); 680 }, 681 682 /** 683 * scrolls to a position 684 * @param pxFromTop - pixels from top 685 */ 686 scrollToPosition: function( pxFromTop, duration ) { 687 688 tdIsScrollingAnimation = true; 689 jQuery("html, body").stop(); 690 691 //go to destination 692 jQuery("html, body").animate( 693 { scrollTop: pxFromTop }, 694 { 695 duration: duration, 696 easing:'easeInOutQuart', 697 complete: function(){ 698 tdIsScrollingAnimation = false; 699 } 700 } 701 ); 702 }, 703 tdMoveY: function ( elm, value ) { 704 var translate = 'translate3d(0px,' + value + 'px, 0px)'; 705 elm.style['-webkit-transform'] = translate; 706 elm.style['-moz-transform'] = translate; 707 elm.style['-ms-transform'] = translate;
708 elm.style['-o-transform'] = translate; 709 elm.style.transform = translate; 710 }, 711 712 713 isValidUrl: function ( str ) { 714 var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol 715 '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name 716 '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address 717 '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path 718 '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string 719 '(\\#[-a-z\\d_]*)?$','i'); // fragment locator 720 721 722 if( !pattern.test(str) ) { 723 return false; 724 } else { 725 return true; 726 } 727 }, 728 729 730 round: function ( value, precision, mode ) { 731 var m, f, isHalf, sgn; // helper variables 732 // making sure precision is integer 733 precision |= 0; 734 m = Math.pow(10, precision); 735 value *= m; 736 // sign of the number 737 sgn = (value > 0) | -(value < 0); 738 isHalf = value % 1 === 0.5 * sgn; 739 f = Math.floor(value); 740 741 if (isHalf) { 742 switch (mode) { 743 case 'PHP_ROUND_HALF_DOWN': 744 // rounds .5 toward zero 745 value = f + (sgn < 0); 746 break; 747 case 'PHP_ROUND_HALF_EVEN': 748 // rouds .5 towards the next even integer 749 value = f + (f % 2 * sgn); 750 break; 751 case 'PHP_ROUND_HALF_ODD': 752 // rounds .5 towards the next odd integer 753 value = f + !(f % 2); 754 break; 755 default: 756 // rounds .5 away from zero 757 value = f + (sgn > 0); 758 } 759 } 760 761 return (isHalf ? value : Math.round(value)) / m; 762 } 763 764 765 766 767 768 769 770 }; 771})(); 772 773 774 775 776 777 778/** 779 * Created by ra on 6/27/14. 780 * copyright tagDiv 2014 781 * V 1.1 - better iOS 8 support 782 */ 783 784/* global jQuery:{} */ 785/* global tdDetect:{} */ 786/* global tdUtil:{} */ 787 788var tdAffix = {}; 789 790(function(){ 791 'use strict'; 792 793 tdAffix = { 794 795 // flag used to stop scrolling 796 allow_scroll: true, 797 798 //settings, obtained from ext 799 menu_selector: '', //the affix menu (this element will get the td-affix) 800 menu_wrap_selector: '', //the menu wrapper / placeholder 801 tds_snap_menu: '', //the panel setting 802 tds_snap_menu_logo: '', //the panel setting 803 804 is_menu_affix_height_computed: false, // flag used to compute menu_affix_height only once, when the menu is affix 805 is_menu_affix_height_on_mobile_computed: false, // flag used to compute menu_affix_height_on_mobile only once, when the menu is affix 806 807 menu_affix_height: 0, // the menu affix height [the height when it's really affix] 808 menu_affix_height_on_mobile: 0, // the menu affix height on mobile [the height when it's really affix] 809 810 811 main_menu_height: 0, // main menu height 812 top_offset: 0, //how much the menu is moved from the original position when it's affixed 813 menu_offset: 0, //used to hide the menu on scroll 814 is_requestAnimationFrame_running: false, //prevent multiple calls to requestAnimationFrame 815 is_menu_affix: false, //the current state of the menu, true if the menu is affix 816 is_top_menu: false, //true when the menu is at the top of the screen (0px topScroll) 817 818 //menu offset boundaries - so we do not fire the animation event when the boundary is hit 819 menu_offset_max_hit: false, 820 menu_offset_min_hit: true, 821 822 823 scroll_window_scrollTop_last: 0, //last scrollTop position, used to calculate the scroll direction 824 825 /** 826 * run the affix, we use the menu wrap selector to compute the menu position from top 827 * 828 { 829 menu_selector: '.td-header-main-menu', 830 menu_wrap_selector: '.td-header-menu-wrap', 831 tds_snap_menu: tdUtil.getBackendVar('tds_snap_menu') 832 } 833 */ 834 init : function ( atts ) { 835 836 //read the settings 837 tdAffix.menu_selector = atts.menu_selector; 838 tdAffix.menu_wrap_selector = atts.menu_wrap_selector; 839 tdAffix.tds_snap_menu = atts.tds_snap_menu; 840 tdAffix.tds_snap_menu_logo = atts.tds_snap_menu_logo; 841 tdAffix.menu_affix_height = atts.menu_affix_height; 842 tdAffix.menu_affix_height_on_mobile = atts.menu_affix_height_on_mobile; 843 844 //the snap menu is disabled from the panel 845 if ( ! tdAffix.tds_snap_menu ) { 846 return; 847 } 848 849 850 // a computation before jquery.ready is necessary for firefox, where tdEvents.scroll comes before 851 if ( tdDetect.isFirefox ) { 852 tdAffix.compute_top(); 853 tdAffix.compute_wrapper(); 854 } 855 856 jQuery().ready(function() { 857 //compute on semi dom ready 858 tdAffix.compute_top(); 859 tdAffix.compute_wrapper(); 860 }); 861 862 //recompute when all the page + logos are loaded 863 jQuery( window ).load(function() { 864 tdAffix.compute_top(); 865 tdAffix.compute_wrapper(); 866 867 //recompute after 1 sec for retarded phones 868 setTimeout(function(){ 869 tdAffix.compute_top(); 870 }, 1000 ); 871 }); 872 }, 873 874 875 /** 876 * - get the real affix height. 877 * The real affix height is computed only once, when the menu is affix. Till then, the function 878 * return the values set at init. 879 * 880 * These values are important because they are used in the tdSmartSidebar.js for the 881 * td_affix_menu_computed_height variable, which then is used to determine the sidebar position. 882 * 883 * For 'Newspaper', the sidebar needs a custom padding top (see @tdSmartSidebar.js), otherwise 884 * the sidebar is sticked to the affix menu. 885 * 886 * 887 * @returns {number} affix height 888 * @private 889 */ 890 _get_menu_affix_height: function() { 891 892 //if (tdDetect.isPhoneScreen === true) { 893 // return tdAffix.menu_affix_height_on_mobile; 894 //} 895 //return tdAffix.menu_affix_height; 896 897 if ( true === tdDetect.isPhoneScreen ) { 898 if ( ! tdAffix.is_menu_affix_height_on_mobile_computed && tdAffix.is_menu_affix ) { 899 900 tdAffix.is_menu_affix_height_on_mobile_computed = true; 901 902 // overwrite the tdAffix.menu_affix_height_on_mobile variable with the real affix height 903 tdAffix.menu_affix_height_on_mobile = jQuery(tdAffix.menu_selector).height(); 904 } 905 return tdAffix.menu_affix_height_on_mobile; 906 } 907 908 if ( ! tdAffix.is_menu_affix_height_computed && tdAffix.is_menu_affix ) { 909 910 tdAffix.is_menu_affix_height_computed = true; 911 912 // overwrite the tdAffix.menu_affix_height variable with the real affix height 913 tdAffix.menu_affix_height = jQuery(tdAffix.menu_selector).height(); 914 } 915 return tdAffix.menu_affix_height; 916 }, 917 918 919 920 /** 921 * called by tdEvents.js on scroll 922 */ 923 td_events_scroll: function( scrollTop ) { 924 925 if ( ! tdAffix.allow_scroll ) { 926 return; 927 } 928 929 //do not run if we don't have a snap menu 930 if ( ! tdAffix.tds_snap_menu ) { 931 return; 932 } 933 934 935 /* ---------------------------------------------------------------------------- 936 scroll direction + delta (used by affix for now) 937 to run thios code: 938 - tdAffix.tds_snap_menu != '' (from above) 939 - tdAffix.tds_snap_menu != 'snap' 940 */ 941 var scroll_direction = ''; 942 943 if ( 'snap' !== tdAffix.tds_snap_menu ) { //do not run on snap 944 if ( ( 'smart_snap_mobile' !== tdAffix.tds_snap_menu || true === tdDetect.isPhoneScreen ) ) { // different from smart_snap_mobile or tdDetect.isPhoneScreen === true 945 946 var scrollDelta = 0; 947 948 //check the direction 949 if ( scrollTop !== tdAffix.scroll_window_scrollTop_last ) { //compute direction only if we have different last scroll top 950 // compute the direction of the scroll 951 if ( scrollTop > tdAffix.scroll_window_scrollTop_last ) { 952 scroll_direction = 'down'; 953 } else { 954 scroll_direction = 'up'; 955 } 956 //calculate the scroll delta 957 scrollDelta = Math.abs( scrollTop - tdAffix.scroll_window_scrollTop_last ); 958 } 959 960 tdAffix.scroll_window_scrollTop_last = scrollTop; 961 } 962 } 963 964 /* ---------------------------------------------------------------------------- */ 965 966 // show the logo on sticky menu if is always snap setting 967 if ( 'snap' === tdAffix.tds_snap_menu && '' !== tdAffix.tds_snap_menu_logo ) { 968 jQuery( '.td-main-menu-logo' ).addClass( 'td-logo-sticky' ); 969 } 970 971 972 973 974 //if the menu is in the affix state 975 976 // the next check is to keep the text from the menu at the same position, when the menu comes from affix off to affix off 977 if ( ( scrollTop > tdAffix.top_offset + ( tdAffix.main_menu_height / 2 - tdAffix._get_menu_affix_height() / 2 ) ) || 978 979 // - the affix is OFF when the next condition is not accomplished, which means that the affix is ON 980 // and the scroll to the top is LOWER than the initial tdAffix.top_offset reduced by the affix real height 981 // - this condition makes the transition from the small affix menu to the larger menu of the page 982 ( ( tdAffix.is_menu_affix === true ) && ( 'smart_snap_always' === tdAffix.tds_snap_menu) && scrollTop > ( tdAffix.top_offset - tdAffix._get_menu_affix_height() ) ) || 983 984 tdAffix.is_top_menu === true ) { 985 986 //get the menu element 987 var td_affix_menu_element = jQuery( tdAffix.menu_selector ); 988 989 //turn affix on for it 990 tdAffix._affix_on( td_affix_menu_element ); 991 992 993 //if the menu is only with snap or we are on smart_snap_mobile + mobile, our job here in this function is done, return
994 if ( 'snap' === tdAffix.tds_snap_menu || ( 'smart_snap_mobile' === tdAffix.tds_snap_menu && false === tdDetect.isPhoneScreen ) ) { 995 return; 996 } 997 998 /* --- end simple snap --- */ 999 1000 1001 /* ---------------------------------------------------------------------------- 1002 check scroll directions (we may also have scroll_direction = '', that's why we have to check for the specific state (up or down)) 1003 */ 1004 1005 1006 // boundary check - to not run the position on each scroll event 1007 if ( ( false === tdAffix.menu_offset_max_hit && 'down' === scroll_direction ) || ( false === tdAffix.menu_offset_min_hit && 'up' === scroll_direction ) ) { 1008 //request animation frame 1009 //if (tdAffix.is_requestAnimationFrame_running === false) { 1010 window.requestAnimationFrame(function(){ 1011 1012 //console.log(tdAffix.menu_offset); 1013 //console.log(scrollDelta); 1014 var offset = 0; 1015 1016 1017 if ( scrollTop > 0 ) { // ios returns negative scrollTop values 1018 if ( 'down' === scroll_direction ) { 1019 1020 //compute the offset 1021 offset = tdAffix.menu_offset - scrollDelta; 1022 1023 // the offset is a value in the [-tdAffix.menu_affix_height, 0] and 1024 // not into the interval [-tdAffix.main_menu_height, 0] 1025 if ( offset < -tdAffix._get_menu_affix_height() ) { 1026 offset = -tdAffix._get_menu_affix_height(); 1027 } 1028 1029 } else if ( 'up' === scroll_direction ) { 1030 //compute the offset 1031 offset = tdAffix.menu_offset + scrollDelta; 1032 if ( offset > 0 ) { 1033 offset = 0; 1034 } 1035 } 1036 } 1037 1038 //td_debug.log_live(scroll_direction + ' | scrollTop: ' + scrollTop + ' | offset: ' + offset); 1039 1040 //tdAffix.is_requestAnimationFrame_running = true; 1041 1042 //console.log(offset); 1043 1044 //move the menu 1045 tdUtil.tdMoveY( td_affix_menu_element[0], offset ); 1046 1047 //td_affix_menu_element.css({top: (offset) + 'px'}); //legacy menu move code 1048 1049 //check boundaries 1050 if ( 0 === offset ) { 1051 tdAffix.menu_offset_min_hit = true; 1052 } else { 1053 tdAffix.menu_offset_min_hit = false; 1054 } 1055 1056 1057 if ( offset === -tdAffix._get_menu_affix_height() ) { 1058 tdAffix.menu_offset_max_hit = true; 1059 //also hide the menu when it's 100% out of view on ios - the safari header is transparent and we can see the menu 1060 if ( ( true === tdDetect.isIos ) || tdDetect.isSafari ) { // safari also 1061 td_affix_menu_element.hide(); 1062 } 1063 1064 //show the logo on smart sticky menu 1065 if ( '' !== tdAffix.tds_snap_menu_logo ) { 1066 jQuery( '.td-main-menu-logo' ).addClass( 'td-logo-sticky' ); 1067 } 1068 } else { 1069 tdAffix.menu_offset_max_hit = false; 1070 1071 if ( ( true === tdDetect.isIos ) || tdDetect.isSafari ) { //ios safari fix 1072 td_affix_menu_element.show(); 1073 } 1074 } 1075 1076 //tdAffix.is_requestAnimationFrame_running = false; 1077 1078 tdAffix.menu_offset = offset; //update the current offset of the menu 1079 1080 }, td_affix_menu_element[0] ); 1081 1082 //} 1083 //console.log(offset + ' ' + scroll_direction); 1084 1085 } //end boundary check 1086 1087 } else { 1088 tdAffix._affix_off( jQuery( tdAffix.menu_selector ) ); 1089 } 1090 }, 1091 1092 1093 /** 1094 * calculates the affix point (the distance from the top when affix should be enabled) 1095 * @see tdAffix.init() 1096 * @see tdEvents 1097 */ 1098 compute_top: function() { 1099 1100 // to compute from the bottom of the menu, the top offset is incremented by the menu wrap height 1101 tdAffix.top_offset = jQuery( tdAffix.menu_wrap_selector ).offset().top;// + jQuery(tdAffix.menu_wrap_selector).height(); 1102 1103 1104 // The top_offset is incremented with the menu_affix_height only on 'smart_snap_always', because of the sidebar 1105 // which use the menu_offset (and menu_offset depends on this top_offset) 1106 // 1107 // Consider that the smart sidebar, increment the td_affix_menu_computed_height with the menu_offset value 1108 // when the menu is on 'smart_snap_always' 1109 if ( 'smart_snap_always' === tdAffix.tds_snap_menu ) { 1110 tdAffix.top_offset += tdAffix.menu_affix_height; 1111 } 1112 1113 1114 //check to see if the menu is at the top of the screen 1115 if ( 1 === tdAffix.top_offset ) { 1116 //switch to affix - because the menu is at the top of the page 1117 //tdAffix._affix_on(jQuery(tdAffix.menu_selector)); 1118 tdAffix.is_top_menu = true; 1119 } else { 1120 //check to see the current top offset 1121 tdAffix.is_top_menu = false; 1122 } 1123 tdAffix.td_events_scroll( jQuery(window).scrollTop() ); 1124 1125 //alert(tdAffix.top_offset); 1126 //console.log('computed: ' + tdAffix.top_offset); 1127 }, 1128 1129 1130 /** 1131 * recalculate the wrapper height. To support different menu heights 1132 */ 1133 compute_wrapper: function() { 1134 1135 // td-affix class is removed to compute a real height when the compute_wrapper is done on a scrolled page 1136 if ( jQuery( tdAffix.menu_selector ).hasClass( 'td-affix' ) ) { 1137 jQuery( tdAffix.menu_selector ).removeClass( 'td-affix' ); 1138 1139 //read the height of the menu 1140 tdAffix.main_menu_height = jQuery( tdAffix.menu_selector ).height(); 1141 1142 jQuery( tdAffix.menu_selector ).addClass( 'td-affix' ); 1143 1144 } else { 1145 //read the height of the menu 1146 tdAffix.main_menu_height = jQuery( tdAffix.menu_selector ).height(); 1147 } 1148 1149 // put the menu height to the wrapper. The wrapper remains in the place when the menu is affixed 1150 jQuery( tdAffix.menu_wrap_selector ).css( 'height', tdAffix.main_menu_height ); 1151 }, 1152 1153 /** 1154 * turns affix on for the menu element 1155 * @param td_affix_menu_element 1156 * @private 1157 */ 1158 _affix_on: function( td_affix_menu_element ) { 1159 if ( false === tdAffix.is_menu_affix ) { 1160 1161 1162 // Bug.Fix - affix menu flickering 1163 // - the td_affix_menu_element is hidden because he is outside of the viewport 1164 // - without it, there's a flicker effect of applying css style (classes) over it 1165 1166 if ( ( 'smart_snap_always' === tdAffix.tds_snap_menu ) && ( tdDetect.isPhoneScreen !== true ) ) { 1167 td_affix_menu_element.css( 'visibility', 'hidden' ); 1168 } 1169 1170 tdAffix.menu_offset = -tdAffix.top_offset; 1171 1172 //make the menu fixed 1173 td_affix_menu_element.addClass( 'td-affix' ); 1174 1175 //add body-td-affix class on body for header style 8 -> when scrolling down the window jumps 76px up when the menu is changing from header style 8 default to header style 8 affix 1176 jQuery( 'body' ).addClass( 'body-td-affix' ); 1177 1178 tdAffix.is_menu_affix = true; 1179 } else { 1180 1181 // the td_affix_menu element is kept visible 1182 if ( true !== tdDetect.isPhoneScreen ) { 1183 td_affix_menu_element.css( 'visibility', '' ); 1184 } 1185 } 1186 }, 1187 1188 1189 1190 /** 1191 * Turns affix off for the menu element 1192 * @param td_affix_menu_element 1193 * @private 1194 */ 1195 _affix_off: function( td_affix_menu_element ) { 1196 if ( true === tdAffix.is_menu_affix ) { 1197 //make the menu normal 1198 jQuery( tdAffix.menu_selector ).removeClass( 'td-affix' ); 1199 1200 //hide the logo from sticky menu when the menu is not affix 1201 if( '' !== tdAffix.tds_snap_menu_logo ) { 1202 jQuery( '.td-main-menu-logo' ).removeClass( 'td-logo-sticky' ); 1203 } 1204 1205 //remove body-td-affix class on body for header style 8 -> when scrolling down the window jumps 76px up when the menu is changing from header style 8 default to header style 8 affix 1206 jQuery( 'body' ).removeClass( 'body-td-affix' ); 1207 1208 tdAffix.is_menu_affix = false; 1209 1210 //move the menu to 0 (ios seems to skip animation frames) 1211 tdUtil.tdMoveY( td_affix_menu_element[0], 0 ); 1212 1213 if ( ( true === tdDetect.isIos ) || tdDetect.isSafari ) { 1214 td_affix_menu_element.show(); 1215 } 1216 } 1217 } 1218 }; 1219})(); 1220 1221 1222 1223 1224 1225 1226 1227/* 1228 tagDiv - 2014
1229 Our portfolio: http://themeforest.net/user/tagDiv/portfolio 1230 Thanks for using our theme! :) 1231*/ 1232 1233 1234/* global jQuery:false */ 1235/* global tdUtil:false */ 1236/* global tdModalImageLastEl:{} */ 1237 1238 1239"use strict"; 1240 1241 1242 1243 1244 1245/* ---------------------------------------------------------------------------- 1246 On load 1247 */ 1248jQuery().ready(function jQuery_ready() { 1249 1250 //retina images 1251 td_retina(); 1252 1253 1254 1255 // the mobile pull left menu (off canvas) 1256 td_mobile_menu(); 1257 1258 //handles the toogle efect on mobile menu 1259 td_mobile_menu_toogle(); 1260 1261 1262 //resize all the videos if we have them 1263 td_resize_videos(); 1264 1265 //fake placeholder for ie 1266 jQuery('input, textarea').placeholder(); 1267 1268 //more stories box 1269 td_more_articles_box.init(); 1270 1271 //used for smart lists 1272 td_smart_lists_magnific_popup(); 1273 1274 //smart list drop down pagination 1275 td_smart_list_dropdown(); 1276 1277 1278 1279}); //end on load 1280 1281 1282/** 1283 * smart lists drop down pagination redirect 1284 */ 1285function td_smart_list_dropdown() { 1286 jQuery('.td-smart-list-dropdown').on('change', function() { 1287 window.location = this.value; 1288 }); 1289} 1290 1291 1292/** 1293 * More stories box 1294 */ 1295var td_more_articles_box = { 1296 is_box_visible:false, 1297 cookie:'', 1298 distance_from_top:400, 1299 1300 init: function init() { 1301 1302 1303 //read the cookie 1304 td_more_articles_box.cookie = td_read_site_cookie('td-cookie-more-articles'); 1305 1306 1307 //setting distance from the top 1308 if(!isNaN(parseInt(tds_more_articles_on_post_pages_distance_from_top)) && isFinite(tds_more_articles_on_post_pages_distance_from_top) && parseInt(tds_more_articles_on_post_pages_distance_from_top) > 0){ 1309 td_more_articles_box.distance_from_top = parseInt(tds_more_articles_on_post_pages_distance_from_top); 1310 } else { 1311 td_more_articles_box.distance_from_top = 400; 1312 } 1313 1314 //adding event to hide the box 1315 jQuery('.td-close-more-articles-box').click(function(){ 1316 1317 //hiding the box 1318 jQuery('.td-more-articles-box').removeClass('td-front-end-display-block'); 1319 jQuery('.td-more-articles-box').hide(); 1320 1321 //cookie life 1322 if(!isNaN(parseInt(tds_more_articles_on_post_time_to_wait)) && isFinite(tds_more_articles_on_post_time_to_wait)){ 1323 //setting cookie 1324 td_set_cookies_life(['td-cookie-more-articles', 'hide-more-articles-box', parseInt(tds_more_articles_on_post_time_to_wait)*86400000]);//86400000 is the number of milliseconds in a day 1325 } 1326 }); 1327 }, 1328 1329 /** 1330 * called by tdEvents.js on scroll 1331 */ 1332 td_events_scroll: function td_events_scroll(scrollTop) { 1333 1334 if(tdIsScrollingAnimation) { //do not fire the event on animations 1335 return; 1336 } 1337 1338 //check to see if it's enable form panel and also from cookie 1339 if(tdUtil.getBackendVar('tds_more_articles_on_post_enable') == "show" && td_more_articles_box.cookie != 'hide-more-articles-box') { 1340 1341 if (scrollTop > td_more_articles_box.distance_from_top ) { 1342 if (td_more_articles_box.is_box_visible === false) { 1343 jQuery('.td-more-articles-box').addClass('td-front-end-display-block'); 1344 td_more_articles_box.is_box_visible = true; 1345 } 1346 } else { 1347 if (td_more_articles_box.is_box_visible === true) { 1348 jQuery('.td-more-articles-box').removeClass('td-front-end-display-block'); 1349 td_more_articles_box.is_box_visible = false; 1350 } 1351 } 1352 } 1353 } 1354}; 1355 1356 1357 1358 1359 1360 1361var td_resize_timer_id; 1362jQuery(window).resize(function() { 1363 clearTimeout(td_resize_timer_id); 1364 td_resize_timer_id = setTimeout(function() { 1365 td_done_resizing(); 1366 }, 200); 1367 1368}); 1369 1370function td_done_resizing(){ 1371 td_resize_videos(); 1372} 1373 1374 1375 1376/* ---------------------------------------------------------------------------- 1377 Resize the videos 1378 */ 1379function td_resize_videos() { 1380 //youtube in content 1381 jQuery(document).find('iframe[src*="youtube.com"]').each(function() { 1382 var videoMainContainer = jQuery(this).parent().parent().parent(), 1383 videoInPlaylist = jQuery(this).parent().hasClass("td_wrapper_playlist_player_vimeo"), 1384 video43AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-43"), //the video is set to 4:3 aspect ratio 1385 video235AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-235"); //the video is set to 2.35:1 aspect ratio 1386 if(videoInPlaylist || video43AspectRatio || video235AspectRatio) { 1387 //do nothing for playlist player youtube or aspect ratios 4:3 and 2.35:1 1388 //the video aspect ratio can be set on Visual Composer - Video Player widget settings 1389 } else { 1390 var td_video = jQuery(this); 1391 td_video.attr('width', '100%'); 1392 var td_video_width = td_video.width(); 1393 td_video.css('height', td_video_width * 0.5625, 'important'); 1394 } 1395 });
1396 1397 1398 //vimeo in content 1399 jQuery(document).find('iframe[src*="vimeo.com"]').each(function() { 1400 var videoMainContainer = jQuery(this).parent().parent().parent(), 1401 videoInPlaylist = jQuery(this).parent().hasClass("td_wrapper_playlist_player_vimeo"), 1402 video43AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-43"), //the video is set to 4:3 aspect ratio 1403 video235AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-235"); //the video is set to 2.35:1 aspect ratio 1404 if(videoInPlaylist || video43AspectRatio || video235AspectRatio) { 1405 //do nothing for playlist player vimeo or aspect ratios 4:3 and 2.35:1 1406 //the video aspect ratio can be set on Visual Composer - Video Player widget settings 1407 } else { 1408 var td_video = jQuery(this); 1409 td_video.attr('width', '100%'); 1410 var td_video_width = td_video.width(); 1411 td_video.css('height', td_video_width * 0.5625, 'important'); 1412 } 1413 }); 1414 1415 1416 //daily motion in content 1417 jQuery(document).find('iframe[src*="dailymotion.com"]').each(function() { 1418 var videoMainContainer = jQuery(this).parent().parent().parent(), 1419 video43AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-43"), //video aspect ratio 4:3 1420 video235AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-235"); //video aspect ratio 2.35:1 1421 if (video43AspectRatio || video235AspectRatio) { 1422 //do nothing for video aspect ratios 4:3 and 2.35:1 1423 //the video aspect ratio can be set on Visual Composer - Video Player widget settings 1424 } else { 1425 var td_video = jQuery(this); 1426 td_video.attr('width', '100%'); 1427 var td_video_width = td_video.width(); 1428 td_video.css('height', td_video_width * 0.6, 'important'); 1429 } 1430 1431 }); 1432 1433 1434 //wordpress embedded 1435 jQuery(document).find(".wp-video-shortcode").each(function() { 1436 var td_video = jQuery(this); 1437 1438 var td_video_width = td_video.width() + 3; 1439 jQuery(this).parent().css('height', td_video_width * 0.56, 'important'); 1440 //td_video.css('height', td_video_width * 0.6, 'important') 1441 td_video.css('width', '100%', 'important'); 1442 td_video.css('height', '100%', 'important'); 1443 }) 1444} 1445 1446 1447 1448 1449 1450 1451//handles mobile menu 1452function td_mobile_menu() { 1453 jQuery('#td-top-mobile-toggle a, .td-mobile-close a').click(function(){ 1454 if(jQuery('body').hasClass('td-menu-mob-open-menu')) { 1455 jQuery('body').removeClass('td-menu-mob-open-menu'); 1456 } else { 1457 if (tdDetect.isMobileDevice) { 1458 // on mobile devices scroll to top instantly and wait a bit and open the menu 1459 window.scrollTo(0, 0); 1460 setTimeout(function(){ 1461 jQuery('body').addClass('td-menu-mob-open-menu'); 1462 }, 100); 1463 } else { 1464 // on desktop open it with full animations 1465 jQuery('body').addClass('td-menu-mob-open-menu'); 1466 setTimeout(function(){ 1467 tdUtil.scrollToPosition(0, 1200); 1468 }, 200); 1469 } 1470 } 1471 }); 1472} 1473 1474 1475//handles open/close mobile menu 1476function td_mobile_menu_toogle() { 1477 1478 jQuery('#td-mobile-nav .menu-item-has-children ul').hide(); 1479 1480 //move thru all the menu and find the item with sub-menues to atach a custom class to them 1481 jQuery(document).find('#td-mobile-nav .menu-item-has-children').each(function(i) { 1482 1483 var class_name = 'td_mobile_elem_with_submenu_' + i; 1484 jQuery(this).addClass(class_name); 1485 1486 //add an element to click on 1487 //jQuery(this).children("a").append('<div class="td-element-after" data-parent-class="' + class_name + '"></div>'); 1488 jQuery(this).children("a").append('<i class="td-icon-menu-down td-element-after" data-parent-class="' + class_name + '"></i>'); 1489 1490 1491 //click on link elements with # 1492 jQuery(this).children("a").addClass("td-link-element-after").attr("data-parent-class", class_name); 1493 });
1494 1495 jQuery(".td-element-after, .td-link-element-after").click(function(event) { 1496 1497 if(jQuery(this).hasClass("td-element-after") || jQuery(this).attr("href") == "#" ){ 1498 event.preventDefault(); 1499 event.stopPropagation(); 1500 } 1501 1502 1503 //take the li parent class 1504 var parent_class = jQuery(this).data('parent-class'); 1505 1506 //target the sub-menu to open 1507 var target_to_open = '#td-mobile-nav .' + parent_class + ' > a + ul'; 1508 if(jQuery(target_to_open).css('display') == 'none') { 1509 jQuery(target_to_open).show(); 1510 } else { 1511 jQuery(target_to_open).hide(); 1512 } 1513 1514 1515 }); 1516} 1517 1518 1519 1520/* ---------------------------------------------------------------------------- 1521 Add retina support 1522 */ 1523 1524function td_retina() { 1525 if (window.devicePixelRatio > 1) { 1526 jQuery('.td-retina').each(function(i) { 1527 var lowres = jQuery(this).attr('src'); 1528 var highres = lowres.replace(".png", "@2x.png"); 1529 highres = highres.replace(".jpg", "@2x.jpg"); 1530 jQuery(this).attr('src', highres); 1531 1532 }); 1533 1534 1535 //custom logo support 1536 jQuery('.td-retina-data').each(function(i) { 1537 jQuery(this).attr('src', jQuery(this).data('retina')); 1538 //fix logo aligment on retina devices 1539 jQuery(this).addClass('td-retina-version'); 1540 }); 1541 1542 } 1543} 1544 1545/* 1546jQuery('body').click(function(e){ 1547 if(! jQuery(e.target).hasClass('custom-background')){ 1548 alert('clicked on something that has not the class theDIV'); 1549 } 1550 1551});*/ 1552 1553//click only on BACKGROUND, for devices that don't have touch (ex: phone, tablets) 1554if(!tdDetect.isTouchDevice && tdUtil.getBackendVar('td_ad_background_click_link') != '') { 1555 1556 //var ev = ev || window.event; 1557 //var target = ev.target || ev.srcElement; 1558 jQuery('body').click(function(event) { 1559 1560 //getting the target element that the user clicks - for W3C and MSIE 1561 var target = (event.target) ? event.target : event.srcElement; 1562 1563 //only click on background 1564 1565 var target_jquery_obj = jQuery(target); 1566 1567 // td-content-wrap for NEWSMAG and td-boxex-layout for NEWSPAPER 1568 if (target_jquery_obj.hasClass('td-content-wrap') || target_jquery_obj.hasClass('td-boxed-layout')) { 1569 1570 //open the link ad page 1571 if(td_ad_background_click_target == '_blank') { 1572 //open in a new window 1573 window.open(td_ad_background_click_link) 1574 } else { 1575 //open in the same window 1576 location.href = td_ad_background_click_link; 1577 } 1578 } 1579 1580 //e.stopPropagation(); 1581 //stopBubble(event); 1582 }); 1583} 1584 1585 1586 1587 1588 1589/** 1590 * reading cookies 1591 * @param name 1592 * @returns {*} 1593 */ 1594function td_read_site_cookie(name) { 1595 var nameEQ = escape(name) + "="; 1596 var ca = document.cookie.split(';'); 1597 for (var i = 0; i < ca.length; i++) { 1598 var c = ca[i]; 1599 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 1600 if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length)); 1601 } 1602 return null; 1603} 1604 1605 1606/** 1607 * 1608 * @param td_time_cookie_array 1609 * 1610 * @param[0]: name of the cookie 1611 * @param[1]: value of the cookie 1612 * @param[2]: expiration time 1613 */ 1614function td_set_cookies_life(td_time_cookie_array) { 1615 var expiry = new Date(); 1616 expiry.setTime(expiry.getTime() + td_time_cookie_array[2]); 1617 1618 // Date()'s toGMTSting() method will format the date correctly for a cookie 1619 document.cookie = td_time_cookie_array[0] + "=" + td_time_cookie_array[1] + "; expires=" + expiry.toGMTString(); 1620} 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641/* ---------------------------------------------------------------------------- 1642 Scroll to top + animation stop 1643 */ 1644 1645var tdIsScrollingAnimation = false; 1646var td_mouse_wheel_or_touch_moved = false; //we want to know if the user stopped the animation via touch or mouse move 1647 1648//stop the animation on mouse wheel 1649jQuery(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function(e){
1650 1651 1652 if (tdIsScrollingAnimation === false) { 1653 return; 1654 } else { 1655 1656 tdIsScrollingAnimation = false; 1657 td_mouse_wheel_or_touch_moved = true; 1658 1659 jQuery("html, body").stop(); 1660 } 1661}); 1662 1663//stop the animation on touch 1664if (document.addEventListener){ 1665 document.addEventListener('touchmove', function(e) { 1666 if (tdIsScrollingAnimation === false) { 1667 return; 1668 } else { 1669 tdIsScrollingAnimation = false; 1670 td_mouse_wheel_or_touch_moved = true; 1671 jQuery("html, body").stop(); 1672 } 1673 }, false); 1674} 1675 1676/** 1677 * called by tdEvents.js on scroll - back to top 1678 */ 1679var td_scroll_to_top_is_visible = false; 1680function td_events_scroll_scroll_to_top(scrollTop) { 1681 if(tdIsScrollingAnimation) { //do not fire the event on animations 1682 return; 1683 } 1684 if (scrollTop > 400) { 1685 if (td_scroll_to_top_is_visible === false) { //only add class if needed 1686 td_scroll_to_top_is_visible = true; 1687 jQuery('.td-scroll-up').addClass('td-scroll-up-visible'); 1688 } 1689 } else { 1690 if (td_scroll_to_top_is_visible === true) { //only add class if needed 1691 td_scroll_to_top_is_visible = false; 1692 jQuery('.td-scroll-up').removeClass('td-scroll-up-visible'); 1693 } 1694 } 1695} 1696 1697 1698jQuery('.td-scroll-up').click(function(){ 1699 if(tdIsScrollingAnimation) { //double check - because when we remove the class, the button is still visible for a while 1700 return; 1701 } 1702 1703 //hide the button 1704 td_scroll_to_top_is_visible = false; 1705 jQuery('.td-scroll-up').removeClass('td-scroll-up-visible'); 1706 1707 //hide more articles box 1708 td_more_articles_box.is_box_visible = false; 1709 jQuery('.td-more-articles-box').removeClass('td-front-end-display-block'); 1710 1711 //scroll to top 1712 tdUtil.scrollToPosition(0, 1200); 1713 1714 return false; 1715}); 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725// small down arrow on template 6 and full width index 1726jQuery('.td-read-down a').click(function(event){ 1727 event.preventDefault(); 1728 tdUtil.scrollToPosition(jQuery('.td-full-screen-header-image-wrap').height(), 1200); 1729 //tdUtil.scrollToPosition(jQuery('.td-full-screen-header-image-wrap').height() + jQuery('.td-full-screen-header-image-wrap').offset().top, 1200); 1730}); 1731 1732/** 1733 * make td-post-template-6 title move down and blurry 1734 * called from single_tempalte_6.php via the js buffer 1735 */ 1736function td_post_template_6_title() { 1737 1738 1739 1740 //define all the variables - for better performance ? 1741 var td_parallax_el = document.getElementById('td_parallax_header_6'); 1742 1743 var td_parallax_bg_el = document.getElementById('td-full-screen-header-image'); 1744 1745 var scroll_from_top = ''; 1746 var distance_from_bottom; 1747 1748 //attach the animation tick on scroll 1749 jQuery(window).scroll(function(){ 1750 // with each scroll event request an animation frame (we have a polyfill for animation frame) 1751 // the requestAnimationFrame is called only once and after that we wait 1752 td_request_tick(); 1753 }); 1754 1755 1756 var td_animation_running = false; //if the tick is running, we set this to true 1757 1758 function td_request_tick() { 1759 if (td_animation_running === false) { 1760 window.requestAnimationFrame(td_do_animation); 1761 } 1762 td_animation_running = true; 1763 } 1764 1765 /** 1766 * the animation loop 1767 */ 1768 function td_do_animation() { 1769 scroll_from_top = jQuery(document).scrollTop(); 1770 if (scroll_from_top <= 950) { //stop the animation after scroll from top 1771 1772 var blur_value = 1 - (scroll_from_top / 800); // @todo trebuie verificata formula?? 1773 if (tdDetect.isIe8 === true) { 1774 blur_value = 1; 1775 } 1776 1777 1778 blur_value = Math.round(blur_value * 100) / 100; 1779 1780 //opacity 1781 td_parallax_el.style.opacity = blur_value; 1782 1783 //move the bg 1784 var parallax_move = -Math.round(scroll_from_top / 4); 1785 tdUtil.tdMoveY(td_parallax_bg_el,-parallax_move); 1786 1787 1788 //move the title + cat 1789 distance_from_bottom = -Math.round(scroll_from_top / 8); 1790 tdUtil.tdMoveY(td_parallax_el,-distance_from_bottom); 1791 //td_parallax_el.style.bottom = distance_from_bottom + "px";
1791 //un accelerated version 1792 1793 1794 } 1795 1796 td_animation_running = false; 1797 } 1798 1799 1800 1801} 1802 1803//used for smart lists 1804function td_smart_lists_magnific_popup() { 1805 //magnific popup 1806 jQuery(".td-slide-smart-list-figure").magnificPopup({ 1807 delegate: "a", 1808 type: "image", 1809 tLoading: "Loading image #%curr%...", 1810 mainClass: "mfp-img-mobile", 1811 gallery: { 1812 enabled: true, 1813 navigateByImgClick: true, 1814 preload: [0,1], 1815 tCounter: tdUtil.getBackendVar('td_magnific_popup_translation_tCounter') // Markup for "1 of 7" counter 1816 }, 1817 image: { 1818 tError: "<a href=\'%url%\'>The image #%curr%</a> could not be loaded.", 1819 titleSrc: function(item) {//console.log(item.el); 1820 //alert(jQuery(item.el).data("caption")); 1821 return item.el.attr("data-caption"); 1822 } 1823 }, 1824 zoom: { 1825 enabled: true, 1826 duration: 300, 1827 opener: function(element) { 1828 return element.find("img"); 1829 } 1830 }, 1831 callbacks: { 1832 change: function(item) { 1833 /** 1834 * if we have pictures only on 3 from 4 slides then remove, from magnific popup, the one with no image 1835 */ 1836 //console.log(item); 1837 //console.log(item.el[0].id); 1838 //console.log(parseInt(nr_slide[1]) + 1); 1839 if(item.el[0].id != '') { 1840 var nr_slide = item.el[0].id.split("_"); 1841
1842 // Will fire when popup is closed 1843 //jQuery(".td-iosSlider").iosSlider("goToSlide", this.currItem.index + 1 ); 1844 jQuery(".td-iosSlider").iosSlider("goToSlide", parseInt(nr_slide[1]) + 1); 1845 } else { 1846 tdModalImageLastEl = item.el; 1847 setTimeout(function(){ 1848 tdUtil.scrollIntoView(item.el); 1849 }, 100); 1850 } 1851 }, 1852 beforeClose: function() { 1853 if (tdModalImageLastEl != '') { 1854 tdUtil.scrollIntoView(tdModalImageLastEl); 1855 } 1856 } 1857 } 1858 }); 1859} 1860 1861 1862 1863 1864 1865function td_get_document_width() { 1866 var x = 0; 1867 if (self.innerHeight) 1868 { 1869 x = self.innerWidth; 1870 } 1871 else if (document.documentElement && document.documentElement.clientHeight) 1872 { 1873 x = document.documentElement.clientWidth; 1874 } 1875 else if (document.body) 1876 { 1877 x = document.body.clientWidth; 1878 } 1879 return x; 1880} 1881 1882function td_get_document_height() { 1883 var y = 0; 1884 if (self.innerHeight) 1885 { 1886 y = self.innerHeight; 1887 } 1888 else if (document.documentElement && document.documentElement.clientHeight) 1889 { 1890 y = document.documentElement.clientHeight; 1891 } 1892 else if (document.body) 1893 { 1894 y = document.body.clientHeight; 1895 } 1896 return y; 1897} 1898 1899 1900/* global jQuery:false */ 1901/* global tdUtil:false */ 1902 1903var tdLoadingBox = {}; 1904 1905 1906( function() { 1907 "use strict"; 1908 tdLoadingBox = { 1909 1910 //arrayColors: ['#ffffff', '#fafafa', '#ececec', '#dddddd', '#bfbfbf', '#9a9a9a', '#7e7e7e', '#636363'],//whiter -> darker 1911 1912 speed: 40, 1913 1914 arrayColorsTemp: [ 1915 'rgba(99, 99, 99, 0)', 1916 'rgba(99, 99, 99, 0.05)', 1917 'rgba(99, 99, 99, 0.08)', 1918 'rgba(99, 99, 99, 0.2)', 1919 'rgba(99, 99, 99, 0.3)', 1920 'rgba(99, 99, 99, 0.5)', 1921 'rgba(99, 99, 99, 0.6)', 1922 'rgba(99, 99, 99, 1)' 1923 ],//whiter -> darker 1924 1925 arrayColors: [], 1926 1927 statusAnimation: 'stop', 1928 1929 //stop loading box 1930 stop : function stop () { 1931 tdLoadingBox.statusAnimation = 'stop'; 1932 //jQuery('.td-loader-gif').html(""); 1933 }, 1934 1935 1936 //init loading box 1937 init : function init (color, speed) { 1938 1939 // set up the speed 1940 if (false === tdUtil.isUndefined(speed)) { 1941 tdLoadingBox.speed = speed; 1942 } 1943 1944 //console.log('test'); 1945 var tdColorRegExp = /^#[a-zA-Z0-9]{3,6}$/; 1946 if(color && tdColorRegExp.test(color)) { 1947 1948 var colRgba = tdLoadingBox.hexToRgb(color); 1949 1950 var rgbaString = "rgba(" + colRgba.r + ", " + colRgba.g + ", " + colRgba.b + ", "; 1951 1952 tdLoadingBox.arrayColors[7] = rgbaString + " 1)"; 1953 tdLoadingBox.arrayColors[6] = rgbaString + " 0.6)"; 1954 tdLoadingBox.arrayColors[5] = rgbaString + " 0.5)"; 1955 tdLoadingBox.arrayColors[4] = rgbaString + " 0.3)"; 1956 tdLoadingBox.arrayColors[3] = rgbaString + " 0.2)"; 1957 tdLoadingBox.arrayColors[2] = rgbaString + " 0.08)"; 1958 tdLoadingBox.arrayColors[1] = rgbaString + " 0.05)"; 1959 tdLoadingBox.arrayColors[0] = rgbaString + " 0)"; 1960 1961 } else { 1962 //default array 1963 tdLoadingBox.arrayColors = tdLoadingBox.arrayColorsTemp.slice(0); 1964 1965 } 1966 1967 if(tdLoadingBox.statusAnimation === 'stop') { 1968 tdLoadingBox.statusAnimation = 'display'; 1969 this.render(); 1970 } 1971 }, 1972 1973 1974 //create the animation 1975 render: function render (color) { 1976 1977 //call the animationDisplay function 1978 tdLoadingBox.animationDisplay( 1979 '<div class="td-lb-box td-lb-box-1" style="background-color:' + tdLoadingBox.arrayColors[0] + '"></div>' + 1980 '<div class="td-lb-box td-lb-box-2" style="background-color:' + tdLoadingBox.arrayColors[1] + '"></div>' + 1981 '<div class="td-lb-box td-lb-box-3" style="background-color:' + tdLoadingBox.arrayColors[2] + '"></div>' + 1982 '<div class="td-lb-box td-lb-box-4" style="background-color:' + tdLoadingBox.arrayColors[3] + '"></div>' + 1983 '<div class="td-lb-box td-lb-box-5" style="background-color:' + tdLoadingBox.arrayColors[4] + '"></div>' + 1984 '<div class="td-lb-box td-lb-box-6" style="background-color:' + tdLoadingBox.arrayColors[5] + '"></div>' + 1985 '<div class="td-lb-box td-lb-box-7" style="background-color:' + tdLoadingBox.arrayColors[6] + '"></div>' + 1986 '<div class="td-lb-box td-lb-box-8" style="background-color:' + tdLoadingBox.arrayColors[7] + '"></div>' 1987 ); 1988 1989 //direction right 1990 var tempColorArray = [ 1991 tdLoadingBox.arrayColors[0], 1992 tdLoadingBox.arrayColors[1], 1993 tdLoadingBox.arrayColors[2], 1994 tdLoadingBox.arrayColors[3], 1995 tdLoadingBox.arrayColors[4], 1996 tdLoadingBox.arrayColors[5], 1997 tdLoadingBox.arrayColors[6], 1998 tdLoadingBox.arrayColors[7] 1999 ]; 2000 2001 tdLoadingBox.arrayColors[0] = tempColorArray[7]; 2002 tdLoadingBox.arrayColors[1] = tempColorArray[0]; 2003 tdLoadingBox.arrayColors[2] = tempColorArray[1]; 2004 tdLoadingBox.arrayColors[3] = tempColorArray[2]; 2005 tdLoadingBox.arrayColors[4] = tempColorArray[3]; 2006 tdLoadingBox.arrayColors[5] = tempColorArray[4]; 2007 tdLoadingBox.arrayColors[6] = tempColorArray[5]; 2008 tdLoadingBox.arrayColors[7] = tempColorArray[6]; 2009 2010 if(tdLoadingBox.statusAnimation === 'display') { 2011 2012 2013 setTimeout(tdLoadingBox.render, tdLoadingBox.speed); 2014 } else { 2015 tdLoadingBox.animationDisplay(''); 2016 } 2017 }, 2018 2019 2020 //display the animation 2021 animationDisplay: function (animation_str) { 2022 jQuery('.td-loader-gif').html(animation_str); 2023 }, 2024 2025 2026 //converts hex to rgba 2027 hexToRgb: function (hex) { 2028 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); 2029 2030 return result ? { 2031 r: parseInt(result[1], 16), 2032 g: parseInt(result[2], 16), 2033 b: parseInt(result[3], 16) 2034 } : null; 2035 } 2036 }; //tdLoadingBox.init();//tdLoadingBox.stop(); 2037})(); 2038 2039 2040 2041 2042 2043 2044 2045/* ---------------------------------------------------------------------------- 2046 On load 2047 */ 2048jQuery().ready(function() { 2049 td_ajax_search.init(); 2050}); 2051 2052 2053var td_ajax_search = { 2054 2055 // private vars 2056 _current_selection_index:0, 2057 _last_request_results_count:0, 2058 _first_down_up:true, 2059 _is_search_open:false, 2060 2061 2062 /** 2063 * init the class 2064 */
2065 init: function init() { 2066 2067 2068 // hide the drop down if we click outside of it 2069 jQuery(document).click(function(e) { 2070 if( 2071 e.target.className !== "td-icon-search" 2072 && e.target.id !== "td-header-search" 2073 && e.target.id !== "td-header-search-top" 2074 && td_ajax_search._is_search_open === true 2075 ) { 2076 td_ajax_search.hide_search_box(); 2077 } 2078 }); 2079 2080 2081 // show and hide the drop down on the search icon 2082 jQuery('#td-header-search-button').click(function(event){ 2083 event.preventDefault(); 2084 if (td_ajax_search._is_search_open === true) { 2085 td_ajax_search.hide_search_box(); 2086 2087 } else { 2088 td_ajax_search.show_search_box(); 2089 } 2090 }); 2091 2092 2093 // keydown on the text box 2094 jQuery('#td-header-search').keydown(function(event) { 2095 if ( 2096 (event.which && event.which == 39) 2097 || (event.keyCode && event.keyCode == 39) 2098 || (event.which && event.which == 37) 2099 || (event.keyCode && event.keyCode == 37)) 2100 { 2101 //do nothing on left and right arrows 2102 td_ajax_search.td_aj_search_input_focus(); 2103 return; 2104 } 2105 2106 2107 2108 2109 if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) { 2110 // on enter 2111 var td_aj_cur_element = jQuery('.td-aj-cur-element'); 2112 if (td_aj_cur_element.length > 0) { 2113 //alert('ra'); 2114 var td_go_to_url = td_aj_cur_element.find('.entry-title a').attr('href'); 2115 window.location = td_go_to_url; 2116 } else { 2117 jQuery(this).parent().parent().submit(); 2118 } 2119 return false; //redirect for search on enter 2120 } else { 2121 2122 if ((event.which && event.which == 40) || (event.keyCode && event.keyCode == 40)) { 2123 // down 2124 td_ajax_search.td_aj_search_move_prompt_down(); 2125 return false; //disable the envent 2126 2127 } else if((event.which && event.which == 38) || (event.keyCode && event.keyCode == 38)) { 2128 //up 2129 td_ajax_search.td_aj_search_move_prompt_up(); 2130 return false; //disable the envent 2131 } else { 2132 2133 //for backspace we have to check if the search query is empty and if so, clear the list 2134 if ((event.which && event.which == 8) || (event.keyCode && event.keyCode == 8)) { 2135 //if we have just one character left, that means it will be deleted now and we also have to clear the search results list 2136 var search_query = jQuery(this).val(); 2137 if (search_query.length == 1) { 2138 jQuery('#td-aj-search').empty(); 2139 } 2140 2141 } 2142 2143 //various keys 2144 td_ajax_search.td_aj_search_input_focus(); 2145 //jQuery('#td-aj-search').empty(); 2146 setTimeout(function(){ 2147 td_ajax_search.do_ajax_call(); 2148 }, 100); 2149 } 2150 return true; 2151 } 2152 2153 }); 2154 2155 }, 2156 2157 2158 show_search_box: function open_search_box() { 2159 jQuery(".td-drop-down-search").addClass('td-drop-down-search-open'); 2160 // do not try to autofocus on ios. It's still buggy as of 18 march 2015 2161 if (tdDetect.isIos !== true) { 2162 setTimeout(function(){ 2163 document.getElementById("td-header-search").focus(); 2164 }, 200); 2165 } 2166 td_ajax_search._is_search_open = true; 2167 }, 2168 2169 2170 hide_search_box: function hide_search_box() { 2171 jQuery(".td-drop-down-search").removeClass('td-drop-down-search-open'); 2172 td_ajax_search._is_search_open = false; 2173 }, 2174 2175 2176 2177 /** 2178 * moves the select up 2179 */ 2180 td_aj_search_move_prompt_up: function td_aj_search_move_prompt_up() { 2181 if (td_ajax_search._first_down_up === true) { 2182 td_ajax_search._first_down_up = false; 2183 if (td_ajax_search._current_selection_index === 0) { 2184 td_ajax_search._current_selection_index = td_ajax_search._last_request_results_count - 1; 2185 } else { 2186 td_ajax_search._current_selection_index--; 2187 } 2188 } else { 2189 if (td_ajax_search._current_selection_index === 0) { 2190 td_ajax_search._current_selection_index = td_ajax_search._last_request_results_count; 2191 } else { 2192 td_ajax_search._current_selection_index--; 2193 } 2194 } 2195 jQuery('.td_module_wrap').removeClass('td-aj-cur-element'); 2196 if (td_ajax_search._current_selection_index > td_ajax_search._last_request_results_count -1) { 2197 //the input is selected 2198 jQuery('.td-search-form').fadeTo(100, 1); 2199 } else { 2200 td_ajax_search.td_aj_search_input_remove_focus(); 2201 jQuery('.td_module_wrap').eq(td_ajax_search._current_selection_index).addClass('td-aj-cur-element'); 2202 } 2203 }, 2204 2205 2206 2207 /** 2208 * moves the select prompt down 2209 */ 2210 td_aj_search_move_prompt_down: function td_aj_search_move_prompt_down() { 2211 if (td_ajax_search._first_down_up === true) { 2212 td_ajax_search._first_down_up = false; 2213 } else { 2214 if (td_ajax_search._current_selection_index === td_ajax_search._last_request_results_count) { 2215 td_ajax_search._current_selection_index = 0; 2216 } else { 2217 td_ajax_search._current_selection_index++; 2218 } 2219 } 2220 jQuery('.td_module_wrap').removeClass('td-aj-cur-element'); 2221 if (td_ajax_search._current_selection_index > td_ajax_search._last_request_results_count - 1 ) { 2222 //the input is selected 2223 jQuery('.td-search-form').fadeTo(100, 1); 2224 } else { 2225 td_ajax_search.td_aj_search_input_remove_focus(); 2226 jQuery('.td_module_wrap').eq(td_ajax_search._current_selection_index).addClass('td-aj-cur-element'); 2227 } 2228 }, 2229 2230 2231 2232 /** 2233 * puts the focus on the input box 2234 */ 2235 td_aj_search_input_focus: function td_aj_search_input_focus() { 2236 td_ajax_search._current_selection_index = 0; 2237 td_ajax_search._first_down_up = true; 2238 jQuery('.td-search-form').fadeTo(100, 1); 2239 jQuery('.td_module_wrap').removeClass('td-aj-cur-element'); 2240 }, 2241 2242 2243 2244 /** 2245 * removes the focus from the input box 2246 */ 2247 td_aj_search_input_remove_focus: function td_aj_search_input_remove_focus() { 2248 if (td_ajax_search._last_request_results_count !== 0) { 2249 jQuery('.td-search-form').css('opacity', 0.5); 2250 } 2251 }, 2252 2253 2254 2255 /** 2256 * AJAX: process the response from the server 2257 */ 2258 process_ajax_response: function (data) { 2259 var current_query = jQuery('#td-header-search').val(); 2260 2261 //the search is empty - drop results 2262 if (current_query == '') { 2263 jQuery('#td-aj-search').empty(); 2264 return; 2265 } 2266 2267 var td_data_object = jQuery.parseJSON(data); //get the data object 2268 //drop the result - it's from a old query 2269 if (td_data_object.td_search_query !== current_query) { 2270 return; 2271 } 2272 2273 //reset the current selection and total posts 2274 td_ajax_search._current_selection_index = 0; 2275 td_ajax_search._last_request_results_count = td_data_object.td_total_in_list; 2276 td_ajax_search._first_down_up = true; 2277 2278 2279 //update the query 2280 jQuery('#td-aj-search').html(td_data_object.td_data); 2281 2282 /* 2283 td_data_object.td_data 2284 td_data_object.td_total_results 2285 td_data_object.td_total_in_list 2286 */ 2287 2288 // the .entry-thumb are searched for in the #td-aj-search object, sorted and added into the view port array items 2289 if ((typeof window['tdAnimationStack'] !== 'undefined') && (window['tdAnimationStack'].activated === true)) { 2290 window['tdAnimationStack'].check_for_new_items('#td-aj-search .td-animation-stack', window['tdAnimationStack'].SORTED_METHOD.sort_left_to_right, true); 2291 window['tdAnimationStack'].compute_items();
2292 } 2293 }, 2294 2295 2296 2297 /** 2298 * AJAX: do the ajax request 2299 */ 2300 do_ajax_call: function do_ajax_call() { 2301 if (jQuery('#td-header-search').val() == '') { 2302 td_ajax_search.td_aj_search_input_focus(); 2303 return; 2304 } 2305 2306 2307 2308 var search_query = jQuery('#td-header-search').val(); 2309 2310 2311 //do we have a cache hit 2312 if (tdLocalCache.exist(search_query)) { 2313 td_ajax_search.process_ajax_response(tdLocalCache.get(search_query)); 2314 return; //cache HIT 2315 } 2316 2317 2318 //fk no cache hit - do the real request 2319 2320 2321 2322 jQuery.ajax({ 2323 type: 'POST', 2324 url: td_ajax_url, 2325 data: { 2326 action: 'td_ajax_search', 2327 td_string: search_query 2328 }, 2329 success: function(data, textStatus, XMLHttpRequest){ 2330 tdLocalCache.set(search_query, data); 2331 td_ajax_search.process_ajax_response(data); 2332 }, 2333 error: function(MLHttpRequest, textStatus, errorThrown){ 2334 //console.log(errorThrown); 2335 } 2336 }); 2337 } 2338 2339 2340}; 2341 2342 2343 2344;'use strict'; 2345 2346/* ---------------------------------------------------------------------------- 2347 tdPostImages.js 2348 --------------------------------------------------------------------------- */ 2349 2350/* global jQuery:{} */ 2351/* global tdUtil:{} */ 2352/* global tdAffix:{} */ 2353/* global tdIsScrollingAnimation:boolean */ 2354 2355/* ---------------------------------------------------------------------------- 2356 On load 2357 */ 2358jQuery().ready(function() { 2359 2360 //handles the modal images 2361 tdModalImage(); 2362 2363 //move classes from post images to figure - td-post-image-full etc 2364 tdUtil.imageMoveClassToFigure( 'td-post-image-full' ); 2365 tdUtil.imageMoveClassToFigure( 'td-post-image-right' ); 2366 tdUtil.imageMoveClassToFigure( 'td-post-image-left' ); 2367 2368 /** 2369 * - add a general td-modal-image class to the all post images 2370 */ 2371 if ( ( 'undefined' !== typeof window.tds_general_modal_image ) && ( '' !== window.tds_general_modal_image ) ) { 2372 jQuery( '.single .td-post-content a > img' ).filter(function( index, element ) { 2373 if ( -1 !== element.className.indexOf( 'wp-image' ) ) { 2374 jQuery( element ).parent().addClass( 'td-modal-image' ); 2375 } 2376 }); 2377 } 2378}); 2379 2380 2381 2382// used for scrolling to the last element 2383var tdModalImageLastEl = ''; 2384 2385// handles modal images for: Featured images, inline image, inline image with caption, galleries 2386function tdModalImage() { 2387 2388 //fix wordpress figure + figcaption (we move the figcaption in the data-caption attribute of the link) 2389 jQuery( 'figure.wp-caption' ).each(function() { 2390 var caption_text = jQuery( this ).children( 'figcaption' ).html(); 2391 jQuery( this ).children( 'a' ).data( 'caption', caption_text ); 2392 }); 2393 2394 //move td-modal-image class to the parent a from the image. We can only add this class to the image via word press media editor 2395 jQuery( '.td-modal-image' ).each(function() { 2396 jQuery( this ).parent().addClass( 'td-modal-image' ); 2397 jQuery( this ).removeClass( 'td-modal-image' ); 2398 }); 2399 2400 2401 2402 //popup on modal images in articles 2403 jQuery( 'article' ).magnificPopup({ 2404 type: 'image', 2405 delegate: ".td-modal-image", 2406 gallery: { 2407 enabled: true, 2408 tPrev: tdUtil.getBackendVar( 'td_magnific_popup_translation_tPrev' ), // Alt text on left arrow 2409 tNext: tdUtil.getBackendVar( 'td_magnific_popup_translation_tNext' ), // Alt text on right arrow 2410 tCounter: tdUtil.getBackendVar( 'td_magnific_popup_translation_tCounter' ) // Markup for "1 of 7" counter 2411 }, 2412 ajax: { 2413 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_ajax_tError' ) 2414 }, 2415 image: { 2416 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_image_tError' ), 2417 titleSrc: function( item ) {//console.log(item.el); 2418 //alert(jQuery(item.el).data("caption")); 2419 var td_current_caption = jQuery( item.el ).data( 'caption' ); 2420 if ( 'undefined' !== typeof td_current_caption ) { 2421 return td_current_caption; 2422 } else { 2423 return ''; 2424 } 2425 } 2426 }, 2427 zoom: { 2428 enabled: true, 2429 duration: 300, 2430 opener: function( element ) {
2431 return element.find( 'img' ); 2432 } 2433 }, 2434 callbacks: { 2435 change: function( item ) { 2436 tdModalImageLastEl = item.el; 2437 //setTimeout(function(){ 2438 tdUtil.scrollIntoView( item.el ); 2439 //}, 100); 2440 }, 2441 beforeClose: function() { 2442 tdAffix.allow_scroll = false; 2443 2444 tdUtil.scrollIntoView( tdModalImageLastEl ); 2445 2446 var interval_td_affix_scroll = setInterval(function() { 2447 2448 if ( ! tdIsScrollingAnimation ) { 2449 clearInterval( interval_td_affix_scroll ); 2450 setTimeout(function() { 2451 tdAffix.allow_scroll = true; 2452 //tdAffix.td_events_scroll(td_events.scroll_window_scrollTop); 2453 }, 100 ); 2454 } 2455 }, 100 ); 2456 } 2457 } 2458 }); 2459 2460 2461 2462 2463 2464 //gallery popup 2465 //detect jetpack carousel and disable the theme popup 2466 if ( 'undefined' === typeof jetpackCarouselStrings ) { 2467 2468 // copy gallery caption from figcaption to data-caption attribute of the link to the full image, in this way the modal can read the caption 2469 jQuery( 'figure.gallery-item' ).each(function() { 2470 var caption_text = jQuery( this ).children( 'figcaption' ).html(); 2471 jQuery( this ).find( 'a' ).data( 'caption', caption_text ); 2472 }); 2473 2474 2475 //jquery tiled gallery 2476 jQuery( '.tiled-gallery' ).magnificPopup({ 2477 type: 'image', 2478 delegate: "a", 2479 gallery: { 2480 enabled: true, 2481 tPrev: tdUtil.getBackendVar( 'td_magnific_popup_translation_tPrev' ), // Alt text on left arrow 2482 tNext: tdUtil.getBackendVar( 'td_magnific_popup_translation_tNext' ), // Alt text on right arrow 2483 tCounter: tdUtil.getBackendVar( 'td_magnific_popup_translation_tCounter' ) // Markup for "1 of 7" counter 2484 }, 2485 ajax: { 2486 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_ajax_tError' ) 2487 }, 2488 image: { 2489 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_image_tError' ), 2490 titleSrc: function( item ) {//console.log(item.el); 2491 var td_current_caption = jQuery( item.el ).parent().find( '.tiled-gallery-caption' ).text(); 2492 if ( 'undefined' !== typeof td_current_caption ) { 2493 return td_current_caption; 2494 } else { 2495 return ''; 2496 } 2497 } 2498 }, 2499 zoom: { 2500 enabled: true, 2501 duration: 300, 2502 opener: function( element ) { 2503 return element.find( 'img' ); 2504 } 2505 }, 2506 callbacks: { 2507 change: function( item ) { 2508 tdModalImageLastEl = item.el; 2509 tdUtil.scrollIntoView( item.el ); 2510 }, 2511 beforeClose: function() { 2512 tdUtil.scrollIntoView( tdModalImageLastEl ); 2513 } 2514 } 2515 }); 2516 2517 2518 2519 jQuery( '.gallery' ).magnificPopup({ 2520 type: 'image', 2521 delegate: '.gallery-icon > a', 2522 gallery: { 2523 enabled: true, 2524 tPrev: tdUtil.getBackendVar( 'td_magnific_popup_translation_tPrev' ), // Alt text on left arrow 2525 tNext: tdUtil.getBackendVar( 'td_magnific_popup_translation_tNext' ), // Alt text on right arrow 2526 tCounter: tdUtil.getBackendVar( 'td_magnific_popup_translation_tCounter' ) // Markup for "1 of 7" counter 2527 }, 2528 ajax: { 2529 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_ajax_tError' ) 2530 }, 2531 image: { 2532 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_image_tError' ), 2533 titleSrc: function( item ) {//console.log(item.el); 2534 var td_current_caption = jQuery( item.el ).data( 'caption' ); 2535 if ( 'undefined' !== typeof td_current_caption ) { 2536 return td_current_caption; 2537 } else { 2538 return ''; 2539 } 2540 } 2541 }, 2542 zoom: { 2543 enabled: true, 2544 duration: 300, 2545 opener: function( element ) {
2546 return element.find( 'img' ); 2547 } 2548 }, 2549 callbacks: { 2550 change: function( item ) { 2551 tdModalImageLastEl = item.el; 2552 tdUtil.scrollIntoView( item.el ); 2553 }, 2554 beforeClose: function() { 2555 tdUtil.scrollIntoView( tdModalImageLastEl ); 2556 } 2557 } 2558 }); 2559 } 2560} //end modal 2561/** 2562 * tdBlocks.js 2563 * v3.0 5 August 2015 2564 * Converted to WP JS standards + jsHint 2565 */ 2566 2567/* global jQuery:false */ 2568/* global td_ajax_url:false */ 2569/* global tds_theme_color_site_wide:false */ 2570 2571 2572 2573/* global tdSmartSidebar:{} */ 2574/* global tdAnimationStack:{} */ 2575/* global tdUtil:false */ //done 2576/* global tdLoadingBox:false */ //done 2577/* global tdInfiniteLoader:false */ //done 2578/* global tdBlocksArray:false */ //done 2579/* global tdDetect:false */ //done 2580/* global tdLocalCache:false */ //done 2581 2582var tdBlocks = {}; 2583 2584( function() { 2585 "use strict"; 2586 2587 /* ---------------------------------------------------------------------------- 2588 On load 2589 */ 2590 jQuery().ready( function() { 2591 tdOnReadyAjaxBlocks(); 2592 }); 2593 2594 2595 2596 2597 2598 2599 function tdOnReadyAjaxBlocks() { 2600 2601 2602 /* ---------------------------------------------------------------------------- 2603 AJAX pagination next 2604 */ 2605 jQuery(".td-ajax-next-page").click( function(event) { 2606 event.preventDefault(); 2607 2608 var currentBlockObj = tdBlocks.tdGetBlockObjById(jQuery(this).data('td_block_id')); 2609 2610 if ( jQuery(this).hasClass('ajax-page-disabled') || true === currentBlockObj.is_ajax_running ) { 2611 return; 2612 } 2613 2614 currentBlockObj.is_ajax_running = true; // ajax is running and we're wayting for a reply from server 2615 2616 currentBlockObj.td_current_page++; 2617 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'next'); 2618 }); 2619 2620 2621 /* ---------------------------------------------------------------------------- 2622 AJAX pagination prev 2623 */ 2624 jQuery(".td-ajax-prev-page").click( function(event) { 2625 event.preventDefault(); 2626 2627 var currentBlockObj = tdBlocks.tdGetBlockObjById(jQuery(this).data('td_block_id')); 2628 2629 if ( jQuery(this).hasClass('ajax-page-disabled') || true === currentBlockObj.is_ajax_running ) { 2630 return; 2631 } 2632 2633 currentBlockObj.is_ajax_running = true; // ajax is running and we're wayting for a reply from server 2634 2635 currentBlockObj.td_current_page--; 2636 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'back'); 2637 }); 2638 2639 2640 /* ---------------------------------------------------------------------------- 2641 AJAX pagination load more 2642 */ 2643 jQuery(".td_ajax_load_more_js").click( function(event) { 2644 event.preventDefault(); 2645 if ( jQuery(this).hasClass('ajax-page-disabled') ) { 2646 return; 2647 } 2648 2649 jQuery(this).css('visibility', 'hidden'); 2650 2651 var currentBlockObj = tdBlocks.tdGetBlockObjById(jQuery(this).data('td_block_id')); 2652 2653 currentBlockObj.td_current_page++; 2654 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'load_more'); 2655 2656 // load_more is hidden if there are no more posts 2657 if ( currentBlockObj.max_num_pages <= currentBlockObj.td_current_page ) { 2658 jQuery(this).addClass('ajax-page-disabled'); 2659 } 2660 }); 2661 2662 2663 2664 /* ---------------------------------------------------------------------------- 2665 pull down open/close //on mobile devices use click event 2666 */ 2667 if ( tdDetect.isMobileDevice ) { 2668 2669 jQuery(".td-pulldown-filter-display-option").click( function () { 2670 var currentBlockUid = jQuery(this).data('td_block_id'); 2671 jQuery("#td_pulldown_" + currentBlockUid).addClass("td-pulldown-filter-list-open"); 2672 2673 //animate the list 2674 var tdPullDownList = jQuery("#td_pulldown_" + currentBlockUid + "_list"); 2675 tdPullDownList.removeClass('fadeOut'); 2676 tdPullDownList.addClass('td_animated td_fadeIn'); //used for opacity animation 2677 //tdPullDownList.css('visibility', 'visible'); 2678 }); 2679 2680 //on desktop devices use hover event 2681 } else { 2682 2683 /** 2684 * (hover) open and close the drop down menu (on blocks on hover) 2685 */ 2686 jQuery(".td-pulldown-filter-display-option").hover( function () { 2687 // hover in 2688 var current_block_uid = jQuery(this).data('td_block_id'); 2689 jQuery("#td_pulldown_" + current_block_uid).addClass("td-pulldown-filter-list-open"); 2690 2691 //animate the list 2692 var tdPullDownList = jQuery("#td_pulldown_" + current_block_uid + "_list"); 2693 tdPullDownList.removeClass('fadeOut'); 2694 tdPullDownList.addClass('td_animated td_fadeIn'); //used for opacity animation 2695 tdPullDownList.css('visibility', 'visible'); 2696 2697 }, 2698 function () { 2699 // hover out 2700 var currentBlockUid = jQuery(this).data('td_block_id'); 2701 jQuery("#td_pulldown_" + currentBlockUid).removeClass("td-pulldown-filter-list-open"); 2702 2703 2704 } 2705 ); 2706 } 2707 2708 2709 2710 /* ---------------------------------------------------------------------------- 2711 click on related posts in single posts 2712 */ 2713 jQuery('.td-related-title a').click( function(event) { 2714 event.preventDefault(); 2715 2716 jQuery('.td-related-title').children('a').removeClass('td-cur-simple-item'); 2717 jQuery(this).addClass('td-cur-simple-item'); 2718 2719 //get the current block id 2720 var currentBlockUid = jQuery(this).data('td_block_id'); 2721 2722 //get current block 2723 var currentBlockObj = tdBlocks.tdGetBlockObjById(currentBlockUid); 2724 2725 //change current filter value - the filter type is readed by td_ajax from the atts of the shortcode 2726 currentBlockObj.td_filter_value = jQuery(this).data('td_filter_value'); 2727 2728 currentBlockObj.td_current_page = 1; //reset the page 2729 2730 //do request 2731 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'pull_down'); 2732 }); 2733 2734 2735 2736 2737 /* ---------------------------------------------------------------------------- 2738 MEGA MENU 2739 */ 2740 // Used to simulate on mobile doubleclick at 300ms @see the function tdAjaxSubCatMegaRun() 2741 var tdSubCatMegaRunLink = false; // run the link if this is true, instead of loading via ajax the mega menu content 2742 var tdSubCatMegaLastTarget = ''; // last event target - to make sure the double click is on the same element 2743 2744 2745 /** 2746 * On touch screens check for double click and redirect to the subcategory page if that's the case, 2747 * if not double click... do the normal ajax request 2748 * @param event 2749 * @param jQueryObject 2750 */ 2751 function tdAjaxSubCatMegaRunOnTouch(event, jQueryObject) { 2752 if ( (true === tdSubCatMegaRunLink) && (event.target === tdSubCatMegaLastTarget) ) { 2753 window.location = event.target; 2754 } else { 2755 tdSubCatMegaRunLink = true; 2756 tdSubCatMegaLastTarget = event.target; 2757 event.preventDefault(); 2758 2759 setTimeout( function() { 2760 tdSubCatMegaRunLink = false; 2761 }, 300); 2762 2763 tdAjaxSubCatMegaRun(event, jQueryObject); 2764 } 2765 } 2766 2767 /**
2768 * this one makes the ajax request for mega menu filter 2769 * hover or click on mega menu subcategories 2770 */ 2771 function tdAjaxSubCatMegaRun(event, jQueryObject) { 2772 /* global this:false */ 2773 //get the current block id 2774 var currentBlockUid = jQueryObject.data('td_block_id'); 2775 var currentBlockObj = tdBlocks.tdGetBlockObjById(currentBlockUid); 2776 2777 // on mega menu, we allow parallel ajax request for better UI. We set is_ajax_running so that the preloader cache will work as expected 2778 currentBlockObj.is_ajax_running = true; 2779 2780 //switch cur cat 2781 jQuery('.mega-menu-sub-cat-' + currentBlockUid).removeClass('cur-sub-cat'); 2782 jQueryObject.addClass('cur-sub-cat'); 2783 2784 //get current block 2785 2786 2787 //change current filter value - the filter type is readed by td_ajax from the atts of the shortcode 2788 currentBlockObj.td_filter_value = jQueryObject.data('td_filter_value'); 2789 2790 currentBlockObj.td_current_page = 1; //reset the page 2791 2792 //do request 2793 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'mega_menu'); 2794 } 2795 2796 2797 /** 2798 * Mega menu filters 2799 */ 2800 //on touch devices use click 2801 // @todo needs testing to determine why we need .click and touchend? 2802 // @todo trebuie refactorizata sa transmita jQuery(this) de aici la functii 2803 if ( tdDetect.isTouchDevice ) { 2804 jQuery(".block-mega-child-cats a") 2805 .click( function(event) { 2806 tdAjaxSubCatMegaRunOnTouch(event, jQuery(this)); 2807 }, false) 2808 .each(function(index, element) { 2809 element.addEventListener('touchend', function(event) { 2810 tdAjaxSubCatMegaRunOnTouch(event, jQuery(this)); 2811 }, false); 2812 }); 2813 2814 } else { 2815 jQuery(".block-mega-child-cats a").hover( function(event) { 2816 tdAjaxSubCatMegaRun(event, jQuery(this)); 2817 }, function (event) {} ); 2818 } 2819 2820 2821 2822 /* ---------------------------------------------------------------------------- 2823 Subcategories 2824 */ 2825 /** 2826 * Newspaper ONLY 2827 * used by the drop down ajax filter on blocks 2828 */ 2829 jQuery('.td-subcat-item a').click( function(event) { 2830 event.preventDefault(); 2831 2832 var currentBlockObj = tdBlocks.tdGetBlockObjById(jQuery(this).data('td_block_id')); 2833 2834 //if ( jQuery(this).hasClass('ajax-page-disabled') || true === currentBlockObj.is_ajax_running ) { 2835 // return; 2836 //} 2837 // 2838 if ( true === currentBlockObj.is_ajax_running ) { 2839 return; 2840 } 2841 2842 2843 currentBlockObj.is_ajax_running = true; // ajax is running and we're waiting for a reply from server 2844 2845 2846 jQuery('.' + jQuery(this).data('td_block_id') + '_rand').find('.td-cur-simple-item').removeClass('td-cur-simple-item'); 2847 jQuery(this).addClass('td-cur-simple-item'); 2848 2849 2850 //change current filter value - the filter type is read by td_ajax from the atts of the shortcode 2851 currentBlockObj.td_filter_value = jQuery(this).data('td_filter_value'); 2852 2853 2854 2855 //reset the page 2856 currentBlockObj.td_current_page = 1; 2857 2858 // we ues 'pull_down' just for the 'td_animated_xlong td_fadeInDown' effect 2859 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'pull_down'); 2860 }); 2861 2862 2863 /** 2864 * Newsmag ONLY 2865 * when a item is from the dropdown menu is clicked (on all the blocks) 2866 * @todo asta face ceva cu ios slider-ul in plus fata de aia de pe Newspaper 2867 */ 2868 jQuery(".td-pulldown-filter-link").click( function(event) { 2869 event.preventDefault(); 2870 2871 2872 2873 //get the current block id 2874 var currentBlockUid = jQuery(this).data('td_block_id'); 2875 2876 //destroy any iossliders to avoid bugs 2877 jQuery('#' + currentBlockUid).find('.iosSlider').iosSlider('destroy'); 2878 2879 //get current block 2880 var currentBlockObj = tdBlocks.tdGetBlockObjById(currentBlockUid); 2881 if ( true === currentBlockObj.is_ajax_running ) { 2882 return; 2883 } 2884 2885 currentBlockObj.is_ajax_running = true; 2886 //change current filter value - the filter type is readed by td_ajax from the atts of the shortcode 2887 currentBlockObj.td_filter_value = jQuery(this).data('td_filter_value'); 2888 2889 2890 currentBlockObj.td_current_page = 1; 2891 2892 2893 //put loading... text and hide the dropdown @todo - tranlation pt loading 2894 //tdBlocks.tdPullDownFilterChangeValue(currentBlockObj.id, '<span>Loading... </span><i class="td-icon-menu-down"></i>'); 2895 tdBlocks.tdPullDownFilterChangeValue(currentBlockUid, '<span>' + jQuery(this).html() + ' </span><i class="td-icon-menu-down"></i>'); 2896 2897 2898 //hide the dropdown 2899 jQuery('#td_pulldown_' + currentBlockUid).removeClass("td-pulldown-filter-list-open"); 2900 2901 2902 //do request 2903 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'pull_down'); 2904 2905 2906 //on mobile devices stop event propagation 2907 if ( tdDetect.isMobileDevice ) { 2908 tdUtil.stopBubble(event); 2909 } 2910 2911 }); 2912 } // end tdOnReadyAjaxBlocks() 2913 2914 2915 2916 2917 2918 2919 tdBlocks = { 2920 2921 2922 /** 2923 * Newsmag ONLY change the pull down filter value to loading... and to the current category after an ajax reply 2924 * is received 2925 * @param td_block_uid 2926 * @param td_text 2927 */ 2928 tdPullDownFilterChangeValue: function(td_block_uid, td_text) { 2929 jQuery('#td-pulldown-' + td_block_uid + '-val').html(td_text); 2930 }, 2931 2932 2933 2934 /** 2935 * makes a ajax block request 2936 * @param current_block_obj 2937 * @param td_user_action - load more or infinite loader (used by the animation) 2938 * @returns {string} 2939 */ 2940 tdAjaxDoBlockRequest: function(current_block_obj, td_user_action) { 2941 //search the cache 2942 var currentBlockObjSignature = JSON.stringify(current_block_obj); 2943 if ( tdLocalCache.exist(currentBlockObjSignature) ) { 2944 //do the animation with cache hit = true 2945 tdBlocks.tdBlockAjaxLoadingStart(current_block_obj, true, td_user_action); 2946 tdBlocks.tdAjaxBlockProcessResponse(tdLocalCache.get(currentBlockObjSignature), td_user_action); 2947 return 'cache_hit'; //cache HIT 2948 } 2949 2950
2951 //cache miss - we make a full request! - cache hit - false 2952 tdBlocks.tdBlockAjaxLoadingStart(current_block_obj, false, td_user_action); 2953//return; 2954 var requestData = { 2955 action: 'td_ajax_block', 2956 td_atts: current_block_obj.atts, 2957 td_block_id:current_block_obj.id, 2958 td_column_number:current_block_obj.td_column_number, 2959 td_current_page:current_block_obj.td_current_page, 2960 block_type:current_block_obj.block_type, 2961 td_filter_value:current_block_obj.td_filter_value, 2962 td_user_action:current_block_obj.td_user_action 2963 }; 2964 2965 //console.log('tdAjaxDoBlockRequest:'); 2966 //console.log(requestData); 2967 2968 jQuery.ajax({ 2969 type: 'POST', 2970 url: td_ajax_url, 2971 cache:true, 2972 data: requestData, 2973 success: function(data, textStatus, XMLHttpRequest) { 2974 2975 tdLocalCache.set(currentBlockObjSignature, data); 2976 tdBlocks.tdAjaxBlockProcessResponse(data, td_user_action); 2977 }, 2978 error: function(MLHttpRequest, textStatus, errorThrown) { 2979 //console.log(errorThrown); 2980 } 2981 }); 2982 }, 2983 2984 2985 /** 2986 * process the response from the ajax query (it also processes the responses stored in the cache) 2987 * @param data 2988 * @param td_user_action - load more or infinite loader (used by the animation) 2989 */ 2990 tdAjaxBlockProcessResponse: function(data, td_user_action) { 2991 2992 //read the server response 2993 var tdReplyObj = jQuery.parseJSON(data); //get the data object 2994 2995 //console.log('tdAjaxBlockProcessResponse:'); 2996 //console.log(tdReplyObj); 2997 /* 2998 td_data_object.td_block_id 2999 td_data_object.td_data 3000 td_data_object.td_cur_cat 3001 */ 3002 3003 3004 3005 3006 3007 3008 //load the content (in place or append) 3009 if ( 'load_more' === td_user_action || 'infinite_load' === td_user_action ) { 3010 3011 // fix needed to keep sidebars fixed down when they are bottom of the content and the content grows up 3012 for ( var i = 0; i < tdSmartSidebar.items.length; i++ ) { 3013 if ( 'case_3_bottom_of_content' === tdSmartSidebar.items[ i ].sidebar_state ) { 3014 tdSmartSidebar.items[ i ].sidebar_state = 'case_1_fixed_down'; 3015 } 3016 } 3017 3018 jQuery(tdReplyObj.td_data).appendTo('#' + tdReplyObj.td_block_id); 3019 //jQuery(tdReplyObj.td_data).addClass('td_animated_xxlong').appendTo('#' + tdReplyObj.td_block_id).addClass('td_fadeIn'); 3020 //jQuery('#' + tdReplyObj.td_block_id).append(tdReplyObj.td_data); //append 3021 } else { 3022 jQuery('#' + tdReplyObj.td_block_id).html(tdReplyObj.td_data); //in place 3023 } 3024 3025 3026 //hide or show prev 3027 if ( true === tdReplyObj.td_hide_prev ) { 3028 jQuery('#prev-page-' + tdReplyObj.td_block_id).addClass('ajax-page-disabled'); 3029 } else { 3030 jQuery('#prev-page-' + tdReplyObj.td_block_id).removeClass('ajax-page-disabled'); 3031 } 3032 3033 //hide or show next 3034 if ( true === tdReplyObj.td_hide_next ) { 3035 jQuery('#next-page-' + tdReplyObj.td_block_id).addClass('ajax-page-disabled'); 3036 } else { 3037 jQuery('#next-page-' + tdReplyObj.td_block_id).removeClass('ajax-page-disabled'); 3038 } 3039 3040 3041 var currentBlockObj = tdBlocks.tdGetBlockObjById(tdReplyObj.td_block_id); 3042 if ( 'slide' === currentBlockObj.block_type ) { 3043 //make the first slide active (to have caption) 3044 jQuery('#' + tdReplyObj.td_block_id + ' .slide-wrap-active-first').addClass('slide-wrap-active'); 3045 } 3046 3047 currentBlockObj.is_ajax_running = false; // finish the loading for this block 3048 3049 3050 //loading effects 3051 tdBlocks.tdBlockAjaxLoadingEnd(tdReplyObj, currentBlockObj, td_user_action); //td_user_action - load more or infinite loader (used by the animation) 3052 }, 3053 3054 3055 3056 /** 3057 * loading start 3058 * @param current_block_obj 3059 * @param cache_hit boolean - is true if we have a cache hit 3060 * @param td_user_action - the request type / infinite_load ? 3061 */ 3062 tdBlockAjaxLoadingStart: function(current_block_obj, cache_hit, td_user_action) { 3063 3064 //get the element 3065 var elCurTdBlockInner = jQuery('#' + current_block_obj.id); 3066 3067 //remove any remaining loaders 3068 jQuery('.td-loader-gif').remove(); 3069 3070 //remove animation classes 3071 elCurTdBlockInner.removeClass('td_fadeInRight td_fadeInLeft td_fadeInDown td_fadeInUp td_animated_xlong'); 3072 3073 elCurTdBlockInner.addClass('td_block_inner_overflow'); 3074 //auto height => fixed height
3075 var tdTmpBlockHeight = elCurTdBlockInner.height(); 3076 elCurTdBlockInner.css('height', tdTmpBlockHeight); 3077 3078 3079 //show the loader only if we have a cache MISS 3080 if ( false === cache_hit ) { 3081 if ( 'load_more' === td_user_action) { 3082 // on load more 3083 elCurTdBlockInner.parent().append('<div class="td-loader-gif td-loader-infinite td-loader-blocks-load-more td-loader-animation-start"></div>'); 3084 tdLoadingBox.init(current_block_obj.header_color ? current_block_obj.header_color : tds_theme_color_site_wide); //init the loading box 3085 setTimeout(function () { 3086 jQuery('.td-loader-gif') 3087 .removeClass('td-loader-animation-start') 3088 .addClass('td-loader-animation-mid'); 3089 }, 50); 3090 3091 } 3092 else if ('infinite_load' === td_user_action) { 3093 // on infinite load 3094 elCurTdBlockInner.parent().append('<div class="td-loader-gif td-loader-infinite td-loader-animation-start"></div>'); 3095 tdLoadingBox.init(current_block_obj.header_color ? current_block_obj.header_color : tds_theme_color_site_wide); //init the loading box 3096 setTimeout(function () { 3097 jQuery('.td-loader-gif') 3098 .removeClass('td-loader-animation-start') 3099 .addClass('td-loader-animation-mid'); 3100 }, 50); 3101 3102 } else { 3103 /** 3104 * the default animation if the user action is NOT load_more or infinite_load 3105 * infinite load has NO animation ! 3106 */ 3107 elCurTdBlockInner.parent().append('<div class="td-loader-gif td-loader-animation-start"></div>'); 3108 tdLoadingBox.init(current_block_obj.header_color ? current_block_obj.header_color : tds_theme_color_site_wide); //init the loading box (the parameter is the block title background color or tds_theme_color_site_wide) 3109 setTimeout( function(){ 3110 jQuery('.td-loader-gif') 3111 .removeClass('td-loader-animation-start') 3112 .addClass('td-loader-animation-mid'); 3113 },50); 3114 elCurTdBlockInner.addClass('td_animated_long td_fadeOut_to_1'); 3115 3116 } 3117 } // end cache_hit if 3118 }, 3119 3120 3121 3122 /** 3123 * we have a reply from the ajax request 3124 * @param td_reply_obj - the reply object that we got from the server, it's useful with infinite load 3125 * @param current_block_obj 3126 * @param td_user_action - load more or infinite loader (used by the animation) 3127 */ 3128 tdBlockAjaxLoadingEnd: function(td_reply_obj, current_block_obj, td_user_action) { 3129 3130 //jQuery('.td-loader-gif').remove(); 3131 // remove the loader 3132 jQuery('.td-loader-gif') 3133 .removeClass('td-loader-animation-mid') 3134 .addClass('td-loader-animation-end'); 3135 setTimeout( function() { 3136 jQuery('.td-loader-gif').remove(); 3137 //stop the loading box 3138 tdLoadingBox.stop(); 3139 },400); 3140 3141 3142 //get the current inner 3143 var elCurTdBlockInner = jQuery('#' + current_block_obj.id); 3144 3145 elCurTdBlockInner.removeClass('td_animated_long td_fadeOut_to_1'); 3146 3147 3148 // by default, the sort method used to animate the ajax response is left to the right 3149 3150 var tdAnimationStackSortType; 3151 3152 if ( true === tdAnimationStack.activated ) { 3153 tdAnimationStackSortType = tdAnimationStack.SORTED_METHOD.sort_left_to_right; 3154 } 3155 3156 switch(td_user_action) { 3157 case 'next': 3158 elCurTdBlockInner.addClass('td_animated_xlong td_fadeInRight'); 3159 3160 // the default sort method is modified to work from right to the left 3161 if ( undefined !== tdAnimationStackSortType ) { 3162 tdAnimationStackSortType = tdAnimationStack.SORTED_METHOD.sort_right_to_left; 3163 } 3164 3165 break; 3166 case 'back': 3167 elCurTdBlockInner.addClass('td_animated_xlong td_fadeInLeft'); 3168 break; 3169 3170 case 'pull_down': 3171 elCurTdBlockInner.addClass('td_animated_xlong td_fadeInDown'); 3172 break; 3173 3174 case 'mega_menu': 3175 elCurTdBlockInner.addClass('td_animated_xlong td_fadeInDown'); 3176 break; 3177 3178 3179 case 'load_more': 3180 //console.log('.' + current_block_obj.id + '_rand .td_ajax_load_more_js'); 3181 setTimeout ( function() { 3182 jQuery('.' + current_block_obj.id + '_rand .td_ajax_load_more_js').css('visibility', 'visible'); 3183 }, 500); 3184 3185 break; 3186 case 'infinite_load': 3187 setTimeout( function() { 3188 //refresh waypoints for infinit scroll tdInfiniteLoader 3189 tdInfiniteLoader.computeTopDistances();
3190 if ( '' !== td_reply_obj.td_data ) { 3191 tdInfiniteLoader.enable_is_visible_callback(current_block_obj.id); 3192 } 3193 }, 500); 3194 3195 3196 setTimeout( function() { 3197 tdInfiniteLoader.computeTopDistances(); 3198 // load next page only if we have new data coming from the last ajax request 3199 }, 1000); 3200 3201 setTimeout( function() { 3202 tdInfiniteLoader.computeTopDistances(); 3203 }, 1500); 3204 break; 3205 3206 } 3207 3208 3209 3210 setTimeout( function() { 3211 jQuery('.td_block_inner_overflow').removeClass('td_block_inner_overflow'); 3212 elCurTdBlockInner.css('height', 'auto'); 3213 3214 tdSmartSidebar.compute(); 3215 },200); 3216 3217 3218 3219 3220 setTimeout( function () { 3221 tdSmartSidebar.compute(); 3222 }, 500); 3223 3224 3225 3226 // the .entry-thumb are searched for in the current block object, sorted and added into the view port array items 3227 if ( undefined !== tdAnimationStackSortType ) { 3228 setTimeout( function () { 3229 tdAnimationStack.check_for_new_items('#' + current_block_obj.id + ' .td-animation-stack', tdAnimationStackSortType, true); 3230 }, 200); 3231 } 3232 }, 3233 3234 /** 3235 * search by block _id 3236 * @param myID - block id 3237 * @returns {number} the index 3238 */ 3239 tdGetBlockIndex: function(myID) { 3240 var cnt = 0; 3241 var tmpReturn = 0; 3242 jQuery.each(tdBlocksArray, function(index, td_block) { 3243 if ( td_block.id === myID ) { 3244 tmpReturn = cnt; 3245 return false; //brake jquery each 3246 } else { 3247 cnt++; 3248 } 3249 }); 3250 return tmpReturn; 3251 }, 3252 3253 3254 3255 /** 3256 * gets the block object using a block ID 3257 * @param myID 3258 * @returns {*} block object 3259 */ 3260 tdGetBlockObjById: function(myID) { 3261 return tdBlocksArray[tdBlocks.tdGetBlockIndex(myID)]; 3262 } 3263 3264 3265 3266 3267 3268 }; //end tdBlocks 3269 3270 3271 3272})(); 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283/* 3284 td_util.js 3285 v1.1 3286 */ 3287 3288/* global jQuery:{} */ 3289/* global tdDetect:{} */ 3290/* global td_ajax_url:string */ 3291 3292/* global td_please_wait:string */ 3293/* global td_email_user_pass_incorrect:string */ 3294/* global td_email_user_incorrect:string */ 3295/* global td_email_incorrect:string */ 3296 3297 3298 3299/* ---------------------------------------------------------------------------- 3300 On load 3301 */ 3302jQuery().ready(function() { 3303 3304 'use strict'; 3305 3306 /** 3307 * Modal window js code 3308 */ 3309 jQuery( '.td-login-modal-js' ).magnificPopup({ 3310 type: 'inline', 3311 preloader: false, 3312 focus: '#name', 3313 removalDelay: 500, 3314 3315 // When elemened is focused, some mobile browsers in some cases zoom in 3316 // It looks not nice, so we disable it: 3317 callbacks: { 3318 beforeOpen: function() { 3319 3320 this.st.mainClass = this.st.el.attr('data-effect'); 3321 3322 //empty all fields 3323 td_modala_empty_all_fields(); 3324 3325 //empty error display div 3326 td_modala_empty_err_div(); 3327 3328 if( jQuery( window ).width() < 700) { 3329 this.st.focus = false; 3330 } else { 3331 if ( false === tdDetect.isIe ) { 3332 //do not focus on ie 10 3333 this.st.focus = '#login_email'; 3334 } 3335 } 3336 }, 3337 3338 beforeClose: function() { 3339 } 3340 } 3341 }); 3342 3343 //login 3344 jQuery( '#login-link' ).on( 'click', function() { 3345 //hides or shows the divs with inputs 3346 show_hide_content_modala( [['#td-login-div', 1], ['#td-register-div', 0], ['#td-forgot-pass-div', 0]] ); 3347 3348 //moves focus on the tab 3349 modala_swich_tabs( [['#login-link', 1], ['#register-link', 0]] ); 3350 3351 if ( jQuery(window).width() > 700 && tdDetect.isIe === false ) { 3352 jQuery( '#login_email' ).focus(); 3353 } 3354 3355 //empty all fields 3356 //td_modala_empty_all_fields(); 3357 3358 //empty error display div 3359 td_modala_empty_err_div(); 3360 });
3361 3362 //login button 3363 jQuery( '#login_button' ).on( 'click', function() { 3364 handle_login_for_modal_window(); 3365 }); 3366 3367 //enter key on #login_pass 3368 jQuery( '#login_pass' ).keydown(function(event) { 3369 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 3370 handle_login_for_modal_window(); 3371 } 3372 }); 3373 3374 //register 3375 jQuery( '#register-link' ).on( 'click', function() { 3376 //hides or shows the divs with inputs 3377 show_hide_content_modala( [['#td-login-div', 0], ['#td-register-div', 1], ['#td-forgot-pass-div', 0]] ); 3378 3379 //moves focus on the tab 3380 modala_swich_tabs( [['#login-link', 0], ['#register-link', 1]] ); 3381 3382 if ( jQuery( window ).width() > 700 && false === tdDetect.isIe ) { 3383 jQuery( '#register_email' ).focus(); 3384 } 3385 3386 //empty all fields 3387 //td_modala_empty_all_fields(); 3388 3389 //empty error display div 3390 td_modala_empty_err_div(); 3391 }); 3392 3393 //register button 3394 jQuery( '#register_button' ).on( 'click', function() { 3395 handle_register_for_modal_window(); 3396 }); 3397 3398 //enter key on #register_user 3399 jQuery( '#register_user' ).keydown(function(event) { 3400 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 3401 handle_register_for_modal_window(); 3402 } 3403 }); 3404 3405 //forgot pass 3406 jQuery( '#forgot-pass-link' ).on( 'click', function() { 3407 //hides or shows the divs with inputs 3408 show_hide_content_modala( [['#td-login-div', 0], ['#td-register-div', 0], ['#td-forgot-pass-div', 1]] ); 3409 3410 //moves focus on the tab 3411 modala_swich_tabs( [['#login-link', 0], ['#register-link', 0]] ); 3412 3413 if (jQuery( window ).width() > 700 && false === tdDetect.isIe ) { 3414 jQuery( '#forgot_email' ).focus(); 3415 } 3416 3417 //empty all fields 3418 //td_modala_empty_all_fields(); 3419 3420 //empty error display div 3421 td_modala_empty_err_div(); 3422 }); 3423 3424 //forgot button 3425 jQuery( '#forgot_button' ).on( 'click', function() { 3426 handle_forgot_password_for_modal_window(); 3427 }); 3428 3429 //enter key on #forgot_email 3430 jQuery( '#forgot_email' ).keydown(function(event) { 3431 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 3432 handle_forgot_password_for_modal_window(); 3433 } 3434 }); 3435});//end jquery ready 3436 3437 3438 3439//patern to check emails 3440var td_mod_pattern_email = /^[a-zA-Z0-9][a-zA-Z0-9_\.-]{0,}[a-zA-Z0-9]@[a-zA-Z0-9][a-zA-Z0-9_\.-]{0,}[a-z0-9][\.][a-z0-9]{2,4}$/, 3441 handle_login_for_modal_window, 3442 handle_register_for_modal_window, 3443 handle_forgot_password_for_modal_window, 3444 show_hide_content_modala, 3445 modala_swich_tabs, 3446 modala_add_remove_class, 3447 td_modala_empty_err_div, 3448 td_modala_write_err_div, 3449 td_modala_empty_all_fields, 3450 td_modala_call_ajax; 3451 3452 3453(function(){ 3454 3455 'use strict'; 3456 3457 /** 3458 * handle all request made from login tab 3459 */ 3460 handle_login_for_modal_window = function() { 3461 var login_email = jQuery( '#login_email' ).val(); 3462 var login_pass = jQuery( '#login_pass' ).val(); 3463 3464 if ( login_email && login_pass ) { 3465 //empty error display div 3466 //td_modala_empty_err_div(); 3467 3468 modala_add_remove_class( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3469 jQuery( '.td_display_err' ).show(); 3470 td_modala_write_err_div( td_please_wait ); 3471 3472 //call ajax for log in 3473 td_modala_call_ajax( 'td_mod_login', login_email, '', login_pass ); 3474 } else { 3475 jQuery( '.td_display_err' ).show(); 3476 td_modala_write_err_div( td_email_user_pass_incorrect ); 3477 } 3478 }; 3479 3480 /** 3481 * handle all request made from register tab 3482 */ 3483 handle_register_for_modal_window = function() { 3484 var register_email = jQuery( '#register_email' ).val(); 3485 var register_user = jQuery( '#register_user' ).val(); 3486 3487 if ( td_mod_pattern_email.test( register_email ) && register_user ) { 3488 //empty error display div 3489 //td_modala_empty_err_div(); 3490 3491 modala_add_remove_class( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3492 jQuery( '.td_display_err' ).show(); 3493 td_modala_write_err_div( td_please_wait ); 3494 3495 //call ajax 3496 td_modala_call_ajax( 'td_mod_register', register_email, register_user, '' ); 3497 } else { 3498 jQuery( '.td_display_err' ).show(); 3499 td_modala_write_err_div( td_email_user_incorrect ); 3500 } 3501 }; 3502 3503 /** 3504 * handle all request made from forgot password tab 3505 */ 3506 handle_forgot_password_for_modal_window = function() { 3507 var forgot_email = jQuery( '#forgot_email' ).val(); 3508 3509 if ( td_mod_pattern_email.test( forgot_email ) ){
3510 //empty error display div 3511 //td_modala_empty_err_div(); 3512 3513 modala_add_remove_class( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3514 jQuery( '.td_display_err' ).show(); 3515 td_modala_write_err_div( td_please_wait ); 3516 3517 //call ajax 3518 td_modala_call_ajax( 'td_mod_remember_pass', forgot_email, '', '' ); 3519 } else { 3520 jQuery( '.td_display_err' ).show(); 3521 td_modala_write_err_div( td_email_incorrect ); 3522 } 3523 }; 3524 3525 3526 /** 3527 * swhich the div's acordingly to the user action (Log In, Register, Remember Password) 3528 * 3529 * ids_array : array of ids that have to be showed or hidden 3530 */ 3531 show_hide_content_modala = function( ids_array ) { 3532 var length = ids_array.length; 3533 3534 for ( var i = 0; i < length; i++ ) { 3535 var element_id = ids_array[ i ][0]; 3536 var element_visibility = ids_array[ i ][1]; 3537 3538 if ( 1 === element_visibility ) { 3539 jQuery( element_id ).removeClass( 'td-dispaly-none' ).addClass( 'td-dispaly-block' ); 3540 } else { 3541 jQuery( element_id ).removeClass( 'td-dispaly-block' ).addClass( 'td-dispaly-none' ); 3542 } 3543 } 3544 }; 3545 3546 3547 /** 3548 * swhich the tab's acordingly to the user action (Log In, Register, Remember Password) 3549 * 3550 * ids_array : array of ids that have to be focus on or unfocus 3551 */ 3552 modala_swich_tabs = function( ids_array ) { 3553 var length = ids_array.length; 3554 3555 for ( var i = 0; i < length; i++ ) { 3556 var element_id = ids_array[ i ][0]; 3557 var element_visibility = ids_array[ i ][1]; 3558 3559 if ( 1 === element_visibility ) { 3560 jQuery( element_id ).addClass( 'td_login_tab_focus' ); 3561 } else { 3562 jQuery( element_id ).removeClass( 'td_login_tab_focus' ); 3563 } 3564 } 3565 }; 3566 3567 3568 /** 3569 * adds or remove a class from an html object 3570 * 3571 * param : array with object identifier (id - # or class - .) 3572 * ex: ['.class_indetifier', 1, 'class_to_add'] or ['.class_indetifier', 0, 'class_to_remove'] 3573 */ 3574 modala_add_remove_class = function( param ) { 3575 3576 //add class 3577 if ( 1 === param[1] ) { 3578 jQuery( param[0] ).addClass( param[2] ); 3579 3580 //remove class 3581 } else { 3582 jQuery( param[0] ).removeClass( param[2] ); 3583 } 3584 }; 3585 3586 3587 /** 3588 * empty the error div 3589 */ 3590 td_modala_empty_err_div = function() { 3591 var jQueryObj = jQuery( '.td_display_err'); 3592 if ( jQueryObj.length ) { 3593 jQueryObj.html( '' ); 3594 jQueryObj.hide(); 3595 } 3596 }; 3597 3598 3599 /** 3600 * write text to error div 3601 */ 3602 td_modala_write_err_div = function( message ) { 3603 jQuery( '.td_display_err' ).html( message ); 3604 }; 3605 3606 3607 /** 3608 * empty all fields in modal window 3609 */ 3610 td_modala_empty_all_fields = function() { 3611 //login fields 3612 jQuery( '#login_email' ).val( '' ); 3613 jQuery( '#login_pass' ).val( '' ); 3614 3615 //register fields 3616 jQuery( '#register_email' ).val( '' ); 3617 jQuery( '#register_user' ).val( '' ); 3618 3619 //forgot pass 3620 jQuery( '#forgot_email' ).val( '' ); 3621 }; 3622 3623 3624 /** 3625 * call to server from modal window 3626 * 3627 * @param $action : what action (log in, register, forgot email) 3628 * @param $email : the email beening sent 3629 * @param $user : the user name beening sent 3630 */ 3631 td_modala_call_ajax = function( sent_action, sent_email, sent_user, sent_pass ) { 3632 jQuery.ajax({ 3633 type: 'POST', 3634 url: td_ajax_url, 3635 data: { 3636 action: sent_action, 3637 email: sent_email, 3638 user: sent_user, 3639 pass: sent_pass 3640 }, 3641 success: function( data, textStatus, XMLHttpRequest ){ 3642 var td_data_object = jQuery.parseJSON( data ); //get the data object 3643 3644 //check the response from server 3645 switch( td_data_object[0] ) { 3646 case 'login': 3647 if ( 1 === td_data_object[1] ) { 3648 location.reload( true ); 3649 } else { 3650 modala_add_remove_class( ['.td_display_err', 0, 'td_display_msg_ok'] ); 3651 jQuery( '.td_display_err' ).show(); 3652 td_modala_write_err_div( td_data_object[2] ); 3653 } 3654 break; 3655 3656 case 'register': 3657 if ( 1 === td_data_object[1] ) { 3658 modala_add_remove_class( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3659 jQuery( '.td_display_err' ).show(); 3660 } else { 3661 modala_add_remove_class( ['.td_display_err', 0, 'td_display_msg_ok'] ); 3662 jQuery( '.td_display_err' ).show(); 3663 } 3664 td_modala_write_err_div( td_data_object[2] ); 3665 break; 3666 3667 case 'remember_pass': 3668 if ( 1 === td_data_object[1] ) { 3669 modala_add_remove_class( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3670 jQuery( '.td_display_err' ).show(); 3671 } else { 3672 modala_add_remove_class( ['.td_display_err', 0, 'td_display_msg_ok'] ); 3673 jQuery( '.td_display_err' ).show(); 3674 } 3675 td_modala_write_err_div( td_data_object[2] ); 3676 break; 3677 3678 } 3679 3680 3681 }, 3682 error: function( MLHttpRequest, textStatus, errorThrown ){ 3683 //console.log(errorThrown); 3684 } 3685 }); 3686 }; 3687 3688})(); 3689 3690 3691 3692/* ---------------------------------------------------------------------------- 3693 tagDiv live css compiler ( 2013 )
3694 - this script is used on our demo site to customize the theme live 3695 - not used on production sites 3696 */ 3697 3698/* global jQuery:{} */ 3699/* global td_read_site_cookie:Function */ 3700/* global td_set_cookies_life:Function */ 3701 3702var td_current_panel_stat = ''; 3703 3704(function() { 3705 3706 'use strict'; 3707 3708 td_current_panel_stat = td_read_site_cookie( 'td_show_panel' ); 3709 3710 if ( 'show' === td_current_panel_stat || null === td_current_panel_stat ) { 3711 3712 var jQueryObj = jQuery( '.td-theme-settings-small' ); 3713 if ( jQueryObj.length ) { 3714 jQueryObj.addClass('td-theme-settings-no-transition'); 3715 jQueryObj.removeClass('td-theme-settings-small'); 3716 } 3717 } 3718 3719})(); 3720 3721 3722 3723/* ---------------------------------------------------------------------------- 3724 On load 3725 */ 3726jQuery().ready(function() { 3727 3728 'use strict'; 3729 3730 //hide panel 3731 jQuery( '#td-theme-set-hide' ).click(function(event){ 3732 event.preventDefault(); 3733 event.stopPropagation(); 3734 //hide 3735 td_set_cookies_life( ['td_show_panel', 'hide', 86400000] );//86400000 is the number of milliseconds in a day 3736 3737 var jQueryObj = jQuery( '#td-theme-settings' ); 3738 if ( jQueryObj.length ) { 3739 jQueryObj.removeClass( 'td-theme-settings-no-transition' ); 3740 jQueryObj.addClass( 'td-theme-settings-small' ); 3741 } 3742 3743 jQuery('.td-set-theme-style-link').removeClass('td_fadeInLeft'); 3744 3745 }); 3746 3747 //show panel 3748 jQuery( '#td-theme-settings' ).click(function(){ 3749 if ( jQuery( this).hasClass( 'td-theme-settings-small' ) ) { 3750 3751 jQuery( '.td-set-theme-style-link' ).addClass( 'td_animated_xlong td_fadeInLeft' ); 3752 3753 //show full 3754 td_set_cookies_life( ['td_show_panel', 'show', 86400000] );//86400000 is the number of milliseconds in a day 3755 jQuery( '.td-theme-settings-small' ).removeClass( 'td-theme-settings-small' ); 3756 } 3757 }); 3758 3759}); //end on load 3760/** 3761 * Created by RADU on 6/24/14. 3762 */ 3763 3764/* global jQuery: {} */ 3765 3766//global object that holds each `trending-now-wrapper` list of posts 3767//var td_trending_now_object = {}; 3768 3769var tdTrendingNowObject = {}; 3770 3771(function() { 3772 3773 "use strict"; 3774 3775 tdTrendingNowObject = { 3776 3777 trendingNowAutostartBlocks: [], 3778 3779 //trending now function : creates the array of posts in each trend and add events to the nav buttons 3780 tdTrendingNow: function() { 3781 3782 //move thru all `trending-now-wrapper's` on the page 3783 jQuery('.td-trending-now-wrapper').each(function() { 3784 var wrapperId = jQuery(this).attr('id'); 3785 var wrapperIdNavigation = jQuery(this).data('start'); 3786 3787 if ('manual' !== wrapperIdNavigation) { 3788 tdTrendingNowObject.trendingNowAutostartBlocks.push(wrapperId); 3789 } 3790 3791 var trendingListPosts = []; 3792 var iCont = 0; 3793 3794 //take the text from each post from current trending-now-wrapper 3795 jQuery('#' + wrapperId + ' .td-trending-now-post').each(function() { 3796 //trending_list_posts[i_cont] = jQuery(this)[0].outerHTML; 3797 trendingListPosts[iCont] = jQuery(this); 3798 3799 //increment the counter 3800 iCont++; 3801 }); 3802 3803 //add this array to `tdTrendingNowObject` 3804 tdTrendingNowObject[wrapperId] = trendingListPosts; 3805 tdTrendingNowObject[wrapperId + '_position'] = 0; 3806 }); 3807 3808 jQuery('.td-trending-now-nav-left').click( function(event) { 3809 event.preventDefault(); 3810 var wrapperIdForNav = jQuery(this).data('wrapper-id'); 3811 3812 // if there's just a single post to be shown, there's no need for next/prev/autostart 3813 if ((undefined !== wrapperIdForNav) && (1 >= tdTrendingNowObject[wrapperIdForNav].length)) { 3814 return; 3815 } 3816 3817 //var data_moving = jQuery(this).data('moving'); 3818 var controlStart = jQuery(this).data('control-start'); 3819 3820 /** 3821 * used when the trending now block is used on auto mod and we click on show prev or show next article title 3822 * this will make the auto mode wait another xx seconds before displaying the next article title 3823 */ 3824 if ('manual' !== controlStart) { 3825 clearInterval(tdTrendingNowObject[wrapperIdForNav + '_timer']); 3826 tdTrendingNowObject[wrapperIdForNav + '_timer'] = setInterval(function() { 3827 tdTrendingNowObject.tdTrendingNowChangeText([wrapperIdForNav, 'left'], true); 3828 }, 3000); 3829 } 3830 3831 3832 //call to change the text 3833 tdTrendingNowObject.tdTrendingNowChangeText([wrapperIdForNav, 'right'], false); 3834 }); 3835 3836 3837 jQuery('.td-trending-now-nav-right').click(function(event) { 3838 event.preventDefault(); 3839 var wrapperIdForNav = jQuery(this).data('wrapper-id'); 3840 3841 // if there's just a single post to be shown, there's no need for next/prev/autostart 3842 if ((undefined !== wrapperIdForNav) && (1 >= tdTrendingNowObject[wrapperIdForNav].length)) { 3843 return; 3844 } 3845 3846 //var data_moving = jQuery(this).data('moving'); 3847 var controlStart = jQuery(this).data('control-start'); 3848 3849 /** 3850 * used when the trending now block is used on auto mod and we click on show prev or show next article title 3851 * this will make the auto mode wait another xx seconds before displaying the next article title 3852 */ 3853 if ('manual' !== controlStart) { 3854 clearInterval(tdTrendingNowObject[wrapperIdForNav + '_timer']); 3855 tdTrendingNowObject[wrapperIdForNav + '_timer'] = setInterval(function() { 3856 tdTrendingNowObject.tdTrendingNowChangeText([wrapperIdForNav, 'left' ], true); 3857 }, 3000); 3858 } 3859 3860 //call to change the text 3861 tdTrendingNowObject.tdTrendingNowChangeText([wrapperIdForNav, 'left'], true); 3862 }); 3863 3864 //console.log(tdTrendingNowObject); 3865 }, 3866 3867 3868 /* 3869 function for changing the posts in `trending now` display area 3870 * 3871 *array_param[0] : the id of current `trending now wrapper` 3872 *array_param[1] : moving direction (left or right) 3873 */ 3874 tdTrendingNowChangeText: function(array_param, to_right) { 3875 3876 //for consistency use the same variables names as thh parent function 3877 var wrapperIdForNav = array_param[0]; 3878 var dataMoving = array_param[1]; 3879 3880 //get the list of post and position for this trending now block 3881 var postsArrayListForThisTrend = tdTrendingNowObject[wrapperIdForNav]; 3882 3883 3884 // the following method is not so good because using it, many timers are already created 3885 // 3886 // if there's just a single post to be shown, there's no need for next/prev/autostart 3887 //if (posts_array_list_for_this_trend.length <= 1) { 3888 // return; 3889 //} 3890 3891 var postsArrayListPosition = tdTrendingNowObject[wrapperIdForNav + '_position']; 3892 3893 var previousPostArrayListPosition = postsArrayListPosition; 3894 3895 //count how many post are in the list 3896 var post_count = postsArrayListForThisTrend.length - 1; 3897 3898 if ('left' === dataMoving) { 3899 postsArrayListPosition += 1;
3900 3901 if (postsArrayListPosition > post_count) { 3902 postsArrayListPosition = 0; 3903 } 3904 3905 } else { 3906 postsArrayListPosition -= 1; 3907 3908 if (postsArrayListPosition < 0) { 3909 postsArrayListPosition = post_count; 3910 } 3911 } 3912 3913 //update the new position in the global `tdTrendingNowObject` 3914 tdTrendingNowObject[wrapperIdForNav + '_position'] = postsArrayListPosition; 3915 3916 postsArrayListForThisTrend[previousPostArrayListPosition].css('opacity', 0); 3917 postsArrayListForThisTrend[previousPostArrayListPosition].css('z-index', 0); 3918 3919 for (var trending_post in postsArrayListForThisTrend) { 3920 if (true === postsArrayListForThisTrend.hasOwnProperty(trending_post)) { 3921 postsArrayListForThisTrend[trending_post].removeClass('td_animated_xlong td_fadeInLeft td_fadeInRight td_fadeOutLeft td_fadeOutRight'); 3922 } 3923 } 3924 3925 postsArrayListForThisTrend[postsArrayListPosition].css('opacity', 1); 3926 postsArrayListForThisTrend[postsArrayListPosition].css('z-index', 1); 3927 3928 if (true === to_right) { 3929 3930 postsArrayListForThisTrend[previousPostArrayListPosition].addClass('td_animated_xlong td_fadeOutLeft'); 3931 postsArrayListForThisTrend[postsArrayListPosition].addClass('td_animated_xlong td_fadeInRight'); 3932 } else { 3933 3934 postsArrayListForThisTrend[previousPostArrayListPosition].addClass('td_animated_xlong td_fadeOutRight'); 3935 postsArrayListForThisTrend[postsArrayListPosition].addClass('td_animated_xlong td_fadeInLeft'); 3936 } 3937 }, 3938 3939 3940 //trending now function to auto start 3941 tdTrendingNowAutoStart: function() { 3942 3943 var list = tdTrendingNowObject.trendingNowAutostartBlocks; 3944 3945 for (var i = 0, len = list.length; i < len; i += 1) { 3946 3947 // if there's just a single post to be shown, there's no need for next/prev/autostart 3948 if (1 >= tdTrendingNowObject[list[i]].length) { 3949 return; 3950 } 3951 3952 tdTrendingNowObject[list[i] + '_timer'] = tdTrendingNowObject.setTimerChangingText(list[i]); 3953 } 3954 }, 3955 3956 setTimerChangingText: function(autoStartItem) { 3957 return setInterval(function () { 3958 //console.log(i + "=>" + list[i] + "\n"); 3959 tdTrendingNowObject.tdTrendingNowChangeText([autoStartItem, 'left'], true); 3960 }, 3000); 3961 } 3962 }; 3963 3964})(); 3965"use strict"; 3966 3967 3968/* ---------------------------------------------------------------------------- 3969 history js 3970 */ 3971 3972var td_history = { 3973 td_history_change_event: false, 3974 3975 // static class init 3976 init: function() { 3977 //hook the popstate event 3978 window.addEventListener('popstate', function(event) { 3979 td_history.td_history_change_event = true; 3980 if (typeof(event.state) != "undefined" && event.state != null) { 3981 jQuery("#" + event.state.slide_id).iosSlider("goToSlide", event.state.current_slide); 3982 } 3983 }); 3984 }, 3985 3986 3987 /** 3988 * generally used on load 3989 * @param data 3990 */ 3991 replace_history_entry: function (data) { 3992 if (tdDetect.hasHistory === false) { 3993 return; //no history support 3994 } 3995 history.replaceState(data, null); 3996 }, 3997 3998 3999 /** 4000 * ads an history entry - it also knows if we are using mod rewrite or not 4001 * @param data - the history data (state) 4002 * @param query_parm_id - 'slide' or other 4003 * @param query_parm_value - the value for slide 4004 */ 4005 add_history_entry: function (data, query_parm_id, query_parm_value) { 4006 4007 if (tdDetect.hasHistory === false) { 4008 return; //no history support 4009 } 4010 4011 4012 if (query_parm_value == '') { 4013 history.pushState(data, null, null); //add the hash via history api 4014 return; 4015 } 4016 4017 // @todo - detect other types of pages ex: ?page_id 4018 var td_query_page_id = td_history.get_query_parameter('p'); 4019 if (td_query_page_id != '') { 4020 //no mod rewrite, we go with ?p= etc 4021 if (query_parm_value == 1) { 4022 history.pushState(data, null, '?p=' + td_query_page_id); //remove the parm for the first item 4023 } else { 4024 history.pushState(data, null, '?p=' + td_query_page_id + '&' + query_parm_id + '=' + query_parm_value);
4024 //add the hash via history api 4025 } 4026 4027 } else { 4028 //mod rewrite 4029 if (query_parm_value == 1) { 4030 history.pushState(data, null, td_history.get_mod_rewrite_base_url()); //add the hash via history api 4031 } else { 4032 history.pushState(data, null, td_history.get_mod_rewrite_base_url() + query_parm_value + '/'); //add the hash via history api 4033 } 4034 } 4035 4036 }, 4037 4038 4039 4040 /** 4041 * returns the base url of urls with mod rewrite + pagination 4042 * @returns {string} 4043 */ 4044 get_mod_rewrite_base_url: function () { 4045 var full_url = document.URL; 4046 4047 //trim the last "/" in the url 4048 if (full_url.charAt(full_url.length - 1) == '/') { 4049 full_url = full_url.slice(0, - 1); 4050 } 4051 4052 if (td_history.get_mod_rewrite_pagination(document.URL) === false) { 4053 // no pagination present 4054 return document.URL; 4055 } 4056 4057 // we have pagination so we have to parse the url to remove it 4058 return full_url.substring(0, full_url.lastIndexOf("/"))+ '/'; 4059 4060 }, 4061 4062 4063 4064 /** 4065 * get the pagination from the urls with mod rewrite on 4066 * @returns {*} 4067 */ 4068 get_mod_rewrite_pagination: function () { 4069 var full_url = document.URL; 4070 4071 //trim the last "/" in the url 4072 if (full_url.charAt(full_url.length - 1) == '/') { 4073 full_url = full_url.slice(0, - 1); 4074 } 4075 4076 var last_url_parameter = full_url.substring(full_url.lastIndexOf("/")+1, full_url.length); 4077 4078 // return the page if it's indeed an integer 4079 if (td_history.isInt(last_url_parameter)) { 4080 return last_url_parameter; 4081 } 4082 4083 //return false if we don't have a page 4084 return false; 4085 }, 4086 4087 4088 /** 4089 * used by the iosslider @startAtSlide, it return 1 if there is no pagination or returns the pagination 4090 * @param query_parm_id 4091 * @returns {*} 4092 */ 4093 get_current_page: function (query_parm_id) { 4094 var td_query_page_id = td_history.get_query_parameter('p'); 4095 if (td_query_page_id != '') { 4096 //no mod rewrite, we go with ?p= etc 4097 var cur_page = td_history.get_query_parameter(query_parm_id); 4098 if (cur_page != '') { 4099 return cur_page; 4100 } else { 4101 return 1; 4102 } 4103 } else { 4104 //mod rewrite 4105 var cur_page = td_history.get_mod_rewrite_pagination(); 4106 if (cur_page !== false) { 4107 return cur_page; 4108 } else { 4109 return 1; 4110 } 4111 } 4112 }, 4113 4114 4115 /** 4116 * used to check if a number is an integer 4117 * @param n 4118 * @returns {boolean} 4119 */ 4120 isInt: function (n) { 4121 return n % 1 === 0; 4122 }, 4123 4124 4125 /** 4126 * returns a query parameter from the current url - we use it for ?p= 4127 * @param name 4128 * @returns {string} 4129 */ 4130 get_query_parameter: function (name) { 4131 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); 4132 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 4133 results = regex.exec(location.search); 4134 return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 4135 }, 4136 4137 /** 4138 * callback for slides with history 4139 * @param args 4140 */ 4141 slide_changed_callback: function(args) { 4142 //do not add another history entry if the slide moved due to the history change event 4143 if (td_history.td_history_change_event === true) { 4144 td_history.td_history_change_event = false; 4145 return; 4146 } 4147 var current_slide = args.currentSlideNumber; 4148 var slide_id = args.sliderContainerObject.attr('id'); 4149 4150 td_history.add_history_entry({current_slide:current_slide, slide_id:slide_id}, 'slide', current_slide); 4151 } 4152 4153}; 4154 4155/** 4156 * ie8 does not have pushState and history 4157 */ 4158if (window.history && window.history.pushState) { 4159 td_history.init(); 4160} 4161 4162/** 4163 * @depends on: 4164 * td_util 4165 * td_events 4166 * tdAffix 4167 */ 4168 4169/* global jQuery:{} */ 4170/* global tdUtil:{} */ 4171/* global tdViewport:{} */ 4172/* global tdAffix:{} */ 4173 4174 4175var tdSmartSidebar = {}; 4176 4177(function(){ 4178 4179 'use strict'; 4180 4181 tdSmartSidebar = { 4182 hasItems: false, // this class will only work when this flag is true. If we don't have any items, all the calculations on scroll will be disabled by this flag 4183 items: [], //the array that has all the items 4184 scroll_window_scrollTop_last: 0, //last scrollTop position, used to calculate the scroll direction 4185 4186 4187 tds_snap_menu: tdUtil.getBackendVar( 'tds_snap_menu' ), //read the snap menu setting from theme panel 4188 4189 4190 /** 4191 * @see tdSmartSidebar.td_events_resize 4192 */ 4193 is_enabled: true, //if the smart sidebar is not needed (ex on mobile) put this flag to true 4194 is_enabled_state_run_once: false, // make sure that we dun enable and disable only once 4195 is_disabled_state_run_once: false, 4196 4197 4198 is_tablet_grid: false, //we detect if the current grid is the tablet portrait one 4199 4200 4201 _view_port_current_interval_index: tdViewport.getCurrentIntervalIndex(), 4202 4203 4204 item: function() { 4205 this.content_jquery_obj = ''; 4206 this.sidebar_jquery_obj = ''; 4207 4208 4209 // the position variables 4210 this.sidebar_top = 0; 4211 this.sidebar_bottom = 0; 4212 this.sidebar_height = 0; 4213 4214 4215 this.content_top = 0; 4216 this.content_bottom = 0; 4217 4218 // the sidebar state 4219 this.sidebar_state = ''; 4220 4221 this.case_1_run_once = false; 4222 this.case_2_run_once = false; 4223 this.case_3_run_once = false; 4224 this.case_3_last_sidebar_height = 0; // case 3 has to be recalculated if the sidebar height changes 4225 this.case_3_last_content_height = 0; // recalculate case 3 if content height has changed 4226 this.case_4_run_once = false; 4227 this.case_4_last_menu_offset = 0; 4228 this.case_5_run_once = false; 4229 this.case_6_run_once = false; 4230 }, 4231 4232 4233 //add item to the array 4234 add_item: function( item ) { 4235 tdSmartSidebar.hasItems = true; //put the flag that we have items 4236 4237 /** 4238 * add clear fix to the content and sidebar. 4239 * we need the clear fix to clear the margin of the first and last element 4240 */ 4241 item.sidebar_jquery_obj 4242 .prepend( '<div class="clearfix"></div>' ) 4243 .append( '<div class="clearfix"></div>' ); 4244 4245 item.content_jquery_obj 4246 .prepend( '<div class="clearfix"></div>' ) 4247 .append( '<div class="clearfix"></div>' ); 4248 4249 4250 tdSmartSidebar.items.push( item ); 4251 }, 4252 4253 4254 td_events_scroll: function( scrollTop ) { 4255 4256 4257 // we don't have any smart sidebars, return 4258 if ( false === tdSmartSidebar.hasItems ) { 4259 return; 4260 } 4261 4262 4263 // check if the smart sidebar is enabled ( the sidebar can be enabled / disabled on runtime ) 4264 if ( false === tdSmartSidebar.is_enabled ) { 4265 4266 if ( false === tdSmartSidebar.is_disabled_state_run_once ) { // this call runs only ONCE / state change - we don't want any code to run on mobile 4267 tdSmartSidebar.is_disabled_state_run_once = true; 4268 for ( var item_index = 0; item_index < tdSmartSidebar.items.length; item_index++ ) { 4269 tdSmartSidebar.items[ item_index ].sidebar_jquery_obj.css({ 4270 width: 'auto', 4271 position: 'static', 4272 top: 'auto', 4273 bottom: 'auto' 4274 }); 4275 } 4276 tdSmartSidebar.log( 'smart_sidebar_disabled' ); 4277 } 4278 4279 return; 4280 } 4281 4282 4283 // all is done in an animation frame 4284 window.requestAnimationFrame(function() { 4285 4286 4287 /** 4288 * this is the height of the menu, computed live. We 4289 * @type {number} 4290 */ 4291 var td_affix_menu_computed_height = 0;
4292 if ( '' !== tdSmartSidebar.tds_snap_menu ) { // if the menu is not snapping in any way - do not calculate this 4293 4294 // The main_menu_height was replaced with the _get_menu_affix_height(), because we need the size of the 4295 // affix menu. In the 'Newspaper' the menu has different sizes when it is affix 'on' and 'off'. 4296 td_affix_menu_computed_height = tdAffix._get_menu_affix_height(); 4297 4298 // Menu offset value is added when we are on 'smart_snap_always' case 4299 if ('smart_snap_always' === tdAffix.tds_snap_menu) { 4300 td_affix_menu_computed_height += tdAffix.menu_offset; 4301 } 4302 } 4303 // The following height is added just for Newspaper theme. 4304 // In the Newsmag theme, the sidebar elements have already a 'padding-top' of 20px 4305 4306 if ( ( 'undefined' !== typeof window.tdThemeName ) && ( 'Newspaper' === window.tdThemeName ) ) { 4307 td_affix_menu_computed_height += 20; 4308 } 4309 4310 4311 4312 4313 4314 // compute the scrolling direction 4315 var scroll_direction = ''; 4316 //check the direction 4317 if ( scrollTop !== tdSmartSidebar.scroll_window_scrollTop_last ) { // compute direction only if we have different last scroll top 4318 // compute the direction of the scroll 4319 if ( scrollTop > tdSmartSidebar.scroll_window_scrollTop_last ) { 4320 scroll_direction = 'down'; 4321 } else { 4322 scroll_direction = 'up'; 4323 } 4324 } 4325 tdSmartSidebar.scroll_window_scrollTop_last = scrollTop; 4326 4327 4328 4329 /** 4330 * scrollTop - is the distance that is scrolled from the top of the document PLUS the height of the menu 4331 */ 4332 4333 4334 4335 var view_port_height = jQuery( window ).height(); // ~ we can get this only once + on resize 4336 var view_port_bottom = scrollTop + view_port_height; 4337 4338 scrollTop = scrollTop + td_affix_menu_computed_height; 4339 4340 // go in all the sidebar items 4341 for ( var item_index = 0; item_index < tdSmartSidebar.items.length; item_index++ ) { 4342 4343 var cur_item_ref = tdSmartSidebar.items[ item_index ]; 4344 4345 cur_item_ref.content_top = cur_item_ref.content_jquery_obj.offset().top; 4346 cur_item_ref.content_height = cur_item_ref.content_jquery_obj.height(); 4347 cur_item_ref.content_bottom = cur_item_ref.content_top + cur_item_ref.content_height; 4348 4349 cur_item_ref.sidebar_top = cur_item_ref.sidebar_jquery_obj.offset().top; 4350 cur_item_ref.sidebar_height = cur_item_ref.sidebar_jquery_obj.height(); 4351 cur_item_ref.sidebar_bottom = cur_item_ref.sidebar_top + cur_item_ref.sidebar_height; 4352 4353 4354 4355 4356 4357 /** 4358 * Is the sidebar smaller than the content ? 4359 */ 4360 if ( cur_item_ref.content_height <= cur_item_ref.sidebar_height ) { 4361 cur_item_ref.sidebar_state = 'case_6_content_too_small'; 4362 4363 4364 4365 /** 4366 * the sidebar is smaller than the view port? that means that we have to switch to a more simpler sidebar AKA affix 4367 */ 4368 4369 } else if ( cur_item_ref.sidebar_height < view_port_height ) { 4370 4371 // ref value used to compare the scroll top 4372 var ref_value = cur_item_ref.content_top; 4373 4374 // For 'Newsmag' the ref value is incremented with td_affix_menu_computed_height 4375 // It solves a case when the affix menu leaves the 'case_2_top_of_content' phase to 'case_4_fixed_up' too early 4376 // It's because of how the grid, and smart sidebar, are built on Newspaper vs Newsmag 4377 if ( ! tdAffix.is_menu_affix && ( 'undefined' !== typeof window.tdThemeName ) && ( 'Newsmag' === window.tdThemeName ) && ( 'smart_snap_always' === tdAffix.tds_snap_menu ) ) { 4378 ref_value += td_affix_menu_computed_height; 4379 } 4380 4381 //if (tdSmartSidebar._is_smaller_or_equal(scrollTop, cur_item_ref.content_top)) { 4382 if ( tdSmartSidebar._is_smaller_or_equal( scrollTop, ref_value ) ) { 4383 // not affix - we did not scroll to reach the sidebar 4384 cur_item_ref.sidebar_state = 'case_2_top_of_content'; 4385 } 4386 4387 // [1] if the sidebar is visible and we have enough space in the sidebar, place it at the top affix top 4388 // [2] if the sidebar is above the view port and n
4388othing is visible, place the sidebar at the bottom of the column 4389 4390 else if ( true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, scrollTop ) ) { 4391 if ( tdSmartSidebar._is_smaller( scrollTop, cur_item_ref.content_bottom - cur_item_ref.sidebar_height ) ) { //this is a special case where on the initial load, the bottom of the content is visible and we have a lot of space to show the widget at the top affixed. 4392 cur_item_ref.sidebar_state = 'case_4_fixed_up'; // [1]87 4393 } else { 4394 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; // [2] 4395 } 4396 4397 4398 } else { 4399 4400 // affix 4401 if ( tdSmartSidebar._is_smaller_or_equal( cur_item_ref.content_bottom, cur_item_ref.sidebar_bottom ) ) { // check to see if we reached the bottom of the content / row 4402 if ( 'up' === scroll_direction && tdSmartSidebar._is_smaller_or_equal( scrollTop, cur_item_ref.sidebar_top ) ) { 4403 cur_item_ref.sidebar_state = 'case_4_fixed_up'; // get out of the case_3_bottom_of_content state 4404 } else { 4405 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 4406 } 4407 4408 } else { 4409 if ( cur_item_ref.content_bottom - scrollTop >= cur_item_ref.sidebar_height ) { 4410 // Make sure that we have space for the sidebar to affix it to the top 4411 cur_item_ref.sidebar_state = 'case_4_fixed_up'; // we are not at the bottom of the content 4412 } else { 4413 4414 // this case isn't reached. It's accomplish by the tdSmartSidebar._is_smaller_or_equal(cur_item_ref.content_bottom, cur_item_ref.sidebar_bottom) case 4415 4416 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 4417 } 4418 //console.log(cur_item_ref.content_bottom + ' >= ' + cur_item_ref.sidebar_bottom); //@todo fix this case pe http://0div.com:69/wp_marius/wp_010/homepage-with-a-post-featured/ 4419 } 4420 } 4421 4422 4423 4424 /** 4425 * the sidebar is larger than the view port and the content is bigger 4426 */ 4427 4428 4429 } else { 4430 4431 //// if the sidebar is above the view port and nothing is visible, place the sidebar at the bottom of the column 4432 //if (tdSmartSidebar._is_smaller(cur_item_ref.sidebar_bottom, scrollTop) === true) { 4433 // cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 4434 // tdSmartSidebar.log(cur_item_ref.sidebar_bottom + ' ~ ' + scrollTop); 4435 //} 4436 4437 4438 // if the sidebar is above the view port and nothing is visible, place the sidebar fixed up if it's smaller than the viewport, 4439 // fixed down, meaning that a possible previous operation could be 'scroll down' 4440 // if none of the above operations meets the conditions, the sidebar is placed at the bottom of the content 4441 if ( true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, scrollTop ) ) { 4442 4443 if ( true === tdSmartSidebar._is_smaller_or_equal(scrollTop, cur_item_ref.sidebar_top ) && 4444 4445 true === tdSmartSidebar._is_smaller_or_equal( cur_item_ref.content_top, scrollTop ) //we are scrolling up ... make sure that we don't overshoot the sidebar by going over content_top. This happens when the sidebar is offseted by x number of pixels vs content 4446 ) { 4447 //console.log('sidebar_top' + cur_item_ref.sidebar_top + ' content top:' + cur_item_ref.content_top); 4448 cur_item_ref.sidebar_state = 'case_4_fixed_up'; 4449 } 4450 else if ( 4451 true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, view_port_bottom ) && 4452 true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, cur_item_ref.content_bottom ) && 4453 cur_item_ref.content_bottom >= view_port_bottom 4454 ) { 4455 cur_item_ref.sidebar_state = 'case_1_fixed_down'; 4456 } 4457 else { 4458 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 4459 } 4460 } 4461 4462 4463 4464 // position:fixed; bottom:0 4465 else if ( 4466 true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, view_port_bottom ) && 4467 true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, cur_item_ref.content_bottom ) && 4468 'down' === scroll_direction && 4469 cur_item_ref.content_bottom >= view_port_bottom 4470 ) { 4471 //console.log(cur_item_ref.sidebar_bottom + ' < ' + cur_item_ref.content_bottom); 4472 cur_item_ref.sidebar_state = 'case_1_fixed_down'; 4473 } 4474 4475 // the sidebar is at the top of the content ( position:static ) 4476 else if ( 4477 true === tdSmartSidebar._is_smaller_or_equal( cur_item_ref.sidebar_top, cur_item_ref.content_top ) && 4478 'up' === scroll_direction && 4479 cur_item_ref.content_bottom >= view_port_bottom 4480 ) { 4481 cur_item_ref.sidebar_state = 'case_2_top_of_content'; 4482 } 4483 4484 4485 4486 4487 // the sidebar reached the bottom of the content 4488 else if ( 4489 ( true === tdSmartSidebar._is_smaller_or_equal(cur_item_ref.content_bottom, cur_item_ref.sidebar_bottom) && 'down' === scroll_direction ) || 4490 cur_item_ref.content_bottom < view_port_bottom 4491 4492 ) { 4493 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 4494 4495 } 4496 // scrolling up, the sidebar is fixed up ( position:fixed; top:0 ) 4497 else if ( true === tdSmartSidebar._is_smaller_or_equal( scrollTop, cur_item_ref.sidebar_top ) && 'up' === scroll_direction && 4498 4499 true === tdSmartSidebar._is_smaller_or_equal( cur_item_ref.content_top, scrollTop ) //we are scrolling up ... make sure that we don't overshoot the sidebar by going over content_top. This happens when the sidebar is offseted by x number of pixels vs content 4500 ) { 4501 //console.log('sidebar_top' + cur_item_ref.sidebar_top + ' content top:' + cur_item_ref.content_top); 4502 cur_item_ref.sidebar_state = 'case_4_fixed_up'; 4503 } 4504 4505 4506 4507 // when to put absolute? 4508 if ( 4509 ( 'case_1_fixed_down' === cur_item_ref.sidebar_state && 'up' === scroll_direction ) || 4510 ( 'case_4_fixed_up' === cur_item_ref.sidebar_state && 'down' === scroll_direction ) 4511 ) { 4512 cur_item_ref.sidebar_state = 'case_5_absolute'; //absolute while going up? 4513 } 4514 4515 } // end sidebar length check cur_item_ref.sidebar_height < view_port_height 4516 4517 4518 4519 4520 /** 4521 * after we have the state, we enter this switch that makes sure that we only have one state change 4522 */ 4523 4524 // we have to set the content width via JS 4525 //var column_content_width = 339; 4526 //if (tdSmartSidebar.is_tablet_grid) { 4527 // column_content_width = 251; 4528 //} 4529 4530 4531 var column_content_width = 0; 4532 4533 var view_port_current_item = tdViewport.getCurrentIntervalItem(); 4534 4535 if ( null !== view_port_current_item ) { 4536 column_content_width = view_port_current_item.sidebarWidth; 4537 //tdSmartSidebar.log("column sidebar width : " + column_content_width); 4538 } 4539 4540 4541 4542 switch ( cur_item_ref.sidebar_state ) { 4543 case 'case_1_fixed_down': 4544 4545 if ( true === cur_item_ref.case_1_run_once ) { 4546 break; 4547 } 4548 4549 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 4550 4551 cur_item_ref.case_1_run_once = true; 4552 cur_item_ref.case_2_run_once = false; 4553 cur_item_ref.case_3_run_once = false; 4554 cur_item_ref.case_4_run_once = false; 4555 cur_item_ref.case_5_run_once = false; 4556 cur_item_ref.case_6_run_once = false; 4557 4558 4559 cur_item_ref.sidebar_jquery_obj.css({ 4560 width: column_content_width, 4561 position: 'fixed', 4562 top: 'auto', 4563 bottom: '0', 4564 'z-index': '1' 4565 }); 4566 4567 4568 break; 4569 4570 case 'case_2_top_of_content': 4571 4572 if ( true === cur_item_ref.case_2_run_once ) { 4573 break; 4574 } 4575 4576 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 4577 4578 cur_item_ref.case_1_run_once = false; 4579 cur_item_ref.case_2_run_once = true; 4580 cur_item_ref.case_3_run_once = false; 4581 cur_item_ref.case_4_run_once = false; 4582 cur_item_ref.case_5_run_once = false; 4583 cur_item_ref.case_6_run_once = false; 4584 4585 4586 cur_item_ref.sidebar_jquery_obj.css({ 4587 width: 'auto', 4588 position: 'static', 4589 top: 'auto', 4590 bottom: 'auto' 4591 }); 4592 break; 4593 4594 case 'case_3_bottom_of_content': 4595 // case 3 has to be recalculated if the sidebar height changes 4596 4597 if ( true === cur_item_ref.case_3_run_once && 4598 cur_item_ref.case_3_last_sidebar_height === cur_item_ref.sidebar_height && 4599 cur_item_ref.case_3_last_content_height === cur_item_ref.content_height 4600 ) { //if the case already runned AND the sidebar height did n
4600ot change 4601 break; 4602 } 4603 4604 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 4605 4606 cur_item_ref.case_1_run_once = false; 4607 cur_item_ref.case_2_run_once = false; 4608 cur_item_ref.case_3_run_once = true; 4609 cur_item_ref.case_3_last_sidebar_height = cur_item_ref.sidebar_height; 4610 cur_item_ref.case_3_last_content_height = cur_item_ref.content_height; 4611 cur_item_ref.case_4_run_once = false; 4612 cur_item_ref.case_5_run_once = false; 4613 cur_item_ref.case_6_run_once = false; 4614 4615 4616 cur_item_ref.sidebar_jquery_obj.css({ 4617 width: column_content_width, 4618 position: 'absolute', 4619 top: cur_item_ref.content_bottom - cur_item_ref.sidebar_height - cur_item_ref.content_top, 4620 bottom: 'auto' 4621 }); 4622 break; 4623 4624 case 'case_4_fixed_up': 4625 4626 if ( true === cur_item_ref.case_4_run_once && cur_item_ref.case_4_last_menu_offset === td_affix_menu_computed_height ) { //if the case already runned AND the menu height did not changed 4627 break; 4628 } 4629 4630 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 4631 4632 cur_item_ref.case_1_run_once = false; 4633 cur_item_ref.case_2_run_once = false; 4634 cur_item_ref.case_3_run_once = false; 4635 cur_item_ref.case_4_run_once = true; 4636 cur_item_ref.case_4_last_menu_offset = td_affix_menu_computed_height; 4637 cur_item_ref.case_5_run_once = false; 4638 cur_item_ref.case_6_run_once = false; 4639 4640 4641 cur_item_ref.sidebar_jquery_obj.css({ 4642 width: column_content_width, 4643 position: 'fixed', 4644 top: td_affix_menu_computed_height, 4645 bottom: 'auto' 4646 }); 4647 break; 4648 4649 case 'case_5_absolute': 4650 4651 if ( true === cur_item_ref.case_5_run_once ) { 4652 break; 4653 } 4654 4655 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 4656 4657 cur_item_ref.case_1_run_once = false; 4658 cur_item_ref.case_2_run_once = false; 4659 cur_item_ref.case_3_run_once = false; 4660 cur_item_ref.case_4_run_once = false; 4661 cur_item_ref.case_5_run_once = true; 4662 cur_item_ref.case_6_run_once = false; 4663 4664 4665 cur_item_ref.sidebar_jquery_obj.css({ 4666 width: column_content_width, 4667 position: 'absolute', 4668 top: cur_item_ref.sidebar_top - cur_item_ref.content_top, 4669 bottom: 'auto' 4670 }); 4671 break; 4672 4673 case 'case_6_content_too_small': 4674 4675 if ( true === cur_item_ref.case_6_run_once ) { 4676 break; 4677 } 4678 4679 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 4680 4681 cur_item_ref.case_1_run_once = false; 4682 cur_item_ref.case_2_run_once = false; 4683 cur_item_ref.case_3_run_once = false; 4684 cur_item_ref.case_4_run_once = false; 4685 cur_item_ref.case_5_run_once = false; 4686 cur_item_ref.case_6_run_once = true; 4687 4688 cur_item_ref.sidebar_jquery_obj.css({ 4689 width: 'auto', 4690 position: 'static', 4691 top: 'auto', 4692 bottom: 'auto' 4693 }); 4694 break; 4695 } 4696 } // end for loop 4697 }); // end request animation frame 4698 }, // end td_events_scroll 4699 4700 4701 compute: function() { 4702 4703 tdSmartSidebar.td_events_scroll( jQuery( window ).scrollTop() ); 4704 }, 4705 4706 4707 // resets the run once flags. It may fail sometimes due to case_3_last_sidebar_height & case_4_last_menu_offset 4708 reset_run_once_flags: function () { 4709 for ( var item_index = 0; item_index < tdSmartSidebar.items.length; item_index++ ) { 4710 tdSmartSidebar.items[ item_index ].case_1_run_once = false; 4711 tdSmartSidebar.items[ item_index ].case_2_run_once = false; 4712 tdSmartSidebar.items[ item_index ].case_3_run_once = false; 4713 tdSmartSidebar.items[ item_index ].case_3_last_sidebar_height = 0; 4714 tdSmartSidebar.items[ item_index ].case_3_last_content_height = 0; 4715 tdSmartSidebar.items[ item_index ].case_4_run_once = false; 4716 tdSmartSidebar.items[ item_index ].case_4_last_menu_offset = 0; 4717 tdSmartSidebar.items[ item_index ].case_5_run_once = false; 4718 tdSmartSidebar.items[ item_index ].case_6_run_once = false; 4719 } 4720 }, 4721 4722 4723 4724 td_events_resize: function() { 4725 // enable and disable the smart sidebar 4726 4727 tdSmartSidebar._view_port_current_interval_index = tdViewport.getCurrentIntervalIndex(); 4728 4729 switch ( tdSmartSidebar._view_port_current_interval_index ) { 4730 4731 case 0 : 4732 4733 tdSmartSidebar.is_enabled = false; 4734 4735 // flag marked false to be made true only once, when the view port has not the first interval index [0] 4736 tdSmartSidebar.is_enabled_state_run_once = false; 4737 4738 break; 4739 4740 case 1 : 4741 if ( false === tdSmartSidebar.is_tablet_grid ) { // we switched 4742 4743 tdSmartSidebar.reset_run_once_flags();
4744 4745 tdSmartSidebar.is_tablet_grid = true; 4746 tdSmartSidebar.is_desktop_grid = false; 4747 4748 tdSmartSidebar.log( 'view port tablet' ); 4749 } 4750 tdSmartSidebar.is_enabled = true; 4751 tdSmartSidebar.is_disabled_state_run_once = false; 4752 4753 if ( false === tdSmartSidebar.is_enabled_state_run_once ) { 4754 tdSmartSidebar.is_enabled_state_run_once = true; 4755 tdSmartSidebar.log( 'smart_sidebar_enabled' ); 4756 } 4757 break; 4758 4759 case 2 : 4760 case 3 : 4761 if ( true === tdSmartSidebar.is_tablet_grid ) { // we switched 4762 4763 tdSmartSidebar.reset_run_once_flags(); 4764 4765 tdSmartSidebar.is_tablet_grid = false; 4766 tdSmartSidebar.is_desktop_grid = true; 4767 4768 tdSmartSidebar.log( 'view port desktop' ); 4769 } 4770 tdSmartSidebar.is_enabled = true; 4771 tdSmartSidebar.is_disabled_state_run_once = false; 4772 4773 if ( false === tdSmartSidebar.is_enabled_state_run_once ) { 4774 tdSmartSidebar.is_enabled_state_run_once = true; 4775 tdSmartSidebar.log( 'smart_sidebar_enabled' ); 4776 } 4777 break; 4778 } 4779 4780 // @todo we may be able to delay the compute a bit (aka run it on the 500ms timer) 4781 tdSmartSidebar.compute(); 4782 }, 4783 4784 4785 log: function( msg ) { 4786 //console.log(msg); 4787 }, 4788 4789 4790 /** 4791 * check if the two numbers are approximately equal OR the number1 is smaller. 4792 * This function is used to compensate for differences in the offset top reported by IE, FF but not chrome 4793 * IE and FF have an error for offset top of +- 0.5 4794 * @param number1 - this has to be smaller or approximately equal with number2 to return true 4795 * @param number2 4796 * @returns {boolean} 4797 * @private 4798 */ 4799 _is_smaller_or_equal: function( number1, number2 ) { 4800 // check if the two numbers are approximately equal 4801 // - first we check if the difference between the numbers is bigger than 1 unit 4802 // - second we check if the first number is bigger than the second one 4803 // if the two conditions are met, we return false 4804 4805 4806 if ( Math.abs( number1 - number2 ) >= 1) { 4807 // we have a difference that is bigger than 1 unit (px), check if the numbers are smaller or bigger 4808 if ( number1 < number2 ) { 4809 return true; 4810 } else { 4811 return false; 4812 } 4813 } else { 4814 // the difference between the two numbers is smaller than one unit (1 px), this means that the two numbers are the same 4815 return true; 4816 } 4817 }, 4818 4819 4820 /** 4821 * Checks to see if number1 < number2 by at least one unit! 4822 * @param number1 4823 * @param number2 4824 * @returns {boolean} 4825 * @private 4826 */ 4827 _is_smaller: function( number1, number2 ) { 4828 if ( Math.abs( number1 - number2 ) >= 1) { 4829 if ( number1 < number2 ) { 4830 return true; 4831 } else { 4832 return false; 4833 } 4834 } else { 4835 // the difference between the two numbers is smaller than one unit (1 px), this means that the two numbers are the same 4836 return false; 4837 } 4838 } 4839 }; 4840 4841 //console.log(tdSmartSidebar.items); 4842})(); 4843 4844 4845 4846/** 4847 * Infinite loader v1.0 by Radu O. / tagDiv 4848 * USES: 4849 * - tdEvents.js 4850 * - for blocks: 4851 * - td_block::get_block_pagination - custom load more 4852 * - in td_js_generator.php - main block object has ajax_pagination_infinite_stop - to stop the infinite scroll after x number of pages and show the load more button after that 4853 * 4854 */ 4855 4856/* global jQuery:false */ 4857/* global tdBlocks:false */ 4858 4859 4860/** 4861 * Global infinite loader object 4862 */ 4863var tdInfiniteLoader = {}; 4864 4865(function () { 4866 "use strict"; 4867 4868 /** 4869 * - register and keep track of dom elements 4870 * - calculate position from the top of each element 4871 * - monitor on scroll event 4872 * - if one or more of the dom elements is visible 4873 * - fire the callback for that dom element! only ONCE 4874 */ 4875 4876 4877 tdInfiniteLoader = { 4878 4879 hasItems: false, // this class will only work when this flag is true. If we don't have any items, all the calculations on scroll will be disabled by this flag 4880 4881 items: [], //the array that has all the items 4882 4883 // one item object (instantiable) 4884 item: function() { 4885 this.uid=''; // - an unique id of the item, usually is the block id! - it is used to enable the callback on a per item basis 4886 this.jqueryObj = ''; //find the item easily for animation ?? 4887 this.bottomTop = 0; //distance from the bottom of the dom element to top - computed in - @see tdInfiniteLoader.compute_top_distances(); 4888 this.isVisibleCallbackEnabled = true; //the callback will fire only when this flag is true. We set it to true after the blocks ajax run @see tdBlocks.tdBlockAjaxLoadingEnd 4889 this.isVisibleCallback = function () { //callback when the item's bottom is visible :) 4890 }; 4891 }, 4892 4893 addItem: function(item) { 4894 tdInfiniteLoader.hasItems = true; //put the flag that we have items 4895 tdInfiniteLoader.items.push(item); 4896 }, 4897 4898 4899 /** 4900 * foreach element from items, compute the distances from the top 4901 * - this is done only on load or when the page is resized 4902 */ 4903 computeTopDistances: function() { 4904 4905 //check the flag to see if we have any items 4906 if ( tdInfiniteLoader.hasItems === false ) { 4907 return; 4908 } 4909 4910 jQuery.each(tdInfiniteLoader.items, function(index, v_event) { 4911 var topTop = tdInfiniteLoader.items[index].jqueryObj.offset().top; 4912 //top of document to bottom of element 4913 tdInfiniteLoader.items[index].bottomTop = topTop + tdInfiniteLoader.items[index].jqueryObj.height(); 4914 }); 4915 4916 //also calculate the events 4917 tdInfiniteLoader.computeEvents(); 4918 4919 }, 4920 4921 4922 /** 4923 * calculate if we have to fire an event like isVisibleCallback() 4924 * - this is done on scroll and on resize! 4925 */ 4926 computeEvents: function() { 4927 //check the flag to see if we have any items 4928 if ( tdInfiniteLoader.hasItems === false ) { 4929 return; 4930 } 4931 4932 var topToViewportBottom = jQuery(window).height() + jQuery(window).scrollTop(); 4933 4934 4935 jQuery.each(tdInfiniteLoader.items, function(index, item) { 4936 if ( tdInfiniteLoader.items[index].bottomTop < topToViewportBottom + 700 ) { 4937 4938 //check to see if we can call the callback again 4939 if ( tdInfiniteLoader.items[index].isVisibleCallbackEnabled === true ) { 4940 tdInfiniteLoader.items[index].isVisibleCallbackEnabled = false; 4941 //the call 4942 tdInfiniteLoader.items[index].isVisibleCallback(); 4943 } 4944 } 4945 4946 4947 }); 4948 }, 4949 4950 4951 /** 4952 * enables the isVisibleCallback - it is called by td_blocks.js only when a block receives an infinite loading ajax reply 4953 * @param $item_uid - an unique id of the item, usually is the block id! 4954 * @see tdBlocks.tdBlockAjaxLoadingEnd 4955 */
4956 enable_is_visible_callback: function($item_uid) { 4957 jQuery.each(tdInfiniteLoader.items, function(index, item) { 4958 if ( item.uid === $item_uid ) { 4959 tdInfiniteLoader.items[index].isVisibleCallbackEnabled = true; 4960 return false; //brake jquery each 4961 } 4962 }); 4963 } 4964 4965 }; 4966 4967 4968 4969 4970 4971 4972 /** 4973 * we are using td_ajax_infinite to know when to trigger a block loading 4974 */ 4975 jQuery('.td_ajax_infinite').each( function() { 4976 4977 // create a new infinite loader item 4978 var tdInfiniteLoaderItem = new tdInfiniteLoader.item(); 4979 4980 tdInfiniteLoaderItem.jqueryObj = jQuery(this); 4981 tdInfiniteLoaderItem.uid = jQuery(this).data('td_block_id'); 4982 4983 4984 /** 4985 * the callback when the bottom of the element is visible on screen and we need to do something - like load another page 4986 * - the callback does not fire again until tdInfiniteLoader.enable_is_visible_callback is called @see tdInfiniteLoader.js:95 4987 */ 4988 tdInfiniteLoaderItem.isVisibleCallback = function () { // the is_visible callback is called when we have to pull new content up because the element is visible 4989 4990 // get the current block object 4991 var currentBlockObj = tdBlocks.tdGetBlockObjById(tdInfiniteLoaderItem.jqueryObj.data('td_block_id')); 4992 4993 // if we don't have a infinite stop limit or if we have one we dint' hit it yet 4994 if ( currentBlockObj.ajax_pagination_infinite_stop === '' || 4995 currentBlockObj.td_current_page < (parseInt(currentBlockObj.ajax_pagination_infinite_stop) + 1) ) { 4996 4997 // get the block data and increment the pagination 4998 currentBlockObj.td_current_page++; 4999 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'infinite_load'); 5000 5001 } else { 5002 /** 5003 * show the load more button. The button is already there, hidden - do not know if it's the best solution :) 5004 * @see td_block::get_block_pagination in td_block.php 5005 */ 5006 if ( currentBlockObj.td_current_page < currentBlockObj.max_num_pages ) { 5007 setTimeout( function(){ 5008 jQuery('#infinite-lm-' + currentBlockObj.id) 5009 .css('display', 'block') 5010 .css('visibility', 'visible') 5011 ; 5012 }, 400); 5013 } 5014 } 5015 }; 5016 tdInfiniteLoader.addItem(tdInfiniteLoaderItem); 5017 }); 5018 5019 5020 5021 5022 5023 5024 5025 5026 //compute to 5027 jQuery(window).load( function() { 5028 tdInfiniteLoader.computeTopDistances(); 5029 }); 5030 5031 jQuery().ready( function() { 5032 tdInfiniteLoader.computeTopDistances(); 5033 }); 5034})(); 5035/** 5036 * activate smooth scroll 5037 */ 5038 5039if (typeof window['tds_smooth_scroll'] !== 'undefined') { 5040 5041 if (tdDetect.isChrome === true && tdDetect.isAndroid === false) { 5042 5043 td_smooth_scroll(); 5044 } 5045} 5046 5047 5048 5049function td_smooth_scroll() { 5050 5051// SmoothScroll v1.2.1 5052// Licensed under the terms of the MIT license. 5053 5054// People involved 5055// - Balazs Galambosi (maintainer) 5056// - Patrick Brunner (original idea) 5057// - Michael Herf (Pulse Algorithm) 5058 5059// Scroll Variables (tweakable) 5060 var defaultOptions = { 5061 5062 // Scrolling Core 5063 frameRate : 150, // [Hz] 5064 animationTime : 600, // [px] 5065 stepSize : 120, // [px] 5066 5067 // Pulse (less tweakable) 5068 // ratio of "tail" to "acceleration" 5069 pulseAlgorithm : true, 5070 pulseScale : 8, 5071 pulseNormalize : 1, 5072 5073 // Acceleration 5074 accelerationDelta : 20, // 20 5075 accelerationMax : 1, // 1 5076 5077 // Keyboard Settings 5078 keyboardSupport : true, // option 5079 arrowScroll : 50, // [px] 5080 5081 // Other 5082 touchpadSupport : true, 5083 fixedBackground : true, 5084 excluded : "" 5085 }; 5086 5087 var options = defaultOptions; 5088 5089 5090// Other Variables
5091 var isExcluded = false; 5092 var isFrame = false; 5093 var direction = { x: 0, y: 0 }; 5094 var initDone = false; 5095 var root = document.documentElement; 5096 var activeElement; 5097 var observer; 5098 var deltaBuffer = [ 120, 120, 120 ]; 5099 5100 var key = { left: 37, up: 38, right: 39, down: 40, spacebar: 32, 5101 pageup: 33, pagedown: 34, end: 35, home: 36 }; 5102 5103 5104 5105 5106 /*********************************************** 5107 * INITIALIZE 5108 ***********************************************/ 5109 5110 5111 5112 /** 5113 * Sets up scrolls array, determines if frames are involved. 5114 */ 5115 function init() { 5116 5117 if (!document.body) return; 5118 5119 var body = document.body; 5120 var html = document.documentElement; 5121 var windowHeight = window.innerHeight; 5122 var scrollHeight = body.scrollHeight; 5123 5124 // check compat mode for root element 5125 root = (document.compatMode.indexOf('CSS') >= 0) ? html : body; 5126 activeElement = body; 5127 5128 5129 initDone = true; 5130 5131 // Checks if this script is running in a frame 5132 if (top != self) { 5133 isFrame = true; 5134 } 5135 5136 /** 5137 * This fixes a bug where the areas left and right to 5138 * the content does not trigger the onmousewheel event 5139 * on some pages. e.g.: html, body { height: 100% } 5140 */ 5141 else if (scrollHeight > windowHeight && 5142 (body.offsetHeight <= windowHeight || 5143 html.offsetHeight <= windowHeight)) { 5144 5145 // DOMChange (throttle): fix height 5146 var pending = false; 5147 var refresh = function () { 5148 if (!pending && html.scrollHeight != document.height) { 5149 pending = true; // add a new pending action 5150 setTimeout(function () { 5151 html.style.height = document.height + 'px'; 5152 pending = false; 5153 }, 500); // act rarely to stay fast 5154 } 5155 }; 5156 html.style.height = 'auto'; 5157 setTimeout(refresh, 10); 5158 5159 var config = { 5160 attributes: true, 5161 childList: true, 5162 characterData: false 5163 }; 5164 5165 observer = new MutationObserver(refresh); 5166 observer.observe(body, config); 5167 5168 // clearfix 5169 if (root.offsetHeight <= windowHeight) { 5170 var underlay = document.createElement("div"); 5171 underlay.style.clear = "both"; 5172 body.appendChild(underlay); 5173 } 5174 } 5175 5176 // gmail performance fix 5177 if (document.URL.indexOf("mail.google.com") > -1) { 5178 var s = document.createElement("style"); 5179 s.innerHTML = ".iu { visibility: hidden }"; 5180 (document.getElementsByTagName("head")[0] || html).appendChild(s); 5181 } 5182 // facebook better home timeline performance 5183 // all the HTML resized images make rendering CPU intensive 5184 else if (document.URL.indexOf("www.facebook.com") > -1) { 5185 var home_stream = document.getElementById("home_stream"); 5186 home_stream && (home_stream.style.webkitTransform = "translateZ(0)"); 5187 } 5188 // disable fixed background 5189 if (!options.fixedBackground && !isExcluded) { 5190 body.style.backgroundAttachment = "scroll"; 5191 html.style.backgroundAttachment = "scroll"; 5192 } 5193 } 5194 5195 5196 /************************************************ 5197 * SCROLLING 5198 ************************************************/ 5199 5200 var que = []; 5201 var pending = false; 5202 var lastScroll = +new Date; 5203 5204 /** 5205 * Pushes scroll actions to the scrolling queue. 5206 */ 5207 function scrollArray(elem, left, top, delay) { 5208 5209 delay || (delay = 1000); 5210 directionCheck(left, top); 5211 5212 if (options.accelerationMax != 1) { 5213 var now = +new Date; 5214 var elapsed = now - lastScroll; 5215 if (elapsed < options.accelerationDelta) { 5216 var factor = (1 + (30 / elapsed)) / 2; 5217 if (factor > 1) { 5218 factor = Math.min(factor, options.accelerationMax); 5219 left *= factor; 5220 top *= factor; 5221 } 5222 } 5223 lastScroll = +new Date; 5224 } 5225 5226 // push a scroll command 5227 que.push({ 5228 x: left, 5229 y: top, 5230 lastX: (left < 0) ? 0.99 : -0.99, 5231 lastY: (top < 0) ? 0.99 : -0.99, 5232 start: +new Date 5233 }); 5234
5235 // don't act if there's a pending queue 5236 if (pending) { 5237 return; 5238 } 5239 5240 var scrollWindow = (elem === document.body); 5241 5242 var step = function (time) { 5243 5244 var now = +new Date; 5245 var scrollX = 0; 5246 var scrollY = 0; 5247 5248 for (var i = 0; i < que.length; i++) { 5249 5250 var item = que[i]; 5251 var elapsed = now - item.start; 5252 var finished = (elapsed >= options.animationTime); 5253 5254 // scroll position: [0, 1] 5255 var position = (finished) ? 1 : elapsed / options.animationTime; 5256 5257 // easing [optional] 5258 if (options.pulseAlgorithm) { 5259 position = pulse(position); 5260 } 5261 5262 // only need the difference 5263 var x = (item.x * position - item.lastX) >> 0; 5264 var y = (item.y * position - item.lastY) >> 0; 5265 5266 // add this to the total scrolling 5267 scrollX += x; 5268 scrollY += y; 5269 5270 // update last values 5271 item.lastX += x; 5272 item.lastY += y; 5273 5274 // delete and step back if it's over 5275 if (finished) { 5276 que.splice(i, 1); i--; 5277 } 5278 } 5279 5280 // scroll left and top 5281 if (scrollWindow) { 5282 window.scrollBy(scrollX, scrollY); 5283 } 5284 else { 5285 if (scrollX) elem.scrollLeft += scrollX; 5286 if (scrollY) elem.scrollTop += scrollY; 5287 } 5288 5289 // clean up if there's nothing left to do 5290 if (!left && !top) { 5291 que = []; 5292 } 5293 5294 if (que.length) { 5295 requestFrame(step, elem, (delay / options.frameRate + 1)); 5296 } else { 5297 pending = false; 5298 } 5299 }; 5300 5301 // start a new queue of actions 5302 requestFrame(step, elem, 0); 5303 pending = true; 5304 } 5305 5306 5307 /*********************************************** 5308 * EVENTS 5309 ***********************************************/ 5310 5311 /** 5312 * Mouse wheel handler. 5313 * @param {Object} event 5314 */ 5315 function wheel(event) { 5316 5317 if (!initDone) { 5318 init(); 5319 } 5320 5321 var target = event.target; 5322 var overflowing = overflowingAncestor(target); 5323 5324 // use default if there's no overflowing 5325 // element or default action is prevented 5326 if (!overflowing || event.defaultPrevented || 5327 isNodeName(activeElement, "embed") || 5328 (isNodeName(target, "embed") && /\.pdf/i.test(target.src))) { 5329 return true; 5330 } 5331 5332 var deltaX = event.wheelDeltaX || 0; 5333 var deltaY = event.wheelDeltaY || 0; 5334 5335 // use wheelDelta if deltaX/Y is not available 5336 if (!deltaX && !deltaY) { 5337 deltaY = event.wheelDelta || 0; 5338 } 5339 5340 // check if it's a touchpad scroll that should be ignored 5341 if (!options.touchpadSupport && isTouchpad(deltaY)) { 5342 return true; 5343 } 5344 5345 // scale by step size 5346 // delta is 120 most of the time 5347 // synaptics seems to send 1 sometimes 5348 if (Math.abs(deltaX) > 1.2) { 5349 deltaX *= options.stepSize / 120; 5350 } 5351 if (Math.abs(deltaY) > 1.2) { 5352 deltaY *= options.stepSize / 120; 5353 } 5354 5355 scrollArray(overflowing, -deltaX, -deltaY); 5356 event.preventDefault(); 5357 } 5358 5359 /** 5360 * Keydown event handler. 5361 * @param {Object} event 5362 */ 5363 function keydown(event) { 5364 5365 var target = event.target; 5366 var modifier = event.ctrlKey || event.altKey || event.metaKey || 5367 (event.shiftKey && event.keyCode !== key.spacebar); 5368 5369 // do nothing if user is editing text 5370 // or using a modifier key (except shift) 5371 // or in a dropdown 5372 if ( /input|textarea|select|embed/i.test(target.nodeName) || 5373 target.isContentEditable || 5374 event.defaultPrevented || 5375 modifier ) { 5376 return true; 5377 } 5378 // spacebar should trigger button press 5379 if (isNodeName(target, "button") && 5380 event.keyCode === key.spacebar) { 5381 return true; 5382 } 5383 5384 var shift, x = 0, y = 0; 5385 var elem = overflowingAncestor(activeElement); 5386 var clientHeight = elem.clientHeight; 5387 5388 if (elem == document.body) { 5389 clientHeight = window.innerHeight; 5390 } 5391 5392 switch (event.keyCode) { 5393 case key.up: 5394 y = -options.arrowScroll; 5395 break; 5396 case key.down: 5397 y = options.arrowScroll; 5398 break; 5399 case key.spacebar: // (+ shift) 5400 shift = event.shiftKey ? 1 : -1; 5401 y = -shift * clientHeight * 0.9; 5402 break; 5403 case key.pageup: 5404 y = -clientHeight * 0.9; 5405 break; 5406 case key.pagedown: 5407 y = clientHeight * 0.9; 5408 break; 5409 case key.home: 5410 y = -elem.scrollTop; 5411 break; 5412 case key.end: 5413 var damt = elem.scrollHeight - elem.scrollTop - clientHeight; 5414 y = (damt > 0) ? damt+10 : 0; 5415 break; 5416 case key.left: 5417 x = -options.arrowScroll; 5418 break; 5419 case key.right: 5420 x = options.arrowScroll; 5421 break; 5422 default: 5423 return true; // a key we don't care about 5424 } 5425 5426 scrollArray(elem, x, y); 5427 event.preventDefault(); 5428 } 5429 5430 /** 5431 * Mousedown event only for updating activeElement 5432 */ 5433 function mousedown(event) { 5434 activeElement = event.target; 5435 } 5436 5437 5438 /*********************************************** 5439 * OVERFLOW 5440 ***********************************************/ 5441 5442 var cache = {}; // cleared out every once in while 5443 setInterval(function () { cache = {}; }, 10 * 1000); 5444 5445 var uniqueID = (function () { 5446 var i = 0; 5447 return function (el) { 5448 return el.uniqueID || (el.uniqueID = i++); 5449 }; 5450 })(); 5451
5452 function setCache(elems, overflowing) { 5453 for (var i = elems.length; i--;) 5454 cache[uniqueID(elems[i])] = overflowing; 5455 return overflowing; 5456 } 5457 5458 function overflowingAncestor(el) { 5459 var elems = []; 5460 var rootScrollHeight = root.scrollHeight; 5461 do { 5462 var cached = cache[uniqueID(el)]; 5463 if (cached) { 5464 return setCache(elems, cached); 5465 } 5466 elems.push(el); 5467 if (rootScrollHeight === el.scrollHeight) { 5468 if (!isFrame || root.clientHeight + 10 < rootScrollHeight) { 5469 return setCache(elems, document.body); // scrolling root in WebKit 5470 } 5471 } else if (el.clientHeight + 10 < el.scrollHeight) { 5472 overflow = getComputedStyle(el, "").getPropertyValue("overflow-y"); 5473 if (overflow === "scroll" || overflow === "auto") { 5474 return setCache(elems, el); 5475 } 5476 } 5477 } while (el = el.parentNode); 5478 } 5479 5480 5481 /*********************************************** 5482 * HELPERS 5483 ***********************************************/ 5484 5485 function addEvent(type, fn, bubble) { 5486 window.addEventListener(type, fn, (bubble||false)); 5487 } 5488 5489 function removeEvent(type, fn, bubble) { 5490 window.removeEventListener(type, fn, (bubble||false)); 5491 } 5492 5493 function isNodeName(el, tag) { 5494 return (el.nodeName||"").toLowerCase() === tag.toLowerCase(); 5495 } 5496 5497 function directionCheck(x, y) { 5498 x = (x > 0) ? 1 : -1; 5499 y = (y > 0) ? 1 : -1; 5500 if (direction.x !== x || direction.y !== y) { 5501 direction.x = x; 5502 direction.y = y; 5503 que = []; 5504 lastScroll = 0; 5505 } 5506 } 5507 5508 var deltaBufferTimer; 5509 5510 function isTouchpad(deltaY) { 5511 if (!deltaY) return; 5512 deltaY = Math.abs(deltaY) 5513 deltaBuffer.push(deltaY); 5514 deltaBuffer.shift(); 5515 clearTimeout(deltaBufferTimer); 5516 deltaBufferTimer = setTimeout(function () { 5517 chrome.storage.local.set({ deltaBuffer: deltaBuffer }); 5518 }, 1000); 5519 var allEquals = (deltaBuffer[0] == deltaBuffer[1] && 5520 deltaBuffer[1] == deltaBuffer[2]); 5521 var allDivisable = (isDivisible(deltaBuffer[0], 120) && 5522 isDivisible(deltaBuffer[1], 120) && 5523 isDivisible(deltaBuffer[2], 120)); 5524 return !(allEquals || allDivisable); 5525 } 5526 5527 function isDivisible(n, divisor) { 5528 return (Math.floor(n / divisor) == n / divisor); 5529 } 5530 5531 if(typeof(chrome) !== 'undefined' && typeof(chrome.storage) !== 'undefined') { 5532 chrome.storage.local.get('deltaBuffer', function (stored) { 5533 if (stored.deltaBuffer) { 5534 deltaBuffer = stored.deltaBuffer; 5535 } 5536 }); 5537 } 5538 5539 var requestFrame = (function () { 5540 return window.requestAnimationFrame || 5541 window.webkitRequestAnimationFrame || 5542 function (callback, element, delay) { 5543 window.setTimeout(callback, delay || (1000/60)); 5544 }; 5545 })(); 5546 5547 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; 5548 5549 5550 /*********************************************** 5551 * PULSE 5552 ***********************************************/ 5553 5554 /** 5555 * Viscous fluid with a pulse for part and decay for the rest. 5556 * - Applies a fixed force over an interval (a damped acceleration), and 5557 * - Lets the exponential bleed away the velocity over a longer interval 5558 * - Michael Herf, http://stereopsis.com/stopping/ 5559 */ 5560 function pulse_(x) { 5561 var val, start, expx; 5562 // test 5563 x = x * options.pulseScale; 5564 if (x < 1) { // acceleartion 5565 val = x - (1 - Math.exp(-x)); 5566 } else { // tail 5567 // the previous animation ended here: 5568 start = Math.exp(-1); 5569 // simple viscous drag 5570 x -= 1; 5571 expx = 1 - Math.exp(-x); 5572 val = start + (expx * (1 - start)); 5573 }
5574 return val * options.pulseNormalize; 5575 } 5576 5577 function pulse(x) { 5578 if (x >= 1) return 1; 5579 if (x <= 0) return 0; 5580 5581 if (options.pulseNormalize == 1) { 5582 options.pulseNormalize /= pulse_(1); 5583 } 5584 return pulse_(x); 5585 } 5586 5587 addEvent("mousedown", mousedown); 5588 addEvent("mousewheel", wheel); 5589 addEvent("load", init); 5590} //end smooth scroll 5591/* 5592* used by vimeo in td_video shortcode 5593* */ 5594 5595"use strict"; 5596 5597var Froogaloop=function(){function e(a){return new e.fn.init(a)}function h(a,c,b){if(!b.contentWindow.postMessage)return!1;var f=b.getAttribute("src").split("?")[0],a=JSON.stringify({method:a,value:c});"//"===f.substr(0,2)&&(f=window.location.protocol+f);b.contentWindow.postMessage(a,f)}function j(a){var c,b;try{c=JSON.parse(a.data),b=c.event||c.method}catch(f){}"ready"==b&&!i&&(i=!0);if(a.origin!=k)return!1;var a=c.value,e=c.data,g=""===g?null:c.player_id;c=g?d[g][b]:d[b];b=[];if(!c)return!1;void 0!== 5598 a&&b.push(a);e&&b.push(e);g&&b.push(g);return 0<b.length?c.apply(null,b):c.call()}function l(a,c,b){b?(d[b]||(d[b]={}),d[b][a]=c):d[a]=c}var d={},i=!1,k="";e.fn=e.prototype={element:null,init:function(a){"string"===typeof a&&(a=document.getElementById(a));this.element=a;a=this.element.getAttribute("src");"//"===a.substr(0,2)&&(a=window.location.protocol+a);for(var a=a.split("/"),c="",b=0,f=a.length;b<f;b++){if(3>b)c+=a[b];else break;2>b&&(c+="/")}k=c;return this},api:function(a,c){if(!this.element|| 5599 !a)return!1;var b=this.element,f=""!==b.id?b.id:null,d=!c||!c.constructor||!c.call||!c.apply?c:null,e=c&&c.constructor&&c.call&&c.apply?c:null;e&&l(a,e,f);h(a,d,b);return this},addEvent:function(a,c){if(!this.element)return!1;var b=this.element,d=""!==b.id?b.id:null;l(a,c,d);"ready"!=a?h("addEventListener",a,b):"ready"==a&&i&&c.call(null,d);return this},removeEvent:function(a){if(!this.element)return!1;var c=this.element,b;a:{if((b=""!==c.id?c.id:null)&&d[b]){if(!d[b][a]){b=!1;break a}d[b][a]=null}else{if(!d[a]){b= 5600 !1;break a}d[a]=null}b=!0}"ready"!=a&&b&&h("removeEventListener",a,c)}};e.fn.init.prototype=e.fn;window.addEventListener?window.addEventListener("message",j,!1):window.attachEvent("onmessage",j);return window.Froogaloop=window.$f=e}(); 5601/* td_custom_events.js - handles the booster td_events that require throttling 5602 * v 1.0 - wp_011 5603 */ 5604 5605/* global tdAnimationScroll:{} */ 5606/* global tdAnimationStack:{} */ 5607/* global tdPullDown:{} */ 5608/* global tdBackstr:{} */ 5609/* global td_backstretch_items:Array */ 5610/* global td_compute_backstretch_item:Function */ 5611 5612var tdCustomEvents = {}; 5613 5614(function(){ 5615 5616 'use strict'; 5617 5618 tdCustomEvents = { 5619 5620 5621 /** 5622 * - callback real scroll called from td_events 5623 * @private 5624 */ 5625 _callback_scroll: function() { 5626 tdAnimationScroll.compute_all_items(); 5627 }, 5628 5629 5630 /** 5631 * - callback real resize called from td_events 5632 * @private 5633 */ 5634 _callback_resize: function() { 5635 5636 }, 5637 5638 5639 /** 5640 * - callback lazy scroll called from td_events at 100ms 5641 * @private 5642 */ 5643 _lazy_callback_scroll_100: function() { 5644 if ( true === tdAnimationStack.activated ) { 5645 tdAnimationStack.td_events_scroll(); 5646 } 5647 }, 5648 5649 5650 /** 5651 * - callback lazy scroll called from td_events at 500ms 5652 * @private 5653 */ 5654 _lazy_callback_scroll_500: function() { 5655 5656 }, 5657 5658 5659 5660 /** 5661 * - callback lazy resize called from td_events at 100ms 5662 * @private 5663 */ 5664 _lazy_callback_resize_100: function() { 5665 tdPullDown.td_events_resize(); 5666 tdBackstr.td_events_resize(); 5667 tdAnimationScroll.td_events_resize(); 5668 }, 5669 5670 5671 /** 5672 * - callback lazy resize called from td_events at 500ms 5673 * @private 5674 */ 5675 _lazy_callback_resize_500: function() { 5676 if ( true === tdAnimationStack.activated ) { 5677 tdAnimationStack.td_events_resize(); 5678 } 5679 5680 // - every tdAnimationScroll.item item of the td_backstretch_items array must be reinitialized and repositioned for parallax effect 5681 for ( var i = 0; i < td_backstretch_items.length; i++ ) { 5682 tdAnimationScroll.reinitialize_item( td_backstretch_items[ i ], true ); 5683 td_compute_backstretch_item( td_backstretch_items[ i ] ); 5684 5685 // compute_all_items is used instead, for requestAnimationFrame 5686 //tdAnimationScroll.compute_item(td_backstretch_items[i]); 5687 } 5688 5689 // for better performance it's used tdAnimationScroll.compute_all_items, because it uses requestAnimationFrame 5690 tdAnimationScroll.compute_all_items();
5691 } 5692 }; 5693})(); 5694 5695/* tdEvents.js - handles the events that require throttling 5696 * v 2.0 - wp_010 5697 * 5698 * moved in theme from wp_booster 5699 */ 5700 5701/* global jQuery:{} */ 5702/* global tdAffix:{} */ 5703/* global tdSmartSidebar:{} */ 5704/* global tdViewport:{} */ 5705/* global tdInfiniteLoader:{} */ 5706/* global td_more_articles_box:{} */ 5707/* global tdDetect:{} */ 5708/* global tdCustomEvents:{} */ 5709 5710/* global td_events_scroll_scroll_to_top:Function */ 5711 5712var tdEvents = {}; 5713 5714(function(){ 5715 'use strict'; 5716 5717 tdEvents = { 5718 5719 //the events - we have timers that look at the variables and fire the event if the flag is true 5720 scroll_event_slow_run: false, 5721 scroll_event_medium_run: false, 5722 5723 resize_event_slow_run: false, //when true, fire up the resize event 5724 resize_event_medium_run: false, 5725 5726 5727 scroll_window_scrollTop: 0, //used to store the scrollTop 5728 5729 window_pageYOffset: window.pageYOffset, // @todo see if it can replace scroll_window_scrollTop [used by others]
5730 window_innerHeight: window.innerHeight, // used to store the window height 5731 window_innerWidth: window.innerWidth, // used to store the window width 5732 5733 init: function() { 5734 5735 jQuery( window ).scroll(function() { 5736 tdEvents.scroll_event_slow_run = true; 5737 tdEvents.scroll_event_medium_run = true; 5738 5739 //read the scroll top 5740 tdEvents.scroll_window_scrollTop = jQuery( window ).scrollTop(); 5741 tdEvents.window_pageYOffset = window.pageYOffset; 5742 5743 /* ---------------------------------------------------------------------------- 5744 Run affix menu event 5745 */ 5746 5747 tdAffix.td_events_scroll( tdEvents.scroll_window_scrollTop ); //main menu 5748 5749 tdSmartSidebar.td_events_scroll( tdEvents.scroll_window_scrollTop ); //smart sidebar scroll 5750 5751 5752 // call real tdCustomEvents scroll 5753 tdCustomEvents._callback_scroll(); 5754 }); 5755 5756 5757 jQuery( window ).resize(function() { 5758 tdEvents.resize_event_slow_run = true; 5759 tdEvents.resize_event_medium_run = true; 5760
5761 tdEvents.window_innerHeight = window.innerHeight; 5762 tdEvents.window_innerWidth = window.innerWidth; 5763 5764 //var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 5765 5766 //w = jQuery(document).width(); 5767 //console.log(w); 5768 5769 5770 // call real tdCustomEvents resize 5771 tdCustomEvents._callback_resize(); 5772 }); 5773 5774 5775 5776 //medium resolution timer for rest? 5777 setInterval(function() { 5778 5779 // it must run before any others 5780 tdViewport.detectChanges(); 5781 5782 //scroll event 5783 if ( tdEvents.scroll_event_medium_run ) { 5784 tdEvents.scroll_event_medium_run = false; 5785 //compute events for the infinite scroll 5786 tdInfiniteLoader.computeEvents(); 5787 5788 5789 // call lazy tdCustomEvents scroll 5790 tdCustomEvents._lazy_callback_scroll_100(); 5791 } 5792 5793 if ( tdEvents.resize_event_medium_run ) { 5794 tdEvents.resize_event_medium_run = false; 5795 tdSmartSidebar.td_events_resize(); 5796 5797 5798 // call lazy tdCustomEvents resize 5799 tdCustomEvents._lazy_callback_resize_100(); 5800 } 5801 }, 100); 5802 5803 5804 5805 //low resolution timer for rest? 5806 setInterval(function() { 5807 //scroll event 5808 if ( tdEvents.scroll_event_slow_run ) { 5809 tdEvents.scroll_event_slow_run = false; 5810 5811 //back to top 5812 td_events_scroll_scroll_to_top( tdEvents.scroll_window_scrollTop ); 5813 5814 //more articles box 5815 td_more_articles_box.td_events_scroll( tdEvents.scroll_window_scrollTop ); 5816 5817 5818 // call lazy tdCustomEvents scroll 5819 tdCustomEvents._lazy_callback_scroll_500(); 5820 } 5821 5822 //resize event 5823 if ( tdEvents.resize_event_slow_run ) { 5824 tdEvents.resize_event_slow_run = false; 5825 tdAffix.compute_wrapper(); 5826 tdAffix.compute_top(); 5827 tdDetect.runIsPhoneScreen(); 5828 5829 5830 // call lazy tdCustomEvents resize 5831 tdCustomEvents._lazy_callback_resize_500(); 5832 } 5833 }, 500); 5834 } 5835 }; 5836 5837 tdEvents.init(); 5838})(); 5839 5840/** 5841 * updates the view counter thru ajax 5842 */ 5843 5844/* global jQuery:{} */ 5845/* global td_ajax_url:string */ 5846 5847var tdAjaxCount = {}; 5848 5849(function(){ 5850 5851 'use strict'; 5852 5853 tdAjaxCount = { 5854 5855 //td_get_views_counts_ajax : function( page_type, array_ids ) { 5856 tdGetViewsCountsAjax : function( postType, arrayIds ) { 5857 5858 //what function to call based on postType 5859 var pageTypeAction = 'td_ajax_get_views';//postType = page 5860 if ( 'post' === postType ) { 5861 pageTypeAction = 'td_ajax_update_views'; 5862 } 5863 5864 jQuery.ajax({ 5865 type: 'POST', 5866 url: td_ajax_url, 5867 cache: true, 5868 data: { 5869 action: pageTypeAction, 5870 td_post_ids: arrayIds 5871 }, 5872 success: function( data, textStatus, XMLHttpRequest ) { 5873 var tdAjaxPostCounts = jQuery.parseJSON( data );//get the return dara 5874 5875 //check the return var to be object 5876 if ( tdAjaxPostCounts instanceof Object ) { 5877 //alert('value is Object!'); 5878 5879 //iterate throw the object 5880 jQuery.each( tdAjaxPostCounts, function( idPost, value ) { 5881 //alert(id_post + ": " + value); 5882 5883 //this is the count placeholder in witch we write the post count 5884 var currentPostCount = '.td-nr-views-' + idPost; 5885 5886 jQuery( currentPostCount ).html( value ); 5887 //console.log(current_post_count + ': ' + value); 5888 }); 5889 } 5890 }, 5891 error: function( MLHttpRequest, textStatus, errorThrown ) { 5892 //console.log(errorThrown); 5893 } 5894 }); 5895 } 5896 }; 5897})(); 5898 5899/* 5900 td_video_playlist.js 5901 v1.1 5902 */ 5903 5904 5905/* global jQuery:{} */ 5906/* global YT:{} */ 5907/* global tdDetect:{} */ 5908/* global $f:{} */ 5909 5910/* global td_youtube_list_ids:{} */ 5911/* global td_vimeo_list_ids:{} */ 5912 5913/* jshint -W069 */ 5914 5915var tdYoutubePlayer = {};
5916var tdVimeoPlaylistObj = {}; 5917var tdPlaylistGeneralFunctions = {}; 5918 5919 5920// @todo this ready hook function must be moved from here 5921// jQuery(window).load(function() {// 5922jQuery().ready(function() { 5923 5924 'use strict'; 5925 5926 //click on a youtube movie 5927 jQuery( '.td_click_video_youtube' ).click(function(){ 5928 5929 //this flag is check to see if to start the movie 5930 tdYoutubePlayer.tdPlaylistVideoAutoplayYoutube = 1; 5931 5932 //add pause to playlist control 5933 tdPlaylistGeneralFunctions.tdPlaylistAddPlayControl( '.td_youtube_control' ); 5934 5935 //create and play the clicked video 5936 var tdYoutubeVideo = jQuery( this ).attr( 'id' ).substring( 3 ); 5937 if ( '' !== tdYoutubeVideo ) { 5938 tdYoutubePlayer.playVideo( tdYoutubeVideo ); 5939 } 5940 }); 5941 5942 5943 5944 //click on youtube play control 5945 jQuery( '.td_youtube_control' ).click(function(){ 5946 5947 //click to play 5948 if ( jQuery( this ).hasClass( 'td-sp-video-play' ) ){ 5949 //this is to enable video playing 5950 tdYoutubePlayer.tdPlaylistVideoAutoplayYoutube = 1; 5951 5952 //play the video 5953 tdYoutubePlayer.tdPlaylistYoutubePlayVideo(); 5954 5955 } else { 5956 5957 //put pause to the player 5958 tdYoutubePlayer.tdPlaylistYoutubePauseVideo(); 5959 } 5960 }); 5961 5962 5963 5964 //check for youtube wrapper and add api code to create the player 5965 if ( jQuery( '.td_wrapper_playlist_player_youtube' ).length > 0) { 5966 5967 if ( '1' == jQuery( '.td_wrapper_playlist_player_youtube').data( 'autoplay' ) ) { 5968 tdYoutubePlayer.tdPlaylistVideoAutoplayYoutube = 1; 5969 } 5970 5971 var firstVideo = jQuery( '.td_wrapper_playlist_player_youtube' ).data( 'first-video' ); 5972 5973 if ( '' !== firstVideo ) { 5974 tdYoutubePlayer.tdPlaylistIdYoutubeVideoRunning = firstVideo; 5975 5976 tdYoutubePlayer.playVideo( firstVideo ); 5977 } 5978 } 5979 5980 5981 5982 //check autoplay vimeo 5983 if ( '1' == jQuery( '.td_wrapper_playlist_player_vimeo' ).data( 'autoplay' ) ) { 5984 tdVimeoPlaylistObj.tdPlaylistVideoAutoplayVimeo = 1; 5985 } 5986 5987 //click on a vimeo 5988 jQuery( '.td_click_video_vimeo' ).click(function(){ 5989 5990 //this flag is check to see if to start the movie 5991 tdVimeoPlaylistObj.tdPlaylistVideoAutoplayVimeo = 1; 5992 5993 //add pause to playlist control 5994 tdPlaylistGeneralFunctions.tdPlaylistAddPlayControl( '.td_vimeo_control' ); 5995 5996 //create and play the clicked video 5997 tdVimeoPlaylistObj.createPlayer( jQuery( this ).attr( 'id' ).substring( 3 ) ); 5998 }); 5999 6000 6001 6002 6003 6004 //check for vimeo wrapper and add api code to create the player 6005 if ( jQuery( '.td_wrapper_playlist_player_vimeo' ).length > 0 ) { 6006 6007 //add play to playlist control 6008 tdPlaylistGeneralFunctions.tdPlaylistAddPlayControl( '.td_vimeo_control' ); 6009 6010 //create the iframe with the video 6011 tdVimeoPlaylistObj.createPlayer( jQuery( '.td_wrapper_playlist_player_vimeo' ).data('first-video' ) ); 6012 } 6013 6014 6015 6016 6017 //click on youtube play control 6018 jQuery( '.td_vimeo_control' ).click(function(){ 6019 6020 //click to play 6021 if ( jQuery( this ).hasClass( 'td-sp-video-play' ) ) { 6022 //this is to enable video playing 6023 tdVimeoPlaylistObj.tdPlaylistVideoAutoplayVimeo = 1; 6024 6025 //play the video 6026 tdVimeoPlaylistObj.tdPlaylistPlayerVimeo.api( 'play' ); 6027 6028 } else { 6029 6030 //put pause to the player 6031 tdVimeoPlaylistObj.tdPlaylistPlayerVimeo.api( 'pause' ); 6032 } 6033 }); 6034 6035}); 6036 6037 6038(function() { 6039 'use strict'; 6040 6041 tdYoutubePlayer = { 6042 tdYtPlayer: '', 6043 6044 tdPlayerContainer: 'player_youtube', 6045 6046 tdPlaylistVideoAutoplayYoutube: 0, 6047 6048 tdPlaylistIdYoutubeVideoRunning: '', 6049 6050 6051 playVideo: function( videoId ) { 6052 if ( 'undefined' === typeof( YT ) || 'undefined' === typeof( YT.Player ) ) { 6053 window.onYouTubePlayerAPIReady = function() { 6054 tdYoutubePlayer.loadPlayer( tdYoutubePlayer.tdPlayerContainer, videoId ); 6055 }; 6056 jQuery.getScript( 'https://www.youtube.com/player_api' ); 6057 } else { 6058 tdYoutubePlayer.loadPlayer( tdYoutubePlayer.tdPlayerContainer, videoId ); 6059 } 6060 }, 6061 6062 6063 loadPlayer: function( container, videoId ) { 6064 //container is here in case we need to add multiple players on page 6065 tdYoutubePlayer.tdPlaylistIdYoutubeVideoRunning = videoId; 6066 6067 var current_video_name = td_youtube_list_ids['td_' + tdYoutubePlayer.tdPlaylistIdYoutubeVideoRunning]['title']; 6068 var current_video_time = td_youtube_list_ids['td_' + tdYoutubePlayer.tdPlaylistIdYoutubeVideoRunning]['time']; 6069 6070 //remove focus from all videos from playlist 6071 tdPlaylistGeneralFunctions.tdVideoPlaylistRemoveFocused( '.td_click_video_youtube' ); 6072 6073 //add focus class on current playing video 6074 jQuery( '#td_' + videoId ).addClass( 'td_video_currently_playing' ); 6075 6076 //ading the current video playing title and time to the control area 6077 jQuery( '#td_current_video_play_title_youtube' ).html( current_video_name ); 6078 jQuery( '#td_current_video_play_time_youtube' ).html( current_video_time ); 6079 6080 tdYoutubePlayer.tdYtPlayer = ''; 6081 jQuery( '.td_wrapper_playlist_player_youtube' ).html( '<div id=' + tdYoutubePlayer.tdPlayerContainer + '></div>' ); 6082 6083 tdYoutubePlayer.tdYtPlayer = new YT.Player( container, {//window.myPlayer = new YT.Player(container, { 6084 playerVars: { 6085 //modestbranding: 1, 6086 //rel: 0, 6087 //showinfo: 0, 6088 autoplay: tdYoutubePlayer.tdPlaylistVideoAutoplayYoutube 6089 }, 6090 height: '100%', 6091 width: '100%', 6092 videoId: videoId, 6093 events: { 6094 'onReady': tdYoutubePlayer.onPlayerReady, 6095 'onStateChange': tdYoutubePlayer.onPlayerStateChange 6096 } 6097 }); 6098 }, 6099 6100 6101 onPlayerStateChange: function( event ) { 6102 if ( event.data === YT.PlayerState.PLAYING ) { 6103 6104 //add pause to playlist control 6105 tdPlaylistGeneralFunctions.tdPlaylistAddPauseControl( '.td_youtube_control' ); 6106 6107 } else if ( event.data === YT.PlayerState.ENDED ) { 6108 //video_events_js.on_stop('youtube'); 6109 6110 //add play to playlist control 6111 tdPlaylistGeneralFunctions.tdPlaylistAddPlayControl( '.td_youtube_control' ); 6112 6113 //if a video has ended then make auto play = 1; This is the case when the user set autoplay = 0 but start watching videos 6114 tdYoutubePlayer.tdPlaylistVideoAutoplayYoutube = 1; 6115 6116 //get the next video 6117 var nextVideoId = tdPlaylistGeneralFunctions.tdPlaylistChooseNextVideo( [ td_youtube_list_ids, tdYoutubePlayer.tdPlaylistIdYoutubeVideoRunning ] );
6118 if ( '' !== nextVideoId ) { 6119 tdYoutubePlayer.playVideo( nextVideoId ); 6120 } 6121 6122 } else if ( YT.PlayerState.PAUSED ) { 6123 //add play to playlist control 6124 tdPlaylistGeneralFunctions.tdPlaylistAddPlayControl( '.td_youtube_control' ); 6125 } 6126 }, 6127 6128 tdPlaylistYoutubeStopVideo: function() { 6129 tdYoutubePlayer.tdYtPlayer.stopVideo(); 6130 }, 6131 6132 tdPlaylistYoutubePlayVideo: function() { 6133 if ( ! tdDetect.isMobileDevice ) { 6134 tdYoutubePlayer.tdYtPlayer.playVideo(); 6135 } 6136 }, 6137 6138 tdPlaylistYoutubePauseVideo: function() { 6139 tdYoutubePlayer.tdYtPlayer.pauseVideo(); 6140 } 6141 }; 6142 6143 6144 6145 //VIMEO 6146 tdVimeoPlaylistObj = { 6147 6148 currentVideoPlaying : '', 6149 6150 tdPlaylistPlayerVimeo: '',//a copy of the vimeo player : needed when playing or pausing the vimeo pleyer from the playlist control 6151 6152 //tdPlaylistVideoAutoplayVimeo: '',//autoplay 6153 tdPlaylistVideoAutoplayVimeo: 0,//autoplay 6154 6155 createPlayer: function ( videoId ) { 6156 if ( '' !== videoId ) { 6157 6158 var vimeo_iframe_autoplay = ''; 6159 6160 this.currentVideoPlaying = videoId; 6161 6162 //remove focus class 6163 tdPlaylistGeneralFunctions.tdVideoPlaylistRemoveFocused( '.td_click_video_vimeo' ); 6164 6165 //add focus clas on play movie 6166 jQuery( '#td_' + videoId ).addClass( 'td_video_currently_playing' ); 6167 6168 //put movie data to control box 6169 this.putMovieDataToControlBox( videoId ); 6170 6171 //check autoplay 6172 if ( 0 !== this.tdPlaylistVideoAutoplayVimeo ) { 6173 vimeo_iframe_autoplay = '&autoplay=1'; 6174 } 6175 6176 6177 jQuery( '.td_wrapper_playlist_player_vimeo' ).html( '' ); 6178 jQuery( '.td_wrapper_playlist_player_vimeo' ).html( '<iframe id="player_vimeo_1" src="https://player.vimeo.com/video/' + videoId + '?api=1&player_id=player_vimeo_1' + vimeo_iframe_autoplay + '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>' );//width="100%" height="100%" 6179 6180 this.createVimeoObjectPlayer( jQuery ); 6181 } 6182 6183 }, 6184 6185 putMovieDataToControlBox: function( videoId ){ 6186 jQuery( '#td_current_video_play_title_vimeo' ).html( td_vimeo_list_ids['td_' + videoId]['title'] ); 6187 jQuery( '#td_current_video_play_time_vimeo' ).html( td_vimeo_list_ids['td_' + videoId]['time'] ); 6188 }, 6189 6190 createVimeoObjectPlayer : function( $ ) { 6191 var iframe = ''; 6192 var player = ''; 6193 6194 iframe = $( '#player_vimeo_1' )[0]; 6195 player = $f( iframe ); 6196 6197 //a copy of the vimeo player : needed when playing or pausing the vimeo pleyer from the playlist control 6198 this.tdPlaylistPlayerVimeo = player; 6199 6200 // When the player is ready, add listeners for pause, finish, and playProgress 6201 player.addEvent( 'ready', function() { 6202 //status.text('ready'); 6203 6204 player.addEvent( 'play', tdVimeoPlaylistObj.onPlay ); 6205 player.addEvent( 'pause', tdVimeoPlaylistObj.onPause ); 6206 player.addEvent( 'finish', tdVimeoPlaylistObj.onFinish ); 6207 player.addEvent( 'playProgress', tdVimeoPlaylistObj.onPlayProgress ); 6208 }); 6209 }, 6210 6211 onPlay : function( id ) { 6212 tdPlaylistGeneralFunctions.tdPlaylistAddPauseControl( '.td_vimeo_control' ); 6213 6214 tdVimeoPlaylistObj.tdPlaylistVideoAutoplayVimeo = 1; 6215 }, 6216 6217 onPause : function( id ) { 6218 tdPlaylistGeneralFunctions.tdPlaylistAddPlayControl( '.td_vimeo_control' ); 6219 }, 6220 6221 onFinish : function( id ) { 6222 //status.text('finished'); 6223 6224 //add play to playlist control 6225 tdPlaylistGeneralFunctions.tdPlaylistAddPlayControl( '.td_vimeo_control' ); 6226 6227 //if a video has ended then make auto play = 1; This is the case when the user set autoplay = 0 but start watching videos
6228 tdVimeoPlaylistObj.tdPlaylistVideoAutoplayVimeo = 1; 6229 6230 if ( ! tdDetect.isMobileDevice || ! tdDetect.isAndroid ) { 6231 6232 //get the next video 6233 var nextVideoId = tdPlaylistGeneralFunctions.tdPlaylistChooseNextVideo( [td_vimeo_list_ids, tdVimeoPlaylistObj.currentVideoPlaying] ); 6234 if ( '' !== nextVideoId ) { 6235 tdVimeoPlaylistObj.createPlayer( nextVideoId ); 6236 } 6237 } 6238 }, 6239 6240 onPlayProgress : function onPlayProgress( data, id ) { 6241 //status.text(data.seconds + 's played'); 6242 } 6243 }; 6244 6245 6246 6247 6248 //this object holds some functions used by both the youtube and vimeo 6249 tdPlaylistGeneralFunctions = { 6250 tdVideoPlaylistRemoveFocused: function( objClass ) { 6251 //remove focus class 6252 jQuery( objClass ).each(function() { 6253 jQuery( this ).removeClass( 'td_video_currently_playing' ); 6254 }); 6255 }, 6256 6257 6258 /* 6259 parram_array = array [ 6260 video_list, 6261 current_video_id_playing 6262 ] 6263 */ 6264 tdPlaylistChooseNextVideo: function( parramArray ){ 6265 //alert('get next'); 6266 6267 var videoList = parramArray[0]; 6268 var currentVideoIdPlaying = 'td_' + parramArray[1]; 6269 6270 //get next video id 6271 var nextVideoId = ''; 6272 var foundCurrent = ''; 6273 for ( var video in videoList ) { 6274 if ( videoList.hasOwnProperty( video ) ) { 6275 if ( 'found' === foundCurrent ) { 6276 nextVideoId = video; 6277 foundCurrent = ''; 6278 break;//found , now exit 6279 } 6280 if ( video === currentVideoIdPlaying ) { 6281 foundCurrent = 'found'; 6282 } 6283 } 6284 } 6285 6286 //play the next video 6287 if ( '' !== nextVideoId ) { 6288 6289 //remove 'td_' from the beginning of the string if necessary 6290 if ( 'td_' === nextVideoId.substring( 0, 3 ) ) { 6291 nextVideoId = nextVideoId.substring( 3 ); 6292 } 6293 6294 return nextVideoId; 6295 } 6296 6297 return ''; 6298 }, 6299 6300 6301 6302 //add pause button playlist control 6303 tdPlaylistAddPauseControl: function( wrapperClass ){ 6304 jQuery( wrapperClass ).removeClass( 'td-sp-video-play' ).addClass( 'td-sp-video-pause' ); 6305 }, 6306 6307 //add play button playlist control 6308 tdPlaylistAddPlayControl: function( wrapperClass ){ 6309 jQuery( wrapperClass ).removeClass( 'td-sp-video-pause' ).addClass( 'td-sp-video-play' ); 6310 } 6311 }; 6312})(); 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324/* 6325 td_slide.js 6326 */ 6327 6328"use strict"; 6329 6330//call function to resize the smartlist on ready (for safary) 6331jQuery(window).load(function() { 6332 td_resize_smartlist_sliders_and_update(); 6333}); 6334 6335//call function to resize the smartlist on ready 6336jQuery().ready(function() { 6337 td_resize_smartlist_sliders_and_update(); 6338}); 6339 6340 6341 6342//function to resize the height of the smartlist slide 6343function td_resize_smartlist_slides(args) { 6344 var slide_displayd = args.currentSlideNumber; 6345 6346 6347 //console.log(args.sliderObject[0]); 6348 //console.log(args.data.obj[0]); 6349 6350 var current_slider = jQuery(args.data.obj[0]).attr("id"); 6351 6352 if(!tdDetect.isIe8) { 6353 jQuery("#" + current_slider).css("overflow", "none"); 6354 jQuery("#" + current_slider + " .td-item").css("overflow", "visible"); 6355 } 6356 6357 var setHeight = 0; 6358 setHeight = jQuery("#" + current_slider + "_item_" + slide_displayd).outerHeight(true); 6359 6360 6361 jQuery("#" + current_slider + ", #" + current_slider + " .td-slider").css({ 6362 height: setHeight 6363 }); 6364} 6365 6366 6367 6368 6369 6370//function to resize and update the height of the smartlist slide 6371function td_resize_smartlist_sliders_and_update() { 6372 jQuery(document).find('.td-smart-list-slider').each(function() { 6373 var current_slider = jQuery(this).attr("id"); 6374 6375 if(!tdDetect.isIe8) { 6376 jQuery("#" + current_slider).css("overflow", "none");
6377 jQuery("#" + current_slider + " .td-item").css("overflow", "visible"); 6378 } 6379 6380 var setHeight = 0; 6381 setHeight = jQuery("#" + current_slider + "_item_" + td_history.get_current_page("slide")).outerHeight(true); 6382 6383 jQuery("#" + current_slider + ", #" + current_slider + " .td-slider").css({ 6384 height: setHeight 6385 }); 6386 6387 if(tdDetect.isAndroid) { 6388 setTimeout(function () { 6389 jQuery("#" + current_slider).iosSlider("update"); 6390 }, 2000); 6391 } 6392 }); 6393} 6394 6395 6396//function to resize the height of the normal slide 6397function td_resize_normal_slide(args) { 6398 var slide_displayd = 0;//args.currentSlideNumber; 6399 6400 var current_slider = jQuery(args.data.obj[0]).attr("id"); 6401 6402 //get window width 6403 var window_wight = td_get_document_width(); 6404 6405 if (!tdDetect.isIe8) { 6406 jQuery("#" + current_slider).css("overflow", "none"); 6407 jQuery("#" + current_slider + " .td-item").css("overflow", "visible"); 6408 } 6409 6410 var setHeight = 0; 6411 var slide_outer_width = jQuery("#" + current_slider + "_item_" + slide_displayd).outerWidth(true); 6412 6413 //only for android, width of the screen to start changing the height of the slide 6414 var max_wight_resize = 780; 6415 if(tdDetect.isAndroid) { 6416 max_wight_resize = 1000; 6417 } 6418 6419 if (window_wight < max_wight_resize && !tdDetect.isIpad) {//problem because we cannot get an accurate page width 6420 if(slide_outer_width > 300) { 6421 setHeight = slide_outer_width * 0.5; 6422 } else { 6423 setHeight = slide_outer_width; 6424 } 6425 6426 //console.log(window_wight); 6427 jQuery("#" + current_slider + ", #" + current_slider + " .td-slider, #" + current_slider + " .td-slider .td-module-thumb").css({ 6428 height: setHeight 6429 }); 6430 } 6431 6432} 6433 6434 6435 6436//function to resize and update the height of the slide for normal sliders 6437function td_resize_normal_slide_and_update(args) { 6438 6439 6440 //console.log('resize 2'); 6441 var slide_displayd = 0;//args.currentSlideNumber; 6442 6443 var current_slider = jQuery(args.data.obj[0]).attr("id"); 6444 6445 //get window width 6446 var window_wight = td_get_document_width(); 6447 6448 if(!tdDetect.isIe8) { 6449 jQuery("#" + current_slider).css("overflow", "none"); 6450 jQuery("#" + current_slider + " .td-item").css("overflow", "visible"); 6451 } 6452 6453 var setHeight = 0; 6454 var slide_outer_width = jQuery("#" + current_slider + "_item_" + slide_displayd).outerWidth(true); 6455 6456 //only for android, width of the screen to start changing the height of the slide 6457 var max_wight_resize = 780; 6458 if(tdDetect.isAndroid) { 6459 max_wight_resize = 1000; 6460 } 6461 6462 if (window_wight < max_wight_resize && !tdDetect.isIpad) {//problem because we cannot get an accurate page width 6463 if(slide_outer_width > 300) { 6464 setHeight = slide_outer_width * 0.5; 6465 } else { 6466 setHeight = slide_outer_width; 6467 } 6468 6469 //console.log(window_wight); 6470 jQuery("#" + current_slider + ", #" + current_slider + " .td-slider, #" + current_slider + " .td-slider .td-module-thumb").css({ 6471 height: setHeight 6472 }); 6473 6474 setTimeout(function () { 6475 jQuery("#" + current_slider).iosSlider("update"); 6476 6477 6478 6479 }, 2000); 6480 6481 } 6482} 6483/** 6484 * Created by tagdiv on 16.02.2015. 6485 */ 6486 6487 6488/* global tdViewport:{} */ 6489/* global jQuery:{} */ 6490 6491var tdPullDown = {}; 6492 6493( function(){ 6494 6495 'use strict'; 6496 6497 tdPullDown = { 6498 6499 6500 // - keeps internally the current interval index 6501 // - it's set at init() 6502 _view_port_interval_index : tdViewport.INTERVAL_INITIAL_INDEX, 6503 6504 6505 6506 // this flag mark that the tdPullDown.items must be reinitialized at the changing view port size 6507 reinitialize_items_at_change_view_port: false, 6508 6509 6510 6511 // - the list of items 6512 items: [], 6513 6514 6515 6516 // - the item represents a pair of lists (a horizontal and a vertical one) 6517 // - to be initialized, every property with 'IT MUST BE SPECIFIED' is mandatory 6518 item: function item() { 6519 6520 // - the jquery object of the horizontal list. 6521 // IT MUST BE SPECIFIED. 6522 this.horizontal_jquery_obj = ''; 6523 6524 // - the jquery object of the vertical list. 6525 // IT MUST BE SPECIFIED 6526 this.vertical_jquery_obj = ''; 6527 6528 // - the jquery container object. 6529 // - it contains the horizontal and the vertical jquery objects 6530 // IT MUST BE SPECIFIED. 6531 this.container_jquery_obj = ''; 6532 6533 // - the css class of an horizontal element. 6534 // IT MUST BE SPECIFIED 6535 this.horizontal_element_css_class = ''; 6536 6537 6538 6539 // the minimum no. of elements to be shown by the horizontal list 6540 // - IT CAN BE SPECIFIED 6541 this.minimum_elements = 2; 6542 6543 6544 6545 // - the array of jquery elements whose widths must be excluded from the width of the container object 6546 // IT CAN BE SPECIFIED 6547 this.excluded_jquery_elements = []; 6548 6549 // - the extra space of the horizontal jquery object occupied by the excluded jquery elements 6550 // - it's not initialized with 0 because widths of the elements can not be integer values 6551 // - now, it's set to 1px 6552 this._horizontal_extra_space = 1; 6553 6554 6555 6556 // - the array of objects from the horizontal list 6557 this._horizontal_elements = []; 6558 6559 // - the array of objects from the vertical list 6560 this._vertical_elements = []; 6561 6562 6563 6564 // - the jquery object of the first ul container in the vertical list 6565 // - it is calculated as the first 'ul' of the vertical jquery object 6566 this._vertical_ul_jquery_obj = ''; 6567 6568 6569 6570 // - the outer width of the vertical top header (ex.'More') 6571 // - it's used to calculate if the last vertical element has enough space in the horizontal list, 6572 // without considering the vertical top header width 6573 this._vertical_jquery_obj_outer_width = 0; 6574 6575 6576 6577 // flag used to mark the initialization item 6578 this._is_initialized = false; 6579 }, 6580 6581 6582 6583 6584 /** 6585 * - function used to init the tdPullDown object 6586 * - it must be called before any item adding 6587 * - it initializes the _view_port_interval_index 6588 * - the items list is initialized 6589 */ 6590 init: function() { 6591 6592 tdPullDown._view_port_interval_index = tdViewport.getCurrentIntervalIndex(); 6593 6594 tdPullDown.items = []; 6595 }, 6596 6597 6598 6599 6600 /** 6601 * - add an item to the item list and initialize it 6602 * 6603 * @param item The item to be added and initialized 6604 */ 6605 add_item: function( item ) { 6606 6607 // the item is added in the item list 6608 tdPullDown.items.push( item ); 6609 6610 // the item is initialized only once when it is added 6611 tdPullDown._initialize_item( item ); 6612 6613 // the item is ready to be computed 6614 tdPullDown._compute_item( item ); 6615 }, 6616 6617 6618 6619 6620 /** 6621 * - internal utility function used to initialize an item 6622 * - an item must be initialized only once 6623 * - every element having a specified css class is added in the horizontal list 6624 * 6625 * @param item {tdPullDown.item} The item to be initialized 6626 * @private 6627 */ 6628 _initialize_item: function( item ) { 6629 6630 // an item must be initialized only once 6631 if ( true === item._is_initialized ) { 6632 return; 6633 } 6634 6635 6636 // the mandatory item properties are verified 6637 if ( ( '' === item.horizontal_jquery_obj ) || 6638 ( '' === item.vertical_jquery_obj ) || 6639 ( '' === item.container_jquery_obj ) || 6640 ( '' === item.horizontal_element_css_class ) ) { 6641 6642 tdPullDown.log( 'Item can\' be initialized. It doesn\'t have all the mandatory properties' ); 6643 return; 6644 } 6645 6646 6647 // the jquery object of the first ul container in the vertical list is initialized 6648 item._vertical_ul_jquery_obj = item.vertical_jquery_obj.find( 'ul:first' ); 6649 6650 if ( 0 === item._vertical_ul_jquery_obj.length ) { 6651 6652 tdPullDown.log( 'Item can\' be initialized. The vertical list doesn\'t have an \'ul\' container' ); 6653 return; 6654 } 6655 6656 6657 // the elements of the horizontal jquery object, having a specified css class 6658 var elements = item.horizontal_jquery_obj.find( '.' + item.horizontal_element_css_class ); 6659 6660 var local_jquery_element = null; 6661 var local_object = null; 6662 6663 // for each element an object is added in the horizontal list 6664 elements.each( function ( index, element ) { 6665 6666 local_jquery_element = jQuery( element ); 6667 6668 // @todo here we need a css class 6669 local_jquery_element.css( '-webkit-transition', 'opacity 0.2s' ); 6670 local_jquery_element.css( '-moz-transition', 'opacity 0.2s' ); 6671 local_jquery_element.css( '-o-transition', 'opacity 0.2s' ); 6672 local_jquery_element.css( 'transition', 'opacity 0.2s' ); 6673 6674 local_jquery_element.css( 'opacity', '1' ); 6675 6676 6677 // the cached object used to keep the jquery object and its outerWidth 6678 local_object = { 6679 6680 // the jquery element 6681 jquery_object: local_jquery_element, 6682 6683 // the outer width including border 6684 calculated_width: local_jquery_element.outerWidth( true ) 6685 }; 6686 6687 // the horizontal list is populated 6688 item._horizontal_elements.push( local_object ); 6689 }); 6690 6691 6692 // the outer width of the vertical top header (ex.'More') is initialized 6693 item._vertical_jquery_obj_outer_width = item.vertical_jquery_obj.outerWidth( true ); 6694 6695 6696 // by default, the vertical jquery object is hidden, being shown when at least one element is moved in it 6697 item.vertical_jquery_obj.css( 'display', 'none' ); 6698 6699 6700 6701 // the the extra space occupied by the horizontal jquery object is calculated 6702 6703 var horizontal_jquery_obj_padding_left = item.horizontal_jquery_obj.css( 'padding-left' ); 6704 if ( ( undefined !== horizontal_jquery_obj_padding_left ) && ( '' !== horizontal_jquery_obj_padding_left ) ) { 6705 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_padding_left.replace( 'px', '' ) ); 6706 } 6707 6708 var horizontal_jquery_obj_padding_right = item.horizontal_jquery_obj.css( 'padding-right' ); 6709 if ( ( undefined !== horizontal_jquery_obj_padding_right ) && ( '' !== horizontal_jquery_obj_padding_right ) ) { 6710 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_padding_right.replace( 'px', '' ) ); 6711 } 6712 6713 6714 var horizontal_jquery_obj_margin_left = item.horizontal_jquery_obj.css( 'margin-left' ); 6715 if ( ( undefined !== horizontal_jquery_obj_margin_left ) && ( '' !== horizontal_jquery_obj_margin_left ) ) { 6716 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_margin_left.replace( 'px', '' ) ); 6717 } 6718 6719 var horizontal_jquery_obj_margin_right = item.horizontal_jquery_obj.css( 'margin-right' ); 6720 if ( ( undefined !== horizontal_jquery_obj_margin_right ) && ( '' !== horizontal_jquery_obj_margin_right ) ) { 6721 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_margin_right.replace( 'px', '' ) ); 6722 } 6723 6724 6725 var horizontal_jquery_obj_border_left = item.horizontal_jquery_obj.css( 'border-left' ); 6726 if ( ( undefined !== horizontal_jquery_obj_border_left ) && ( '' !== horizontal_jquery_obj_border_left ) ) { 6727 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_border_left.replace( 'px', '' ) ); 6728 } 6729 6730 var horizontal_jquery_obj_border_right = item.horizontal_jquery_obj.css( 'border-right' ); 6731 if ( ( undefined !== horizontal_jquery_obj_border_right ) && ( '' !== horizontal_jquery_obj_border_right ) ) { 6732 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_border_right.replace( 'px', '' ) ); 6733 } 6734 6735 6736 // the item is marked as initialized, being ready to be computed 6737 item._is_initialized = true; 6738 }, 6739 6740 6741 6742 6743 /** 6744 * - internal utility function used to summarize width of the horizontal elements 6745 * 6746 * @param item {tdPullDown.item} The item whose horizontal list is processed 6747 * @returns {number} 6748 * @private 6749 */ 6750 _get_horizontal_elements_width: function( item ) { 6751 6752 var sum_width = 0; 6753 6754 for ( var i = item._horizontal_elements.length - 1; i >= 0; i-- ) { 6755 sum_width += item._horizontal_elements[ i ].calculated_width; 6756 } 6757 return sum_width; 6758 }, 6759 6760 6761 6762 6763 /** 6764 * - internal utility function used to reinitialize all items at the view resolution changing 6765 */ 6766 _reinitialize_all_items: function() { 6767 6768 for ( var i = tdPullDown.items.length - 1; i >= 0; i-- ) { 6769 tdPullDown._reinitialize_item( tdPullDown.items[ i ] ); 6770 } 6771 }, 6772 6773 6774 6775 6776 /** 6777 * - internal utility function used to reinitialize an item at the view resolution changing 6778 * 6779 * @param item The item being reinitialized 6780 */ 6781 _reinitialize_item: function( item ) { 6782 6783 // a not initialized item can't be reinitialized 6784 if ( false === item._is_initialized ) { 6785 return; 6786 } 6787 6788 // the flag is marked, so any further operation on this item is stopped 6789 item._is_initialized = false; 6790 6791 // the html elements of the vertical list are all moved into the horizontal jquery object 6792 item.horizontal_jquery_obj.html( item.horizontal_jquery_obj.html() + item._vertical_ul_jquery_obj.html() ); 6793 6794 // the html content of the vertical list is cleared 6795 item._vertical_ul_jquery_obj.html( '' ); 6796 6797 // the horizontal list is empty initialized 6798 item._horizontal_elements = []; 6799 6800 // the vertical list is empty initialized 6801 item._vertical_elements = []; 6802 6803 // the extra space is initialized 6804 item._horizontal_extra_space = 1; 6805 6806 // the item is ready to be initialized again 6807 tdPullDown._initialize_item( item ); 6808 }, 6809 6810 6811 6812 6813 /** 6814 * - an internal function used to move elements from the horizontal to the vertical list and vice versa, in according with 6815 * the space for horizontal elements. 6816 * - it's called every time at the viewport resize, when the space for horizontal elements is modified 6817 * 6818 * @param item - the item being computed 6819 * @private 6820 */ 6821 _compute_item: function( item ) { 6822 6823 // the item must be initialized first 6824 if ( false === item._is_initialized ) { 6825 return; 6826 } 6827 6828 6829 6830 // the horizontal header margin is set 0 and the horizontal space is computing without its margin 6831 // @see tdPullDown._prepare_horizontal_header 6832 tdPullDown._prepare_horizontal_header( item, true ); 6833 6834 6835 6836 // - the space where horizontal elements lie 6837 // - it is the container width minus any extra horizontal space 6838 var space_for_horizontal_elements = 0; 6839
6840 // the object container width 6841 var container_jquery_width = item.container_jquery_obj.css( 'width' ); 6842 6843 if ( ( undefined !== container_jquery_width ) && ( '' !== container_jquery_width ) ) { 6844 6845 // the space for new horizontal elements is initialized by the container width 6846 space_for_horizontal_elements = container_jquery_width.replace( 'px', '' ); 6847 6848 // then this space is reduced by the widths of the excluded elements 6849 for ( var i = item.excluded_jquery_elements.length - 1; i >= 0; i-- ) { 6850 space_for_horizontal_elements -= item.excluded_jquery_elements[ i ].contents().outerWidth( true ); 6851 } 6852 } 6853 6854 6855 // if the vertical list is empty, the space for horizontal elements does not contain the width of the vertical head list 6856 if ( item._vertical_elements.length > 0 ) { 6857 space_for_horizontal_elements -= item._vertical_jquery_obj_outer_width; 6858 } 6859 6860 // the space occupied by the horizontal elements is removed 6861 space_for_horizontal_elements -= tdPullDown._get_horizontal_elements_width( item ); 6862 6863 // the horizontal extra space is used to add an extra gap when the width of one element or a js math computation does a not integer value 6864 space_for_horizontal_elements -= item._horizontal_extra_space; 6865 6866 6867 // the current element being moved between the lists 6868 var local_current_element; 6869 6870 6871 // if there's not enough space for the horizontal elements, then the last of them are moved to the vertical list 6872 while ( space_for_horizontal_elements < 0 ) { 6873 6874 // if there's specified a minimum number of horizontal elements, this must be considered 6875 if ( ( item.minimum_elements !== 0 ) && ( item._horizontal_elements.length <= item.minimum_elements ) ) { 6876 6877 // all elements are moved to the vertical list 6878 tdPullDown._make_all_elements_vertical( item ); 6879 6880 6881 6882 6883 // the horizontal header margin is set before return 6884 tdPullDown._prepare_horizontal_header( item ); 6885 6886 6887 6888 // the following checks are not more eligible to do 6889 return; 6890 6891 } else { 6892 6893 // If the vertical list does not contain any elements yet, 6894 // the space for horizontal elements is minimized by the vertical top header width 6895 if ( 0 === item._vertical_elements.length ) { 6896 space_for_horizontal_elements -= item._vertical_jquery_obj_outer_width; 6897 } 6898 6899 local_current_element = tdPullDown._make_element_vertical( item ); 6900 space_for_horizontal_elements += local_current_element.calculated_width; 6901 } 6902 } 6903 6904 6905 6906 // This is the case when there's specified a no. of minimum horizontal elements and the horizontal list is empty. 6907 // If the following conditions are accomplished the horizontal list is refilled with elements from the vertical list 6908 // 6909 // - if there's specified a no. of minimum horizontal elements 6910 // - if there is no horizontal elements 6911 // - if there are vertical elements 6912 // - if there's enough horizontal space for the first vertical element 6913 6914 if ( ( 0 !== item.minimum_elements ) && 6915 ( 0 === item._horizontal_elements.length ) && 6916 ( item._vertical_elements.length > 0 ) && 6917 ( space_for_horizontal_elements >= item._vertical_elements[ 0 ].calculated_width ) ) { 6918 6919 // the necessary space needed for the minimum no. of horizontal elements 6920 var local_necessary_space = 0; 6921 6922 for ( var j = 0; ( j < item.minimum_elements ) && ( j < item._vertical_elements.length ); j++ ) { 6923 local_necessary_space += item._vertical_elements[ j ].calculated_width; 6924 } 6925 6926 // the necessary space really occupied by the minimum no. of horizontal elements 6927 var local_space = 0; 6928 var local_minimum_elements = item.minimum_elements; 6929 6930 while ( ( local_minimum_elements > 0 ) && 6931 ( item._vertical_elements.length > 0 ) && 6932 ( space_for_horizontal_elements >= local_necessary_space ) ) { 6933 6934 local_current_element = tdPullDown._make_element_horizontal( item ); 6935 6936 if ( null !== local_current_element ) { 6937 local_space += local_current_element.calculated_width; 6938 local_minimum_elements--; 6939 } else { 6940 6941 // the horizontal header margin is set before return 6942 tdPullDown._prepare_horizontal_header( item ); 6943 6944 return; 6945 } 6946 6947 } 6948 space_for_horizontal_elements -= local_space; 6949 } 6950 6951 6952 6953 // It's the case when there isn't specified a no. of minimum horizontal elements or it is specified and the 6954 // horizontal list is not empty, and in the same time there's enough horizontal space for more elements 6955 while ( ( ( item._horizontal_elements.length > 0 ) || ( 0 === item._horizontal_elements.length && 0 === item.minimum_elements ) ) && 6956 ( item._vertical_elements.length > 0 ) && 6957 ( space_for_horizontal_elements >= item._vertical_elements[ 0 ].calculated_width ) ) { 6958 6959 local_current_element = tdPullDown._make_element_horizontal( item ); 6960 6961 if ( null !== local_current_element ) { 6962 space_for_horizontal_elements -= local_current_element.calculated_width; 6963 } else { 6964 6965 // the horizontal header margin is set before return 6966 tdPullDown._prepare_horizontal_header( item ); 6967 6968 return; 6969 } 6970 } 6971 6972 6973
6974 // if the vertical list contains just one element, the horizontal space for it must be calculated without considering the vertical top header width (ex.'More') 6975 if ( ( 1 === item._vertical_elements.length ) && 6976 ( space_for_horizontal_elements + item._vertical_jquery_obj_outer_width >= item._vertical_elements[ 0 ].calculated_width ) ) { 6977 tdPullDown._make_element_horizontal( item ); 6978 } 6979 6980 6981 // the horizontal header margin is set before return 6982 tdPullDown._prepare_horizontal_header( item ); 6983 }, 6984 6985 6986 /** 6987 * - add margin to the element with '.block-title' css class, to keep the vertical_jquery_obj not overlapping over it when 6988 * there are no horizontal elements and it is too wide [more strings in name] 6989 * @param item tdPullDown.item 6990 * @param clear_margin boolean True to just clear margin, or false to check the horizontal elements length and then set the margin 6991 * @private 6992 */ 6993 _prepare_horizontal_header: function _prepare_horizontal_header( item, clear_margin ) { 6994 var block_title_jquery_obj = item.horizontal_jquery_obj.parent().siblings( '.block-title:first' ); 6995 6996 if ( 1 === block_title_jquery_obj.length ) { 6997 var content_element = block_title_jquery_obj.find( 'span:first' ); 6998 6999 if ( 1 === content_element.length ) { 7000 7001 if ( 'undefined' !== typeof( clear_margin ) && true === clear_margin ) { 7002 content_element.css( 'margin-right', 0 ); 7003 } else { 7004 if ( 0 === item._horizontal_elements.length ) { 7005 content_element.css( 'margin-right', item._vertical_jquery_obj_outer_width + 'px' ); 7006 } else { 7007 content_element.css( 'margin-right', 0 ); 7008 } 7009 } 7010 } 7011 } 7012 }, 7013 7014 7015 7016 7017 /** 7018 * - function used to compute all items in the item list 7019 * 7020 * @private 7021 */ 7022 _compute_all_items: function() { 7023 for ( var i = tdPullDown.items.length - 1; i >= 0; i-- ) { 7024 7025 // a type check is done for every item in the item list 7026 if ( tdPullDown.items[ i ].constructor === tdPullDown.item ) { 7027 tdPullDown._compute_item( tdPullDown.items[ i ] ); 7028 } 7029 } 7030 }, 7031 7032 7033 7034 7035 /** 7036 * - function used to move one element from the vertical list to the horizontal one 7037 * - the function returns the element that has been moved, otherwise null 7038 * - the last element moving hides the vertical top header 7039 * 7040 * @param item - the item whose element is moved 7041 * @returns {T} - the moved element 7042 * @private 7043 */ 7044 _make_element_horizontal: function( item ) { 7045 7046 // the item must be initialized and the vertical list must contain at least an element 7047 if ( false === item._is_initialized || 0 === item._vertical_elements.length ) { 7048 return null; 7049 } 7050 7051 // the first element of the vertical list is shifted 7052 var local_element = item._vertical_elements.shift(); 7053 7054 // the vertical list is shown when there's at least one vertical element 7055 if ( 0 === item._vertical_elements.length ) { 7056 item.vertical_jquery_obj.css( 'display', 'none' ); 7057 } 7058 7059 // the element is added on the last position in the horizontal list 7060 item._horizontal_elements.push( local_element ); 7061 7062 local_element.jquery_object.css( 'opacity', '0' ); 7063 7064 // the DOM is changing 7065 local_element.jquery_object.detach().appendTo( item.horizontal_jquery_obj ); 7066 7067 setTimeout( function() { 7068 local_element.jquery_object.css( 'opacity', '1' ); 7069 }, 50); 7070 7071 //tdPullDown.log('horizontal'); 7072 7073 return local_element; 7074 }, 7075 7076 7077 7078 7079 /** 7080 * - function used to move one element from the horizontal list to the vertical one 7081 * - the function returns the element that has been moved, otherwise null 7082 * - the first element moving shows the vertical top header 7083 * 7084 * @param item - the item whose element is moved 7085 * @returns {T} - the moved element 7086 * @private 7087 */ 7088 _make_element_vertical: function( item ) { 7089 7090 // the item must be initialized and the horizontal list must contain at least an element 7091 if ( false === item._is_initialized || 0 === item._horizontal_elements.length ) { 7092 return null; 7093 } 7094 7095 // the last element of the horizontal list is popped out 7096 var local_element = item._horizontal_elements.pop(); 7097 7098 // the vertical list is hidden when there are no vertical elements 7099 if ( 0 === item._vertical_elements.length ) { 7100 item.vertical_jquery_obj.css( 'display', '' ); 7101 } 7102 7103 //the element is added on the first position into the vertical list 7104 item._vertical_elements.unshift( local_element ); 7105 7106 // the DOM is changed 7107 local_element.jquery_object.detach().prependTo( item._vertical_ul_jquery_obj ); 7108 7109 //tdPullDown.log('vertical'); 7110 7111 return local_element; 7112 }, 7113 7114 7115 7116 7117 /** 7118 * - function used to move all elements to the vertical list 7119 * - it's used when the minimum horizontal elements is greater than 0 7120 * 7121 * @param item - the item whose elements are moved 7122 * @private 7123 */ 7124 _make_all_elements_vertical: function( item ) { 7125 while ( item._horizontal_elements.length > 0 ) { 7126 tdPullDown._make_element_vertical( item ); 7127 } 7128 }, 7129 7130 7131 7132 7133 7134 7135 /** 7136 * - function necessary to be called when the window is being resized 7137 */ 7138 td_events_resize: function() { 7139 7140 if ( 0 === tdPullDown.items.length ) { 7141 return; 7142 } 7143 7144 if ( true === tdPullDown.reinitialize_items_at_change_view_port && tdPullDown._view_port_interval_index !== tdViewport.getCurrentIntervalIndex() ) { 7145 tdPullDown._reinitialize_all_items();
7146 } 7147 7148 tdPullDown._compute_all_items(); 7149 }, 7150 7151 7152 7153 7154 log: function log( msg ) { 7155 //console.log(msg); 7156 } 7157 }; 7158 7159 7160 tdPullDown.init(); 7161 7162})(); 7163 7164 7165 7166 7167 7168 7169 7170 7171var td_fps = { 7172 7173 start_time: 0, 7174 7175 current_time: 0, 7176 7177 frame_number: 0, 7178 7179 init: function init() { 7180 td_fps.start_time = 0; 7181 7182 var previous_result = 0, 7183 result = 0, 7184 elapsed_time = 0; 7185 7186 var td_fps_table = jQuery("#fps_table"); 7187 7188 if (td_fps_table.length == 0) { 7189 td_fps_table = jQuery('<div>').css({ 7190 "position": "fixed", 7191 "top": "120px", 7192 "left": "10px", 7193 "width": "100px", 7194 "height": "20px", 7195 "border": "1px solid black", 7196 "font-size": "11px", 7197 "z-index": "100000", 7198 "background-color": "white" 7199 }); 7200 7201 td_fps_table.appendTo('body'); 7202 } 7203 7204 var get_fps = function() { 7205 td_fps.frame_number++;
7206 td_fps.current_time = Date.now(); 7207 7208 elapsed_time = (td_fps.current_time - td_fps.start_time) / 1000; 7209 7210 result = (td_fps.frame_number / elapsed_time).toPrecision(2); 7211 7212 if (result != previous_result) { 7213 previous_result = result; 7214 td_fps_table.html(previous_result + ' fps'); 7215 //console.log(previous_result); 7216 } 7217 7218 if (elapsed_time > 1) { 7219 td_fps.start_time = td_fps.current_time; 7220 td_fps.frame_number = 0; 7221 } 7222 7223 requestAnimationFrame(get_fps); 7224 }; 7225 7226 get_fps(); 7227 } 7228}; 7229 7230/** 7231 * Created by tagdiv on 16.02.2015. 7232 */ 7233 7234/* global jQuery: {} */ 7235/* global tdEvents: {} */ 7236 7237var tdAnimationScroll = {}; 7238 7239(function() { 7240 7241 'use strict'; 7242 7243 tdAnimationScroll = { 7244 7245 7246 // the bunch of tdAnimationScroll items 7247 items: [], 7248 7249 7250 7251 // the current request animation frame id 7252 rAFIndex: 0, 7253 7254 7255 7256 // flag used to not call 'requestAnimationFrame' when it's steel running 7257 animation_running: false, 7258 7259 7260 7261 item: function item() { 7262 7263 // the computed percent value of the jquery object in the viewport 7264 // - 0 when the top of object enters into the viewport 7265 // - 100 when the bottom of the object goes outside of the viewport 7266 this.percent_value = 0; 7267 7268 // the animation callback function 7269 this.animation_callback = null; 7270 7271 // the jquery object of the tdAnimationScroll.item 7272 this.jqueryObj = ''; 7273 7274 // optional - a jquery object that wraps the current item. Used in callback 7275 this.wrapper_jquery_obj = undefined; 7276 7277 // a jquery span obj added dynamically added at the top of jqueryObj 7278 this.top_marker_jquery_obj = ''; 7279 7280 // the full outer height of the item 7281 this.full_height = 0; 7282 7283 // the offset top of the top_marker_jquery_obj 7284 this.offset_top = ''; 7285 7286 // the offset top of the top_marker_jquery_obj and the full_height 7287 this.offset_bottom_top = ''; 7288 7289 // the properties registered with the item 7290 this.properties = {}; 7291 7292 // the computed properties that probably will be applied by animation callback function over the jquery object 7293 this.computed_item_properties = {}; 7294 7295 // flag made 'true' for items having at least one computed property 7296 this.redraw = false; 7297 7298 // top is out of screen 7299 this.top_is_out = false; 7300 7301 // flag used to mark the initialization item 7302 this._is_initialized = false; 7303 7304 // flag used to stop an item to be computed 7305 this.computation_stopped = false; 7306 7307 7308 7309 7310 /** 7311 * - when a new item property is added, it's added as a real property in the item.properties object. 7312 * - if it's already added, the settings of the property are appended 7313 * - the settings for an item property must be added in order of the percents 7314 * - the percent intervals must not be overloaded (ex. 10-30 and 20-40) 7315 * - it doesn't matter how many settings are added to an item property 7316 * - after an adding the space of percentage is full, that means after adding 7317 * ex: add_item_property('opacity', 10, 30, 0, 1, easing) 7318 * 7319 * item.properties.opacity.settings : 7320 * [ 7321 * [0, 10, 0, 0, ''] 7322 * [10, 30, 0, 1, easing] - property added 7323 * [30, 100, 1, 1, ''] 7324 * ] 7325 * 7326 * ex: add_item_property('opacity', 40, 50, 1, 0) 7327 * 7328 * item.properties.opacity.settings : 7329 * [ 7330 * [0, 10, 0, 0, ''] 7331 * [10, 30, 0, 1, easing] - property added 7332 * [30, 40, 1, 1, ''] 7333 * [40, 50, 1, 0, easing] - property added 7334 * [50, 100, 0, 0, ''] 7335 * ] 7336 * 7337 * - callable jQuery easing functions: 7338 * swing 7339 * easeInQuad 7340 * easeOutQuad 7341 * easeInOutQuad 7342 * easeInCubic 7343 * easeOutCubic 7344 * easeInOutCubic 7345 * easeInQuart 7346 * easeOutQuart 7347 * easeInOutQuart 7348 * easeInQuint 7349 * easeOutQuint 7350 * easeInOutQuint 7351 * easeInSine 7352 * easeOutSine 7353 * easeInOutSine 7354 * easeInExpo 7355 * easeOutExpo 7356 * easeInOutExpo 7357 * easeInCirc 7358 * easeOutCirc 7359 * easeInOutCirc 7360 * easeInElastic 7361 * easeOutElastic 7362 * easeInOutElastic 7363 * easeInBack 7364 * easeOutBack 7365 * easeInOutBack 7366 * easeInBounce 7367 * easeOutBounce 7368 * easeInOutBounce 7369 * 7370 * @param name string 7371 * @param start_percent numeric 7372 * @param end_percent numeric 7373 * @param start_value numeric 7374 * @param end_value numeric
7375 * @param easing string [optional] 7376 */ 7377 this.add_item_property = function add_item_property(name, start_percent, end_percent, start_value, end_value, easing) { 7378 7379 if (start_percent >= end_percent) { 7380 return; 7381 } 7382 7383 if (undefined === this.properties[name]) { 7384 7385 this.properties[name] = { 7386 computed_value: '', 7387 settings: [] 7388 }; 7389 7390 if (0 !== start_percent) { 7391 this.properties[name].settings[this.properties[name].settings.length] = { 7392 start_percent: 0, 7393 end_percent: start_percent, 7394 start_value: start_value, 7395 end_value: start_value, 7396 easing: '' 7397 }; 7398 } 7399 7400 this.properties[name].settings[this.properties[name].settings.length] = { 7401 start_percent: start_percent, 7402 end_percent: end_percent, 7403 start_value: start_value, 7404 end_value: end_value, 7405 easing: easing 7406 }; 7407 7408 this.properties[name].settings[this.properties[name].settings.length] = { 7409 start_percent: end_percent, 7410 end_percent: 100, 7411 start_value: end_value, 7412 end_value: end_value, 7413 easing: '' 7414 }; 7415 7416 } else { 7417 7418 var last_setting = this.properties[name].settings[this.properties[name].settings.length - 1]; 7419 7420 if (last_setting.start_percent !== start_percent) { 7421 this.properties[name].settings[this.properties[name].settings.length - 1] = { 7422 start_percent: last_setting.start_percent, 7423 end_percent: start_percent, 7424 start_value: last_setting.end_value, 7425 end_value: last_setting.end_value, 7426 easing: '' 7427 }; 7428 7429 this.properties[name].settings[this.properties[name].settings.length] = { 7430 start_percent: start_percent, 7431 end_percent: end_percent, 7432 start_value: start_value, 7433 end_value: end_value, 7434 easing: easing 7435 }; 7436 } else { 7437 this.properties[name].settings[this.properties[name].settings.length - 1] = { 7438 start_percent: start_percent, 7439 end_percent: end_percent, 7440 start_value: start_value, 7441 end_value: end_value, 7442 easing: easing 7443 }; 7444 } 7445 7446 if (100 !== end_percent) { 7447 this.properties[name].settings[this.properties[name].settings.length] = { 7448 start_percent: end_percent, 7449 end_percent: 100, 7450 start_value: end_value, 7451 end_value: end_value, 7452 easing: '' 7453 }; 7454 } 7455 } 7456 }; 7457 7458 7459 /** 7460 * remove an item property 7461 * 7462 * @param name {String} The name of the property 7463 * @returns {boolean} 7464 */ 7465 this.remove_item_property = function remove_item_property(name) { 7466 if (undefined === this.properties[name]) { 7467 return false; 7468 } 7469 7470 delete this.properties[name]; 7471 7472 return true; 7473 }; 7474 }, 7475 7476 7477 7478 7479 /** 7480 * - function used to init the tdAnimationScroll object 7481 * - it must be called before adding any item 7482 * - the _view_port_interval_index flag is initialized 7483 * - the items list is empty initialized 7484 */
7485 init: function init() { 7486 7487 tdAnimationScroll.items = []; 7488 }, 7489 7490 7491 7492 7493 /** 7494 * - used to add an item to the item list and initialize it 7495 * 7496 * @param item The item to be added and initialized 7497 */ 7498 add_item: function add_item(item) { 7499 7500 if (item.constructor !== tdAnimationScroll.item) { 7501 return; 7502 } 7503 7504 // the item is added in the item list 7505 tdAnimationScroll.items.push(item); 7506 7507 // the item is initialized only once when it is added 7508 tdAnimationScroll._initialize_item(item); 7509 7510 // for efficiently rendering all items are computed at once, so do not compute item individually 7511 }, 7512 7513 7514 7515 7516 /** 7517 * - used to initialize an item 7518 * - an item must be initialized only once 7519 * 7520 * @param item 7521 * @private 7522 */ 7523 _initialize_item: function _initialize_item(item) { 7524 7525 // an item must be initialized only once 7526 if (true === item._is_initialized) { 7527 return; 7528 } 7529 7530 // the item full height is computed 7531 if (undefined === item.wrapper_jquery_obj) { 7532 item.full_height = item.jqueryObj.outerHeight(true); 7533 } else { 7534 item.full_height = item.wrapper_jquery_obj.height(); 7535 } 7536 7537 if (0 === item.full_height) { 7538 return; 7539 } 7540 7541 var new_jquery_obj_reference = jQuery('<div class="td_marker_animation" style="height: 0; width: 0">'); 7542 7543 new_jquery_obj_reference.insertBefore(item.jqueryObj); 7544 7545 item.top_marker_jquery_obj = new_jquery_obj_reference; 7546 7547 item.offset_top = item.top_marker_jquery_obj.offset().top; 7548 7549 //console.log("initializare " + tdAnimationScroll.items.length + " : " + item.top_marker_jquery_obj.offset().top); 7550 7551 item.offset_bottom_top = item.offset_top + item.full_height; 7552 7553 item.top_is_out = tdEvents.window_pageYOffset > item.offset_top; 7554 7555 // the item is marked as initialized, being ready to be computed 7556 // for efficiently rendering all items are computed at once 7557 item._is_initialized = true; 7558 7559 7560 // maybe it's better to try a request animation frame after every initialization, for computing the already added items 7561 //tdAnimationScroll.compute_all_items(); 7562 }, 7563 7564 7565 7566 7567 /** 7568 * - used to reinitialize all items at the view resolution changing 7569 * 7570 * @param recompute_height boolean True if it's necessary to recompute the item's height [when view port changes] 7571 */ 7572 reinitialize_all_items: function reinitialize_all_items(recompute_height) { 7573 7574 for (var i = tdAnimationScroll.items.length - 1; i >= 0; i--) { 7575 tdAnimationScroll.reinitialize_item(tdAnimationScroll.items[i], recompute_height); 7576 } 7577 }, 7578 7579 7580 7581 7582 7583 7584 /** 7585 * - used to reinitialize an item at the view resolution changing 7586 * 7587 * @param item tdAnimationScroll.item 7588 * @param recompute_height boolean True if it's necessary to recompute the item height [when view port changes] 7589 * @private 7590 */ 7591 reinitialize_item: function reinitialize_item(item, recompute_height) { 7592 7593 // a not initialized item can't be reinitialized 7594 if (false === item._is_initialized) { 7595 return; 7596 } 7597 7598 // prevent the following item computing, till the reinitialization is finished 7599 item._is_initialized = false; 7600 7601 item.offset_top = item.top_marker_jquery_obj.offset().top; 7602 7603 //console.log("reinitializare " + tdAnimationScroll.items.length + " : " + item.top_marker_jquery_obj.offset().top); 7604 7605 if (true === recompute_height) { 7606 if (undefined === item.wrapper_jquery_obj) { 7607 item.full_height = item.jqueryObj.outerHeight(true); 7608 } else { 7609 item.full_height = item.wrapper_jquery_obj.height(); 7610 } 7611 7612 if (0 === item.full_height) { 7613 return; 7614 } 7615 } 7616 7617 item.offset_bottom_top = item.offset_top + item.full_height; 7618 7619 item._is_initialized = true; 7620 }, 7621 7622 7623 7624 7625 /**
7626 * - used for computing item properties 7627 * 7628 * @param item The item whose properties are computed 7629 * @private 7630 */ 7631 _compute_item_properties: function _compute_item_properties(item) { 7632 7633 var computed_properties = {}, 7634 current_item_property; 7635 7636 for (var property in item.properties) { 7637 7638 if (true === item.properties.hasOwnProperty(property)) { 7639 7640 current_item_property = item.properties[property]; 7641 7642 var current_setting, 7643 new_computed_value, 7644 local_computed_value, 7645 easing_step, 7646 easing_computed_value, 7647 easing_division_interval = 1000; 7648 7649 for (var i = 0; i < current_item_property.settings.length; i++) { 7650 7651 current_setting = current_item_property.settings[i]; 7652 7653 // the check is done using this form [...) of the interval or the last position 100% 7654 if ((current_setting.start_percent <= item.percent_value && item.percent_value < current_setting.end_percent) || 7655 (item.percent_value === current_setting.end_percent && 100 === item.percent_value)) { 7656 7657 if (current_setting.start_value === current_setting.end_value) { 7658 7659 new_computed_value = current_setting.start_value; 7660 7661 } else { 7662 7663 // local computed value can have a positive value or a negative value, it depends of the difference end_value - start_value 7664 // for a linear easing function, the new computed value is the start_value + local_computed_value 7665 // if start_value < end_value, the variable local_computed_value is positive 7666 // if start_value > end_value, the variable local_computed_value is negative 7667 local_computed_value = (item.percent_value - current_setting.start_percent) / (current_setting.end_percent - current_setting.start_percent) * (current_setting.end_value - current_setting.start_value); 7668 7669 7670 // if there's specified an easing function, it's applied over the computed_value 7671 if ((undefined === current_setting.easing) || ('' === current_setting.easing)) { 7672 7673 // linear easing function 7674 7675 new_computed_value = current_setting.start_value + local_computed_value; 7676 7677 } else { 7678 7679 // specifying an easing function 7680 7681 easing_step = Math.abs(current_setting.start_value - current_setting.end_value) / easing_division_interval; 7682 7683 if (current_setting.start_value < current_setting.end_value) { 7684 7685 easing_computed_value = current_setting.start_value + jQuery.easing[current_setting.easing]( 7686 null, 7687 local_computed_value, 7688 0, 7689 easing_step, 7690 current_setting.end_value - current_setting.start_value) * easing_division_interval; 7691 7692 } else { 7693 7694 easing_computed_value = current_setting.start_value - jQuery.easing[current_setting.easing]( 7695 null, 7696 -local_computed_value, 7697 0, 7698 easing_step, 7699 current_setting.start_value - current_setting.end_value) * easing_division_interval; 7700 } 7701 7702 new_computed_value = easing_computed_value; 7703 7704 //console.log(current_setting.easing + ' : ' + easing_step + ' ~ ' + easing_computed_value + ' ~ ' + (current_setting.start_value + computed_value) + ' & ' + current_setting.start_value + ' $ ' + current_setting.end_value); 7705 } 7706 } 7707 7708 // if the existing computed value is different, the new computed value is cached 7709 if (current_item_property.computed_value !== new_computed_value) { 7710 current_item_property.computed_value = new_computed_value; 7711 computed_properties[property] = new_computed_value; 7712 7713 // the item is marked that it has at least one property that need to be redraw 7714 // the animation callback functions are called just for the marked items 7715 item.redraw = true; 7716 } 7717 break; 7718 } 7719 } 7720 } 7721 } 7722 7723 // a plain javascript object is added if there is no computed property 7724 item.computed_item_properties = computed_properties; 7725 }, 7726 7727 7728 7729 7730 /**
7731 * - used for computing item 7732 * - the item properties are computed only when the item is in the view port and it is moving 7733 * 7734 * @param item The tdAnimationScroll.item to be computed 7735 */ 7736 compute_item: function compute_item(item) { 7737 //console.clear(); 7738 7739 // the item must be initialized first 7740 if (false === item._is_initialized) { 7741 return; 7742 } 7743 7744 var percent_display_value = 0; 7745 7746 if (tdEvents.window_pageYOffset + tdEvents.window_innerHeight >= item.offset_top) { 7747 7748 if (tdEvents.window_pageYOffset > item.offset_bottom_top) { 7749 percent_display_value = 100; 7750 } else { 7751 percent_display_value = (tdEvents.window_pageYOffset + tdEvents.window_innerHeight - item.offset_top) * 100 / (tdEvents.window_innerHeight + item.full_height); 7752 } 7753 } 7754 7755 //console.log(window.pageYOffset + ' : ' + item.offset_top + ' : ' + item.offset_bottom_top); 7756 7757 if (item.percent_value !== percent_display_value) { 7758 item.percent_value = percent_display_value; 7759 tdAnimationScroll._compute_item_properties(item); 7760 } 7761 7762 item.top_is_out = tdEvents.window_pageYOffset > item.offset_top; 7763 7764 7765 //console.log(percent_display_value); 7766 }, 7767 7768 7769 7770 7771 /** 7772 * - used to request an animation frame for computing all items 7773 * - the flag animation_running is set to false by the last requestAnimationFrame callback (the last animation call), 7774 * so a new call to requestAnimationFrame can be done 7775 */ 7776 compute_all_items: function compute_all_items() { 7777 //tdAnimationScroll.animate(); 7778 7779 if (false === tdAnimationScroll.animation_running) { 7780 tdAnimationScroll.rAFIndex = window.requestAnimationFrame( tdAnimationScroll._animate_all_items ); 7781 } 7782 7783 tdAnimationScroll.animation_running = true; 7784 }, 7785 7786 7787 7788 7789 /** 7790 * - used to call the existing callback animate functions 7791 * 7792 * @private 7793 */ 7794 _animate_all_items: function _animate_all_items() { 7795 //var start_time = Date.now(); 7796 7797 for (var i = 0; i < tdAnimationScroll.items.length; i++) { 7798 if ( false === tdAnimationScroll.items[i].computation_stopped) { 7799 tdAnimationScroll.compute_item(tdAnimationScroll.items[i]); 7800 } 7801 } 7802 7803 for (var j = 0; j < tdAnimationScroll.items.length; j++) { 7804 if (true === tdAnimationScroll.items[j].redraw) { 7805 tdAnimationScroll.items[j].animation_callback(); 7806 } 7807 } 7808 7809 tdAnimationScroll.animation_running = false; 7810 7811 //var end_time = Date.now(); 7812 // 7813 //var debug_table = jQuery("#debug_table"); 7814 //debug_table.html((end_time - start_time) + ' ms'); 7815 }, 7816 7817 7818 7819 7820 7821 /** @todo we'll see if it's necessary to make reinitialization just at the view port changing. Now, it's not 7822 * - necessary to be called when the window is being resized 7823 */ 7824 td_events_resize: function td_events_resize() { 7825 7826 if (0 === tdAnimationScroll.items.length) { 7827 return; 7828 } 7829 7830 // this will be applied if it depends just by view port changing 7831 7832 //if (tdAnimationScroll._changed_view_port_width()) { 7833 // tdAnimationScroll.reinitialize_all_items(); 7834 //} 7835 7836 tdAnimationScroll.reinitialize_all_items(false); 7837 7838 tdAnimationScroll.compute_all_items(); 7839 }, 7840 7841 7842 7843 7844 7845 7846 log: function log(msg) { 7847 //console.log(msg); 7848 } 7849 }; 7850 7851 tdAnimationScroll.init(); 7852 7853})(); 7854 7855 7856 7857/** 7858 * Created by tagdiv on 23.02.2015. 7859 */ 7860 7861var tdBackstr = {}; 7862 7863(function(){ 7864 7865 'use strict'; 7866 7867 tdBackstr = { 7868 7869 7870 items: [], 7871 7872 7873 item: function() { 7874 7875 // check if is necessary to apply modification (css) 7876 this.previous_value = 0; 7877 7878 // the image aspect ratio 7879 this.image_aspect_rate = 0; 7880 7881 // the wrapper jquery object 7882 this.wrapper_image_jquery_obj = ''; 7883 7884 // the image jquery object 7885 this.image_jquery_obj = ''; 7886 }, 7887 7888 7889 /** 7890 * 7891 * @param item 7892 */ 7893 add_item: function( item ) { 7894 7895 if ( item.constructor !== tdBackstr.item ) { 7896 return; 7897 } 7898 7899 //if ((item.image_jquery_obj.complete) 7900 // 7901 // // this is a case when the image is still not loaded but the height() and width() return both 24px 7902 // // @todo it must be modified. It's used because for backstretch are usually used large images 7903 // && ((item.image_jquery_obj.height() != 24) && (item.image_jquery_obj.width() != 24)) 7904 //) 7905
7906 if ( item.image_jquery_obj.get( 0 ).complete ) { 7907 tdBackstr._load_item_image( item ); 7908 7909 } else { 7910 7911 item.image_jquery_obj.on( 'load', function() { 7912 tdBackstr._load_item_image( item ); 7913 }); 7914 7915 7916 //var currentTimeStart = Date.now(); 7917 // 7918 //var loaded_image_jquery_ojb = false; 7919 // 7920 //item.image_jquery_obj.on('load', function() { 7921 // 7922 // loaded_image_jquery_ojb = true; 7923 // 7924 // 7925 // tdBackstr._load_item_image(item); 7926 // console.log('backstr tarziu ' + item.image_jquery_obj.height() + ' > timp : ' + (Date.now() - currentTimeStart)); 7927 //}); 7928 // 7929 // 7930 //var indexInterval = setInterval(function() { 7931 // if (loaded_image_jquery_ojb) { 7932 // clearInterval(indexInterval); 7933 // console.log('imagine incarcata ' + item.image_jquery_obj.height() + ' > timp : ' + (Date.now() - currentTimeStart)); 7934 // } 7935 //}, 0); 7936 } 7937 }, 7938 7939 7940 _load_item_image: function( item ) { 7941 item.image_aspect_rate = item.image_jquery_obj.width() / item.image_jquery_obj.height(); 7942 tdBackstr.items.push( item ); 7943 tdBackstr._compute_item( item ); 7944 7945 item.image_jquery_obj.css( 'opacity', '1' ); 7946 }, 7947 7948 7949 /** 7950 * 7951 * @param item 7952 * @private 7953 */ 7954 _compute_item: function( item ) { 7955 7956 // the wrapper aspect ratio can vary, so it's recomputed at computing item 7957 var wrapper_aspect_rate = item.wrapper_image_jquery_obj.width() / item.wrapper_image_jquery_obj.height(); 7958 7959 var current_value = 0; 7960 7961 if ( wrapper_aspect_rate < item.image_aspect_rate ) { 7962 7963 current_value = 1; 7964 7965 if ( item.previous_value !== current_value ) { 7966 item.image_jquery_obj.removeClass( 'td-stretch-width' ); 7967 item.image_jquery_obj.addClass( 'td-stretch-height' ); 7968 7969 item.previous_value = current_value; 7970 } 7971 } else { 7972 7973 current_value = 2; 7974 7975 if ( item.previous_value !== current_value ) { 7976 item.image_jquery_obj.removeClass( 'td-stretch-height' ); 7977 item.image_jquery_obj.addClass( 'td-stretch-width' ); 7978 7979 item.previous_value = current_value; 7980 } 7981 } 7982 }, 7983 7984 7985 /** 7986 * 7987 * @private 7988 */ 7989 _compute_all_items: function() { 7990 for ( var i = 0; i < tdBackstr.items.length; i++ ) { 7991 tdBackstr._compute_item( tdBackstr.items[ i ] ); 7992 } 7993 }, 7994 7995 7996 td_events_resize: function() { 7997 7998 if ( 0 === tdBackstr.items.length ) { 7999 return; 8000 } 8001 8002 tdBackstr._compute_all_items(); 8003 }, 8004 8005 8006 8007 8008 log: function( msg ) { 8009 window.console.log( msg ); 8010 } 8011 }; 8012 8013 8014})(); 8015 8016 8017 8018 8019/** 8020 * Created by tagdiv on 11.03.2015. 8021 */ 8022 8023/** 8024 * abstract: 8025 * - check all items in page, sort them using one of a sorted methods and add them in the items array 8026 * - at every scroll the items are verified if they are in view port or above 8027 * - every item in view port is added into the _items_in_view_port array and they are ready for animation 8028 * - items above view port are animated all at once 8029 * - items in view port are animated at crescendo intervals [interval / remaining items] 8030 * - there's a max and a min interval 8031 * - td_block ajax request response use a sort method and add founded items into view port array or into items array 8032 */ 8033 8034 8035/* global jQuery:false */ 8036/* global tdDetect:false */ 8037/* global tdEvents:{} */ 8038 8039var tdAnimationStack = {}; 8040 8041( function() { 8042 8043 "use strict"; 8044 8045 tdAnimationStack = { 8046 8047 /* 8048 Important: 8049 1. The first animation step is produced by the the body selector @see animation-stack.less 8050 2. The second animation step can be applied by the animation_css_class1 8051 3. The final (the main) animation step is applied by the animation_css_class2 8052 */ 8053 8054 8055 8056 8057 // - flag css class used by the non 'type0' animation effect 8058 // - flag used just to look for not yet computed item 8059 // - it's set by ready_init (on ready) 8060 // - all dom components that need to be animated will be marked with this css class in ready_init 8061 // - it can be used for a precomputed style, but carefully, because it's applied at ready_init (on ready) 8062 _animation_css_class1: '', 8063 8064 8065 8066 // - flag css class used by the non 'type0' animation effect 8067 // - flag css class used to animate custom 8068 // - this css class applies the final animation 8069 _animation_css_class2: '', 8070 8071 8072 8073 // - the default animation effect 'type0' is applied if the global window.td_animation_stack_effect is the empty string
8074 // - it's used for consistency of animation effects presented into the animation-stack.less [all types have a name (...type...)] 8075 _animation_default_effect: 'type0', 8076 8077 8078 8079 // - tdAnimationStack runs just only when this flag is true 8080 // - it's done true by the init function 8081 activated: false, 8082 8083 8084 8085 // flag checked by the major animation operations 8086 _ready_for_initialization: true, 8087 8088 // interval used by ready_init to check tdAnimationStack state 8089 _ready_init_timeout: undefined, 8090 8091 8092 // max time[ms] interval waiting for first tdAnimationStack.init call 8093 max_waiting_for_init: 3000, 8094 8095 8096 8097 // the specific selectors are used to look for new elements inside of the specific sections 8098 _specific_selectors: '', 8099 8100 // the general selectors are used to look for elements over extend areas in DOM 8101 _general_selectors: '', 8102 8103 8104 8105 8106 8107 8108 /** 8109 * - wait for tdAnimationStack.init() for max_waiting_for_init time 8110 * - if time is elapsed, the animation is canceled 8111 * - the ready_init is canceled by a fast tdAnimationStack.init call 8112 */ 8113 ready_init: function() { 8114 8115 // - special case for IE8 and IE9 (and if Visual Composer image carousel exists) 8116 // Important! The Visual Compose images carousel has hidden elements (images) that does not allow for computing the real position of the other DOM elements in the viewport 8117 // - the animation is forced removed and the altered css body is cleaned 8118 if ( tdDetect.isIe8 || tdDetect.isIe9 || ( jQuery( '.vc_images_carousel' ).length > 0 ) ) { 8119 tdAnimationStack._ready_for_initialization = false; 8120 8121 if ( undefined !== window.td_animation_stack_effect ) { 8122 if ( '' === window.td_animation_stack_effect ) { 8123 window.td_animation_stack_effect = tdAnimationStack._animation_default_effect; 8124 } 8125 jQuery( 'body' ).removeClass( 'td-animation-stack-' + window.td_animation_stack_effect ); 8126 } 8127 return; 8128 } 8129 8130 8131 if ( undefined === window.tds_animation_stack || undefined === window.td_animation_stack_effect ) { 8132 8133 // lock any further operation using the _ready_for_initialization flag 8134 tdAnimationStack._ready_for_initialization = false; 8135 8136 } else { 8137 8138 // the tdAnimationStack._specific_selectors is set by the global variable window.td_animation_stack_specific_selectors 8139 if ( undefined !== window.td_animation_stack_specific_selectors ) { 8140 tdAnimationStack._specific_selectors = window.td_animation_stack_specific_selectors; 8141 } 8142 8143 8144 // if the global variable window.td_animation_stack_effect has the empty string value, the 'full fade' (type0) effect is prepared to be applied 8145 if ( '' === window.td_animation_stack_effect ) { 8146 window.td_animation_stack_effect = tdAnimationStack._animation_default_effect; 8147 } 8148 8149 tdAnimationStack._animation_css_class1 = 'td-animation-stack-' + window.td_animation_stack_effect + '-1'; 8150 tdAnimationStack._animation_css_class2 = 'td-animation-stack-' + window.td_animation_stack_effect + '-2'; 8151 8152 8153 // - the tdAnimationStack._general_selectors is set by the global variable window.td_animation_stack_general_selectors 8154 if ( undefined !== window.td_animation_stack_general_selectors ) { 8155 tdAnimationStack._general_selectors = window.td_animation_stack_general_selectors; 8156 } 8157 8158 // the tdAnimationStack._animation_css_class1 css class is applied for all elements need to be animated later 8159 jQuery( tdAnimationStack._general_selectors ).addClass( tdAnimationStack._animation_css_class1 ); 8160 8161 8162 // - timeout used by the ready_init function, to cut down tdAnimationStack.init calling at loading page, when the call comes too late 8163 // - if tdAnimationStack.init comes earlier, it does a clearTimeout call over the tdAnimationStack._ready_init_timeout variable 8164 tdAnimationStack._ready_init_timeout = setTimeout( function() { 8165 8166 // if tdAnimationStack is activated, do nothing 8167 if ( true === tdAnimationStack.activated ) { 8168 return; 8169 } 8170 8171 // lock any further operation using the _ready_for_initialization flag 8172 tdAnimationStack._ready_for_initialization = false; 8173 8174 // remove the loading animation css class effect from the body 8175 // this class is applied from the theme settings 8176 if ( undefined !== window.td_animation_stack_effect ) { 8177 jQuery( 'body' ).removeClass( 'td-animation-stack-' + window.td_animation_stack_effect ); 8178 } 8179 8180 }, tdAnimationStack.max_waiting_for_init ); 8181 } 8182 }, 8183 8184 8185 // flag marks items where they are 8186 _ITEM_TO_VIEW_PORT: { 8187 8188 ITEM_ABOVE_VIEW_PORT: 0, 8189 8190 ITEM_IN_VIEW_PORT: 1, 8191 8192 ITEM_UNDER_VIEW_PORT: 2 8193 }, 8194 8195 8196 // predefined sorting methods 8197 SORTED_METHOD: { 8198 8199 sort_left_to_right: function sort_left_to_right( item1, item2 ) { 8200 if ( item1.offset_top > item2.offset_top ) { 8201 return 1; 8202 } else if ( item1.offset_top < item2.offset_top ) { 8203 return -1; 8204 } else if ( item1._order > item2._order ) { 8205 return 1; 8206 } else if ( item1._order < item2._order ) { 8207 return -1; 8208 } 8209 return 0; 8210 }, 8211 8212 8213 sort_right_to_left: function sort_right_to_left( item1, item2 ) { 8214 if ( item1.offset_top > item2.offset_top ) { 8215 return 1; 8216 } else if ( item1.offset_top < item2.offset_top ) { 8217 return -1; 8218 } else if ( item1._order > item2._order ) { 8219 return -1; 8220 } else if ( item1._order < item2._order ) { 8221 return 1; 8222 } 8223 return -1; 8224 } 8225 }, 8226 8227 8228 // keeps the DOM reading order, used in the sorting methods 8229 _order: 0, 8230 8231 8232 // interval divided to animate items 8233 // ex. interval 100 and 2 items => one item at 100 / 2 and one item at 100 / 1, but not lower than min_interval and not higher than max_interval 8234 interval: 70, 8235 8236 // min interval of a set timer 8237 min_interval: 17, 8238 8239 // max interval of a set timer 8240 max_interval: 40, 8241 8242 8243 8244 // keep current setInterval 8245 _current_interval: undefined, 8246 8247 // items in view port are moved here 8248 _items_in_view_port: [], 8249 8250 // items above the view port are moved here 8251 _items_above_view_port: [], 8252 8253 // all items that will be processed 8254 items: [], 8255 8256 8257 8258 8259 8260 8261 8262 8263 /** 8264 * - tdAnimationStack.item 8265 */ 8266 item: function() { 8267 // offset from the top of the item, to the top 8268 // it's set at the initialization item 8269 this.offset_top = undefined; 8270 8271 8272 // offset from the bottom of the item, to the top 8273 // it's set at the initialization item 8274 this.offset_bottom_to_top = undefined; 8275 8276 8277 // jquery object reference 8278 // it's set before the initialization of the item 8279 this.jqueryObj = undefined; 8280 8281 8282 // the reading order from DOM 8283 // it's set at the initialization item 8284 this._order = undefined; 8285 }, 8286 8287 8288 8289 8290 /** 8291 * - initialize a tdAnimationStack.item and add it in tdAnimationStack.items 8292 * @param item tdAnimationStack.item 8293 */ 8294 //add_item: function add_item(item) { 8295 // 8296 // if (item.constructor != tdAnimationStack.item) { 8297 // return; 8298 // } 8299 // 8300 // tdAnimationStack.items.push(item); 8301 //}, 8302 8303 8304 8305 /** 8306 * - initialize the offset top of the tdAnimationStack.item parameter 8307 * @param item tdAnimationStack.item 8308 * @private 8309 */ 8310 _initialize_item: function( item ) { 8311 item._order = tdAnimationStack._order++; 8312 8313 item.offset_top = item.jqueryObj.offset().top; 8314 //item.offset_relative = Math.sqrt(Math.pow(item.jqueryObj.offset().top, 2) + Math.pow(item.jqueryObj.offset().left, 2)); 8315 8316 item.offset_bottom_to_top = item.offset_top + item.jqueryObj.height(); 8317 8318 //item.jqueryObj.parent().prepend('<div class="debug_item" style="position: absolute; width: 100%; height: 20px; border: 1px solid red; background-color: white">' + item.offset_top + '</div>'); 8319 }, 8320 8321 8322 /** 8323 * - dynamically search for new elements to create new tdAnimationStack.item 8324 * - the items are added in the tdAnimationStack._items_in_view_port, that means they are ready to be animated, 8325 * or in the tdAnimationStack.items to be computed later (checked if they are in the view port and animated) 8326 * @param selector {string} - jQuery selector 8327 * @param sort_type {tdAnimationStack.SORTED_METHOD} - a preferred tdAnimationStack.SORTED_METHOD 8328 * @param in_view_port {boolean} - add an item in the tdAnimationStack._items_in_view_port or in the tdAnimationStack.items 8329 */ 8330 check_for_new_items: function( selector, sort_type, in_view_port ) { 8331 8332 // tdAnimationStack must be activated and not stopped for initialization by the ready_init checker 8333 if ( ( false === tdAnimationStack.activated ) || ( false === tdAnimationStack._ready_for_initialization ) ) { 8334 return; 8335 } 8336 8337 8338 if ( undefined === selector ) { 8339 selector = ''; 8340 } 8341 8342 8343 8344 // the local stack of searched items 8345 var local_stack = []; 8346 8347 8348 8349 //if (window.td_animation_stack_effect === 'type0') { 8350 // // for every founded element there's an instantiated tdAnimationStack.item, then initialized and added to the local stack 8351 // var founded_elements = jQuery(selector + ', .post').find(tdAnimationStack._specific_selectors).filter(function() { 8352 // return jQuery(this).css('opacity') === '0'; 8353 // });
8354 // 8355 //} else { 8356 jQuery( tdAnimationStack._general_selectors).not( '.' + tdAnimationStack._animation_css_class2 ).addClass( tdAnimationStack._animation_css_class1 ); 8357 8358 // for every founded element there's an instantiated tdAnimationStack.item, then initialized and added to the local stack 8359 var founded_elements = jQuery( selector + ', .post' ).find( tdAnimationStack._specific_selectors ).filter( function() { 8360 return jQuery( this ).hasClass( tdAnimationStack._animation_css_class1 ); 8361 }); 8362 //} 8363 8364 8365 8366 founded_elements.each( function( index, element ) { 8367 8368 var item_animation_stack = new tdAnimationStack.item(); 8369 8370 item_animation_stack.jqueryObj = jQuery( element ); 8371 8372 tdAnimationStack.log( index ); 8373 8374 tdAnimationStack._initialize_item( item_animation_stack ); 8375 8376 local_stack.push( item_animation_stack ); 8377 }); 8378 8379 8380 8381 // new scope having its own timer used for checking not yet loaded images 8382 ( function(){ 8383 8384 var images_loaded = true; 8385 8386 for ( var i = 0; i < local_stack.length; i++ ) { 8387 8388 // for every image element the 'complete' property is checked 8389 // "If the image is finished loading, the complete property returns true" 8390 // when tdAnimationStack.init is called on load, as normally, it calls tdAnimationStack.check_for_new_items and all these element has 'complete' property true 8391 // when tdAnimationStack.check_for_new_items is called by block's ajax response, the next timer is used to wait for all elements being loaded 8392 if ( false === founded_elements[ i ].complete ) { 8393 images_loaded = false; 8394 break; 8395 } 8396 } 8397 8398 // if there's at least one element not loaded, a timer is started to wait for 8399 if ( false === images_loaded ) { 8400 8401 var date = new Date(); 8402 var start_time = date.getTime(); 8403 8404 8405 tdAnimationStack.log( 'TIMER - started' ); 8406 8407 8408 // the timer is started 8409 var interval_check_loading_image = setInterval( function() { 8410 8411 // if there's too much time waiting for image loading, they are made visible 8412 var date = new Date(); 8413 8414 var i = 0; 8415 8416 if ( ( date.getTime() - start_time ) > tdAnimationStack.max_waiting_for_init ) { 8417 8418 clearInterval( interval_check_loading_image ); 8419 8420 for ( i = 0; i < local_stack.length; i++ ) { 8421 8422 8423 8424 8425 //if (window.td_animation_stack_effect === 'type0') { 8426 // local_stack[i].jqueryObj.css('opacity', 1); 8427 //} else { 8428 local_stack[ i ].jqueryObj.removeClass( tdAnimationStack._animation_css_class1 ); 8429 local_stack[ i ].jqueryObj.addClass( tdAnimationStack._animation_css_class2 ); 8430 //} 8431 8432 8433 8434 8435 8436 8437 } 8438 return; 8439 } 8440 8441 8442 // at every interval step, the element's 'complete' property is checked again 8443 images_loaded = true; 8444 8445 for ( i = 0; i < local_stack.length; i++ ) { 8446 8447 if ( false === founded_elements[ i ].complete ) { 8448 images_loaded = false; 8449 break; 8450 } 8451 } 8452 8453 if ( true === images_loaded ) { 8454 8455 clearInterval( interval_check_loading_image ); 8456 8457 tdAnimationStack.log( 'TIMER - stopped' ); 8458 8459 tdAnimationStack._precompute_items( local_stack, sort_type, in_view_port ); 8460 tdAnimationStack.compute_items();
8461 } 8462 8463 }, 100); 8464 8465 } else { 8466 tdAnimationStack._precompute_items( local_stack, sort_type, in_view_port ); 8467 tdAnimationStack.compute_items(); 8468 } 8469 8470 })(); 8471 8472 tdAnimationStack.log( 'checked for new items finished' ); 8473 }, 8474 8475 8476 /** 8477 * - _precompute_items sorts and adds items in the tdAnimationStack.items array or even in the 8478 * tdAnimationStack._items_in_view_port array 8479 * - this function is necessary because at scroll just the tdAnimationStack.compute_items function is called 8480 * 8481 * @param stack_items {[]} founded items 8482 * @param sort_type {function} sorting method 8483 * @param in_view_port {boolean} add in view port to be already computed, or in the general items array 8484 * @private 8485 */ 8486 _precompute_items: function( stack_items, sort_type, in_view_port ) { 8487 8488 stack_items.sort( sort_type ); 8489 8490 if ( true === in_view_port ) { 8491 8492 while ( stack_items.length > 0 ) { 8493 tdAnimationStack.log( 'add item 1 : ' + stack_items.length ); 8494 tdAnimationStack._items_in_view_port.push( stack_items.shift() ); 8495 } 8496 8497 } else { 8498 8499 while (stack_items.length > 0) { 8500 tdAnimationStack.log( 'add item 2 : ' + stack_items.length ); 8501 tdAnimationStack.items.push( stack_items.shift() ); 8502 } 8503 } 8504 }, 8505 8506 8507 8508 /** 8509 * - IT'S CALLED ON PAGE LOAD [actually in tdLastInit.js] 8510 * - the general init function 8511 * - the items are added to the tdAnimationStack.items using check_for_new_items method, and then computed 8512 * - the arrays are cleared to be prepared for a reinitialization 8513 */ 8514 init: function() { 8515 if ( undefined === window.tds_animation_stack ) { 8516 return; 8517 } 8518 8519 // tdAnimationStack must not be already stopped for initialization by a pre_init checker 8520 if ( false === tdAnimationStack._ready_for_initialization ) { 8521 return; 8522 } 8523 8524 // clear the _ready_init_timeout, to stop it doing more checking 8525 clearTimeout( tdAnimationStack._ready_init_timeout ); 8526 8527 // the tdAnimationStack is activated 8528 tdAnimationStack.activated = true; 8529 8530 tdAnimationStack.check_for_new_items( '.td-animation-stack', tdAnimationStack.SORTED_METHOD.sort_left_to_right, false ); 8531 }, 8532 8533 8534 /** 8535 * - the arrays are cleared to be prepared for a reinitialization 8536 * - the init call is done 8537 */ 8538 reinit: function() { 8539 8540 // tdAnimationStack must not be already stopped for initialization by a pre_init checker 8541 if ( false === tdAnimationStack._ready_for_initialization ) { 8542 return; 8543 } 8544 8545 tdAnimationStack.items = []; 8546 tdAnimationStack._items_in_view_port = []; 8547 tdAnimationStack._items_above_view_port = []; 8548 8549 tdAnimationStack.init(); 8550 }, 8551 8552 8553 /** 8554 * - compute all items 8555 */ 8556 compute_items: function() { 8557 8558 // tdAnimationStack must be activated and not stopped for initialization by the ready_init checker 8559 if ( ( false === tdAnimationStack.activated ) || ( false === tdAnimationStack._ready_for_initialization ) ) { 8560 return; 8561 } 8562 8563 // the tdAnimationStack.items are processed 8564 tdAnimationStack._separate_items(); 8565 8566 // the items above the port view are animated 8567 while ( tdAnimationStack._items_above_view_port.length > 0 ) { 8568 tdAnimationStack.log( 'animation - above the view port' ); 8569 8570 var item_above_view_port = tdAnimationStack._items_above_view_port.shift(); 8571 8572 8573 8574 //if (window.td_animation_stack_effect === 'type0') { 8575 // item_above_view_port.jqueryObj.css('opacity', 1); 8576 //} else { 8577 item_above_view_port.jqueryObj.removeClass( tdAnimationStack._animation_css_class1 ); 8578 item_above_view_port.jqueryObj.addClass( tdAnimationStack._animation_css_class2 ); 8579 //} 8580 8581 8582 8583 8584 } 8585 8586 8587 // the items in the port view are prepared to be animated 8588 if ( tdAnimationStack._items_in_view_port.length > 0 ) { 8589 8590 // clear any opened interval by a previous compute_items call 8591 clearInterval( tdAnimationStack._current_interval ); 8592 8593 var current_animation_item = tdAnimationStack._get_item_from_view_port(); 8594 8595 8596 8597 8598 //if (window.td_animation_stack_effect === 'type0') { 8599 // current_animation_item.jqueryObj.css('opacity', 1); 8600 //} else { 8601 current_animation_item.jqueryObj.removeClass( tdAnimationStack._animation_css_class1 ); 8602 current_animation_item.jqueryObj.addClass( tdAnimationStack._animation_css_class2 ); 8603 // } 8604 8605 8606 8607 8608 8609 if ( tdAnimationStack._items_in_view_port.length > 0 ) { 8610 8611 tdAnimationStack.log( 'start animation timer' ); 8612 8613 tdAnimationStack._to_timer( tdAnimationStack._get_right_interval( tdAnimationStack.interval * ( 1 / tdAnimationStack._items_in_view_port.length ) ) ); 8614 } 8615 } 8616 }, 8617 8618 8619 /** 8620 * - timer function initially called by a tdAnimationStack.compute_items function, and then it's auto called 8621 * - it calls a setInterval using the interval parameter 8622 * @param interval {int} - interval ms 8623 */ 8624 _to_timer: function( interval ) { 8625 8626 tdAnimationStack._current_interval = setInterval( function () { 8627 8628 if ( tdAnimationStack._items_in_view_port.length > 0 ) { 8629 8630 var current_animation_item = tdAnimationStack._get_item_from_view_port(); 8631 8632 tdAnimationStack.log( 'animation at interval: ' + interval ); 8633 8634 8635 8636 8637 //if (window.td_animation_stack_effect === 'type0') { 8638 // current_animation_item.jqueryObj.css('opacity', 1); 8639 //} else { 8640 current_animation_item.jqueryObj.removeClass( tdAnimationStack._animation_css_class1 ); 8641 current_animation_item.jqueryObj.addClass( tdAnimationStack._animation_css_class2 ); 8642 //} 8643 8644 8645 8646 8647 clearInterval( tdAnimationStack._current_interval ); 8648 8649 if ( tdAnimationStack._items_in_view_port.length > 0 ) { 8650 tdAnimationStack._to_timer( tdAnimationStack._get_right_interval( tdAnimationStack.interval * ( 1 / tdAnimationStack._items_in_view_port.length ) ) ); 8651 } 8652 } 8653 }, interval ); 8654 }, 8655 8656 8657 /** 8658 * - get an item from the tdAnimationStack._items_in_view_port array 8659 * @returns {tdAnimationStack.item} 8660 * @private 8661 */ 8662 _get_item_from_view_port: function() { 8663 8664 return tdAnimationStack._items_in_view_port.shift(); 8665 }, 8666 8667 8668 8669 /** 8670 * - get the interval considering tdAnimationStack.min_interval and tdAnimationStack.max_interval 8671 * @param interval {int} - the checked interval value 8672 * @returns {int} - the result interval value 8673 * @private 8674 */ 8675 _get_right_interval: function( interval ) { 8676 8677 if ( interval < tdAnimationStack.min_interval ) { 8678 return tdAnimationStack.min_interval; 8679 8680 } else if ( interval > tdAnimationStack.max_interval ) { 8681 return tdAnimationStack.max_interval; 8682 } 8683 return interval; 8684 }, 8685 8686 8687 /** 8688 * - check where the item is to the view port 8689 * @param item {tdAnimationStack.item} 8690 * @returns {number} _ITEM_TO_VIEW_PORT value 8691 * @private 8692 */ 8693 _item_to_view_port: function( item ) { 8694 8695 tdAnimationStack.log( 'position item relative to the view port >>
8695 ' + tdEvents.window_pageYOffset + tdEvents.window_innerHeight + ' : ' + item.offset_top ); 8696 8697 if ( tdEvents.window_pageYOffset + tdEvents.window_innerHeight < item.offset_top ) { 8698 return tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_UNDER_VIEW_PORT; 8699 8700 } else if ( ( tdEvents.window_pageYOffset + tdEvents.window_innerHeight >= item.offset_top ) && ( tdEvents.window_pageYOffset <= item.offset_bottom_to_top ) ) { 8701 return tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_IN_VIEW_PORT; 8702 8703 } 8704 return tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_ABOVE_VIEW_PORT; 8705 }, 8706 8707 8708 /** 8709 * - check the sorted tdAnimationStack.items and move them into the _items_above_view_port array or into the _items_in_view_port 8710 * - the remaining items are kept by the tdAnimationStack.items for next processing 8711 * @private 8712 */ 8713 _separate_items: function() { 8714 if ( 0 === tdAnimationStack.items.length ) { 8715 return; 8716 } 8717 8718 while ( tdAnimationStack.items.length > 0 ) { 8719 var item_to_view_port = tdAnimationStack._item_to_view_port( tdAnimationStack.items[ 0 ] ); 8720 8721 switch ( item_to_view_port ) { 8722 case tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_ABOVE_VIEW_PORT : 8723 tdAnimationStack._items_above_view_port.push( tdAnimationStack.items.shift() ); 8724 break; 8725 8726 case tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_IN_VIEW_PORT : 8727 tdAnimationStack._items_in_view_port.push( tdAnimationStack.items.shift() ); 8728 break; 8729 8730 case tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_UNDER_VIEW_PORT : 8731 tdAnimationStack.log( 'after separation items >> above: ' + tdAnimationStack._items_above_view_port.length + ' in: ' + tdAnimationStack._items_in_view_port.length + ' under: ' + tdAnimationStack.items.length ); 8732 return; 8733 } 8734 } 8735 }, 8736 8737 8738 /** 8739 * - scroll event usually called by tdCustomEvents 8740 */ 8741 td_events_scroll: function() { 8742 tdAnimationStack.compute_items(); 8743 }, 8744 8745 8746 8747 /** 8748 * - resize event usually called by tdCustomEvents 8749 */ 8750 td_events_resize: function() { 8751 // clear an existing interval 8752 clearInterval( tdAnimationStack._current_interval ); 8753 8754 // reinitialize tdAnimationStack searching in page for not already animated items [which were already repositioned by resize] 8755 tdAnimationStack.reinit(); 8756 }, 8757 8758 8759 8760 log: function( msg ) { 8761 //console.log(msg); 8762 } 8763 8764 }; 8765})(); 8766 8767/* global jQuery:{} */ 8768/* global tdSmartSidebar:{} */ 8769/* global tdUtil:{} */ 8770/* global tdDetect:{} */ 8771/* global tdPullDown:{} */ 8772/* global tdAnimationScroll:{} */ 8773/* global tdAnimationStack:{} */ 8774/* global tdEvents:{} */ 8775/* global tdAffix:{} */ 8776 8777'use strict'; 8778 8779/** 8780 * affix menu 8781 */ 8782tdAffix.init({ 8783 menu_selector: '.td-header-menu-wrap', 8784 menu_wrap_selector: '.td-header-menu-wrap-full', 8785 tds_snap_menu: tdUtil.getBackendVar('tds_snap_menu'), 8786 tds_snap_menu_logo: tdUtil.getBackendVar('tds_logo_on_sticky'), 8787 menu_affix_height: 48, // value must be set because it can't be computed at runtime because at the time of td_affix.init() we can have no affixed menu on page 8788 menu_affix_height_on_mobile: 54 8789}); 8790 8791 8792/** 8793 * smooth scroll init 8794 */ 8795/* 8796jQuery().ready(function () { 8797 if (tdDetect.isChrome === true && tdDetect.isOsx === false) { 8798 td_smooth_scroll(); 8799 } 8800}); 8801*/ 8802 8803 8804/** 8805 * sidebar init 8806 */ 8807if (tdUtil.getBackendVar('tds_smart_sidebar') == 'enabled' && tdDetect.isIos === false) { 8808 jQuery(window).load(function() { 8809 // find the rows and the sidebars objects and add them to the magic sidebar object array 8810 jQuery('.td-ss-row').each(function () { 8811 //@todo check to see if the sidebar + content is pressent 8812 var td_smart_sidebar_item = new tdSmartSidebar.item(); 8813 td_smart_sidebar_item.sidebar_jquery_obj = jQuery(this).children('.td-pb-span4').children('.wpb_wrapper'); 8814 td_smart_sidebar_item.content_jquery_obj = jQuery(this).children('.td-pb-span8').children('.wpb_wrapper'); 8815 tdSmartSidebar.add_item(td_smart_sidebar_item); 8816 }); 8817 8818 8819 8820 // check the page to see if we have smart sidebar classes (.td-ss-main-content and .td-ss-main-sidebar) 8821 if (jQuery('.td-ss-main-content').length > 0 && jQuery('.td-ss-main-sidebar').length > 0) { 8822 var td_smart_sidebar_item = new tdSmartSidebar.item(); 8823 td_smart_sidebar_item.sidebar_jquery_obj = jQuery('.td-ss-main-sidebar'); 8824 td_smart_sidebar_item.content_jquery_obj = jQuery('.td-ss-main-content'); 8825 tdSmartSidebar.add_item(td_smart_sidebar_item); 8826 } 8827 8828 tdSmartSidebar.td_events_resize(); 8829 });
8830} 8831 8832 8833/** 8834 * pulldown lists 8835 * 8836 */ 8837 8838jQuery('.td-subcat-filter').each(function(index, element) { 8839 var jquery_object_container = jQuery(element); 8840 var horizontal_jquery_obj = jquery_object_container.find('.td-subcat-list:first'); 8841 var vertical_jquery_obj = jquery_object_container.find('.td-subcat-dropdown:first'); 8842 8843 if (horizontal_jquery_obj.length == 1 && vertical_jquery_obj.length == 1) { 8844 8845 var pulldown_item_obj = new tdPullDown.item(); 8846 8847 pulldown_item_obj.horizontal_jquery_obj = horizontal_jquery_obj; 8848 pulldown_item_obj.vertical_jquery_obj = vertical_jquery_obj; 8849 pulldown_item_obj.horizontal_element_css_class = 'td-subcat-item'; 8850 pulldown_item_obj.container_jquery_obj = horizontal_jquery_obj.parents('.td_block_wrap:first'); 8851 pulldown_item_obj.excluded_jquery_elements = [horizontal_jquery_obj.parent().siblings('.block-title:first')]; 8852 8853 tdPullDown.add_item(pulldown_item_obj); 8854 } 8855}); 8856 8857jQuery('.td-category-siblings').each(function(index, element) { 8858 var jquery_object_container = jQuery(element); 8859 var horizontal_jquery_obj = jquery_object_container.find('.td-category:first'); 8860 var vertical_jquery_obj = jquery_object_container.find('.td-subcat-dropdown:first'); 8861 8862 if (horizontal_jquery_obj.length == 1 && vertical_jquery_obj.length == 1) { 8863 8864 var pulldown_item_obj = new tdPullDown.item(); 8865 8866 pulldown_item_obj.horizontal_jquery_obj = horizontal_jquery_obj; 8867 pulldown_item_obj.vertical_jquery_obj = vertical_jquery_obj; 8868 pulldown_item_obj.horizontal_element_css_class = 'entry-category'; 8869 pulldown_item_obj.container_jquery_obj = horizontal_jquery_obj.parents('.td-category-siblings:first'); 8870 8871 tdPullDown.add_item(pulldown_item_obj); 8872 } 8873}); 8874 8875 8876 8877 8878 8879/** 8880 * parallax effect 8881 */ 8882 8883// array keeping the tdAnimationScroll.item items used for backstretch 8884var td_backstretch_items = []; 8885 8886 8887jQuery(window).ready(function() { 8888 8889 jQuery('.td-backstretch').each(function (index, element) { 8890 8891 if (!jQuery(element).hasClass('not-parallax')) { 8892 8893 var item = new tdAnimationScroll.item(); 8894 item.jqueryObj = jQuery(element); 8895 item.wrapper_jquery_obj = item.jqueryObj.parent(); 8896 8897 // - ideal translation is when the top of wrapper_jquery_obj is at the top of the view port, the jqueryObj image 8898 // is also already translated at the top of the view port 8899 // - the start_value should be item.wrapper_jquery_obj.offset().top + how much the jqueryObj was translated 8900 8901 tdAnimationScroll.add_item(item); 8902 8903 // we keep the tdAnimationScroll.item to change operation settings when the viewport is changing 8904 td_backstretch_items.push(item); 8905 8906 td_compute_backstretch_item(item); 8907 } 8908 }); 8909 8910 8911 jQuery('.td-parallax-header').each(function (index, element) { 8912 8913 var item = new tdAnimationScroll.item(); 8914 item.jqueryObj = jQuery(element); 8915 8916 item.add_item_property('move_y', 50, 100, 0, 100, ''); 8917 item.add_item_property('opacity', 50, 100, 1, 0, ''); 8918 8919 item.animation_callback = function () { 8920 8921 var move_y_property = parseFloat(item.computed_item_properties['move_y']).toFixed(); 8922 var opacity_property = parseFloat(item.computed_item_properties['opacity']); 8923 8924 item.jqueryObj.css({ 8925 '-webkit-transform': 'translate3d(0px,' + move_y_property + 'px, 0px)', 8926 'transform': 'translate3d(0px,' + move_y_property + 'px, 0px)' 8927 }); 8928 8929 item.jqueryObj.css('transform', 'translate3d(0px,' + move_y_property + 'px, 0px)'); 8930 8931 item.jqueryObj.css('opacity', opacity_property); 8932 8933 item.redraw = false; 8934 } 8935 8936 tdAnimationScroll.add_item(item); 8937 }); 8938 8939 8940 tdAnimationScroll.compute_all_items(); 8941 8942 8943 8944 8945 // load animation stack 8946 tdAnimationStack.ready_init(); 8947}); 8948 8949 8950 8951 8952/** 8953 * Function used to register the 'move_y' property for every td_animations_scroll.item item of the td_backstretch_items array. 8954 * It scales the object image and translate it. At first it is translated so its bottom is at the bottom of the viewport, 8955 * but considering the backstretch css classes applied 8956 * 8957 * @param item tdAnimationScroll.item 8958 */ 8959function td_compute_backstretch_item(item) { 8960 8961 // Important! The following variables must be computed after add_item calling function, because they need item.full_height, item.offset_top, etc 8962 8963 // percent when the object is in initial position 8964 // Important! It doesn't matter if the document is scrolled
8965 var initial_percent = (tdEvents.window_innerHeight - item.offset_top) * 100 / (tdEvents.window_innerHeight + item.full_height); 8966 8967 // percent when the object has its top at the top of the window 8968 var intermediary_top_percent = (tdEvents.window_innerHeight) * 100 / (tdEvents.window_innerHeight + item.full_height); 8969 8970 8971 // IMPORTANT! We suppose the item.offset_top is positive 8972 8973 8974 // the value used to compute the scale_factor 8975 // Important! It can be any value 8976 var scale_seed = item.offset_top / 4; 8977 8978 // if item.offset_top is zero, we set the scale_seed at a custom value 8979 if (scale_seed == 0) { 8980 scale_seed = 100; 8981 } 8982 8983 // the start_value is half of the scale_seed, so the object [image] is translated as its bottom is at the bottom of its view 8984 var start_value = - scale_seed / 2; 8985 8986 8987 // DO NOT DELETE THE NEXT CODE LINES. The right value would be the next, but the divide operation does not have 100% accuracy, so we increase the interval 8988 // and so we are sure the object is not translated more than needed when is at the top of the window 8989 // 8990 // When the top of the view is at the top of the window, the object [image] must be already translated at the top of the window. 8991 // 8992 //var end_value = ((100 - initial_percent) * scale_seed) / (intermediary_top_percent - initial_percent);; 8993 // 8994 //or actually 8995 // 8996 //var end_value = ((100 - initial_percent) * (item.offset_top / 2)) / (intermediary_top_percent - initial_percent);; 8997 8998 var end_value = ((100 - initial_percent) * (scale_seed / 1.2)) / (intermediary_top_percent - initial_percent); 8999 9000 // fix for firefox. It rounds up and loose 1 pixel 9001 start_value += 0.5; 9002 9003 9004 // if there already exists a 'move_y' property, it is removed 9005 item.remove_item_property('move_y'); 9006 9007 item.add_item_property('move_y', initial_percent, 100, start_value, end_value, ''); 9008 9009 9010 var scale_factor = parseFloat(1 + Math.abs(scale_seed) / item.full_height).toFixed(2); 9011 9012 9013 // if there's already registered an 'animation_callback' function, it is removed 9014 delete item.animation_callback; 9015 9016 item.animation_callback = function () { 9017 9018 var property_value = parseFloat(item.computed_item_properties['move_y']).toFixed(); 9019 9020 item.jqueryObj.css({ 9021 'left': '50%', 9022 '-webkit-transform': 'translate3d(-50%,' + property_value + 'px, 0px) scale(' + scale_factor + ',' + scale_factor + ')', 9023 'transform': 'translate3d(-50%,' + property_value + 'px, 0px) scale(' + scale_factor + ',' + scale_factor + ')' 9024 }); 9025 9026 item.redraw = false; 9027 }; 9028} 9029 9030/** 9031 * Created by ra on 8/12/2015. 9032 */ 9033 9034/* global jQuery:false */ 9035/* global tdInfiniteLoader:false */ 9036/* global tdAnimationStack:{} */ 9037/* global tdSmartSidebar:false */ 9038/* global tdLoadingBox:{} */ 9039/* global tds_theme_color_site_wide:string */ 9040 9041 9042/* global td_ajax_url:false */ 9043 9044/** 9045 * tdAjaxLoop.init() is called from: @see includes/wp_booster/td_page_generator::render_infinite_pagination 9046 */ 9047var tdAjaxLoop = {}; 9048 9049(function () { 9050 'use strict'; 9051 9052 tdAjaxLoop = { 9053 loopState: { 9054 'sidebarPosition': '', 9055 'moduleId': 1, 9056 'currentPage': 1, 9057 'max_num_pages': 0, 9058 'atts' : {}, 9059 'ajax_pagination_infinite_stop' : 0, 9060 'server_reply_html_data': '' 9061 }, 9062 9063 9064 /** 9065 * tdAjaxLoop.init() is called from: @see includes/wp_booster/td_page_generator::render_infinite_pagination 9066 * only when needed 9067 */ 9068 init: function () { 9069 jQuery('.td-ajax-loop-infinite').each( function() { 9070 // create a new infinite loader item 9071 var tdInfiniteLoaderItem = new tdInfiniteLoader.item(); 9072 9073 tdInfiniteLoaderItem.jqueryObj = jQuery(this); 9074 tdInfiniteLoaderItem.uid = 'tdAjaxLoop'; 9075 9076 9077 /** 9078 * the callback when the bottom of the element is visible on screen and we need to do something - like load another page 9079 * - the callback does not fire again until tdInfiniteLoader.enable_is_visible_c
9079allback is called @see tdInfiniteLoader.js:95 9080 */ 9081 tdInfiniteLoaderItem.isVisibleCallback = function () { // the is_visible callback is called when we have to pull new content up because the element is visible 9082 9083 if ( 9084 0 !== tdAjaxLoop.loopState.ajax_pagination_infinite_stop && 9085 tdAjaxLoop.loopState.currentPage >= tdAjaxLoop.loopState.ajax_pagination_infinite_stop && 9086 tdAjaxLoop.loopState.currentPage + 1 < tdAjaxLoop.loopState.max_num_pages // do we have a next page? 9087 ) { 9088 // stop the callback and show the load more button 9089 jQuery('.td-load-more-infinite-wrap') 9090 .css('display', 'block') 9091 .css('visibility', 'visible') 9092 ; 9093 9094 } else { 9095 // load up the next page 9096 tdAjaxLoop.infiniteNextPage(false); 9097 } 9098 }; 9099 tdInfiniteLoader.addItem(tdInfiniteLoaderItem); 9100 }); 9101 9102 9103 // click on load more - the button should not be visible only when the ajax_pagination_infinite_stop limit is reached 9104 jQuery('.td-load-more-infinite-wrap').click(function(event) { 9105 event.preventDefault(); 9106 9107 9108 jQuery('.td-load-more-infinite-wrap').css('visibility', 'hidden'); 9109 9110 tdAjaxLoop.infiniteNextPage(true); 9111 }); 9112 }, 9113 9114 9115 infiniteNextPage: function (isLoadMoreButton) { 9116 9117 // prepare the request object 9118 tdAjaxLoop.loopState.currentPage++ ; 9119 tdAjaxLoop.loopState.server_reply_html_data = ''; 9120 9121 // check here to avoid making an unnecessary ajax request when using infinite loading without button 9122 if ( tdAjaxLoop.loopState.currentPage > tdAjaxLoop.loopState.max_num_pages ) { 9123 //console.log('END' + tdAjaxLoop.loopState.currentPage + ' max: ' + tdAjaxLoop.loopState.max_num_pages); 9124 return; 9125 } 9126 9127 9128 9129 jQuery('.td-ss-main-content').append('<div class="td-loader-gif td-loader-infinite td-loader-animation-start"></div>'); 9130 tdLoadingBox.init(tds_theme_color_site_wide, 45); //init the loading box 9131 setTimeout(function () { 9132 jQuery('.td-loader-gif') 9133 .removeClass('td-loader-animation-start') 9134 .addClass('td-loader-animation-mid'); 9135 }, 50); 9136 9137 9138 var requestData = { 9139 action: 'td_ajax_loop', 9140 loopState: tdAjaxLoop.loopState 9141 }; 9142 9143 //console.log('request:'); 9144 //console.log(tdAjaxLoop.loopState); 9145 jQuery.ajax({ 9146 type: 'POST', 9147 url: td_ajax_url, 9148 cache:true, 9149 data: requestData, 9150 success: function(data, textStatus, XMLHttpRequest) { 9151 tdAjaxLoop._processAjaxRequest(data, isLoadMoreButton); 9152 }, 9153 error: function(MLHttpRequest, textStatus, errorThrown) { 9154 //console.log(errorThrown); 9155 } 9156 }); 9157 }, 9158 9159 _processAjaxRequest: function (data, isLoadMoreButton) { 9160 // stop the loader 9161 jQuery('.td-loader-gif').remove(); 9162 tdLoadingBox.stop(); 9163 9164 var dataObj = jQuery.parseJSON(data); 9165 9166 9167 9168 // empty reply - stop everything 9169 if ( '' === dataObj.server_reply_html_data ) { 9170 jQuery('.td-load-more-infinite-wrap').css('visibility', 'hidden'); 9171 return; 9172 } 9173 9174 9175 /** 9176 * @var {tdAjaxLoop.loopState} 9177 */ 9178 9179 jQuery('.td-ajax-loop-infinite').before(dataObj.server_reply_html_data); 9180 9181 //console.log('reply:'); 9182 //console.log(dataObj); 9183 9184 if ( parseInt( dataObj.currentPage ) >= parseInt(dataObj.max_num_pages) ) { 9185 jQuery('.td-load-more-infinite-wrap').css('visibility', 'hidden'); 9186 } else { 9187 if ( true === isLoadMoreButton ) { 9188 jQuery('.td-load-more-infinite-wrap').css('visibility', 'visible'); 9189 } 9190 } 9191 9192 setTimeout( function () { 9193 tdAnimationStack.check_for_new_items('.td-main-content' + ' .td-animation-stack', tdAnimationStack.SORTED_METHOD.sort_left_to_right, true); 9194 //tdSmartSidebar.compute(); 9195 }, 200); 9196 9197 9198 // on load more button, we don't have to compute the infinite loader event 9199 if ( true === isLoadMoreButton ) { 9200 return; 9201 } 9202 9203 setTimeout( function() { 9204 //refresh waypoints for infinit scroll tdInfiniteLoader 9205 tdInfiniteLoader.computeTopDistances();
9206 tdInfiniteLoader.enable_is_visible_callback('tdAjaxLoop'); 9207 //tdSmartSidebar.compute(); 9208 }, 500); 9209 9210 9211 setTimeout( function() { 9212 tdInfiniteLoader.computeTopDistances(); 9213 }, 1000); 9214 9215 setTimeout( function() { 9216 tdInfiniteLoader.computeTopDistances(); 9217 }, 1500); 9218 9219 } 9220 }; 9221 9222})(); 9223/** 9224 * Created by ra on 9/30/2015. 9225 */ 9226 9227/* 9228 tdWeather.js 9229 v1.0 9230 */ 9231/* global jQuery:false */ 9232/* global tdDetect:false */ 9233/* global tdUtil:false */ 9234/* global alert:false */ 9235/* global tdLocalCache:false */ 9236 9237 9238 9239 9240var tdWeather = {}; 9241 9242( function(){ 9243 "use strict"; 9244 9245 tdWeather = { 9246 9247 // used to translate the OWM code to icon 9248 _icons: { 9249 // day 9250 '01d' : 'clear-sky-d', 9251 '02d' : 'few-clouds-d', 9252 '03d' : 'scattered-clouds-d', 9253 '04d' : 'broken-clouds-d', 9254 '09d' : 'shower-rain-d', // ploaie hardcore 9255 '10d' : 'rain-d', // ploaie light 9256 '11d' : 'thunderstorm-d', 9257 '13d' : 'snow-d', 9258 '50d' : 'mist-d', 9259 9260 //night: 9261 '01n' : 'clear-sky-n', 9262 '02n' : 'few-clouds-n', 9263 '03n' : 'scattered-clouds-n', 9264 '04n' : 'broken-clouds-n', 9265 '09n' : 'shower-rain-n', // ploaie hardcore 9266 '10n' : 'rain-n', // ploaie light 9267 '11n' : 'thunderstorm-n', 9268 '13n' : 'snow-n', 9269 '50n' : 'mist-n' 9270 }, 9271 9272 _currentRequestInProgress: false, // prevent multiple parallel requests 9273 _currentItem: '', // current weather object, it is set on click and after we modify it, it will be displayed 9274 9275 // latitude and longitude position, used in callback hell 9276 _currentLatitude: 0, 9277 _currentLongitude: 0, 9278 _currentPositionCacheKey: '', 9279 9280 // all the weather items 9281 items: [], /** an item is json encoded from this in PHP: @see td_weather::$weather_data */ 9282 9283 9284 9285 /** 9286 * Init the class, we hook the click event 9287 */ 9288 init: function () { 9289 9290 // weather location button click 9291 jQuery('.td-icons-location').click(function() { 9292 if (tdWeather._currentRequestInProgress === true) { 9293 return; 9294 } 9295 tdWeather._currentRequestInProgress = true; 9296 9297 // get the block id 9298 tdWeather._currentItem = tdWeather._getItemByBlockID(jQuery(this).data('block-uid')); 9299 9300 // get the position + callback 9301 var timeoutVal = 10 * 1000 * 1000; 9302 if (navigator.geolocation) { 9303 navigator.geolocation.getCurrentPosition(tdWeather._updateLocationCallback, tdWeather._displayLocationApiError, {enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 600000}); 9304 } 9305 9306 }); 9307 9308 jQuery('.td-weather-now').click(function(){ 9309 if (tdWeather._currentRequestInProgress === true) { 9310 return; 9311 } 9312 tdWeather._currentRequestInProgress = true; 9313 9314 // get the block id 9315 tdWeather._currentItem = tdWeather._getItemByBlockID(jQuery(this).data('block-uid')); 9316 9317 if (tdWeather._currentItem.current_unit === 1) { 9318 tdWeather._currentItem.current_unit = 0; 9319 } else { 9320 tdWeather._currentItem.current_unit = 1; 9321 } 9322 tdWeather._renderCurrentItem(); 9323 }); 9324 }, 9325 9326 9327 /** 9328 * 1. LOCATION api - position callback 9329 * @param position 9330 * @private 9331 */ 9332 _updateLocationCallback: function(position) { 9333 tdWeather._currentLatitude = position.coords.latitude; 9334 tdWeather._currentLongitude = position.coords.longitude; 9335 tdWeather._currentPositionCacheKey = position.coords.latitude + '_' + position.coords.longitude; // update the cache key for current position 9336 9337 // check the cache first and avoid doing the same ajax request again 9338 if (tdLocalCache.exist(tdWeather._currentPositionCacheKey + '_today')) { 9339 tdWeather._owmGetTodayDataCallback(tdLocalCache.get(tdWeather._currentPositionCacheKey + '_today')); 9340 } else { 9341 var weather = 'http://api.openweathermap.org/data/2.5/weather?lat=' + tdWeather._currentLatitude + '&lon=' + tdWeather._currentLongitude + '&units=metric&lang=' + tdWeather._currentItem.api_language + '&appid=' + tdWeather._currentItem.api_key; 9342 jQuery.ajax({ 9343 dataType: "jsonp", 9344 url: weather, 9345 success: tdWeather._owmGetTodayDataCallback, 9346 cache: true 9347 }); 9348 } 9349 9350 //alert(position.coords.latitude + ' ' + position.coords.longitude); 9351 9352 }, 9353 9354 9355 /** 9356 * 2. AJAX callback for today forecast, this also makes a call to ajax 5 days forecast 9357 * @param data - OWM api response - NOTICE: We don't check anything if it's correct :) 9358 * @private 9359 */ 9360 _owmGetTodayDataCallback: function (data) { 9361 // save the data to localCache 9362 tdLocalCache.set(tdWeather._currentPositionCacheKey + '_today', data); 9363 9364 9365 // prepare the tdWeather._currentItem object, notice that tdWeather._currentItem is a reference to an object stored in tdWeather.items 9366 tdWeather._currentItem.api_location = data.name; 9367 tdWeather._currentItem.today_clouds = tdUtil.round(data.clouds.all); 9368 tdWeather._currentItem.today_humidity = tdUtil.round(data.main.humidity); 9369 tdWeather._currentItem.today_icon = tdWeather._icons[data.weather[0].icon]; 9370 tdWeather._currentItem.today_icon_text = data.weather[0].description; 9371 tdWeather._currentItem.today_max[0] = tdUtil.round(data.main.temp_max, 1); //celsius 9372 tdWeather._currentItem.today_max[1] = tdWeather._celsiusToFahrenheit(data.main.temp_max); //imperial 9373 tdWeather._currentItem.today_min[0] = tdUtil.round(data.main.temp_min, 1); //celsius 9374 tdWeather._currentItem.today_min[1] = tdWeather._celsiusToFahrenheit(data.main.temp_min); //imperial 9375 tdWeather._currentItem.today_temp[0] = tdUtil.round(data.main.temp, 1); //celsius 9376 tdWeather._currentItem.today_temp[1] = tdWeather._celsiusToFahrenheit(data.main.temp); //imperial 9377 tdWeather._currentItem.today_wind_speed[0] = tdUtil.round(data.wind.speed, 1); //metric 9378 tdWeather._currentItem.today_wind_speed[1] = tdWeather._kmphToMph(data.wind.speed); //imperial 9379 9380 //console.log(tdWeather._currentItem); 9381 //console.log(data); 9382 9383 // check the cache first and avoid doing the same ajax request again 9384 if (tdLocalCache.exist(tdWeather._currentPositionCacheKey)) { 9385 tdWeather._owmGetFiveDaysData(tdLocalCache.get(tdWeather._currentPositionCacheKey)); 9386 } else { 9387 var weather = 'http://api.openweathermap.org/data/2.5/forecast/daily?lat=' + tdWeather._currentLatitude + '&lon=' + tdWeather._currentLongitude + '&units=metric&lang=' + tdWeather._currentItem.api_language + '&appid=' + tdWeather._currentItem.api_key; 9388 jQuery.ajax({ 9389 dataType: "jsonp", 9390 url: weather, 9391 success: tdWeather._owmGetFiveDaysData, 9392 cache:true 9393 }); 9394 } 9395 9396 }, 9397 9398 9399 /** 9400 * 3. AJAX callback for the 5 days forecast 9401 * @param data - OWM api response NOTICE: We don't check anything if it's correct :) 9402 * @private 9403 */ 9404 _owmGetFiveDaysData: function (data) { 9405 // save the data to localCache 9406 tdLocalCache.set(tdWeather._currentPositionCacheKey, data); 9407 9408 // process the data 9409 for (var item_index = 0; item_index < tdWeather._currentItem.forecast.length ; item_index++) { 9410 var current_forecast = tdWeather._currentItem.forecast[item_index]; 9411 current_forecast.day_temp[0] = tdUtil.round(data.list[current_forecast.owm_day_index].temp.day); //celsius 9412 current_forecast.day_temp[1] = tdWeather._celsiusToFahrenheit(current_forecast.day_temp[0]); //imperial 9413 } 9414 tdWeather._renderCurrentItem(); 9415 }, 9416 9417 9418 /** 9419 * 4. Here we render the global tdWeather._currentItem object to the screen. The object already contains all the needed information 9420 * about where and what we have to render. 9421 * @private 9422 */ 9423 _renderCurrentItem: function () { 9424 9425 //console.log('.' + tdWeather._currentItem.block_uid + ' .td-weather-city'); 9426 9427 var blockInner = jQuery('#' + tdWeather._currentItem.block_uid); 9428 9429 // city 9430 blockInner.find('.td-weather-city').html(tdWeather._currentItem.api_location); 9431 9432 // conditions 9433 blockInner.find('.td-weather-condition').html(tdWeather._currentItem.today_icon_text); 9434 9435 // animation 9436 // we remove all the classes! including the animation ones 9437 var icon_el = blockInner.find('.td-w-today-icon'); 9438 icon_el.removeClass(); 9439 icon_el.addClass('td-w-today-icon'); 9440 icon_el.addClass(tdWeather._currentItem.today_icon); 9441 9442 var currentTempUnit = tdWeather._currentItem.current_unit; 9443 var currentSpeedLabel = 'kmh'; 9444 var currentTempLabel = 'C'; 9445 9446 // preapare the labels 9447 if (currentTempUnit === 1) { 9448 currentSpeedLabel = 'mph'; 9449 currentTempLabel = 'F'; 9450 } 9451 9452 9453 // main temp 9454 blockInner.find('.td-big-degrees').html(tdWeather._currentItem.today_temp[currentTempUnit]); 9455 9456 // main temp units 9457 blockInner.find('.td-weather-unit').html(currentTempLabel); 9458 9459 9460 // high 9461 blockInner.find('.td-w-high-temp').html(tdWeather._currentItem.today_max[currentTempUnit]); 9462 9463 // low 9464 blockInner.find('.td-w-low-temp').html(tdWeather._currentItem.today_min[currentTempUnit]); 9465 9466 // humidity 9467 blockInner.find('.td-w-today-humidity').html(tdWeather._currentItem.today_humidity + '%'); 9468 9469 // wind speed 9470 blockInner.find('.td-w-today-wind-speed').html(tdWeather._currentItem.today_wind_speed[currentTempUnit] + currentSpeedLabel); 9471 9472 // clouds 9473 blockInner.find('.td-w-today-clouds').html(tdWeather._currentItem.today_clouds + '%'); 9474 9475 // full list of items! - just the temperature 9476 for (var item_index = 0; item_index < tdWeather._currentItem.forecast.length ; item_index++) { 9477 blockInner.find('.td-degrees-' + item_index).html(tdWeather._currentItem.forecast[item_index].day_temp[currentTempUnit]); 9478 } 9479 9480 9481 tdWeather._currentRequestInProgress = false; // allow other requests to take place 9482 }, 9483 9484 9485 /** 9486 * gets a weather item based on block_uid 9487 * @param block_uid 9488 * @returns {*} 9489 * @private 9490 */ 9491 _getItemByBlockID: function (block_uid) { 9492 for (var item_index = 0; item_index < tdWeather.items.length; item_index++) { 9493 if (tdWeather.items[item_index].block_uid === block_uid) { 9494 return tdWeather.items[item_index]; 9495 } 9496 } 9497 return false; 9498 }, 9499 9500 9501 /**
9502 * Displays a friendly error when the location api fails 9503 * @param error - a location api error object? 9504 * @private 9505 */ 9506 _displayLocationApiError: function (error) { 9507 9508 if (error.code === 1) { 9509 if (tdDetect.isAndroid) { 9510 alert('Please enable your gps and reload the page.'); 9511 return; 9512 } 9513 9514 else if (tdDetect.isIos) { 9515 alert("Please enable Location services for Safari Websites and reload the page. \n ---------------------- \nSettings > Privacy > Location Services"); 9516 return; 9517 } 9518 9519 9520 alert("Permission denied. Enable GPS or Location services and reload the page"); 9521 return; 9522 9523 } 9524 9525 // the rest of the errors 9526 var errors = { 9527 2: 'Position unavailable', 9528 3: 'Request timeout' 9529 }; 9530 alert("Error: " + errors[error.code]); 9531 }, 9532 9533 9534 /** 9535 * C to F converter. It rounds on big F numbers because we don't have space on the UI. 9536 * @param celsiusDegrees 9537 * @returns {*} 9538 * @private 9539 */ 9540 _celsiusToFahrenheit: function (celsiusDegrees) { 9541 var f_degrees = celsiusDegrees * 9 / 5 + 32; 9542 9543 var rounded_val = tdUtil.round(f_degrees, 1); 9544 if (rounded_val > 99.9) { // if the value is bigger than 100, round it 9545 return tdUtil.round(f_degrees); 9546 } 9547 9548 return rounded_val; 9549 }, 9550 9551 /** 9552 * converter for KMH -> MPH ex: 2.3 9553 * @param $kmph 9554 * @returns {*} 9555 * @private 9556 */ 9557 _kmphToMph: function ($kmph) { 9558 return tdUtil.round($kmph * 0.621371192, 1); 9559 } 9560 9561 }; // end tdWeather 9562})(); 9563 9564tdWeather.init(); //init the class 9565/* global jQuery:{} */ 9566/* global tdUtil:{} */ 9567/* global tdTrendingNowObject:{} */ 9568 9569jQuery( window ).load(function() { 9570 9571 'use strict'; 9572 9573 jQuery( 'body' ).addClass( 'td-js-loaded' ); 9574 9575 window.tdAnimationStack.init(); 9576}); 9577 9578jQuery( window ).ready(function() { 9579 9580 'use strict'; 9581 9582 /* 9583 - code used to allow external links from td_smart_list, when the Google Yoast "Track outbound click and downloads" is checked 9584 - internal links ("#with-hash") are allowed too 9585 */ 9586 9587 jQuery( '.td_smart_list_1 a, .td_smart_list_3 a' ).click(function( event ) { 9588 9589 if ( event.target === event.currentTarget ) { 9590 var currentUrl = jQuery( this ).attr( 'href' ); 9591 9592 if ( ( window.location.href !== currentUrl ) && tdUtil.isValidUrl( currentUrl ) ) { 9593 window.location.href = currentUrl; 9594 } 9595 } 9596 }); 9597 9598 //trending now 9599 tdTrendingNowObject.tdTrendingNow(); 9600 9601 //call to trending now function to start auto scroll 9602 tdTrendingNowObject.tdTrendingNowAutoStart(); 9603}); 9604 9605/** 9606 * Created by tagdiv on 29.09.2015. 9607 */ 9608 9609/* global jQuery:{} */ 9610 9611var tdAnimationSprite = {}; 9612 9613(function(){ 9614 'use strict'; 9615 9616 tdAnimationSprite = { 9617 9618 items: [], 9619 9620 // flag used to not call requestAnimationFrame until the previous requestAnimationFrame callback runs 9621 isInRequestAnimation: false, 9622 9623 9624 // The item that needs animation 9625 item: function item() { 9626 9627 // boolean - an item must be initialized only once 9628 this._isInitialized = false; 9629 9630 // boolean - an item can be paused and restarted 9631 this.paused = false; 9632 9633 // boolean - the animation automatically starts at the computing item 9634 this.automatStart = true; 9635 9636 // object - css properties that will be changed (key - value; ex: 'color' : '#00FFCC') 9637 this.properties = []; 9638 9639 // boolean - flag used by the requestAnimationFrame callback to know which items have properties to apply 9640 this.readyToAnimate = false; 9641 9642 // the index of the current frame 9643 this.nextFrame = 1; 9644 9645 // number - the current interval id set for the animation 9646 this.interval = undefined; 9647 9648 // the jquery obj whose background will be animated 9649 this.jqueryObj = undefined; 9650 9651 // the css class selector of the jqueryObj 9652 this.animationSpriteClass = undefined; 9653 9654 // string - default direction for parsing the sprite img 9655 this._currentDirection = 'right'; 9656 9657 // number - the executed loops 9658 this._executedLoops = 0; 9659 9660 9661 // string - css background position 9662 this._prop_background_position = undefined; 9663 9664 9665 // The followings will be set from the class selector 9666 9667 // int - number of frames (it must be greater than 1 to allow animation) 9668 this.frames = undefined; 9669 9670 // the width(px) of a frame 9671 this.frameWidth = undefined; 9672 9673 // int - the interval time (ms) the animation runs 9674 this.velocity = undefined; 9675 9676 // boolean - to the right and vice versa 9677 this.reverse = undefined; 9678 9679 // number - number of loops to animate 9680 this.loops = undefined; 9681 9682 9683 // Function actually compute the params for animation, prepare the params for next animation and calls t 9684 // he requestAnimationFrame with a callback function to animate all items ready for animation 9685 this.animate = function() { 9686 9687 this._prop_background_position = ( -1 * this.nextFrame * this.frameWidth ) + 'px 0'; 9688 this.readyToAnimate = true; 9689 9690 9691 // The nextFrame value is computed for next frame 9692 if ( true === this.reverse) { 9693 9694 if ( 'right' === this._currentDirection ) { 9695 9696 if ( this.nextFrame === this.frames - 1 ) { 9697 this._currentDirection = 'left'; 9698 this.nextFrame--; 9699 } else { 9700 this.nextFrame++; 9701 } 9702 9703 } else if ( 'left' === this._currentDirection ) { 9704 if ( 0 === this.nextFrame ) { 9705 9706 this._currentDirection = 'right'; 9707 this.nextFrame++; 9708 this._executedLoops++; 9709 9710 if ( ( 0 !== this.loops ) && ( this._executedLoops === this.loops ) ) { 9711 clearInterval( this.interval ); 9712 } 9713 } else { 9714 this.nextFrame--; 9715 } 9716 } 9717 9718 } else { 9719 9720 if ( this.nextFrame === this.frames - 1 ) { 9721 9722 this._executedLoops++; 9723 9724 // complete tour ( once to the right ), so we stop 9725 if ( ( 0 !== this.loops ) && ( this._executedLoops === this.loops ) ) { 9726 clearInterval( this.interval ); 9727 } 9728 9729 this.nextFrame = 0; 9730 } else { 9731 this.nextFrame++; 9732 } 9733 } 9734 9735 9736 //this.jqueryObj.css('background-position', horizontalPosition + 'px 0'); 9737 9738 // Any calls to requestAnimationFrame are stopped. Anyway, the settings of the current item are ready, 9739 // so the callback will consider it. 9740 if ( false === tdAnimationSprite.isInRequestAnimation ) { 9741 tdAnimationSprite.isInRequestAnimation = true; 9742 window.requestAnimationFrame( tdAnimationSprite.animateAllItems ); 9743 } 9744 }; 9745 }, 9746 9747 /** 9748 * The css class selector must be some like this 'td_animation_sprite-10-50-500-0-1-1' 9749 * It must start with 'td_animation_sprite' 9750 * Fields order: 9751 * - number of frames 9752 * - width of a frame 9753 * - velocity in ms 9754 * - loops (number) : reload the animation cycle at infinity or specify the number of loops 9755 * - reverse (0 or 1) : the loop include, or not, the reverse path 9756 * - automatstart (0 or 1) : the item animation starts, or not, automatically 9757 * 9758 * @param item 9759 * @private 9760 */ 9761 _initializeItem: function( item ) { 9762 if ( ( true === item._isInitialized ) ) { 9763 return; 9764 } 9765 9766 // get all strings containing 'td_animation_sprite' 9767 var regex = /(td_animation_sprite\S*)/gi; 9768 9769 // resultMatch is an array of matches, or null if there's no matching 9770 var resultMatch = item.jqueryObj.attr( 'class' ).match( regex ); 9771 9772 if ( null !== resultMatch ) { 9773 9774 item.offsetTop = item.jqueryObj.offset().top; 9775 item.offsetBottomToTop = item.offsetTop + item.jqueryObj.height(); 9776 9777 // the last matching is considered, because new css classes that matches, can be added before recomputing an item 9778 item.animationSpriteClass = resultMatch[ resultMatch.length - 1 ]; 9779 9780 var sceneParams = item.animationSpriteClass.split( '-' ); 9781
9782 if ( 7 === sceneParams.length ) { 9783 9784 item.frames = parseInt( sceneParams[1] ); 9785 item.frameWidth = parseInt( sceneParams[2] ); 9786 item.velocity = parseInt( sceneParams[3] ); 9787 item.loops = parseInt( sceneParams[4] ); 9788 9789 if ( 1 === parseInt( sceneParams[5] ) ) { 9790 item.reverse = true; 9791 } else { 9792 item.reverse = false; 9793 } 9794 9795 if ( 1 === parseInt( sceneParams[6] ) ) { 9796 item.automatStart = true; 9797 } else { 9798 item.automatStart = false; 9799 } 9800 9801 item._isInitialized = true; 9802 } 9803 } 9804 }, 9805 9806 addItem: function( item ) { 9807 9808 if ( item.constructor === tdAnimationSprite.item ) { 9809 tdAnimationSprite.items.push( item ); 9810 tdAnimationSprite._initializeItem( item ); 9811 9812 if ( true === item.automatStart ) { 9813 tdAnimationSprite.computeItem( item ); 9814 } 9815 } 9816 }, 9817 9818 computeItem: function( item ) { 9819 9820 // set interval just for frames greater than 1 9821 if ( item.frames > 1 ) { 9822 9823 // Check the item interval to not be set 9824 if ( undefined !== item.interval ) { 9825 return; 9826 } 9827 9828 item.interval = setInterval(function(){ 9829 9830 if ( false === item.paused ) { 9831 item.animate(); 9832 } 9833 9834 }, item.velocity ); 9835 } 9836 }, 9837 9838 // At recomputing, an item will check again its last css class selector and it is reinitialized. So, if a new 9839 // css class selector is added, it will use it. This way the animation can be modified 9840 recomputeItem: function( item ) { 9841 9842 // stop any animation 9843 clearInterval( item.interval ); 9844 9845 // reset the item interval 9846 item.interval = undefined; 9847 9848 // reset the _isInitialized flag 9849 item._isInitialized = false; 9850 9851 // reinitialize item 9852 tdAnimationSprite._initializeItem( item ); 9853 9854 // compute the item again 9855 tdAnimationSprite.computeItem( item ); 9856 }, 9857 9858 // Clear the interval set for an item. 9859 stopItem: function( item ) { 9860 if ( ( item.constructor === tdAnimationSprite.item ) && ( true === item._isInitialized ) ) { 9861 clearInterval( item.interval ); 9862 9863 // reset the item interval 9864 item.interval = undefined; 9865 } 9866 }, 9867 9868 // Start animation of a paused item 9869 startItem: function( item ) { 9870 if ( ( item.constructor === tdAnimationSprite.item ) && ( true === item._isInitialized ) ) { 9871 item.paused = false; 9872 } 9873 }, 9874 9875 // Pause animation of an item 9876 pauseItem: function( item ) { 9877 if ( ( item.constructor === tdAnimationSprite.item ) && ( true === item._isInitialized ) ) { 9878 item.paused = true; 9879 } 9880 }, 9881 9882 9883 9884 9885 computeAllItems: function() { 9886 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 9887 tdAnimationSprite.computeItem( tdAnimationSprite.items[i] ); 9888 } 9889 }, 9890 9891 recomputeAllItems: function() { 9892 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 9893 tdAnimationSprite.recomputeItem( tdAnimationSprite.items[i] ); 9894 } 9895 }, 9896 9897 stopAllItems: function() { 9898 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 9899 tdAnimationSprite.stopItem( tdAnimationSprite.items[i] ); 9900 } 9901 }, 9902 9903 pauseAllItems: function() { 9904 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 9905 tdAnimationSprite.pauseItem( tdAnimationSprite.items[i] ); 9906 } 9907 }, 9908 9909 startAllItems: function() { 9910 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 9911 tdAnimationSprite.startItem( tdAnimationSprite.items[i] ); 9912 } 9913 }, 9914 9915 9916 // The requestAnimationFrame callback function. 9917 // The 'background-position' is set and then the 'readyToAnimate' flag is set to false 9918 animateAllItems: function() { 9919 var currentItem; 9920 9921 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 9922 currentItem = tdAnimationSprite.items[i]; 9923 if ( true === currentItem.readyToAnimate ) { 9924 currentItem.jqueryObj.css( 'background-position', currentItem._prop_background_position ); 9925 currentItem.readyToAnimate = false; 9926 } 9927 } 9928 tdAnimationSprite.isInRequestAnimation = false; 9929 } 9930 }; 9931 9932 /* 9933 <div class="td_animation_sprite-a-b-c-d-e-f"></div> 9934 9935 a - number of frames 9936 b - width(px) of a frame 9937 c - velocity 9938 d - loops number (0 for infinity) 9939 e - loop include reverse 9940 f - animation start automatically 9941 */ 9942 9943 var tdAnimationSpriteElements = jQuery( 'span[class^="td_animation_sprite"]' ); 9944 9945 for ( var i = 0; i < tdAnimationSpriteElements.length; i++ ) { 9946 var tdAnimationSpriteItem = new tdAnimationSprite.item(); 9947 tdAnimationSpriteItem.jqueryObj = jQuery( tdAnimationSpriteElements[i] ); 9948 tdAnimationSprite.addItem( tdAnimationSpriteItem ); 9949 } 9950})(); 9951
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.