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 89/* global jQuery:false */ 90 91 92var tdDetect = {}; 93 94( function(){ 95 "use strict"; 96 tdDetect = { 97 isIe8: false, 98 isIe9 : false, 99 isIe10 : false, 100 isIe11 : false, 101 isIe : false, 102 isSafari : false, 103 isChrome : false, 104 isIpad : false, 105 isTouchDevice : false, 106 hasHistory : false, 107 isPhoneScreen : false, 108 isIos : false, 109 isAndroid : false, 110 isOsx : false, 111 isFirefox : false, 112 isWinOs : false, 113 isMobileDevice:false, 114 htmlJqueryObj:null, //here we keep the jQuery object for the HTML element 115 116 /** 117 * function to check the phone screen 118 * @see tdEvents 119 * The jQuery windows width is not reliable cross browser! 120 */ 121 runIsPhoneScreen: function () { 122 if ( (jQuery(window).width() < 768 || jQuery(window).height() < 768) && false === tdDetect.isIpad ) { 123 tdDetect.isPhoneScreen = true; 124 125 } else { 126 tdDetect.isPhoneScreen = false; 127 } 128 }, 129 130 131 set: function (detector_name, value) { 132 tdDetect[detector_name] = value; 133 //alert('tdDetect: ' + detector_name + ': ' + value); 134 } 135 }; 136 137 138 tdDetect.htmlJqueryObj = jQuery('html'); 139 140 141 // is touch device ? 142 if ( -1 !== navigator.appVersion.indexOf("Win") ) { 143 tdDetect.set('isWinOs', true); 144 } 145 146 // it looks like it has to have ontouchstart in window and NOT be windows OS. Why? we don't know. 147 if ( !!('ontouchstart' in window) && !tdDetect.isWinOs ) { 148 tdDetect.set('isTouchDevice', true); 149 } 150 151 152 // detect ie8 153 if ( tdDetect.htmlJqueryObj.is('.ie8') ) { 154 tdDetect.set('isIe8', true); 155 tdDetect.set('isIe', true); 156 } 157 158 // detect ie9 159 if ( tdDetect.htmlJqueryObj.is('.ie9') ) { 160 tdDetect.set('isIe9', true); 161 tdDetect.set('isIe', true); 162 } 163 164 // detect ie10 - also adds the ie10 class //it also detects windows mobile IE as IE10 165 if( navigator.userAgent.indexOf("MSIE 10.0") > -1 ){ 166 tdDetect.set('isIe10', true); 167 tdDetect.set('isIe', true); 168 } 169 170 //ie 11 check - also adds the ie11 class - it may detect ie on windows mobile 171 if ( !!navigator.userAgent.match(/Trident.*rv\:11\./) ){ 172 tdDetect.set('isIe11', true); 173 //this.isIe = true; //do not flag ie11 as isIe
174 } 175 176 177 //do we have html5 history support? 178 if (window.history && window.history.pushState) { 179 tdDetect.set('hasHistory', true); 180 } 181 182 //check for safary 183 if ( -1 !== navigator.userAgent.indexOf('Safari') && -1 === navigator.userAgent.indexOf('Chrome') ) { 184 tdDetect.set('isSafari', true); 185 } 186 187 //chrome and chrome-ium check 188 if (/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())) { 189 tdDetect.set('isChrome', true); 190 } 191 192 if ( null !== navigator.userAgent.match(/iPad/i)) { 193 tdDetect.set('isIpad', true); 194 } 195 196 197 if (/(iPad|iPhone|iPod)/g.test( navigator.userAgent )) { 198 tdDetect.set('isIos', true); 199 } 200 201 202 //detect if we run on a mobile device - ipad included - used by the modal / scroll to @see scrollIntoView 203 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { 204 tdDetect.set('isMobileDevice', true); 205 } 206 207 tdDetect.runIsPhoneScreen(); 208 209 //test for android 210 var user_agent = navigator.userAgent.toLowerCase(); 211 if ( user_agent.indexOf("android") > -1 ) { 212 tdDetect.set('isAndroid', true); 213 } 214 215 216 if ( -1 !== navigator.userAgent.indexOf('Mac OS X') ) { 217 tdDetect.set('isOsx', true); 218 } 219 220 if ( -1 !== navigator.userAgent.indexOf('Firefox') ) { 221 tdDetect.set('isFirefox', true); 222 } 223 224})(); 225 226/** 227 * Created by tagdiv on 13.05.2015. 228 */ 229 230/* global tdDetect: {} */ 231/* global jQuery: {} */ 232 233var tdViewport = {}; 234 235(function(){ 236 237 "use strict"; 238 239 tdViewport = { 240 241 /** 242 * - initial (default) value of the _currentIntervalIndex 243 * - it's used by third part libraries 244 * - it used just as constant value 245 */ 246 INTERVAL_INITIAL_INDEX: -1, 247 248 249 250 /** 251 * - keep the current interval index 252 * - it should be modified/taken just by setter/getter methods 253 * - after computing, it should not be a negative value 254 */ 255 _currentIntervalIndex : tdViewport.INTERVAL_INITIAL_INDEX, 256 257 258 259 /** 260 * - it keeps the interval index 261 * - it should be modified/taken just by setter/getter methods 262 * - it must be a crescendo positive values 263 */ 264 _intervalList : [], 265 266 267 268 /** 269 * 270 */ 271 init: function() { 272 if (('undefined' !== typeof window.td_viewport_interval_list) && (Array === window.td_viewport_interval_list.constructor)) { 273 274 for (var i = 0; i < window.td_viewport_interval_list.length; i++) { 275 var item = new tdViewport.item(); 276 277 var currentVal = window.td_viewport_interval_list[i]; 278 279 // the check is done to be sure that the intervals are well formatted 280 if (!currentVal.hasOwnProperty('limitBottom') || !currentVal.hasOwnProperty('sidebarWidth')) { 281 break; 282 } 283 284 item.limitBottom = currentVal.limitBottom; 285 item.sidebarWidth = currentVal.sidebarWidth; 286 287 tdViewport._items.push(item); 288 } 289 290 tdViewport.detectChanges(); 291 } 292 }, 293 294 295 296 /** 297 * - getter of the _currentIntervalIndex 298 * - it should be used by outsiders libraries 299 * @returns {*} 300 */ 301 getCurrentIntervalIndex : function() { 302 return tdViewport._currentIntervalIndex; 303 }, 304 305 306 307 /** 308 * - setter of the _intervalList 309 - it should be used by outsiders libraries 310 * @param value 311 */ 312 setIntervalList : function(value) { 313 tdViewport._intervalList = value; 314 }, 315 316 317 318 /** 319 * - getter of the _intervalList 320 * - it should be used by outsiders libraries 321 * @returns {*} 322 */ 323 getIntervalList : function() { 324 return tdViewport._intervalList; 325 }, 326 327 328 329 /** 330 * - getter of the tdViewport current item 331 * - it should be used by outsiders libraries 332 * @returns {*} 333 */ 334 getCurrentIntervalItem : function() { 335 336 if ((tdViewport.INTERVAL_INITIAL_INDEX === tdViewport._currentIntervalIndex) || (0 === tdViewport._currentIntervalIndex)) { 337 return null; 338 } 339 return tdViewport._items[tdViewport._currentIntervalIndex - 1]; 340 }, 341 342 343 344 _items : [], 345 346 347 348 item : function() { 349 this.limitBottom = undefined; 350 this.sidebarWidth = undefined; 351 }, 352 353 354 355 356 357 /**
358 * - detect view port changes 359 * - it returns true if the change view port has changed, false otherwise 360 * - it also sets the _currentIntervalIndex 361 * @returns {boolean} True when viewport has changed 362 */ 363 detectChanges: function() { 364 var result = false; 365 366 var realViewPortWidth = 0; 367 var localCurrentIntervalIndex = 0; 368 369 if (true === tdDetect.isSafari) { 370 realViewPortWidth = this._safariWiewPortWidth.getRealWidth(); 371 } else { 372 realViewPortWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 373 } 374 375 for (var i = 0; i < tdViewport._items.length; i++) { 376 377 if (realViewPortWidth <= tdViewport._items[i].limitBottom) { 378 379 if (localCurrentIntervalIndex !== tdViewport._currentIntervalIndex) { 380 tdViewport._currentIntervalIndex = localCurrentIntervalIndex; 381 result = true; 382 383 tdViewport.log('changing viewport ' + tdViewport._currentIntervalIndex + ' ~ ' + realViewPortWidth); 384 } 385 break; 386 } 387 localCurrentIntervalIndex++; 388 } 389 390 if ((false === result) && (localCurrentIntervalIndex !== tdViewport._currentIntervalIndex)) { 391 tdViewport._currentIntervalIndex = localCurrentIntervalIndex; 392 result = true; 393 394 tdViewport.log('changing viewport ' + tdViewport._currentIntervalIndex + ' ~ ' + realViewPortWidth); 395 } 396 return result; 397 }, 398 399 400 /** 401 * get the real view port width on safari 402 * @type {{divAdded: boolean, divJqueryObject: string, getRealWidth: Function}} 403 */ 404 _safariWiewPortWidth : { 405 divAdded : false, 406 divJqueryObject : '', 407 408 getRealWidth : function() { 409 if (false === this.divAdded) { 410 // we don't have a div present 411 this.divJqueryObject = jQuery('<div>') 412 .css({ 413 "height": "1px", 414 "position": "absolute", 415 "top": "-1px", 416 "left": "0", 417 "right": "0", 418 "visibility": "hidden", 419 "z-index": "-1" 420 }); 421 this.divJqueryObject.appendTo('body'); 422 this.divAdded = true; 423 } 424 return this.divJqueryObject.width(); 425 } 426 }, 427 428 429 430 log: function log(msg) { 431 //console.log(msg); 432 } 433 }; 434 435 tdViewport.init(); 436 437})(); 438 439/* ---------------------------------------------------------------------------- 440 Menu script 441 */ 442 443/* global jQuery:{} */ 444/* global tdDetect:{} */ 445 446 447(function(){ 448 'use strict'; 449 450 // top menu 451 452 if (tdDetect.isTouchDevice) { 453 //touch 454 jQuery('.td-header-sp-top-menu .top-header-menu').superfish({ 455 delay:300, 456 speed:'fast', 457 useClick:true 458 }); 459 460 } else { 461 462 //not touch 463 jQuery('.td-header-sp-top-menu .top-header-menu').superfish({ 464 delay:600, 465 speed:200, 466 useClick:false 467 }); 468 } 469 470/* ---------------------------------------------------------------------------- 471 On load 472 */ 473 474 // header menu 475 jQuery('#td-header-menu .sf-menu').supersubs({ 476 minWidth: 10, // minimum width of sub-menus in em units 477 maxWidth: 40, // maximum width of sub-menus in em units 478 extraWidth: 1 // extra width can ensure lines don't sometimes turn over 479 }); 480 481 482 483 if (tdDetect.isTouchDevice) { 484 //touch 485 jQuery('#td-header-menu .sf-menu').superfish({ 486 delay:300, 487 speed:'fast', 488 useClick:true 489 }); 490 491 } else { 492 493 //not touch 494 jQuery('#td-header-menu .sf-menu').superfish({ 495 delay:600, 496 speed:200, 497 useClick:false 498 }); 499 } 500})(); 501 502 503 504 505 506 507 508/* 509 td_util.js 510 v2.0 511 */ 512/* global jQuery:false */ 513/* global tdDetect:false */ 514/* global td`ScrollingAnimation:false */ 515/* jshint -W020 */ 516 517var tdUtil = {}; 518 519( function() { 520 "use strict"; 521 522 tdUtil = { 523 524 525 /** 526 * stop propagation of an event - we should check this if we can remove window.event.cancelBubble - possible 527 * a windows mobile issue 528 * @param event 529 */ 530 stopBubble: function( event ) { 531 if ( event && event.stopPropagation ) { 532 event.stopPropagation(); 533 } else { 534 window.event.cancelBubble=true; 535 } 536 }, 537 538 /** 539 * utility function, used by td_post_images.js 540 * @param classSelector 541 */ 542 imageMoveClassToFigure: function ( classSelector ) { 543 jQuery('figure .' + classSelector).each( function() { 544 jQuery(this).parents('figure:first').addClass(classSelector); 545 jQuery(this).removeClass(classSelector); 546 }); 547 }, 548 549 550 551 /** 552 * 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 553 * @param variableName 554 * @returns {*} 555 */ 556 getBackendVar: function ( variableName ) { 557 if ( typeof window[variableName] === 'undefined' ) { 558 return ''; 559 } 560 return window[variableName]; 561 }, 562 563 564 /** 565 * is a given variable undefined? - this is the underscore method of checking this 566 * @param obj 567 * @returns {boolean} 568 */ 569 isUndefined : function ( obj ) { 570 return obj === void 0; 571 }, 572 573 574 575 576 /** 577 * scrolls to a dom element 578 * @param domElement 579 */ 580 scrollToElement: function( domElement, duration ) { 581 tdIsScrollingAnimation = true; 582 jQuery("html, body").stop(); 583 584 585 var dest; 586 587 //calculate destination place 588 if ( domElement.offset().top > jQuery(document).height() - jQuery(window).height() ) { 589 dest = jQuery(document).height() - jQuery(window).height(); 590 } else { 591 dest = domElement.offset().top; 592 } 593 //go to destination 594 jQuery("html, body").animate( 595 { scrollTop: dest }, 596 { 597 duration: duration, 598 easing:'easeInOutQuart', 599 complete: function(){ 600 tdIsScrollingAnimation = false; 601 } 602 } 603 ); 604 }, 605 606 607 /** 608 * scrolls to a dom element - the element will be close to the center of the screen 609 * !!! compensates for long distances !!! 610 */ 611 scrollIntoView: function ( domElement ) { 612 613 tdIsScrollingAnimation = true; 614 615 if ( tdDetect.isMobileDevice === true ) { 616 return; //do not run on any mobile device 617 } 618 619 jQuery("html, body").stop(); 620 621 622 var destination = domElement.offset().top; 623 destination = destination - 150; 624 625 var distance = Math.abs( jQuery(window).scrollTop() - destination ); 626 var computed_time = distance / 5; 627 //console.log(distance + ' -> ' + computed_time + ' -> ' + (1100+computed_time)); 628 629 //go to destination 630 jQuery("html, body").animate( 631 { scrollTop: destination }, 632 { 633 duration: 1100 + computed_time, 634 easing:'easeInOutQuart', 635 complete: function(){ 636 tdIsScrollingAnimation = false; 637 } 638 } 639 ); 640 }, 641 642 /** 643 * scrolls to a position 644 * @param pxFromTop - pixels from top 645 */ 646 scrollToPosition: function( pxFromTop, duration ) { 647 648 tdIsScrollingAnimation = true; 649 jQuery("html, body").stop(); 650 651 //go to destination 652 jQuery("html, body").animate( 653 { scrollTop: pxFromTop }, 654 { 655 duration: duration, 656 easing:'easeInOutQuart', 657 complete: function(){ 658 tdIsScrollingAnimation = false; 659 } 660 } 661 ); 662 }, 663 tdMoveY: function ( elm, value ) { 664 var translate = 'translate3d(0px,' + value + 'px, 0px)'; 665 elm.style['-webkit-transform'] = translate; 666 elm.style['-moz-transform'] = translate; 667 elm.style['-ms-transform'] = translate;
668 elm.style['-o-transform'] = translate; 669 elm.style.transform = translate; 670 }, 671 672 673 isValidUrl: function ( str ) { 674 var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol 675 '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name 676 '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address 677 '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path 678 '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string 679 '(\\#[-a-z\\d_]*)?$','i'); // fragment locator 680 681 682 if( !pattern.test(str) ) { 683 return false; 684 } else { 685 return true; 686 } 687 }, 688 689 690 round: function ( value, precision, mode ) { 691 var m, f, isHalf, sgn; // helper variables 692 // making sure precision is integer 693 precision |= 0; 694 m = Math.pow(10, precision); 695 value *= m; 696 // sign of the number 697 sgn = (value > 0) | -(value < 0); 698 isHalf = value % 1 === 0.5 * sgn; 699 f = Math.floor(value); 700 701 if (isHalf) { 702 switch (mode) { 703 case 'PHP_ROUND_HALF_DOWN': 704 // rounds .5 toward zero 705 value = f + (sgn < 0); 706 break; 707 case 'PHP_ROUND_HALF_EVEN': 708 // rouds .5 towards the next even integer 709 value = f + (f % 2 * sgn); 710 break; 711 case 'PHP_ROUND_HALF_ODD': 712 // rounds .5 towards the next odd integer 713 value = f + !(f % 2); 714 break; 715 default: 716 // rounds .5 away from zero 717 value = f + (sgn > 0); 718 } 719 } 720 721 return (isHalf ? value : Math.round(value)) / m; 722 } 723 724 725 726 727 728 729 730 }; 731})(); 732 733 734 735 736 737 738/** 739 * Created by ra on 6/27/14. 740 * copyright tagDiv 2014 741 * V 1.1 - better iOS 8 support 742 */ 743 744/* global jQuery:{} */ 745/* global tdDetect:{} */ 746/* global tdUtil:{} */ 747 748var tdAffix = {}; 749 750(function(){ 751 'use strict'; 752 753 tdAffix = { 754 755 // flag used to stop scrolling 756 allow_scroll: true, 757 758 //settings, obtained from ext 759 menu_selector: '', //the affix menu (this element will get the td-affix) 760 menu_wrap_selector: '', //the menu wrapper / placeholder 761 tds_snap_menu: '', //the panel setting 762 tds_snap_menu_logo: '', //the panel setting 763 764 is_menu_affix_height_computed: false, // flag used to compute menu_affix_height only once, when the menu is affix 765 is_menu_affix_height_on_mobile_computed: false, // flag used to compute menu_affix_height_on_mobile only once, when the menu is affix 766 767 menu_affix_height: 0, // the menu affix height [the height when it's really affix] 768 menu_affix_height_on_mobile: 0, // the menu affix height on mobile [the height when it's really affix] 769 770 771 main_menu_height: 0, // main menu height 772 top_offset: 0, //how much the menu is moved from the original position when it's affixed 773 menu_offset: 0, //used to hide the menu on scroll 774 is_requestAnimationFrame_running: false, //prevent multiple calls to requestAnimationFrame 775 is_menu_affix: false, //the current state of the menu, true if the menu is affix 776 is_top_menu: false, //true when the menu is at the top of the screen (0px topScroll) 777 778 //menu offset boundaries - so we do not fire the animation event when the boundary is hit 779 menu_offset_max_hit: false, 780 menu_offset_min_hit: true, 781 782 783 scroll_window_scrollTop_last: 0, //last scrollTop position, used to calculate the scroll direction 784 785 /** 786 * run the affix, we use the menu wrap selector to compute the menu position from top 787 * 788 { 789 menu_selector: '.td-header-main-menu', 790 menu_wrap_selector: '.td-header-menu-wrap', 791 tds_snap_menu: tdUtil.getBackendVar('tds_snap_menu') 792 } 793 */ 794 init : function ( atts ) { 795 796 //read the settings 797 tdAffix.menu_selector = atts.menu_selector; 798 tdAffix.menu_wrap_selector = atts.menu_wrap_selector; 799 tdAffix.tds_snap_menu = atts.tds_snap_menu; 800 tdAffix.tds_snap_menu_logo = atts.tds_snap_menu_logo; 801 tdAffix.menu_affix_height = atts.menu_affix_height; 802 tdAffix.menu_affix_height_on_mobile = atts.menu_affix_height_on_mobile; 803 804 //the snap menu is disabled from the panel 805 if ( ! tdAffix.tds_snap_menu ) { 806 return; 807 } 808 809 810 // a computation before jquery.ready is necessary for firefox, where tdEvents.scroll comes before 811 if ( tdDetect.isFirefox ) { 812 tdAffix.compute_wrapper(); 813 tdAffix.compute_top(); 814 815 } 816 817 jQuery().ready(function() { 818 //compute on semi dom ready 819 tdAffix.compute_wrapper(); 820 tdAffix.compute_top(); 821 822 }); 823 824 //recompute when all the page + logos are loaded 825 jQuery( window ).load(function() { 826 tdAffix.compute_wrapper(); 827 tdAffix.compute_top(); 828 829 //recompute after 1 sec for retarded phones 830 setTimeout(function(){ 831 tdAffix.compute_top(); 832 }, 1000 ); 833 }); 834 }, 835 836 837 /** 838 * - get the real affix height. 839 * The real affix height is computed only once, when the menu is affix. Till then, the function 840 * return the values set at init. 841 * 842 * These values are important because they are used in the tdSmartSidebar.js for the 843 * td_affix_menu_computed_height variable, which then is used to determine the sidebar position. 844 * 845 * For 'Newspaper', the sidebar needs a custom padding top (see @tdSmartSidebar.js), otherwise 846 * the sidebar is sticked to the affix menu. 847 * 848 * 849 * @returns {number} affix height 850 * @private 851 */ 852 _get_menu_affix_height: function() { 853 854 //if (tdDetect.isPhoneScreen === true) { 855 // return tdAffix.menu_affix_height_on_mobile; 856 //} 857 //return tdAffix.menu_affix_height; 858 859 if ( true === tdDetect.isPhoneScreen ) { 860 if ( ! tdAffix.is_menu_affix_height_on_mobile_computed && tdAffix.is_menu_affix ) { 861 862 tdAffix.is_menu_affix_height_on_mobile_computed = true; 863 864 // overwrite the tdAffix.menu_affix_height_on_mobile variable with the real affix height 865 tdAffix.menu_affix_height_on_mobile = jQuery(tdAffix.menu_selector).height(); 866 } 867 return tdAffix.menu_affix_height_on_mobile; 868 } 869 870 if ( ! tdAffix.is_menu_affix_height_computed && tdAffix.is_menu_affix ) { 871 872 tdAffix.is_menu_affix_height_computed = true; 873 874 // overwrite the tdAffix.menu_affix_height variable with the real affix height 875 tdAffix.menu_affix_height = jQuery(tdAffix.menu_selector).height(); 876 } 877 return tdAffix.menu_affix_height; 878 }, 879 880 881 882 /** 883 * called by tdEvents.js on scroll 884 */ 885 td_events_scroll: function( scrollTop ) { 886 887 if ( ! tdAffix.allow_scroll ) { 888 return; 889 } 890 891 //do not run if we don't have a snap menu 892 if ( ! tdAffix.tds_snap_menu ) { 893 return; 894 } 895 896 897 /* ---------------------------------------------------------------------------- 898 scroll direction + delta (used by affix for now) 899 to run thios code: 900 - tdAffix.tds_snap_menu != '' (from above) 901 - tdAffix.tds_snap_menu != 'snap' 902 */ 903 var scroll_direction = ''; 904 905 if ( 'snap' !== tdAffix.tds_snap_menu ) { //do not run on snap 906 if ( ( 'smart_snap_mobile' !== tdAffix.tds_snap_menu || true === tdDetect.isPhoneScreen ) ) { // different from smart_snap_mobile or tdDetect.isPhoneScreen === true 907 908 var scrollDelta = 0; 909 910 //check the direction 911 if ( scrollTop !== tdAffix.scroll_window_scrollTop_last ) { //compute direction only if we have different last scroll top 912 // compute the direction of the scroll 913 if ( scrollTop > tdAffix.scroll_window_scrollTop_last ) { 914 scroll_direction = 'down'; 915 } else { 916 scroll_direction = 'up'; 917 } 918 //calculate the scroll delta 919 scrollDelta = Math.abs( scrollTop - tdAffix.scroll_window_scrollTop_last ); 920 } 921 922 tdAffix.scroll_window_scrollTop_last = scrollTop; 923 } 924 } 925 926 /* ---------------------------------------------------------------------------- */ 927 928 // show the logo on sticky menu
929 if ( '' !== tdAffix.tds_snap_menu && '' !== tdAffix.tds_snap_menu_logo ) { 930 jQuery( '.td-main-menu-logo' ).addClass( 'td-logo-sticky' ); 931 } 932 933 934 935 936 //if the menu is in the affix state 937 938 // 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 939 if ( ( scrollTop > tdAffix.top_offset + ( tdAffix.main_menu_height / 2 - tdAffix._get_menu_affix_height() / 2 ) ) || 940 941 // - the affix is OFF when the next condition is not accomplished, which means that the affix is ON 942 // and the scroll to the top is LOWER than the initial tdAffix.top_offset reduced by the affix real height 943 // - this condition makes the transition from the small affix menu to the larger menu of the page 944 ( ( tdAffix.is_menu_affix === true ) && ( 'smart_snap_always' === tdAffix.tds_snap_menu) && scrollTop > ( tdAffix.top_offset - tdAffix._get_menu_affix_height() ) ) || 945 946 tdAffix.is_top_menu === true ) { 947 948 //get the menu element 949 var td_affix_menu_element = jQuery( tdAffix.menu_selector ); 950 951 //turn affix on for it 952 tdAffix._affix_on( td_affix_menu_element ); 953 954 955 //if the menu is only with snap or we are on smart_snap_mobile + mobile, our job here in this function is done, return 956 if ( 'snap' === tdAffix.tds_snap_menu || ( 'smart_snap_mobile' === tdAffix.tds_snap_menu && false === tdDetect.isPhoneScreen ) ) { 957 return; 958 } 959 960 /* --- end simple snap --- */ 961 962 963 /* ---------------------------------------------------------------------------- 964 check scroll directions (we may also have scroll_direction = '', that's why we have to check for the specific state (up or down)) 965 */ 966 967 968 // boundary check - to not run the position on each scroll event 969 if ( ( false === tdAffix.menu_offset_max_hit && 'down' === scroll_direction ) || ( false === tdAffix.menu_offset_min_hit && 'up' === scroll_direction ) ) { 970 //request animation frame 971 //if (tdAffix.is_requestAnimationFrame_running === false) { 972 window.requestAnimationFrame(function(){ 973 974 //console.log(tdAffix.menu_offset); 975 //console.log(scrollDelta); 976 var offset = 0; 977 978 979 if ( scrollTop > 0 ) { // ios returns negative scrollTop values 980 if ( 'down' === scroll_direction ) { 981 982 //compute the offset 983 offset = tdAffix.menu_offset - scrollDelta; 984 985 // the offset is a value in the [-tdAffix.menu_affix_height, 0] and 986 // not into the interval [-tdAffix.main_menu_height, 0] 987 if ( offset < -tdAffix._get_menu_affix_height() ) { 988 offset = -tdAffix._get_menu_affix_height(); 989 } 990 991 } else if ( 'up' === scroll_direction ) { 992 //compute the offset 993 offset = tdAffix.menu_offset + scrollDelta; 994 if ( offset > 0 ) { 995 offset = 0; 996 } 997 } 998 } 999 1000 //td_debug.log_live(scroll_direction + ' | scrollTop: ' + scrollTop + ' | offset: ' + offset); 1001 1002 //tdAffix.is_requestAnimationFrame_running = true; 1003 1004 //console.log(offset); 1005 1006 //move the menu 1007 tdUtil.tdMoveY( td_affix_menu_element[0], offset ); 1008 1009 //td_affix_menu_element.css({top: (offset) + 'px'}); //legacy menu move code 1010 1011 //check boundaries 1012 if ( 0 === offset ) { 1013 tdAffix.menu_offset_min_hit = true; 1014 } else { 1015 tdAffix.menu_offset_min_hit = false; 1016 } 1017 1018 1019 if ( offset === -tdAffix._get_menu_affix_height() ) { 1020 tdAffix.menu_offset_max_hit = true; 1021 //also hide the menu when it's 100% out of view on ios - the safari header is transparent and we can see the menu 1022 if ( ( true === tdDetect.isIos ) || tdDetect.isSafari ) { // safari also 1023 td_affix_menu_element.hide(); 1024 } 1025 1026 //show the logo on smart sticky menu
1027 if ( '' !== tdAffix.tds_snap_menu_logo ) { 1028 jQuery( '.td-main-menu-logo' ).addClass( 'td-logo-sticky' ); 1029 } 1030 } else { 1031 tdAffix.menu_offset_max_hit = false; 1032 1033 if ( ( true === tdDetect.isIos ) || tdDetect.isSafari ) { //ios safari fix 1034 td_affix_menu_element.show(); 1035 } 1036 } 1037 1038 //tdAffix.is_requestAnimationFrame_running = false; 1039 1040 tdAffix.menu_offset = offset; //update the current offset of the menu 1041 1042 }, td_affix_menu_element[0] ); 1043 1044 //} 1045 //console.log(offset + ' ' + scroll_direction); 1046 1047 } //end boundary check 1048 1049 } else { 1050 tdAffix._affix_off( jQuery( tdAffix.menu_selector ) ); 1051 } 1052 }, 1053 1054 1055 /** 1056 * calculates the affix point (the distance from the top when affix should be enabled) 1057 * @see tdAffix.init() 1058 * @see tdEvents 1059 */ 1060 compute_top: function() { 1061 1062 // to compute from the bottom of the menu, the top offset is incremented by the menu wrap height 1063 tdAffix.top_offset = jQuery( tdAffix.menu_wrap_selector ).offset().top;// + jQuery(tdAffix.menu_wrap_selector).height(); 1064 1065 1066 // The top_offset is incremented with the menu_affix_height only on 'smart_snap_always', because of the sidebar 1067 // which use the menu_offset (and menu_offset depends on this top_offset) 1068 // 1069 // Consider that the smart sidebar, increment the td_affix_menu_computed_height with the menu_offset value 1070 // when the menu is on 'smart_snap_always' 1071 if ( 'smart_snap_always' === tdAffix.tds_snap_menu ) { 1072 tdAffix.top_offset += tdAffix.menu_affix_height; 1073 } 1074 1075 1076 //check to see if the menu is at the top of the screen 1077 if ( 1 === tdAffix.top_offset ) { 1078 //switch to affix - because the menu is at the top of the page 1079 //tdAffix._affix_on(jQuery(tdAffix.menu_selector)); 1080 tdAffix.is_top_menu = true; 1081 } else { 1082 //check to see the current top offset 1083 tdAffix.is_top_menu = false; 1084 } 1085 tdAffix.td_events_scroll( jQuery(window).scrollTop() ); 1086 1087 //alert(tdAffix.top_offset); 1088 //console.log('computed: ' + tdAffix.top_offset); 1089 }, 1090 1091 1092 /** 1093 * recalculate the wrapper height. To support different menu heights 1094 */ 1095 compute_wrapper: function() { 1096 1097 // td-affix class is removed to compute a real height when the compute_wrapper is done on a scrolled page 1098 if ( jQuery( tdAffix.menu_selector ).hasClass( 'td-affix' ) ) { 1099 jQuery( tdAffix.menu_selector ).removeClass( 'td-affix' ); 1100 1101 //read the height of the menu 1102 tdAffix.main_menu_height = jQuery( tdAffix.menu_selector ).height(); 1103 1104 jQuery( tdAffix.menu_selector ).addClass( 'td-affix' ); 1105 1106 } else { 1107 //read the height of the menu 1108 tdAffix.main_menu_height = jQuery( tdAffix.menu_selector ).height(); 1109 } 1110 1111 // put the menu height to the wrapper. The wrapper remains in the place when the menu is affixed 1112 jQuery( tdAffix.menu_wrap_selector ).css( 'height', tdAffix.main_menu_height ); 1113 }, 1114 1115 /** 1116 * turns affix on for the menu element 1117 * @param td_affix_menu_element 1118 * @private 1119 */ 1120 _affix_on: function( td_affix_menu_element ) { 1121 if ( false === tdAffix.is_menu_affix ) { 1122 1123 1124 // Bug.Fix - affix menu flickering 1125 // - the td_affix_menu_element is hidden because he is outside of the viewport 1126 // - without it, there's a flicker effect of applying css style (classes) over it 1127 1128 if ( ( 'smart_snap_always' === tdAffix.tds_snap_menu ) && ( tdDetect.isPhoneScreen !== true ) ) { 1129 td_affix_menu_element.css( 'visibility', 'hidden' ); 1130 } 1131 1132 tdAffix.menu_offset = -tdAffix.top_offset; 1133 1134 //make the menu fixed 1135 td_affix_menu_element.addClass( 'td-affix' ); 1136 1137 //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 1138 jQuery( 'body' ).addClass( 'body-td-affix' ); 1139 1140 tdAffix.is_menu_affix = true; 1141 } else { 1142 1143 // the td_affix_menu element is kept visible 1144 if ( true !== tdDetect.isPhoneScreen ) { 1145 td_affix_menu_element.css( 'visibility', '' ); 1146 } 1147 } 1148 }, 1149 1150 1151 1152 /** 1153 * Turns affix off for the menu element 1154 * @param td_affix_menu_element 1155 * @private 1156 */ 1157 _affix_off: function( td_affix_menu_element ) { 1158 if ( true === tdAffix.is_menu_affix ) { 1159 //make the menu normal 1160 jQuery( tdAffix.menu_selector ).removeClass( 'td-affix' ); 1161 1162 //console.log(tdAffix.tds_snap_menu_logo); 1163 //hide the logo from sticky menu when the menu is not affix 1164 if( '' === tdAffix.tds_snap_menu_logo ) { 1165 jQuery( '.td-main-menu-logo' ).removeClass( 'td-logo-sticky' ); 1166 } 1167 1168 //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 1169 jQuery( 'body' ).removeClass( 'body-td-affix' ); 1170 1171 tdAffix.is_menu_affix = false; 1172 1173 //move the menu to 0 (ios seems to skip animation frames) 1174 tdUtil.tdMoveY( td_affix_menu_element[0], 0 ); 1175 1176 if ( ( true === tdDetect.isIos ) || tdDetect.isSafari ) { 1177 td_affix_menu_element.show(); 1178 } 1179 } 1180 } 1181 }; 1182})(); 1183 1184 1185 1186 1187 1188 1189 1190/* 1191 tagDiv - 2014
1192 Our portfolio: http://themeforest.net/user/tagDiv/portfolio 1193 Thanks for using our theme! :) 1194*/ 1195 1196 1197/* global jQuery:false */ 1198/* global tdUtil:false */ 1199/* global tdModalImageLastEl:{} */ 1200/* global tdEvents:{} */ 1201 1202 1203"use strict"; 1204 1205 1206 1207 1208 1209/* ---------------------------------------------------------------------------- 1210 On load 1211 */ 1212jQuery().ready(function jQuery_ready() { 1213 1214 //retina images 1215 td_retina(); 1216 1217 1218 1219 // the mobile pull left menu (off canvas) 1220 //td_mobile_menu(); 1221 1222 //handles the toogle efect on mobile menu 1223 td_mobile_menu_toogle(); 1224 1225 1226 //resize all the videos if we have them 1227 td_resize_videos(); 1228 1229 //fake placeholder for ie 1230 jQuery('input, textarea').placeholder(); 1231 1232 //more stories box 1233 td_more_articles_box.init(); 1234 1235 //used for smart lists 1236 td_smart_lists_magnific_popup(); 1237 1238 //smart list drop down pagination 1239 td_smart_list_dropdown(); 1240 1241 // the top menu date 1242 if (typeof tdsDateFormat !== 'undefined') { 1243 1244 // php time() equivalent - js deals in milliseconds and php in seconds 1245 var tdsDateTimestamp = Math.floor(new Date().getTime() / 1000); 1246 1247 // replace the date 1248 var tdNewDateI18n = td_date_i18n(tdsDateFormat, tdsDateTimestamp); 1249 jQuery('.td_data_time').text(tdNewDateI18n); 1250 } 1251 1252 setMenuMinHeight(); 1253 1254}); //end on load 1255 1256 1257/** 1258 * smart lists drop down pagination redirect 1259 */ 1260function td_smart_list_dropdown() { 1261 jQuery('.td-smart-list-dropdown').on('change', function() { 1262 window.location = this.value; 1263 }); 1264} 1265 1266 1267/** 1268 * More stories box 1269 */ 1270var td_more_articles_box = { 1271 is_box_visible:false, 1272 cookie:'', 1273 distance_from_top:400, 1274 1275 init: function init() { 1276 1277 1278 //read the cookie 1279 td_more_articles_box.cookie = td_read_site_cookie('td-cookie-more-articles'); 1280 1281 1282 //setting distance from the top 1283 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){ 1284 td_more_articles_box.distance_from_top = parseInt(tds_more_articles_on_post_pages_distance_from_top); 1285 } else { 1286 td_more_articles_box.distance_from_top = 400; 1287 } 1288 1289 //adding event to hide the box 1290 jQuery('.td-close-more-articles-box').click(function(){ 1291 1292 //hiding the box 1293 jQuery('.td-more-articles-box').removeClass('td-front-end-display-block'); 1294 jQuery('.td-more-articles-box').hide(); 1295 1296 //cookie life 1297 if(!isNaN(parseInt(tds_more_articles_on_post_time_to_wait)) && isFinite(tds_more_articles_on_post_time_to_wait)){ 1298 //setting cookie 1299 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 1300 } 1301 }); 1302 }, 1303 1304 /** 1305 * called by tdEvents.js on scroll 1306 */ 1307 td_events_scroll: function td_events_scroll(scrollTop) { 1308 1309 if(tdIsScrollingAnimation) { //do not fire the event on animations 1310 return; 1311 } 1312 1313 //check to see if it's enable form panel and also from cookie 1314 if(tdUtil.getBackendVar('tds_more_articles_on_post_enable') == "show" && td_more_articles_box.cookie != 'hide-more-articles-box') { 1315 1316 if (scrollTop > td_more_articles_box.distance_from_top ) { 1317 if (td_more_articles_box.is_box_visible === false) { 1318 jQuery('.td-more-articles-box').addClass('td-front-end-display-block'); 1319 td_more_articles_box.is_box_visible = true; 1320 } 1321 } else { 1322 if (td_more_articles_box.is_box_visible === true) { 1323 jQuery('.td-more-articles-box').removeClass('td-front-end-display-block'); 1324 td_more_articles_box.is_box_visible = false; 1325 } 1326 } 1327 } 1328 } 1329}; 1330 1331 1332 1333 1334 1335 1336var td_resize_timer_id; 1337jQuery(window).resize(function() { 1338 clearTimeout(td_resize_timer_id); 1339 td_resize_timer_id = setTimeout(function() {
1340 td_done_resizing(); 1341 }, 200); 1342 1343}); 1344 1345function td_done_resizing(){ 1346 td_resize_videos(); 1347} 1348 1349 1350 1351/* ---------------------------------------------------------------------------- 1352 Resize the videos 1353 */ 1354function td_resize_videos() { 1355 //youtube in content 1356 jQuery(document).find('iframe[src*="youtube.com"]').each(function() { 1357 var videoMainContainer = jQuery(this).parent().parent().parent(), 1358 videoInPlaylist = jQuery(this).parent().hasClass("td_wrapper_playlist_player_vimeo"), 1359 video43AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-43"), //the video is set to 4:3 aspect ratio 1360 video235AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-235"); //the video is set to 2.35:1 aspect ratio 1361 if(videoInPlaylist || video43AspectRatio || video235AspectRatio) { 1362 //do nothing for playlist player youtube or aspect ratios 4:3 and 2.35:1 1363 //the video aspect ratio can be set on Visual Composer - Video Player widget settings 1364 } else { 1365 var td_video = jQuery(this); 1366 td_video.attr('width', '100%'); 1367 var td_video_width = td_video.width(); 1368 td_video.css('height', td_video_width * 0.5625, 'important'); 1369 } 1370 }); 1371 1372 1373 //vimeo in content 1374 jQuery(document).find('iframe[src*="vimeo.com"]').each(function() { 1375 var videoMainContainer = jQuery(this).parent().parent().parent(), 1376 videoInPlaylist = jQuery(this).parent().hasClass("td_wrapper_playlist_player_vimeo"), 1377 video43AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-43"), //the video is set to 4:3 aspect ratio 1378 video235AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-235"); //the video is set to 2.35:1 aspect ratio 1379 if(videoInPlaylist || video43AspectRatio || video235AspectRatio) { 1380 //do nothing for playlist player vimeo or aspect ratios 4:3 and 2.35:1 1381 //the video aspect ratio can be set on Visual Composer - Video Player widget settings 1382 } else { 1383 var td_video = jQuery(this); 1384 td_video.attr('width', '100%'); 1385 var td_video_width = td_video.width(); 1386 td_video.css('height', td_video_width * 0.5625, 'important'); 1387 } 1388 }); 1389 1390 1391 //daily motion in content 1392 jQuery(document).find('iframe[src*="dailymotion.com"]').each(function() { 1393 var videoMainContainer = jQuery(this).parent().parent().parent(), 1394 video43AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-43"), //video aspect ratio 4:3 1395 video235AspectRatio = videoMainContainer.hasClass("vc_video-aspect-ratio-235"); //video aspect ratio 2.35:1 1396 if (video43AspectRatio || video235AspectRatio) { 1397 //do nothing for video aspect ratios 4:3 and 2.35:1 1398 //the video aspect ratio can be set on Visual Composer - Video Player widget settings 1399 } else { 1400 var td_video = jQuery(this); 1401 td_video.attr('width', '100%'); 1402 var td_video_width = td_video.width(); 1403 td_video.css('height', td_video_width * 0.6, 'important'); 1404 } 1405 1406 }); 1407 1408 1409 //wordpress embedded 1410 jQuery(document).find(".wp-video-shortcode").each(function() { 1411 var td_video = jQuery(this); 1412 1413 var td_video_width = td_video.width() + 3; 1414 jQuery(this).parent().css('height', td_video_width * 0.56, 'important'); 1415 //td_video.css('height', td_video_width * 0.6, 'important') 1416 td_video.css('width', '100%', 'important'); 1417 td_video.css('height', '100%', 'important'); 1418 }) 1419} 1420 1421 1422 1423 1424 1425 1426//handles mobile menu 1427function td_mobile_menu() { 1428 //jQuery('#td-top-mobile-toggle a, .td-mobile-close a').click(function(){ 1429 // if(jQuery('body').hasClass('td-menu-mob-open-menu')) { 1430 // jQuery('body').removeClass('td-menu-mob-open-menu'); 1431 // } else { 1432 // if (tdDetect.isMobileDevice) { 1433 // // on mobile devices scroll to top instantly and wait a bit and open the menu 1434 // window.scrollTo(0, 0); 1435 // setTimeout(function(){ 1436 // jQuery('body').addClass('td-menu-mob-open-menu'); 1437 // }, 100); 1438 // } else { 1439 // // on desktop open it with full animations 1440 // jQuery('body').addClass('td-menu-mob-open-menu'); 1441 // setTimeout(function(){ 1442 // tdUtil.scrollToPosition(0, 1200); 1443 // }, 200); 1444 // } 1445 // } 1446 //}); 1447} 1448 1449 1450//handles open/close mobile menu 1451function td_mobile_menu_toogle() { 1452 1453 //jQuery('#td-mobile-nav .menu-item-has-children ul').hide(); 1454 // 1455 ////move thru all the menu and find the item with sub-menues to atach a custom class to them 1456 //jQuery(document).find('#td-mobile-nav .menu-item-has-children').each(function(i) { 1457 // 1458 // var class_name = 'td_mobile_elem_with_submenu_' + i; 1459 // jQuery(this).addClass(class_name); 1460 // 1461 // //add an element to click on 1462 // //jQuery(this).children("a").append('<div class="td-element-after" data-parent-class="' + class_name + '"></div>'); 1463 // jQuery(this).children("a").append('<i class="td-icon-menu-down td-element-after" data-parent-class="' + class_name + '"></i>'); 1464 // 1465 // 1466 // //click on link elements with # 1467 // jQuery(this).children("a").addClass("td-link-element-after").attr("data-parent-class", class_name); 1468 //}); 1469 // 1470 //jQuery(".td-element-after, .td-link-element-after").click(function(event) { 1471 // 1472 // if(jQuery(this).hasClass("td-element-after") || jQuery(this).attr("href") == "#" ){ 1473 // event.preventDefault(); 1474 // event.stopPropagation(); 1475 // } 1476 // 1477 // 1478 // //take the li parent class 1479 // var parent_class = jQuery(this).data('parent-class'); 1480 // 1481 // //target the sub-menu to open 1482 // var target_to_open = '#td-mobile-nav .' + parent_class + ' > a + ul'; 1483 // if(jQuery(target_to_open).css('display') == 'none') { 1484 // jQuery(target_to_open).show(); 1485 // } else { 1486 // jQuery(target_to_open).hide(); 1487 // } 1488 // 1489 // 1490 //}); 1491 1492 jQuery( '#td-top-mobile-toggle a, .td-mobile-close a' ).click(function(){ 1493 if ( jQuery( 'body' ).hasClass( 'td-menu-mob-open-menu' ) ) { 1494 jQuery( 'body' ).removeClass( 'td-menu-mob-open-menu' ); 1495 } else { 1496 jQuery( 'body' ).addClass( 'td-menu-mob-open-menu' ); 1497 } 1498 });
1499 1500 1501 //handles open/close mobile menu 1502 1503 //move thru all the menu and find the item with sub-menues to atach a custom class to them 1504 jQuery( document ).find( '#td-mobile-nav .menu-item-has-children' ).each(function( i ) { 1505 1506 var class_name = 'td_mobile_elem_with_submenu_' + i; 1507 jQuery(this).addClass( class_name ); 1508 1509 //click on link elements with # 1510 jQuery(this).children('a').addClass( 'td-link-element-after' ); 1511 1512 jQuery(this).click(function( event ) { 1513 1514 /** 1515 * currentTarget - the li element 1516 * target - the element clicked inside of the currentTarget 1517 */ 1518 1519 var jQueryTarget = jQuery( event.target ); 1520 1521 // html i element 1522 if ( jQueryTarget.length && 1523 ( ( jQueryTarget.hasClass( 'td-element-after') || jQueryTarget.hasClass( 'td-link-element-after') ) && 1524 ( '#' === jQueryTarget.attr( 'href' ) || undefined === jQueryTarget.attr( 'href' ) ) ) ) { 1525 1526 event.preventDefault(); 1527 event.stopPropagation(); 1528 1529 jQuery( this ).toggleClass( 'td-sub-menu-open' ); 1530 } 1531 }); 1532 }); 1533} 1534 1535 1536 1537/* ---------------------------------------------------------------------------- 1538 Add retina support 1539 */ 1540 1541function td_retina() { 1542 if (window.devicePixelRatio > 1) { 1543 jQuery('.td-retina').each(function(i) { 1544 var lowres = jQuery(this).attr('src'); 1545 var highres = lowres.replace(".png", "@2x.png"); 1546 highres = highres.replace(".jpg", "@2x.jpg"); 1547 jQuery(this).attr('src', highres); 1548 1549 }); 1550 1551 1552 //custom logo support 1553 jQuery('.td-retina-data').each(function(i) { 1554 jQuery(this).attr('src', jQuery(this).data('retina')); 1555 //fix logo aligment on retina devices 1556 jQuery(this).addClass('td-retina-version'); 1557 }); 1558 1559 } 1560} 1561 1562/* 1563jQuery('body').click(function(e){ 1564 if(! jQuery(e.target).hasClass('custom-background')){ 1565 alert('clicked on something that has not the class theDIV'); 1566 } 1567 1568});*/ 1569 1570//click only on BACKGROUND, for devices that don't have touch (ex: phone, tablets) 1571if(!tdDetect.isTouchDevice && tdUtil.getBackendVar('td_ad_background_click_link') != '') { 1572 1573 //var ev = ev || window.event; 1574 //var target = ev.target || ev.srcElement; 1575 jQuery('body').click(function(event) { 1576 1577 //getting the target element that the user clicks - for W3C and MSIE 1578 var target = (event.target) ? event.target : event.srcElement; 1579 1580 //only click on background 1581 1582 var target_jquery_obj = jQuery(target); 1583 1584 // td-content-wrap for NEWSMAG and td-boxex-layout for NEWSPAPER 1585 if (target_jquery_obj.hasClass('td-content-wrap') || target_jquery_obj.hasClass('td-boxed-layout')) { 1586 1587 //open the link ad page 1588 if(td_ad_background_click_target == '_blank') { 1589 //open in a new window 1590 window.open(td_ad_background_click_link) 1591 } else { 1592 //open in the same window 1593 location.href = td_ad_background_click_link; 1594 } 1595 } 1596 1597 //e.stopPropagation(); 1598 //stopBubble(event); 1599 }); 1600} 1601 1602 1603 1604 1605 1606/** 1607 * reading cookies 1608 * @param name 1609 * @returns {*} 1610 */ 1611function td_read_site_cookie(name) { 1612 var nameEQ = escape(name) + "="; 1613 var ca = document.cookie.split(';'); 1614 for (var i = 0; i < ca.length; i++) { 1615 var c = ca[i]; 1616 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 1617 if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length)); 1618 } 1619 return null; 1620} 1621 1622 1623/** 1624 * 1625 * @param td_time_cookie_array 1626 * 1627 * @param[0]: name of the cookie 1628 * @param[1]: value of the cookie 1629 * @param[2]: expiration time 1630 */ 1631function td_set_cookies_life(td_time_cookie_array) { 1632 var expiry = new Date(); 1633 expiry.setTime(expiry.getTime() + td_time_cookie_array[2]); 1634 1635 // Date()'s toGMTSting() method will format the date correctly for a cookie 1636 document.cookie = td_time_cookie_array[0] + "=" + td_time_cookie_array[1] + "; expires=" + expiry.toGMTString() + "; path=/"; 1637} 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658/* ---------------------------------------------------------------------------- 1659 Scroll to top + animation stop 1660 */ 1661 1662var tdIsScrollingAnimation = false; 1663var td_mouse_wheel_or_touch_moved = false; //we want to know if the user stopped the animation via touch or mouse move 1664 1665//stop the animation on mouse wheel 1666jQuery(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function(e){
1667 1668 1669 if (tdIsScrollingAnimation === false) { 1670 return; 1671 } else { 1672 1673 tdIsScrollingAnimation = false; 1674 td_mouse_wheel_or_touch_moved = true; 1675 1676 jQuery("html, body").stop(); 1677 } 1678}); 1679 1680//stop the animation on touch 1681if (document.addEventListener){ 1682 document.addEventListener('touchmove', function(e) { 1683 if (tdIsScrollingAnimation === false) { 1684 return; 1685 } else { 1686 tdIsScrollingAnimation = false; 1687 td_mouse_wheel_or_touch_moved = true; 1688 jQuery("html, body").stop(); 1689 } 1690 }, false); 1691} 1692 1693/** 1694 * called by tdEvents.js on scroll - back to top 1695 */ 1696var td_scroll_to_top_is_visible = false; 1697function td_events_scroll_scroll_to_top(scrollTop) { 1698 if(tdIsScrollingAnimation) { //do not fire the event on animations 1699 return; 1700 } 1701 if (scrollTop > 400) { 1702 if (td_scroll_to_top_is_visible === false) { //only add class if needed 1703 td_scroll_to_top_is_visible = true; 1704 jQuery('.td-scroll-up').addClass('td-scroll-up-visible'); 1705 } 1706 } else { 1707 if (td_scroll_to_top_is_visible === true) { //only add class if needed 1708 td_scroll_to_top_is_visible = false; 1709 jQuery('.td-scroll-up').removeClass('td-scroll-up-visible'); 1710 } 1711 } 1712} 1713 1714 1715jQuery('.td-scroll-up').click(function(){ 1716 if(tdIsScrollingAnimation) { //double check - because when we remove the class, the button is still visible for a while 1717 return; 1718 } 1719 1720 //hide the button 1721 td_scroll_to_top_is_visible = false; 1722 jQuery('.td-scroll-up').removeClass('td-scroll-up-visible'); 1723 1724 //hide more articles box 1725 td_more_articles_box.is_box_visible = false; 1726 jQuery('.td-more-articles-box').removeClass('td-front-end-display-block'); 1727 1728 //scroll to top 1729 tdUtil.scrollToPosition(0, 1200); 1730 1731 return false; 1732}); 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742// small down arrow on template 6 and full width index 1743jQuery('.td-read-down a').click(function(event){ 1744 event.preventDefault(); 1745 tdUtil.scrollToPosition(jQuery('.td-full-screen-header-image-wrap').height(), 1200); 1746 //tdUtil.scrollToPosition(jQuery('.td-full-screen-header-image-wrap').height() + jQuery('.td-full-screen-header-image-wrap').offset().top, 1200); 1747}); 1748 1749/** 1750 * make td-post-template-6 title move down and blurry 1751 * called from single_tempalte_6.php via the js buffer 1752 */ 1753function td_post_template_6_title() { 1754 1755 1756 1757 //define all the variables - for better performance ? 1758 var td_parallax_el = document.getElementById('td_parallax_header_6'); 1759 1760 var td_parallax_bg_el = document.getElementById('td-full-screen-header-image'); 1761 1762 var scroll_from_top = ''; 1763 var distance_from_bottom; 1764 1765 //attach the animation tick on scroll 1766 jQuery(window).scroll(function(){ 1767 // with each scroll event request an animation frame (we have a polyfill for animation frame) 1768 // the requestAnimationFrame is called only once and after that we wait 1769 td_request_tick(); 1770 }); 1771 1772 1773 var td_animation_running = false; //if the tick is running, we set this to true 1774 1775 function td_request_tick() { 1776 if (td_animation_running === false) { 1777 window.requestAnimationFrame(td_do_animation); 1778 } 1779 td_animation_running = true; 1780 } 1781 1782 /** 1783 * the animation loop 1784 */ 1785 function td_do_animation() { 1786 scroll_from_top = jQuery(document).scrollTop(); 1787 if (scroll_from_top <= 950) { //stop the animation after scroll from top 1788 1789 var blur_value = 1 - (scroll_from_top / 800); // @todo trebuie verificata formula?? 1790 if (tdDetect.isIe8 === true) { 1791 blur_value = 1; 1792 } 1793 1794 1795 blur_value = Math.round(blur_value * 100) / 100; 1796 1797 //opacity 1798 td_parallax_el.style.opacity = blur_value; 1799 1800 //move the bg 1801 var parallax_move = -Math.round(scroll_from_top / 4); 1802 tdUtil.tdMoveY(td_parallax_bg_el,-parallax_move); 1803 1804 1805 //move the title + cat 1806 distance_from_bottom = -Math.round(scroll_from_top / 8); 1807 tdUtil.tdMoveY(td_parallax_el,-distance_from_bottom); 1808 //td_parallax_el.style.bottom = distance_from_bottom + "px";
1808 //un accelerated version 1809 1810 1811 } 1812 1813 td_animation_running = false; 1814 } 1815 1816 1817 1818} 1819 1820//used for smart lists 1821function td_smart_lists_magnific_popup() { 1822 //magnific popup 1823 jQuery(".td-lightbox-enabled").magnificPopup({ 1824 delegate: "a", 1825 type: "image", 1826 tLoading: "Loading image #%curr%...", 1827 mainClass: "mfp-img-mobile", 1828 gallery: { 1829 enabled: true, 1830 navigateByImgClick: true, 1831 preload: [0,1], 1832 tCounter: tdUtil.getBackendVar('td_magnific_popup_translation_tCounter') // Markup for "1 of 7" counter 1833 }, 1834 image: { 1835 tError: "<a href=\'%url%\'>The image #%curr%</a> could not be loaded.", 1836 titleSrc: function(item) {//console.log(item.el); 1837 //alert(jQuery(item.el).data("caption")); 1838 return item.el.attr("data-caption"); 1839 } 1840 }, 1841 zoom: { 1842 enabled: true, 1843 duration: 300, 1844 opener: function(element) { 1845 return element.find("img"); 1846 } 1847 }, 1848 callbacks: { 1849 change: function(item) { 1850 /** 1851 * if we have pictures only on 3 from 4 slides then remove, from magnific popup, the one with no image 1852 */ 1853 //console.log(item); 1854 //console.log(item.el[0].id); 1855 //console.log(parseInt(nr_slide[1]) + 1); 1856 if(item.el[0].id != '') { 1857 var nr_slide = item.el[0].id.split("_"); 1858
1859 // Will fire when popup is closed 1860 //jQuery(".td-iosSlider").iosSlider("goToSlide", this.currItem.index + 1 ); 1861 jQuery(".td-iosSlider").iosSlider("goToSlide", parseInt(nr_slide[1]) + 1); 1862 } else { 1863 tdModalImageLastEl = item.el; 1864 setTimeout(function(){ 1865 tdUtil.scrollIntoView(item.el); 1866 }, 100); 1867 } 1868 }, 1869 beforeClose: function() { 1870 if (tdModalImageLastEl != '') { 1871 1872 tdUtil.scrollIntoView(tdModalImageLastEl); 1873 } 1874 } 1875 } 1876 }); 1877} 1878 1879 1880 1881 1882 1883function td_get_document_width() { 1884 var x = 0; 1885 if (self.innerHeight) 1886 { 1887 x = self.innerWidth; 1888 } 1889 else if (document.documentElement && document.documentElement.clientHeight) 1890 { 1891 x = document.documentElement.clientWidth; 1892 } 1893 else if (document.body) 1894 { 1895 x = document.body.clientWidth; 1896 } 1897 return x; 1898} 1899 1900function td_get_document_height() { 1901 var y = 0; 1902 if (self.innerHeight) 1903 { 1904 y = self.innerHeight; 1905 } 1906 else if (document.documentElement && document.documentElement.clientHeight) 1907 { 1908 y = document.documentElement.clientHeight; 1909 } 1910 else if (document.body) 1911 { 1912 y = document.body.clientHeight; 1913 } 1914 return y; 1915} 1916 1917 1918/* ---------------------------------------------------------------------------- 1919 Set the mobile menu min-height property 1920 1921 This is usually used to force vertical scroll bar appearance from the beginning. 1922 Without it, on some mobile devices (ex Android), at scroll bar appearance there are some 1923 visual issues. 1924 1925 */ 1926function setMenuMinHeight() { 1927 var tdMobileMenu = jQuery( '#td-mobile-nav' ); 1928 1929 if ( tdMobileMenu.length ) { 1930 tdMobileMenu.css( 'min-height' , (tdEvents.window_innerHe
1930ight+1) + 'px' ); 1931 } 1932} 1933/* global jQuery:false */ 1934/* global tdUtil:false */ 1935 1936var tdLoadingBox = {}; 1937 1938 1939( function() { 1940 "use strict"; 1941 tdLoadingBox = { 1942 1943 //arrayColors: ['#ffffff', '#fafafa', '#ececec', '#dddddd', '#bfbfbf', '#9a9a9a', '#7e7e7e', '#636363'],//whiter -> darker 1944 1945 speed: 40, 1946 1947 arrayColorsTemp: [ 1948 'rgba(99, 99, 99, 0)', 1949 'rgba(99, 99, 99, 0.05)', 1950 'rgba(99, 99, 99, 0.08)', 1951 'rgba(99, 99, 99, 0.2)', 1952 'rgba(99, 99, 99, 0.3)', 1953 'rgba(99, 99, 99, 0.5)', 1954 'rgba(99, 99, 99, 0.6)', 1955 'rgba(99, 99, 99, 1)' 1956 ],//whiter -> darker 1957 1958 arrayColors: [], 1959 1960 statusAnimation: 'stop', 1961 1962 //stop loading box 1963 stop : function stop () { 1964 tdLoadingBox.statusAnimation = 'stop'; 1965 //jQuery('.td-loader-gif').html(""); 1966 }, 1967 1968 1969 //init loading box 1970 init : function init (color, speed) { 1971 1972 // set up the speed 1973 if (false === tdUtil.isUndefined(speed)) { 1974 tdLoadingBox.speed = speed; 1975 } 1976 1977 //console.log('test'); 1978 var tdColorRegExp = /^#[a-zA-Z0-9]{3,6}$/; 1979 if(color && tdColorRegExp.test(color)) { 1980 1981 var colRgba = tdLoadingBox.hexToRgb(color); 1982 1983 var rgbaString = "rgba(" + colRgba.r + ", " + colRgba.g + ", " + colRgba.b + ", "; 1984 1985 tdLoadingBox.arrayColors[7] = rgbaString + " 1)"; 1986 tdLoadingBox.arrayColors[6] = rgbaString + " 0.6)"; 1987 tdLoadingBox.arrayColors[5] = rgbaString + " 0.5)"; 1988 tdLoadingBox.arrayColors[4] = rgbaString + " 0.3)"; 1989 tdLoadingBox.arrayColors[3] = rgbaString + " 0.2)"; 1990 tdLoadingBox.arrayColors[2] = rgbaString + " 0.08)"; 1991 tdLoadingBox.arrayColors[1] = rgbaString + " 0.05)"; 1992 tdLoadingBox.arrayColors[0] = rgbaString + " 0)"; 1993 1994 } else { 1995 //default array 1996 tdLoadingBox.arrayColors = tdLoadingBox.arrayColorsTemp.slice(0); 1997 1998 } 1999 2000 if(tdLoadingBox.statusAnimation === 'stop') { 2001 tdLoadingBox.statusAnimation = 'display'; 2002 this.render(); 2003 } 2004 }, 2005 2006 2007 //create the animation 2008 render: function render (color) { 2009 2010 //call the animationDisplay function 2011 tdLoadingBox.animationDisplay( 2012 '<div class="td-lb-box td-lb-box-1" style="background-color:' + tdLoadingBox.arrayColors[0] + '"></div>' + 2013 '<div class="td-lb-box td-lb-box-2" style="background-color:' + tdLoadingBox.arrayColors[1] + '"></div>' + 2014 '<div class="td-lb-box td-lb-box-3" style="background-color:' + tdLoadingBox.arrayColors[2] + '"></div>' + 2015 '<div class="td-lb-box td-lb-box-4" style="background-color:' + tdLoadingBox.arrayColors[3] + '"></div>' + 2016 '<div class="td-lb-box td-lb-box-5" style="background-color:' + tdLoadingBox.arrayColors[4] + '"></div>' + 2017 '<div class="td-lb-box td-lb-box-6" style="background-color:' + tdLoadingBox.arrayColors[5] + '"></div>' + 2018 '<div class="td-lb-box td-lb-box-7" style="background-color:' + tdLoadingBox.arrayColors[6] + '"></div>' + 2019 '<div class="td-lb-box td-lb-box-8" style="background-color:' + tdLoadingBox.arrayColors[7] + '"></div>' 2020 ); 2021 2022 //direction right 2023 var tempColorArray = [ 2024 tdLoadingBox.arrayColors[0], 2025 tdLoadingBox.arrayColors[1], 2026 tdLoadingBox.arrayColors[2], 2027 tdLoadingBox.arrayColors[3], 2028 tdLoadingBox.arrayColors[4], 2029 tdLoadingBox.arrayColors[5], 2030 tdLoadingBox.arrayColors[6], 2031 tdLoadingBox.arrayColors[7] 2032 ]; 2033 2034 tdLoadingBox.arrayColors[0] = tempColorArray[7]; 2035 tdLoadingBox.arrayColors[1] = tempColorArray[0]; 2036 tdLoadingBox.arrayColors[2] = tempColorArray[1]; 2037 tdLoadingBox.arrayColors[3] = tempColorArray[2]; 2038 tdLoadingBox.arrayColors[4] = tempColorArray[3]; 2039 tdLoadingBox.arrayColors[5] = tempColorArray[4]; 2040 tdLoadingBox.arrayColors[6] = tempColorArray[5]; 2041 tdLoadingBox.arrayColors[7] = tempColorArray[6]; 2042 2043 if(tdLoadingBox.statusAnimation === 'display') { 2044 2045 2046 setTimeout(tdLoadingBox.render, tdLoadingBox.speed); 2047 } else { 2048 tdLoadingBox.animationDisplay(''); 2049 } 2050 }, 2051 2052 2053 //display the animation 2054 animationDisplay: function (animation_str) { 2055 jQuery('.td-loader-gif').html(animation_str); 2056 }, 2057 2058 2059 //converts hex to rgba 2060 hexToRgb: function (hex) { 2061 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); 2062 2063 return result ? { 2064 r: parseInt(result[1], 16), 2065 g: parseInt(result[2], 16), 2066 b: parseInt(result[3], 16) 2067 } : null; 2068 } 2069 }; //tdLoadingBox.init();//tdLoadingBox.stop(); 2070})(); 2071 2072 2073 2074 2075 2076 2077 2078/* global jQuery:{} */ 2079/* global tdDetect:{} */ 2080/* global tdLocalCache:{} */ 2081/* global td_ajax_url:{} */ 2082 2083var tdAjaxSearch = {}; 2084 2085jQuery().ready(function() { 2086 2087 'use strict'; 2088 2089 tdAjaxSearch.init(); 2090 2091}); 2092 2093(function() { 2094 2095 'use strict'; 2096 2097 tdAjaxSearch = { 2098 2099 // private vars 2100 _current_selection_index: 0, 2101 _last_request_results_count: 0, 2102 _first_down_up: true, 2103 _is_search_open: false, 2104 2105 2106 /** 2107 * init the class 2108 */
2109 init: function init() { 2110 2111 // hide the drop down if we click outside of it 2112 jQuery(document).click(function(e) { 2113 if ( 2114 'td-icon-search' !== e.target.className && 2115 'td-header-search' !== e.target.id && 2116 'td-header-search-top' !== e.target.id && 2117 true === tdAjaxSearch._is_search_open 2118 ) { 2119 tdAjaxSearch.hide_search_box(); 2120 } 2121 }); 2122 2123 2124 // show and hide the drop down on the search icon 2125 jQuery( '#td-header-search-button' ).click(function(event){ 2126 event.preventDefault(); 2127 if (tdAjaxSearch._is_search_open === true) { 2128 tdAjaxSearch.hide_search_box(); 2129 2130 } else { 2131 tdAjaxSearch.show_search_box(); 2132 } 2133 }); 2134 2135 2136 // show and hide the drop down on the search icon for mobile 2137 jQuery( '#td-header-search-button-mob' ).click(function(event){ 2138 jQuery( 'body' ).addClass( 'td-search-opened' ); 2139 2140 var current_query = jQuery('#td-header-search-mob').val().trim(); 2141 if ( current_query.length > 0 ) { 2142 tdAjaxSearch.do_ajax_call_mob(); 2143 } 2144 }); 2145 2146 2147 //close the search 2148 jQuery( '.td-search-close a' ).click(function(){ 2149 jQuery( 'body' ).removeClass( 'td-search-opened' ); 2150 }); 2151 2152 2153 // keydown on the text box 2154 jQuery( '#td-header-search' ).keydown(function(event) { 2155 if ( 2156 ( event.which && 39 === event.which ) || 2157 ( event.keyCode && 39 === event.keyCode ) || 2158 ( event.which && 37 === event.which ) || 2159 ( event.keyCode && 37 === event.keyCode ) ) 2160 { 2161 //do nothing on left and right arrows 2162 tdAjaxSearch.td_aj_search_input_focus(); 2163 return; 2164 } 2165 2166 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 2167 // on enter 2168 var td_aj_cur_element = jQuery('.td-aj-cur-element'); 2169 if (td_aj_cur_element.length > 0) { 2170 //alert('ra'); 2171 var td_go_to_url = td_aj_cur_element.find('.entry-title a').attr('href'); 2172 window.location = td_go_to_url; 2173 } else { 2174 jQuery(this).parent().parent().submit(); 2175 } 2176 return false; //redirect for search on enter 2177 2178 } else if ( ( event.which && 40 === event.which ) || ( event.keyCode && 40 === event.keyCode ) ) { 2179 // down 2180 tdAjaxSearch.move_prompt_down(); 2181 return false; //disable the envent 2182 2183 } else if ( ( event.which && 38 === event.which ) || ( event.keyCode && 38 === event.keyCode ) ) { 2184 //up 2185 tdAjaxSearch.move_prompt_up(); 2186 return false; //disable the envent 2187 2188 } else { 2189 //for backspace we have to check if the search query is empty and if so, clear the list 2190 if ( ( event.which && 8 === event.which ) || ( event.keyCode && 8 === event.keyCode ) ) { 2191 //if we have just one character left, that means it will be deleted now and we also have to clear the search results list 2192 var search_query = jQuery(this).val(); 2193 if ( 1 === search_query.length ) { 2194 jQuery('#td-aj-search').empty(); 2195 } 2196 } 2197 2198 //various keys 2199 tdAjaxSearch.td_aj_search_input_focus(); 2200 //jQuery('#td-aj-search').empty(); 2201 setTimeout(function(){ 2202 tdAjaxSearch.do_ajax_call(); 2203 }, 100); 2204 } 2205 return true; 2206 }); 2207 2208 // keydown on the text box 2209 jQuery('#td-header-search-mob').keydown(function(event) { 2210 2211 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 2212 // on enter 2213 var td_aj_cur_element = jQuery('.td-aj-cur-element'); 2214 if (td_aj_cur_element.length > 0) { 2215 //alert('ra'); 2216 var td_go_to_url = td_aj_cur_element.find( '.entry-title a' ).attr( 'href' ); 2217 window.location = td_go_to_url; 2218 } else { 2219 jQuery(this).parent().parent().submit(); 2220 } 2221 return false; //redirect for search on enter 2222 } else { 2223 2224 //for backspace we have to check if the search query is empty and if so, clear the list 2225 if ( ( event.which && 8 === event.which ) || ( event.keyCode && 8 === event.keyCode ) ) { 2226 //if we have just one character left, that means it will be deleted now and we also have to clear the search results list 2227 var search_query = jQuery(this).val(); 2228 if ( 1 === search_query.length ) { 2229 jQuery('#td-aj-search-mob').empty(); 2230 } 2231 } 2232 2233 setTimeout(function(){ 2234 tdAjaxSearch.do_ajax_call_mob(); 2235 }, 100); 2236 2237 return true; 2238 } 2239 }); 2240 }, 2241 2242 2243 show_search_box: function() { 2244 jQuery( '.td-drop-down-search' ).addClass( 'td-drop-down-search-open' ); 2245 // do not try to autofocus on ios. It's still buggy as of 18 march 2015 2246 if ( true !== tdDetect.isIos ) { 2247 setTimeout(function(){ 2248 document.getElementById( 'td-header-search' ).focus(); 2249 }, 200); 2250 } 2251 tdAjaxSearch._is_search_open = true; 2252 }, 2253 2254 2255 hide_search_box: function hide_search_box() { 2256 jQuery(".td-drop-down-search").removeClass('td-drop-down-search-open'); 2257 tdAjaxSearch._is_search_open = false; 2258 }, 2259 2260 2261 2262 /** 2263 * moves the select up 2264 */ 2265 td_aj_search_move_prompt_up: function() { 2266 if (tdAjaxSearch._first_down_up === true) { 2267 tdAjaxSearch._first_down_up = false; 2268 if (tdAjaxSearch._current_selection_index === 0) { 2269 tdAjaxSearch._current_selection_index = tdAjaxSearch._last_request_results_count - 1; 2270 } else { 2271 tdAjaxSearch._current_selection_index--; 2272 } 2273 } else { 2274 if (tdAjaxSearch._current_selection_index === 0) { 2275 tdAjaxSearch._current_selection_index = tdAjaxSearch._last_request_results_count; 2276 } else { 2277 tdAjaxSearch._current_selection_index--; 2278 } 2279 } 2280 tdAjaxSearch._repaintCurrentElement(); 2281 }, 2282 2283 2284 2285 /** 2286 * moves the select prompt down 2287 */ 2288 move_prompt_down: function() { 2289 if (tdAjaxSearch._first_down_up === true) { 2290 tdAjaxSearch._first_down_up = false; 2291 } else { 2292 if (tdAjaxSearch._current_selection_index === tdAjaxSearch._last_request_results_count) { 2293 tdAjaxSearch._current_selection_index = 0; 2294 } else { 2295 tdAjaxSearch._current_selection_index++; 2296 } 2297 } 2298 tdAjaxSearch._repaintCurrentElement(); 2299 }, 2300 2301 2302 /** 2303 * Recompute the current element in the search results. 2304 * Used by the move_prompt_up and move_prompt_down 2305 * @private 2306 */ 2307 _repaintCurrentElement: function() { 2308 jQuery( '.td_module_wrap' ).removeClass( 'td-aj-cur-element' ); 2309 2310 if (tdAjaxSearch._current_selection_index > tdAjaxSearch._last_request_results_count - 1 ) { 2311 //the input is selected 2312 jQuery( '.td-search-form' ).fadeTo( 100, 1 ); 2313 } else { 2314 tdAjaxSearch.td_aj_search_input_remove_focus(); 2315 jQuery( '.td_module_wrap' ).eq( tdAjaxSearch._current_selection_index ).addClass( 'td-aj-cur-element' ); 2316 } 2317 }, 2318 2319 2320 /** 2321 * puts the focus on the input box 2322 */ 2323 td_aj_search_input_focus: function() { 2324 tdAjaxSearch._current_selection_index = 0; 2325 tdAjaxSearch._first_down_up = true; 2326 jQuery( '.td-search-form' ).fadeTo( 100, 1 ); 2327 jQuery( '.td_module_wrap' ).removeClass( 'td-aj-cur-element' ); 2328 }, 2329 2330 2331 2332 /** 2333 * removes the focus from the input box 2334 */ 2335 td_aj_search_input_remove_focus: function() { 2336 if ( 0 !== tdAjaxSearch._last_request_results_count ) { 2337 jQuery( '.td-search-form' ).css( 'opacity', 0.5 ); 2338 } 2339 }, 2340 2341 2342 2343 /** 2344 * AJAX: process the response from the server 2345 */ 2346 process_ajax_response: function(data) { 2347 var current_query = jQuery( '#td-header-search' ).val(); 2348 2349 //the search is empty - drop results 2350 if ( '' === current_query ) { 2351 jQuery( '#td-aj-search' ).empty(); 2352 return; 2353 } 2354 2355 var td_data_object = jQuery.parseJSON(data); //get the data object 2356 //drop the result - it's from a old query 2357 if ( td_data_object.td_search_query !== current_query ) { 2358 return; 2359 } 2360 2361 //reset the current selection and total posts 2362 tdAjaxSearch._current_selection_index = 0; 2363 tdAjaxSearch._last_request_results_count = td_data_object.td_total_in_list; 2364 tdAjaxSearch._first_down_up = true; 2365 2366 //update the query 2367 jQuery( '#td-aj-search' ).html( td_data_object.td_data ); 2368 2369 /* 2370 td_data_object.td_data 2371 td_data_object.td_total_results 2372 td_data_object.td_total_in_list 2373 */ 2374 2375 // the .entry-thumb are searched for in the #td-aj-search object, sorted and added into the view port array items 2376 if ( ( 'undefined' !== typeof window.tdAnimationStack ) && ( true === window.tdAnimationStack.activated ) ) { 2377 window.tdAnimationStack.check_for_new_items( '#td-aj-search .td-animation-stack', window.tdAnimationStack.SORTED_METHOD.sort_left_to_right, true ); 2378 window.tdAnimationStack.compute_items();
2379 } 2380 }, 2381 2382 2383 /** 2384 * AJAX: process the response from the server for the responsive version of the theme 2385 */ 2386 process_ajax_response_mob: function(data) { 2387 var current_query = jQuery( '#td-header-search-mob' ).val(); 2388 2389 //the search is empty - drop results 2390 if ( '' === current_query ) { 2391 jQuery('#td-aj-search-mob').empty(); 2392 return; 2393 } 2394 2395 var td_data_object = jQuery.parseJSON( data ); //get the data object 2396 //drop the result - it's from a old query 2397 if ( td_data_object.td_search_query !== current_query ) { 2398 return; 2399 } 2400 2401 //update the query 2402 jQuery( '#td-aj-search-mob' ).html( td_data_object.td_data ); 2403 2404 // the .entry-thumb are searched for in the #td-aj-search-mob object, sorted and added into the view port array items 2405 if ( ( 'undefined' !== typeof window.tdAnimationStack ) && ( true === window.tdAnimationStack.activated ) ) { 2406 window.tdAnimationStack.check_for_new_items( '#td-aj-search-mob .td-animation-stack', window.tdAnimationStack.SORTED_METHOD.sort_left_to_right, true ); 2407 window.tdAnimationStack.compute_items(); 2408 } 2409 }, 2410 2411 2412 /** 2413 * AJAX: do the ajax request 2414 */ 2415 do_ajax_call: function() { 2416 var search_query = jQuery('#td-header-search').val(); 2417 2418 if ( '' === search_query ) { 2419 tdAjaxSearch.td_aj_search_input_focus(); 2420 return; 2421 } 2422 2423 //do we have a cache hit 2424 if (tdLocalCache.exist(search_query)) { 2425 tdAjaxSearch.process_ajax_response(tdLocalCache.get(search_query)); 2426 return; //cache HIT 2427 } 2428 2429 //fk no cache hit - do the real request 2430 2431 jQuery.ajax({ 2432 type: 'POST', 2433 url: td_ajax_url, 2434 data: { 2435 action: 'td_ajax_search', 2436 td_string: search_query 2437 }, 2438 success: function(data, textStatus, XMLHttpRequest){ 2439 tdLocalCache.set(search_query, data); 2440 tdAjaxSearch.process_ajax_response(data); 2441 }, 2442 error: function(MLHttpRequest, textStatus, errorThrown){ 2443 //console.log(errorThrown); 2444 } 2445 }); 2446 }, 2447 2448 2449 /** 2450 * AJAX: do the ajax request for the responsive version of the theme 2451 */ 2452 do_ajax_call_mob: function() { 2453 var search_query = jQuery( '#td-header-search-mob' ).val(); 2454 2455 if ( '' === search_query) { 2456 return; 2457 } 2458 2459 //do we have a cache hit 2460 if ( tdLocalCache.exist( search_query ) ) { 2461 tdAjaxSearch.process_ajax_response_mob( tdLocalCache.get( search_query ) ); 2462 return; //cache HIT 2463 } 2464 2465 //fk no cache hit - do the real request 2466 2467 jQuery.ajax({ 2468 type: 'POST', 2469 url: td_ajax_url, 2470 data: { 2471 action: 'td_ajax_search', 2472 td_string: search_query 2473 }, 2474 success: function( data, textStatus, XMLHttpRequest ){ 2475 tdLocalCache.set( search_query, data ); 2476 tdAjaxSearch.process_ajax_response_mob( data ); 2477 }, 2478 error: function( MLHttpRequest, textStatus, errorThrown ){ 2479 //console.log(errorThrown); 2480 } 2481 }); 2482 } 2483 }; 2484 2485})(); 2486 2487;'use strict'; 2488 2489/* ---------------------------------------------------------------------------- 2490 tdPostImages.js 2491 --------------------------------------------------------------------------- */ 2492 2493/* global jQuery:{} */ 2494/* global tdUtil:{} */ 2495/* global tdAffix:{} */ 2496/* global tdIsScrollingAnimation:boolean */ 2497 2498/* ---------------------------------------------------------------------------- 2499 On load 2500 */ 2501jQuery().ready(function() { 2502 2503 //handles the modal images 2504 tdModalImage(); 2505 2506 //move classes from post images to figure - td-post-image-full etc 2507 tdUtil.imageMoveClassToFigure( 'td-post-image-full' ); 2508 tdUtil.imageMoveClassToFigure( 'td-post-image-right' ); 2509 tdUtil.imageMoveClassToFigure( 'td-post-image-left' ); 2510 2511 /** 2512 * - add a general td-modal-image class to the all post images 2513 */ 2514 if ( ( 'undefined' !== typeof window.tds_general_modal_image ) && ( '' !== window.tds_general_modal_image ) ) { 2515 jQuery( '.single .td-post-content a > img' ).filter(function( index, element ) { 2516 if ( -1 !== element.className.indexOf( 'wp-image' ) ) { 2517 jQuery( element ).parent().addClass( 'td-modal-image' ); 2518 } 2519 }); 2520 } 2521}); 2522 2523 2524 2525// used for scrolling to the last element 2526var tdModalImageLastEl = ''; 2527 2528// handles modal images for: Featured images, inline image, inline image with caption, galleries 2529function tdModalImage() { 2530 2531 //fix wordpress figure + figcaption (we move the figcaption in the data-caption attribute of the link) 2532 jQuery( 'figure.wp-caption' ).each(function() { 2533 var caption_text = jQuery( this ).children( 'figcaption' ).html(); 2534 jQuery( this ).children( 'a' ).data( 'caption', caption_text ); 2535 });
2536 2537 //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 2538 jQuery( '.td-modal-image' ).each(function() { 2539 jQuery( this ).parent().addClass( 'td-modal-image' ); 2540 jQuery( this ).removeClass( 'td-modal-image' ); 2541 }); 2542 2543 2544 2545 //popup on modal images in articles 2546 jQuery( 'article' ).magnificPopup({ 2547 type: 'image', 2548 delegate: ".td-modal-image", 2549 gallery: { 2550 enabled: true, 2551 tPrev: tdUtil.getBackendVar( 'td_magnific_popup_translation_tPrev' ), // Alt text on left arrow 2552 tNext: tdUtil.getBackendVar( 'td_magnific_popup_translation_tNext' ), // Alt text on right arrow 2553 tCounter: tdUtil.getBackendVar( 'td_magnific_popup_translation_tCounter' ) // Markup for "1 of 7" counter 2554 }, 2555 ajax: { 2556 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_ajax_tError' ) 2557 }, 2558 image: { 2559 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_image_tError' ), 2560 titleSrc: function( item ) {//console.log(item.el); 2561 //alert(jQuery(item.el).data("caption")); 2562 var td_current_caption = jQuery( item.el ).data( 'caption' ); 2563 if ( 'undefined' !== typeof td_current_caption ) { 2564 return td_current_caption; 2565 } else { 2566 return ''; 2567 } 2568 } 2569 }, 2570 zoom: { 2571 enabled: true, 2572 duration: 300, 2573 opener: function( element ) { 2574 return element.find( 'img' ); 2575 } 2576 }, 2577 callbacks: { 2578 change: function( item ) { 2579 tdModalImageLastEl = item.el; 2580 //setTimeout(function(){ 2581 tdUtil.scrollIntoView( item.el ); 2582 //}, 100); 2583 }, 2584 beforeClose: function() { 2585 tdAffix.allow_scroll = false; 2586 2587 tdUtil.scrollIntoView( tdModalImageLastEl ); 2588 2589 var interval_td_affix_scroll = setInterval(function() { 2590 2591 if ( ! tdIsScrollingAnimation ) { 2592 clearInterval( interval_td_affix_scroll ); 2593 setTimeout(function() { 2594 tdAffix.allow_scroll = true; 2595 //tdAffix.td_events_scroll(td_events.scroll_window_scrollTop); 2596 }, 100 ); 2597 } 2598 }, 100 ); 2599 } 2600 } 2601 }); 2602 2603 2604 2605 2606 2607 //gallery popup 2608 //detect jetpack carousel and disable the theme popup 2609 if ( 'undefined' === typeof jetpackCarouselStrings ) { 2610 2611 // 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 2612 jQuery( 'figure.gallery-item' ).each(function() { 2613 var caption_text = jQuery( this ).children( 'figcaption' ).html(); 2614 jQuery( this ).find( 'a' ).data( 'caption', caption_text ); 2615 }); 2616 2617 2618 //jquery tiled gallery 2619 jQuery( '.tiled-gallery' ).magnificPopup({ 2620 type: 'image', 2621 delegate: "a", 2622 gallery: { 2623 enabled: true, 2624 tPrev: tdUtil.getBackendVar( 'td_magnific_popup_translation_tPrev' ), // Alt text on left arrow 2625 tNext: tdUtil.getBackendVar( 'td_magnific_popup_translation_tNext' ), // Alt text on right arrow 2626 tCounter: tdUtil.getBackendVar( 'td_magnific_popup_translation_tCounter' ) // Markup for "1 of 7" counter 2627 }, 2628 ajax: { 2629 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_ajax_tError' ) 2630 }, 2631 image: { 2632 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_image_tError' ), 2633 titleSrc: function( item ) {//console.log(item.el); 2634 var td_current_caption = jQuery( item.el ).parent().find( '.tiled-gallery-caption' ).text(); 2635 if ( 'undefined' !== typeof td_current_caption ) { 2636 return td_current_caption; 2637 } else { 2638 return ''; 2639 } 2640 } 2641 }, 2642 zoom: { 2643 enabled: true, 2644 duration: 300, 2645 opener: function( element ) {
2646 return element.find( 'img' ); 2647 } 2648 }, 2649 callbacks: { 2650 change: function( item ) { 2651 tdModalImageLastEl = item.el; 2652 tdUtil.scrollIntoView( item.el ); 2653 }, 2654 beforeClose: function() { 2655 tdUtil.scrollIntoView( tdModalImageLastEl ); 2656 } 2657 } 2658 }); 2659 2660 2661 2662 jQuery( '.gallery' ).magnificPopup({ 2663 type: 'image', 2664 delegate: '.gallery-icon > a', 2665 gallery: { 2666 enabled: true, 2667 tPrev: tdUtil.getBackendVar( 'td_magnific_popup_translation_tPrev' ), // Alt text on left arrow 2668 tNext: tdUtil.getBackendVar( 'td_magnific_popup_translation_tNext' ), // Alt text on right arrow 2669 tCounter: tdUtil.getBackendVar( 'td_magnific_popup_translation_tCounter' ) // Markup for "1 of 7" counter 2670 }, 2671 ajax: { 2672 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_ajax_tError' ) 2673 }, 2674 image: { 2675 tError: tdUtil.getBackendVar( 'td_magnific_popup_translation_image_tError' ), 2676 titleSrc: function( item ) {//console.log(item.el); 2677 var td_current_caption = jQuery( item.el ).data( 'caption' ); 2678 if ( 'undefined' !== typeof td_current_caption ) { 2679 return td_current_caption; 2680 } else { 2681 return ''; 2682 } 2683 } 2684 }, 2685 zoom: { 2686 enabled: true, 2687 duration: 300, 2688 opener: function( element ) { 2689 return element.find( 'img' ); 2690 } 2691 }, 2692 callbacks: { 2693 change: function( item ) { 2694 tdModalImageLastEl = item.el; 2695 tdUtil.scrollIntoView( item.el ); 2696 }, 2697 beforeClose: function() { 2698 tdUtil.scrollIntoView( tdModalImageLastEl ); 2699 } 2700 } 2701 }); 2702 } 2703} //end modal 2704/** 2705 * tdBlocks.js 2706 * v3.0 5 August 2015 2707 * Converted to WP JS standards + jsHint 2708 */ 2709 2710/* global jQuery:false */ 2711/* global td_ajax_url:false */ 2712/* global tds_theme_color_site_wide:false */ 2713 2714 2715 2716/* global tdSmartSidebar:{} */ 2717/* global tdAnimationStack:{} */ 2718/* global tdUtil:false */ //done 2719/* global tdLoadingBox:false */ //done 2720/* global tdInfiniteLoader:false */ //done 2721/* global tdBlocksArray:false */ //done 2722/* global tdDetect:false */ //done 2723/* global tdLocalCache:false */ //done 2724 2725var tdBlocks = {}; 2726 2727( function() { 2728 "use strict"; 2729 2730 /* ---------------------------------------------------------------------------- 2731 On load 2732 */ 2733 jQuery().ready( function() { 2734 tdOnReadyAjaxBlocks(); 2735 }); 2736 2737 2738 2739 2740 2741 2742 function tdOnReadyAjaxBlocks() { 2743 2744 2745 /* ---------------------------------------------------------------------------- 2746 AJAX pagination next 2747 */ 2748 jQuery(".td-ajax-next-page").click( function(event) { 2749 event.preventDefault(); 2750 2751 var currentBlockObj = tdBlocks.tdGetBlockObjById(jQuery(this).data('td_block_id')); 2752 2753 if ( jQuery(this).hasClass('ajax-page-disabled') || true === currentBlockObj.is_ajax_running ) { 2754 return; 2755 } 2756 2757 currentBlockObj.is_ajax_running = true; // ajax is running and we're wayting for a reply from server 2758 2759 currentBlockObj.td_current_page++; 2760 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'next'); 2761 }); 2762 2763 2764 /* ---------------------------------------------------------------------------- 2765 AJAX pagination prev 2766 */ 2767 jQuery(".td-ajax-prev-page").click( function(event) { 2768 event.preventDefault(); 2769 2770 var currentBlockObj = tdBlocks.tdGetBlockObjById(jQuery(this).data('td_block_id')); 2771 2772 if ( jQuery(this).hasClass('ajax-page-disabled') || true === currentBlockObj.is_ajax_running ) { 2773 return; 2774 } 2775 2776 currentBlockObj.is_ajax_running = true; // ajax is running and we're wayting for a reply from server 2777 2778 currentBlockObj.td_current_page--; 2779 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'back'); 2780 }); 2781 2782 2783 /* ---------------------------------------------------------------------------- 2784 AJAX pagination load more 2785 */ 2786 jQuery(".td_ajax_load_more_js").click( function(event) { 2787 event.preventDefault(); 2788 if ( jQuery(this).hasClass('ajax-page-disabled') ) { 2789 return; 2790 } 2791 2792 jQuery(this).css('visibility', 'hidden'); 2793 2794 var currentBlockObj = tdBlocks.tdGetBlockObjById(jQuery(this).data('td_block_id')); 2795 2796 currentBlockObj.td_current_page++; 2797 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'load_more'); 2798 2799 // load_more is hidden if there are no more posts 2800 if ( currentBlockObj.max_num_pages <= currentBlockObj.td_current_page ) { 2801 jQuery(this).addClass('ajax-page-disabled'); 2802 } 2803 }); 2804 2805 2806 2807 /* ---------------------------------------------------------------------------- 2808 pull down open/close //on mobile devices use click event 2809 */ 2810 if ( tdDetect.isMobileDevice ) { 2811 2812 jQuery(".td-pulldown-filter-display-option").click( function () { 2813 var currentBlockUid = jQuery(this).data('td_block_id'); 2814 jQuery("#td_pulldown_" + currentBlockUid).addClass("td-pulldown-filter-list-open"); 2815 2816 //animate the list 2817 var tdPullDownList = jQuery("#td_pulldown_" + currentBlockUid + "_list"); 2818 tdPullDownList.removeClass('fadeOut'); 2819 tdPullDownList.addClass('td_animated td_fadeIn'); //used for opacity animation 2820 //tdPullDownList.css('visibility', 'visible'); 2821 }); 2822 2823 //on desktop devices use hover event 2824 } else { 2825 2826 /** 2827 * (hover) open and close the drop down menu (on blocks on hover) 2828 */ 2829 jQuery(".td-pulldown-filter-display-option").hover( function () { 2830 // hover in 2831 var current_block_uid = jQuery(this).data('td_block_id'); 2832 jQuery("#td_pulldown_" + current_block_uid).addClass("td-pulldown-filter-list-open"); 2833 2834 //animate the list 2835 var tdPullDownList = jQuery("#td_pulldown_" + current_block_uid + "_list"); 2836 tdPullDownList.removeClass('fadeOut'); 2837 tdPullDownList.addClass('td_animated td_fadeIn'); //used for opacity animation 2838 tdPullDownList.css('visibility', 'visible'); 2839 2840 }, 2841 function () { 2842 // hover out 2843 var currentBlockUid = jQuery(this).data('td_block_id'); 2844 jQuery("#td_pulldown_" + currentBlockUid).removeClass("td-pulldown-filter-list-open"); 2845 2846 2847 } 2848 ); 2849 } 2850 2851 2852 2853 /* ---------------------------------------------------------------------------- 2854 click on related posts in single posts 2855 */ 2856 jQuery('.td-related-title a').click( function(event) { 2857 event.preventDefault(); 2858 2859 jQuery('.td-related-title').children('a').removeClass('td-cur-simple-item'); 2860 jQuery(this).addClass('td-cur-simple-item'); 2861 2862 //get the current block id 2863 var currentBlockUid = jQuery(this).data('td_block_id'); 2864 2865 //get current block 2866 var currentBlockObj = tdBlocks.tdGetBlockObjById(currentBlockUid); 2867 2868 //change current filter value - the filter type is readed by td_ajax from the atts of the shortcode 2869 currentBlockObj.td_filter_value = jQuery(this).data('td_filter_value'); 2870 2871 currentBlockObj.td_current_page = 1; //reset the page 2872 2873 //do request 2874 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'pull_down'); 2875 }); 2876 2877 2878 2879 2880 /* ---------------------------------------------------------------------------- 2881 MEGA MENU 2882 */ 2883 // Used to simulate on mobile doubleclick at 300ms @see the function tdAjaxSubCatMegaRun() 2884 var tdSubCatMegaRunLink = false; // run the link if this is true, instead of loading via ajax the mega menu content 2885 var tdSubCatMegaLastTarget = ''; // last event target - to make sure the double click is on the same element 2886 2887 2888 /** 2889 * On touch screens check for double click and redirect to the subcategory page if that's the case, 2890 * if not double click... do the normal ajax request 2891 * @param event 2892 * @param jQueryObject 2893 */ 2894 function tdAjaxSubCatMegaRunOnTouch(event, jQueryObject) { 2895 if ( (true === tdSubCatMegaRunLink) && (event.target === tdSubCatMegaLastTarget) ) { 2896 window.location = event.target; 2897 } else { 2898 tdSubCatMegaRunLink = true; 2899 tdSubCatMegaLastTarget = event.target; 2900 event.preventDefault(); 2901 2902 setTimeout( function() { 2903 tdSubCatMegaRunLink = false; 2904 }, 300); 2905 2906 tdAjaxSubCatMegaRun(event, jQueryObject); 2907 } 2908 } 2909 2910 /**
2911 * this one makes the ajax request for mega menu filter 2912 * hover or click on mega menu subcategories 2913 */ 2914 function tdAjaxSubCatMegaRun(event, jQueryObject) { 2915 /* global this:false */ 2916 //get the current block id 2917 var currentBlockUid = jQueryObject.data('td_block_id'); 2918 var currentBlockObj = tdBlocks.tdGetBlockObjById(currentBlockUid); 2919 2920 // 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 2921 currentBlockObj.is_ajax_running = true; 2922 2923 //switch cur cat 2924 jQuery('.mega-menu-sub-cat-' + currentBlockUid).removeClass('cur-sub-cat'); 2925 jQueryObject.addClass('cur-sub-cat'); 2926 2927 //get current block 2928 2929 2930 //change current filter value - the filter type is readed by td_ajax from the atts of the shortcode 2931 currentBlockObj.td_filter_value = jQueryObject.data('td_filter_value'); 2932 2933 currentBlockObj.td_current_page = 1; //reset the page 2934 2935 //do request 2936 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'mega_menu'); 2937 } 2938 2939 2940 /** 2941 * Mega menu filters 2942 */ 2943 //on touch devices use click 2944 // @todo needs testing to determine why we need .click and touchend? 2945 // @todo trebuie refactorizata sa transmita jQuery(this) de aici la functii 2946 if ( tdDetect.isTouchDevice ) { 2947 jQuery(".block-mega-child-cats a") 2948 .click( function(event) { 2949 tdAjaxSubCatMegaRunOnTouch(event, jQuery(this)); 2950 }, false) 2951 .each(function(index, element) { 2952 element.addEventListener('touchend', function(event) { 2953 tdAjaxSubCatMegaRunOnTouch(event, jQuery(this)); 2954 }, false); 2955 }); 2956 2957 } else { 2958 jQuery(".block-mega-child-cats a").hover( function(event) { 2959 tdAjaxSubCatMegaRun(event, jQuery(this)); 2960 }, function (event) {} ); 2961 } 2962 2963 2964 2965 /* ---------------------------------------------------------------------------- 2966 Subcategories 2967 */ 2968 /** 2969 * Newspaper ONLY 2970 * used by the drop down ajax filter on blocks 2971 */ 2972 jQuery('.td-subcat-item a').click( function(event) { 2973 event.preventDefault(); 2974 2975 var currentBlockObj = tdBlocks.tdGetBlockObjById(jQuery(this).data('td_block_id')); 2976 2977 //if ( jQuery(this).hasClass('ajax-page-disabled') || true === currentBlockObj.is_ajax_running ) { 2978 // return; 2979 //} 2980 // 2981 if ( true === currentBlockObj.is_ajax_running ) { 2982 return; 2983 } 2984 2985 2986 currentBlockObj.is_ajax_running = true; // ajax is running and we're waiting for a reply from server 2987 2988 2989 jQuery('.' + jQuery(this).data('td_block_id') + '_rand').find('.td-cur-simple-item').removeClass('td-cur-simple-item'); 2990 jQuery(this).addClass('td-cur-simple-item'); 2991 2992 2993 //change current filter value - the filter type is read by td_ajax from the atts of the shortcode 2994 currentBlockObj.td_filter_value = jQuery(this).data('td_filter_value'); 2995 2996 2997 2998 //reset the page 2999 currentBlockObj.td_current_page = 1; 3000 3001 // we ues 'pull_down' just for the 'td_animated_xlong td_fadeInDown' effect 3002 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'pull_down'); 3003 }); 3004 3005 3006 /** 3007 * Newsmag ONLY 3008 * when a item is from the dropdown menu is clicked (on all the blocks) 3009 * @todo asta face ceva cu ios slider-ul in plus fata de aia de pe Newspaper 3010 */ 3011 jQuery(".td-pulldown-filter-link").click( function(event) { 3012 event.preventDefault(); 3013 3014 3015 3016 //get the current block id 3017 var currentBlockUid = jQuery(this).data('td_block_id'); 3018 3019 //destroy any iossliders to avoid bugs 3020 jQuery('#' + currentBlockUid).find('.iosSlider').iosSlider('destroy'); 3021 3022 //get current block 3023 var currentBlockObj = tdBlocks.tdGetBlockObjById(currentBlockUid); 3024 if ( true === currentBlockObj.is_ajax_running ) { 3025 return; 3026 } 3027 3028 currentBlockObj.is_ajax_running = true; 3029 //change current filter value - the filter type is readed by td_ajax from the atts of the shortcode 3030 currentBlockObj.td_filter_value = jQuery(this).data('td_filter_value'); 3031 3032 3033 currentBlockObj.td_current_page = 1; 3034 3035 3036 //put loading... text and hide the dropdown @todo - tranlation pt loading 3037 //tdBlocks.tdPullDownFilterChangeValue(currentBlockObj.id, '<span>Loading... </span><i class="td-icon-menu-down"></i>'); 3038 tdBlocks.tdPullDownFilterChangeValue(currentBlockUid, '<span>' + jQuery(this).html() + ' </span><i class="td-icon-menu-down"></i>'); 3039 3040 3041 //hide the dropdown 3042 jQuery('#td_pulldown_' + currentBlockUid).removeClass("td-pulldown-filter-list-open"); 3043 3044 3045 //do request 3046 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'pull_down'); 3047 3048 3049 //on mobile devices stop event propagation 3050 if ( tdDetect.isMobileDevice ) { 3051 tdUtil.stopBubble(event); 3052 } 3053 3054 }); 3055 } // end tdOnReadyAjaxBlocks() 3056 3057 3058 3059 3060 3061 3062 tdBlocks = { 3063 3064 3065 /** 3066 * Newsmag ONLY change the pull down filter value to loading... and to the current category after an ajax reply 3067 * is received 3068 * @param td_block_uid 3069 * @param td_text 3070 */ 3071 tdPullDownFilterChangeValue: function(td_block_uid, td_text) { 3072 jQuery('#td-pulldown-' + td_block_uid + '-val').html(td_text); 3073 }, 3074 3075 3076 3077 /** 3078 * makes a ajax block request 3079 * @param current_block_obj 3080 * @param td_user_action - load more or infinite loader (used by the animation) 3081 * @returns {string} 3082 */ 3083 tdAjaxDoBlockRequest: function(current_block_obj, td_user_action) { 3084 //search the cache 3085 var currentBlockObjSignature = JSON.stringify(current_block_obj); 3086 if ( tdLocalCache.exist(currentBlockObjSignature) ) { 3087 //do the animation with cache hit = true 3088 tdBlocks.tdBlockAjaxLoadingStart(current_block_obj, true, td_user_action); 3089 tdBlocks.tdAjaxBlockProcessResponse(tdLocalCache.get(currentBlockObjSignature), td_user_action); 3090 return 'cache_hit'; //cache HIT 3091 } 3092 3093
3094 //cache miss - we make a full request! - cache hit - false 3095 tdBlocks.tdBlockAjaxLoadingStart(current_block_obj, false, td_user_action); 3096//return; 3097 var requestData = { 3098 action: 'td_ajax_block', 3099 td_atts: current_block_obj.atts, 3100 td_block_id:current_block_obj.id, 3101 td_column_number:current_block_obj.td_column_number, 3102 td_current_page:current_block_obj.td_current_page, 3103 block_type:current_block_obj.block_type, 3104 td_filter_value:current_block_obj.td_filter_value, 3105 td_user_action:current_block_obj.td_user_action 3106 }; 3107 3108 //console.log('tdAjaxDoBlockRequest:'); 3109 //console.log(requestData); 3110 3111 jQuery.ajax({ 3112 type: 'POST', 3113 url: td_ajax_url, 3114 cache:true, 3115 data: requestData, 3116 success: function(data, textStatus, XMLHttpRequest) { 3117 3118 tdLocalCache.set(currentBlockObjSignature, data); 3119 tdBlocks.tdAjaxBlockProcessResponse(data, td_user_action); 3120 }, 3121 error: function(MLHttpRequest, textStatus, errorThrown) { 3122 //console.log(errorThrown); 3123 } 3124 }); 3125 }, 3126 3127 3128 /** 3129 * process the response from the ajax query (it also processes the responses stored in the cache) 3130 * @param data 3131 * @param td_user_action - load more or infinite loader (used by the animation) 3132 */ 3133 tdAjaxBlockProcessResponse: function(data, td_user_action) { 3134 3135 //read the server response 3136 var tdReplyObj = jQuery.parseJSON(data); //get the data object 3137 3138 //console.log('tdAjaxBlockProcessResponse:'); 3139 //console.log(tdReplyObj); 3140 /* 3141 td_data_object.td_block_id 3142 td_data_object.td_data 3143 td_data_object.td_cur_cat 3144 */ 3145 3146 3147 3148 3149 3150 3151 //load the content (in place or append) 3152 if ( 'load_more' === td_user_action || 'infinite_load' === td_user_action ) { 3153 3154 // fix needed to keep sidebars fixed down when they are bottom of the content and the content grows up 3155 for ( var i = 0; i < tdSmartSidebar.items.length; i++ ) { 3156 if ( 'case_3_bottom_of_content' === tdSmartSidebar.items[ i ].sidebar_state ) { 3157 tdSmartSidebar.items[ i ].sidebar_state = 'case_1_fixed_down'; 3158 } 3159 } 3160 3161 jQuery(tdReplyObj.td_data).appendTo('#' + tdReplyObj.td_block_id); 3162 //jQuery(tdReplyObj.td_data).addClass('td_animated_xxlong').appendTo('#' + tdReplyObj.td_block_id).addClass('td_fadeIn'); 3163 //jQuery('#' + tdReplyObj.td_block_id).append(tdReplyObj.td_data); //append 3164 } else { 3165 jQuery('#' + tdReplyObj.td_block_id).html(tdReplyObj.td_data); //in place 3166 } 3167 3168 3169 //hide or show prev 3170 if ( true === tdReplyObj.td_hide_prev ) { 3171 jQuery('#prev-page-' + tdReplyObj.td_block_id).addClass('ajax-page-disabled'); 3172 } else { 3173 jQuery('#prev-page-' + tdReplyObj.td_block_id).removeClass('ajax-page-disabled'); 3174 } 3175 3176 //hide or show next 3177 if ( true === tdReplyObj.td_hide_next ) { 3178 jQuery('#next-page-' + tdReplyObj.td_block_id).addClass('ajax-page-disabled'); 3179 } else { 3180 jQuery('#next-page-' + tdReplyObj.td_block_id).removeClass('ajax-page-disabled'); 3181 } 3182 3183 3184 var currentBlockObj = tdBlocks.tdGetBlockObjById(tdReplyObj.td_block_id); 3185 if ( 'slide' === currentBlockObj.block_type ) { 3186 //make the first slide active (to have caption) 3187 jQuery('#' + tdReplyObj.td_block_id + ' .slide-wrap-active-first').addClass('slide-wrap-active'); 3188 } 3189 3190 currentBlockObj.is_ajax_running = false; // finish the loading for this block 3191 3192 3193 //loading effects 3194 tdBlocks.tdBlockAjaxLoadingEnd(tdReplyObj, currentBlockObj, td_user_action); //td_user_action - load more or infinite loader (used by the animation) 3195 }, 3196 3197 3198 3199 /** 3200 * loading start 3201 * @param current_block_obj 3202 * @param cache_hit boolean - is true if we have a cache hit 3203 * @param td_user_action - the request type / infinite_load ? 3204 */ 3205 tdBlockAjaxLoadingStart: function(current_block_obj, cache_hit, td_user_action) { 3206 3207 //get the element 3208 var elCurTdBlockInner = jQuery('#' + current_block_obj.id); 3209 3210 //remove any remaining loaders 3211 jQuery('.td-loader-gif').remove(); 3212 3213 //remove animation classes 3214 elCurTdBlockInner.removeClass('td_fadeInRight td_fadeInLeft td_fadeInDown td_fadeInUp td_animated_xlong'); 3215 3216 elCurTdBlockInner.addClass('td_block_inner_overflow'); 3217 //auto height => fixed height
3218 var tdTmpBlockHeight = elCurTdBlockInner.height(); 3219 elCurTdBlockInner.css('height', tdTmpBlockHeight); 3220 3221 3222 //show the loader only if we have a cache MISS 3223 if ( false === cache_hit ) { 3224 if ( 'load_more' === td_user_action) { 3225 // on load more 3226 elCurTdBlockInner.parent().append('<div class="td-loader-gif td-loader-infinite td-loader-blocks-load-more td-loader-animation-start"></div>'); 3227 tdLoadingBox.init(current_block_obj.header_color ? current_block_obj.header_color : tds_theme_color_site_wide); //init the loading box 3228 setTimeout(function () { 3229 jQuery('.td-loader-gif') 3230 .removeClass('td-loader-animation-start') 3231 .addClass('td-loader-animation-mid'); 3232 }, 50); 3233 3234 } 3235 else if ('infinite_load' === td_user_action) { 3236 // on infinite load 3237 elCurTdBlockInner.parent().append('<div class="td-loader-gif td-loader-infinite td-loader-animation-start"></div>'); 3238 tdLoadingBox.init(current_block_obj.header_color ? current_block_obj.header_color : tds_theme_color_site_wide); //init the loading box 3239 setTimeout(function () { 3240 jQuery('.td-loader-gif') 3241 .removeClass('td-loader-animation-start') 3242 .addClass('td-loader-animation-mid'); 3243 }, 50); 3244 3245 } else { 3246 /** 3247 * the default animation if the user action is NOT load_more or infinite_load 3248 * infinite load has NO animation ! 3249 */ 3250 elCurTdBlockInner.parent().append('<div class="td-loader-gif td-loader-animation-start"></div>'); 3251 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) 3252 setTimeout( function(){ 3253 jQuery('.td-loader-gif') 3254 .removeClass('td-loader-animation-start') 3255 .addClass('td-loader-animation-mid'); 3256 },50); 3257 elCurTdBlockInner.addClass('td_animated_long td_fadeOut_to_1'); 3258 3259 } 3260 } // end cache_hit if 3261 }, 3262 3263 3264 3265 /** 3266 * we have a reply from the ajax request 3267 * @param td_reply_obj - the reply object that we got from the server, it's useful with infinite load 3268 * @param current_block_obj 3269 * @param td_user_action - load more or infinite loader (used by the animation) 3270 */ 3271 tdBlockAjaxLoadingEnd: function(td_reply_obj, current_block_obj, td_user_action) { 3272 3273 //jQuery('.td-loader-gif').remove(); 3274 // remove the loader 3275 jQuery('.td-loader-gif') 3276 .removeClass('td-loader-animation-mid') 3277 .addClass('td-loader-animation-end'); 3278 setTimeout( function() { 3279 jQuery('.td-loader-gif').remove(); 3280 //stop the loading box 3281 tdLoadingBox.stop(); 3282 },400); 3283 3284 3285 //get the current inner 3286 var elCurTdBlockInner = jQuery('#' + current_block_obj.id); 3287 3288 elCurTdBlockInner.removeClass('td_animated_long td_fadeOut_to_1'); 3289 3290 3291 // by default, the sort method used to animate the ajax response is left to the right 3292 3293 var tdAnimationStackSortType; 3294 3295 if ( true === tdAnimationStack.activated ) { 3296 tdAnimationStackSortType = tdAnimationStack.SORTED_METHOD.sort_left_to_right; 3297 } 3298 3299 switch(td_user_action) { 3300 case 'next': 3301 elCurTdBlockInner.addClass('td_animated_xlong td_fadeInRight'); 3302 3303 // the default sort method is modified to work from right to the left 3304 if ( undefined !== tdAnimationStackSortType ) { 3305 tdAnimationStackSortType = tdAnimationStack.SORTED_METHOD.sort_right_to_left; 3306 } 3307 3308 break; 3309 case 'back': 3310 elCurTdBlockInner.addClass('td_animated_xlong td_fadeInLeft'); 3311 break; 3312 3313 case 'pull_down': 3314 elCurTdBlockInner.addClass('td_animated_xlong td_fadeInDown'); 3315 break; 3316 3317 case 'mega_menu': 3318 elCurTdBlockInner.addClass('td_animated_xlong td_fadeInDown'); 3319 break; 3320 3321 3322 case 'load_more': 3323 //console.log('.' + current_block_obj.id + '_rand .td_ajax_load_more_js'); 3324 setTimeout ( function() { 3325 jQuery('.' + current_block_obj.id + '_rand .td_ajax_load_more_js').css('visibility', 'visible'); 3326 }, 500); 3327 3328 break; 3329 case 'infinite_load': 3330 setTimeout( function() { 3331 //refresh waypoints for infinit scroll tdInfiniteLoader 3332 tdInfiniteLoader.computeTopDistances();
3333 if ( '' !== td_reply_obj.td_data ) { 3334 tdInfiniteLoader.enable_is_visible_callback(current_block_obj.id); 3335 } 3336 }, 500); 3337 3338 3339 setTimeout( function() { 3340 tdInfiniteLoader.computeTopDistances(); 3341 // load next page only if we have new data coming from the last ajax request 3342 }, 1000); 3343 3344 setTimeout( function() { 3345 tdInfiniteLoader.computeTopDistances(); 3346 }, 1500); 3347 break; 3348 3349 } 3350 3351 3352 3353 setTimeout( function() { 3354 jQuery('.td_block_inner_overflow').removeClass('td_block_inner_overflow'); 3355 elCurTdBlockInner.css('height', 'auto'); 3356 3357 tdSmartSidebar.compute(); 3358 },200); 3359 3360 3361 3362 3363 setTimeout( function () { 3364 tdSmartSidebar.compute(); 3365 }, 500); 3366 3367 3368 3369 // the .entry-thumb are searched for in the current block object, sorted and added into the view port array items 3370 if ( undefined !== tdAnimationStackSortType ) { 3371 setTimeout( function () { 3372 tdAnimationStack.check_for_new_items('#' + current_block_obj.id + ' .td-animation-stack', tdAnimationStackSortType, true); 3373 }, 200); 3374 } 3375 }, 3376 3377 /** 3378 * search by block _id 3379 * @param myID - block id 3380 * @returns {number} the index 3381 */ 3382 tdGetBlockIndex: function(myID) { 3383 var cnt = 0; 3384 var tmpReturn = 0; 3385 jQuery.each(tdBlocksArray, function(index, td_block) { 3386 if ( td_block.id === myID ) { 3387 tmpReturn = cnt; 3388 return false; //brake jquery each 3389 } else { 3390 cnt++; 3391 } 3392 }); 3393 return tmpReturn; 3394 }, 3395 3396 3397 3398 /** 3399 * gets the block object using a block ID 3400 * @param myID 3401 * @returns {*} block object 3402 */ 3403 tdGetBlockObjById: function(myID) { 3404 return tdBlocksArray[tdBlocks.tdGetBlockIndex(myID)]; 3405 } 3406 3407 3408 3409 3410 3411 }; //end tdBlocks 3412 3413 3414 3415})(); 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426/* 3427 td_util.js 3428 v1.1 3429 */ 3430 3431/* global jQuery:{} */ 3432/* global tdDetect:{} */ 3433/* global td_ajax_url:string */ 3434 3435/* global td_please_wait:string */ 3436/* global td_email_user_pass_incorrect:string */ 3437/* global td_email_user_incorrect:string */ 3438/* global td_email_incorrect:string */ 3439 3440 3441 3442/* ---------------------------------------------------------------------------- 3443 On load 3444 */ 3445jQuery().ready(function() { 3446 3447 'use strict'; 3448 3449 /** 3450 * Modal window js code 3451 */ 3452 3453 var modalSettings = { 3454 type: 'inline', 3455 preloader: false, 3456 focus: '#name', 3457 removalDelay: 500, 3458 3459 // When elemened is focused, some mobile browsers in some cases zoom in 3460 // It looks not nice, so we disable it: 3461 callbacks: { 3462 beforeOpen: function() { 3463 3464 this.st.mainClass = this.st.el.attr('data-effect'); 3465 3466 //empty all fields 3467 tdLogin.clearFields(); 3468 3469 //empty error display div 3470 tdLogin.showHideMsg(); 3471 3472 if( jQuery( window ).width() < 700) { 3473 this.st.focus = false; 3474 } else { 3475 if ( false === tdDetect.isIe ) { 3476 //do not focus on ie 10 3477 this.st.focus = '#login_email'; 3478 } 3479 } 3480 }, 3481 3482 beforeClose: function() { 3483 } 3484 }, 3485 3486 // The modal login is disabled for widths under less than 750px 3487 disableOn: function() { 3488 if( jQuery(window).width() < 750 ) { 3489 return false; 3490 } 3491 return true; 3492 } 3493 }; 3494 3495 3496 3497 if ( undefined !== window.tds_login_sing_in_widget ) { 3498 // The following settings are only for the modal magnific popup, which is disable when width is less than 750px 3499 jQuery( '.comment-reply-login' ).attr({ 3500 'href': '#login-form',
3501 'data-effect': 'mpf-td-login-effect' 3502 }); 3503 3504 // Set the modal magnific popup settings 3505 jQuery( '.comment-reply-login, .td-login-modal-js' ).magnificPopup( modalSettings ); 3506 } 3507 3508 // - Set the normal link that will apply only for windows widths less than 750px 3509 // - Used for log in to leave a comment on post page to open the login section 3510 jQuery( '.td-login-modal-js, .comment-reply-login' ).on( 'click', function( event ) { 3511 3512 if ( jQuery( window ).width() < 750 && undefined !== window.tds_login_sing_in_widget ) { 3513 3514 3515 event.preventDefault(); 3516 3517 // open the menu background 3518 jQuery( 'body' ).addClass( 'td-menu-mob-open-menu' ); 3519 3520 // hide the menu content 3521 jQuery( '.td-mobile-container' ).hide(); 3522 jQuery( '#td-mobile-nav' ).addClass( 'td-hide-menu-content' ); 3523 3524 setTimeout(function(){ 3525 jQuery( '.td-mobile-container' ).show(); 3526 }, 500); 3527 3528 //hides or shows the divs with inputs 3529 tdLogin.showHideElementsMobile( [['#td-login-mob', 1], ['#td-register-mob', 0], ['#td-forgot-pass-mob', 0]] ); 3530 } 3531 }); 3532 3533 3534 //login 3535 jQuery( '#login-link' ).on( 'click', function() { 3536 //hides or shows the divs with inputs 3537 tdLogin.showHideElements( [['#td-login-div', 1], ['#td-register-div', 0], ['#td-forgot-pass-div', 0]] ); 3538 3539 //moves focus on the tab 3540 tdLogin.showTabs( [['#login-link', 1], ['#register-link', 0]] ); 3541 3542 if ( jQuery(window).width() > 700 && tdDetect.isIe === false ) { 3543 jQuery( '#login_email' ).focus(); 3544 } 3545 3546 //empty error display div 3547 tdLogin.showHideMsg(); 3548 }); 3549 3550 3551 //register 3552 jQuery( '#register-link' ).on( 'click', function() { 3553 //hides or shows the divs with inputs 3554 tdLogin.showHideElements( [['#td-login-div', 0], ['#td-register-div', 1], ['#td-forgot-pass-div', 0]] ); 3555 3556 //moves focus on the tab 3557 tdLogin.showTabs( [['#login-link', 0], ['#register-link', 1]] ); 3558 3559 if ( jQuery( window ).width() > 700 && false === tdDetect.isIe ) { 3560 jQuery( '#register_email' ).focus(); 3561 } 3562 3563 //empty error display div 3564 tdLogin.showHideMsg(); 3565 }); 3566 3567 3568 //forgot pass 3569 jQuery( '#forgot-pass-link' ).on( 'click', function(event) { 3570 //prevent scroll to page top 3571 event.preventDefault(); 3572 //hides or shows the divs with inputs 3573 tdLogin.showHideElements( [['#td-login-div', 0], ['#td-register-div', 0], ['#td-forgot-pass-div', 1]] ); 3574 3575 //moves focus on the tab 3576 tdLogin.showTabs( [['#login-link', 0], ['#register-link', 0]] ); 3577 3578 if (jQuery( window ).width() > 700 && false === tdDetect.isIe ) { 3579 jQuery( '#forgot_email' ).focus(); 3580 } 3581 3582 //empty error display div 3583 tdLogin.showHideMsg(); 3584 }); 3585 3586 3587 //login button 3588 jQuery( '#login_button' ).on( 'click', function() { 3589 tdLogin.handlerLogin(); 3590 }); 3591 3592 //enter key on #login_pass 3593 jQuery( '#login_pass' ).keydown(function(event) { 3594 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 3595 tdLogin.handlerLogin(); 3596 } 3597 }); 3598 3599 3600 //register button 3601 jQuery( '#register_button' ).on( 'click', function() { 3602 tdLogin.handlerRegister(); 3603 }); 3604 3605 //enter key on #register_user 3606 jQuery( '#register_user' ).keydown(function(event) { 3607 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 3608 tdLogin.handlerRegister(); 3609 } 3610 }); 3611 3612 3613 //forgot button 3614 jQuery( '#forgot_button' ).on( 'click', function() { 3615 tdLogin.handlerForgotPass(); 3616 }); 3617 3618 //enter key on #forgot_email 3619 jQuery( '#forgot_email' ).keydown(function(event) { 3620 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 3621 tdLogin.handlerForgotPass(); 3622 } 3623 });
3624});//end jquery ready 3625 3626 3627 3628 3629var tdLogin = {}; 3630 3631 3632(function(){ 3633 3634 'use strict'; 3635 3636 tdLogin = { 3637 3638 //patern to check emails 3639 email_pattern : /^[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}$/, 3640 3641 /** 3642 * handle all request made from login tab 3643 */ 3644 handlerLogin : function() { 3645 var loginEmailEl = jQuery( '#login_email'), 3646 loginPassEl = jQuery( '#login_pass' ); 3647 3648 if ( loginEmailEl.length && loginPassEl.length ) { 3649 var loginEmailVal = loginEmailEl.val().trim(), 3650 loginPassVal = loginPassEl.val().trim(); 3651 3652 if ( loginEmailVal && loginPassVal ) { 3653 tdLogin.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3654 tdLogin.showHideMsg( td_please_wait ); 3655 3656 //call ajax for log in 3657 tdLogin.doAction( 'td_mod_login', loginEmailVal, '', loginPassVal ); 3658 } else { 3659 tdLogin.showHideMsg( td_email_user_pass_incorrect ); 3660 } 3661 } 3662 }, 3663 3664 3665 /** 3666 * handle all request made from register tab 3667 */ 3668 handlerRegister : function() { 3669 var registerEmailEl = jQuery( '#register_email' ), 3670 registerUserEl = jQuery( '#register_user' ); 3671 3672 if ( registerEmailEl.length && registerUserEl.length ) { 3673 var registerEmailVal = registerEmailEl.val().trim(), 3674 registerUserVal = registerUserEl.val().trim(); 3675 3676 if ( tdLogin.email_pattern.test( registerEmailVal ) && registerUserVal ) { 3677 3678 tdLogin.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3679 tdLogin.showHideMsg( td_please_wait ); 3680 3681 //call ajax 3682 tdLogin.doAction( 'td_mod_register', registerEmailVal, registerUserVal, '' ); 3683 } else { 3684 tdLogin.showHideMsg( td_email_user_incorrect ); 3685 } 3686 } 3687 }, 3688 3689 3690 /** 3691 * handle all request made from forgot password tab 3692 */ 3693 handlerForgotPass : function() { 3694 var forgotEmailEl = jQuery( '#forgot_email' ); 3695 3696 if ( forgotEmailEl.length ) { 3697 var forgotEmailVal = forgotEmailEl.val().trim(); 3698 3699 if ( tdLogin.email_pattern.test( forgotEmailVal ) ){ 3700 3701 tdLogin.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3702 tdLogin.showHideMsg( td_please_wait ); 3703 3704 //call ajax 3705 tdLogin.doAction( 'td_mod_remember_pass', forgotEmailVal, '', '' ); 3706 } else { 3707 tdLogin.showHideMsg( td_email_incorrect ); 3708 } 3709 } 3710 }, 3711 3712 3713 /** 3714 * swhich the div's acordingly to the user action (Log In, Register, Remember Password) 3715 * 3716 * ids_array : array of ids that have to be showed or hidden 3717 */ 3718 showHideElements : function( ids_array ) { 3719 if ( ids_array.constructor === Array ) { 3720 var length = ids_array.length; 3721 3722 for ( var i = 0; i < length; i++ ) { 3723 if ( ids_array[ i ].constructor === Array && 2 === ids_array[ i ].length ) { 3724 var jqElement = jQuery( ids_array[ i ][0] ); 3725 if ( jqElement.length ) { 3726 if ( 1 === ids_array[ i ][1] ) { 3727 jqElement.removeClass( 'td-display-none' ).addClass( 'td-display-block' ); 3728 } else { 3729 jqElement.removeClass( 'td-display-block' ).addClass( 'td-display-none' ); 3730 } 3731 } 3732 } 3733 } 3734 } 3735 }, 3736 3737 showHideElementsMobile : function( ids_array ) { 3738 if ( ids_array.constructor === Array ) { 3739 var length = ids_array.length; 3740 3741 for ( var i = 0; i < length; i++ ) { 3742 if ( ids_array[ i ].constructor === Array && 2 === ids_array[ i ].length ) { 3743 var jqElement = jQuery( ids_array[ i ][0] ); 3744 if ( jqElement.length ) { 3745 if ( 1 === ids_array[ i ][1] ) { 3746 jqElement.removeClass( 'td-login-hide' ).addClass( 'td-login-show' ); 3747 } else { 3748 jqElement.removeClass( 'td-login-show' ).addClass( 'td-login-hide' ); 3749 } 3750 } 3751 } 3752 } 3753 } 3754 }, 3755 3756 3757 showTabs : function( ids_array ) { 3758 if ( ids_array.constructor === Array ) { 3759 var length = ids_array.length; 3760 3761 for ( var i = 0; i < length; i++ ) { 3762 if ( ids_array[ i ].constructor === Array && 2 === ids_array[ i ].length ) { 3763 var jqElement = jQuery( ids_array[ i ][0] ); 3764 if ( jqElement.length ) { 3765 if ( 1 === ids_array[ i ][1] ) { 3766 jqElement.addClass( 'td_login_tab_focus' ); 3767 } else { 3768 jqElement.removeClass( 'td_login_tab_focus' ); 3769 } 3770 } 3771 } 3772 } 3773 } 3774 }, 3775 3776 3777 /** 3778 * adds or remove a class from an html object 3779 * 3780 * param : array with object identifier (id - # or class - .) 3781 * ex: ['.class_indetifier', 1, 'class_to_add'] or ['.class_indetifier', 0, 'class_to_remove'] 3782 */ 3783 addRemoveClass : function( param ) { 3784 if ( param.constructor === Array && 3 === param.length ) { 3785 var tdElement = jQuery( param[0] ); 3786 if ( tdElement.length ) { 3787 if ( 1 === param[1] ) { 3788 tdElement.addClass( param[2] ); 3789 } else { 3790 tdElement.removeClass( param[2] ); 3791 } 3792 } 3793 } 3794 }, 3795 3796 3797 showHideMsg : function( msg ) { 3798 var tdDisplayErr = jQuery( '.td_display_err' ); 3799 if ( tdDisplayErr.length ) { 3800 if ( undefined !== msg && msg.constructor === String && msg.length > 0 ) { 3801 tdDisplayErr.show(); 3802 tdDisplayErr.html( msg ); 3803 } else { 3804 tdDisplayErr.hide(); 3805 tdDisplayErr.html( '' ); 3806 } 3807 } 3808 }, 3809 3810 3811 /** 3812 * empty all fields in modal window 3813 */ 3814 clearFields : function() { 3815 //login fields 3816 jQuery( '#login_email' ).val( '' ); 3817 jQuery( '#login_pass' ).val( '' ); 3818 3819 //register fields 3820 jQuery( '#register_email' ).val( '' ); 3821 jQuery( '#register_user' ).val( '' ); 3822 3823 //forgot pass 3824 jQuery( '#forgot_email' ).val( '' ); 3825 }, 3826 3827 3828 /** 3829 * call to server from modal window 3830 * 3831 * @param $action : what action (log in, register, forgot email) 3832 * @param $email : the email beening sent 3833 * @param $user : the user name beening sent 3834 */ 3835 doAction : function( sent_action, sent_email, sent_user, sent_pass ) { 3836 jQuery.ajax({ 3837 type: 'POST', 3838 url: td_ajax_url, 3839 data: { 3840 action: sent_action, 3841 email: sent_email, 3842 user: sent_user, 3843 pass: sent_pass 3844 }, 3845 success: function( data, textStatus, XMLHttpRequest ){ 3846 var td_data_object = jQuery.parseJSON( data ); //get the data object 3847 3848 //check the response from server 3849 switch( td_data_object[0] ) { 3850 case 'login': 3851 if ( 1 === td_data_object[1] ) { 3852 location.reload( true ); 3853 } else { 3854 tdLogin.addRemoveClass( ['.td_display_err', 0, 'td_display_msg_ok'] ); 3855 tdLogin.showHideMsg( td_data_object[2] ); 3856 } 3857 break; 3858 3859 case 'register': 3860 if ( 1 === td_data_object[1] ) { 3861 tdLogin.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3862 } else { 3863 tdLogin.addRemoveClass( ['.td_display_err', 0, 'td_display_msg_ok'] ); 3864 } 3865 tdLogin.showHideMsg( td_data_object[2] ); 3866 break; 3867 3868 case 'remember_pass': 3869 if ( 1 === td_data_object[1] ) { 3870 tdLogin.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 3871 } else { 3872 tdLogin.addRemoveClass( ['.td_display_err', 0, 'td_display_msg_ok'] ); 3873 } 3874 tdLogin.showHideMsg( td_data_object[2] ); 3875 break; 3876 } 3877 }, 3878 error: function( MLHttpRequest, textStatus, errorThrown ){ 3879 //console.log(errorThrown); 3880 } 3881 }); 3882 } 3883 }; 3884 3885})(); 3886/* 3887 td_util.js 3888 v1.1 3889 */ 3890 3891/* global jQuery:{} */ 3892/* global tdDetect:{} */ 3893/* global td_ajax_url:string */ 3894 3895/* global td_please_wait:string */ 3896/* global td_email_user_pass_incorrect:string */ 3897/* global td_email_user_incorrect:string */ 3898/* global td_email_incorrect:string */ 3899 3900 3901 3902/* ---------------------------------------------------------------------------- 3903 On load 3904 */ 3905jQuery().ready(function() { 3906 3907 'use strict'; 3908 3909 //login 3910 jQuery( '#login-link-mob' ).on( 'click', function() { 3911 //hides or shows the divs with inputs 3912 tdLoginMob.showHideElements( [['#td-login-mob', 1], ['#td-register-mob', 0], ['#td-forgot-pass-mob', 0]] ); 3913 3914 jQuery( '#td-mobile-nav' ).addClass( 'td-hide-menu-content' ); 3915 3916 if ( jQuery(window).width() > 700 && tdDetect.isIe === false ) { 3917 jQuery( '#login_email-mob' ).focus(); 3918 } 3919 3920 //empty error display div 3921 tdLoginMob.showHideMsg(); 3922 });
3923 3924 //register 3925 jQuery( '#register-link-mob' ).on( 'click', function() { 3926 //hides or shows the divs with inputs 3927 tdLoginMob.showHideElements( [['#td-login-mob', 0], ['#td-register-mob', 1], ['#td-forgot-pass-mob', 0]] ); 3928 3929 jQuery( '#td-mobile-nav' ).addClass( 'td-hide-menu-content' ); 3930 3931 if ( jQuery( window ).width() > 700 && false === tdDetect.isIe ) { 3932 jQuery( '#register_email-mob' ).focus(); 3933 } 3934 3935 //empty error display div 3936 tdLoginMob.showHideMsg(); 3937 }); 3938 3939 //forgot pass 3940 jQuery( '#forgot-pass-link-mob' ).on( 'click', function() { 3941 //hides or shows the divs with inputs 3942 tdLoginMob.showHideElements( [['#td-login-mob', 0], ['#td-register-mob', 0], ['#td-forgot-pass-mob', 1]] ); 3943 3944 if (jQuery( window ).width() > 700 && false === tdDetect.isIe ) { 3945 jQuery( '#forgot_email-mob' ).focus(); 3946 } 3947 3948 //empty error display div 3949 tdLoginMob.showHideMsg(); 3950 }); 3951 3952 3953 //login button 3954 jQuery( '#login_button-mob' ).on( 'click', function() { 3955 tdLoginMob.handlerLogin(); 3956 }); 3957 3958 //enter key on #login_pass 3959 jQuery( '#login_pass-mob' ).keydown(function(event) { 3960 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 3961 tdLoginMob.handlerLogin(); 3962 } 3963 }); 3964 3965 3966 //register button 3967 jQuery( '#register_button-mob' ).on( 'click', function() { 3968 tdLoginMob.handlerRegister(); 3969 }); 3970 3971 //enter key on #register_user 3972 jQuery( '#register_user-mob' ).keydown(function(event) { 3973 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 3974 tdLoginMob.handlerRegister(); 3975 } 3976 }); 3977 3978 3979 //forgot button 3980 jQuery( '#forgot_button-mob' ).on( 'click', function() { 3981 tdLoginMob.handlerForgotPass(); 3982 }); 3983 3984 //enter key on #forgot_email 3985 jQuery( '#forgot_email-mob' ).keydown(function(event) { 3986 if ( ( event.which && 13 === event.which ) || ( event.keyCode && 13 === event.keyCode ) ) { 3987 tdLoginMob.handlerForgotPass(); 3988 } 3989 }); 3990 3991 3992 // marius 3993 // ***************************************************************************** 3994 // ***************************************************************************** 3995 // back login/register button 3996 jQuery( '#td-mobile-nav .td-login-close a, #td-mobile-nav .td-register-close a' ).on( 'click', function() { 3997 //hides or shows the divs with inputs 3998 tdLoginMob.showHideElements( [['#td-login-mob', 0], ['#td-register-mob', 0], ['#td-forgot-pass-mob', 0]] ); 3999 4000 jQuery( '#td-mobile-nav' ).removeClass( 'td-hide-menu-content' ); 4001 }); 4002 4003 // back forgot pass button 4004 jQuery( '#td-mobile-nav .td-forgot-pass-close a' ).on( 'click', function() { 4005 //hides or shows the divs with inputs 4006 tdLoginMob.showHideElements( [['#td-login-mob', 1], ['#td-register-mob', 0], ['#td-forgot-pass-mob', 0]] ); 4007 }); 4008 4009});//end jquery ready 4010 4011 4012 4013 4014 4015var tdLoginMob = {}; 4016 4017 4018(function(){ 4019 4020 'use strict'; 4021 4022 tdLoginMob = { 4023 4024 //patern to check emails 4025 email_pattern : /^[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}$/, 4026 4027 /** 4028 * handle all request made from login tab 4029 */ 4030 handlerLogin : function() { 4031 var loginEmailEl = jQuery( '#login_email-mob'), 4032 loginPassEl = jQuery( '#login_pass-mob' ); 4033 4034 if ( loginEmailEl.length && loginPassEl.length ) { 4035 var loginEmailVal = loginEmailEl.val().trim(), 4036 loginPassVal = loginPassEl.val().trim(); 4037 4038 if ( loginEmailVal && loginPassVal ) { 4039 tdLoginMob.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 4040 tdLoginMob.showHideMsg( td_please_wait ); 4041 4042 //call ajax for log in 4043 tdLoginMob.doAction( 'td_mod_login', loginEmailVal, '', loginPassVal ); 4044 } else { 4045 tdLoginMob.showHideMsg( td_email_user_pass_incorrect ); 4046 } 4047 } 4048 }, 4049 4050 4051 /** 4052 * handle all request made from register tab 4053 */ 4054 handlerRegister : function() { 4055 var registerEmailEl = jQuery( '#register_email-mob' ), 4056 registerUserEl = jQuery( '#register_user-mob' ); 4057 4058 if ( registerEmailEl.length && registerUserEl.length ) { 4059 var registerEmailVal = registerEmailEl.val().trim(), 4060 registerUserVal = registerUserEl.val().trim(); 4061 4062 if ( tdLoginMob.email_pattern.test( registerEmailVal ) && registerUserVal ) { 4063 4064 tdLoginMob.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 4065 tdLoginMob.showHideMsg( td_please_wait ); 4066 4067 //call ajax 4068 tdLoginMob.doAction( 'td_mod_register', registerEmailVal, registerUserVal, '' ); 4069 } else { 4070 tdLoginMob.showHideMsg( td_email_user_incorrect ); 4071 } 4072 } 4073 }, 4074 4075 4076 /** 4077 * handle all request made from forgot password tab 4078 */ 4079 handlerForgotPass : function() { 4080 var forgotEmailEl = jQuery( '#forgot_email-mob' ); 4081 4082 if ( forgotEmailEl.length ) { 4083 var forgotEmailVal = forgotEmailEl.val().trim(); 4084 4085 if ( tdLoginMob.email_pattern.test( forgotEmailVal ) ){ 4086 4087 tdLoginMob.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 4088 tdLoginMob.showHideMsg( td_please_wait ); 4089 4090 //call ajax 4091 tdLoginMob.doAction( 'td_mod_remember_pass', forgotEmailVal, '', '' ); 4092 } else { 4093 tdLoginMob.showHideMsg( td_email_incorrect ); 4094 } 4095 } 4096 }, 4097 4098 4099 /** 4100 * swhich the div's acordingly to the user action (Log In, Register, Remember Password) 4101 * 4102 * ids_array : array of ids that have to be showed or hidden 4103 */ 4104 showHideElements : function( ids_array ) { 4105 if ( ids_array.constructor === Array ) { 4106 var length = ids_array.length; 4107 4108 for ( var i = 0; i < length; i++ ) { 4109 if ( ids_array[ i ].constructor === Array && 2 === ids_array[ i ].length ) { 4110 var jqElement = jQuery( ids_array[ i ][0] ); 4111 if ( jqElement.length ) { 4112 if ( 1 === ids_array[ i ][1] ) { 4113 jqElement.removeClass( 'td-login-hide' ).addClass( 'td-login-show' ); 4114 } else { 4115 jqElement.removeClass( 'td-login-show' ).addClass( 'td-login-hide' ); 4116 } 4117 } 4118 } 4119 } 4120 } 4121 }, 4122 4123 4124 /** 4125 * adds or remove a class from an html object 4126 * 4127 * param : array with object identifier (id - # or class - .) 4128 * ex: ['.class_indetifier', 1, 'class_to_add'] or ['.class_indetifier', 0, 'class_to_remove'] 4129 */ 4130 addRemoveClass : function( param ) { 4131 if ( param.constructor === Array && 3 === param.length ) { 4132 var jqElement = jQuery( param[0] ); 4133 if ( jqElement.length ) { 4134 if ( 1 === param[1] ) { 4135 jqElement.addClass( param[2] ); 4136 } else { 4137 jqElement.removeClass( param[2] ); 4138 } 4139 } 4140 } 4141 }, 4142 4143 4144 showHideMsg : function( msg ) { 4145 var tdDisplayErr = jQuery( '.td_display_err' ); 4146 if ( tdDisplayErr.length ) { 4147 if ( undefined !== msg && msg.constructor === String && msg.length > 0 ) { 4148 tdDisplayErr.show(); 4149 tdDisplayErr.html( msg ); 4150 } else { 4151 tdDisplayErr.hide(); 4152 tdDisplayErr.html( '' ); 4153 } 4154 } 4155 }, 4156 4157 4158 /** 4159 * empty all fields in modal window 4160 */ 4161 clearFields : function() { 4162 //login fields 4163 jQuery( '#login_email-mob' ).val( '' ); 4164 jQuery( '#login_pass-mob' ).val( '' ); 4165 4166 //register fields 4167 jQuery( '#register_email-mob' ).val( '' ); 4168 jQuery( '#register_user-mob' ).val( '' ); 4169 4170 //forgot pass 4171 jQuery( '#forgot_email-mob' ).val( '' ); 4172 }, 4173 4174 4175 /** 4176 * call to server from modal window 4177 * 4178 * @param $action : what action (log in, register, forgot email) 4179 * @param $email : the email beening sent 4180 * @param $user : the user name beening sent 4181 */ 4182 doAction : function( sent_action, sent_email, sent_user, sent_pass ) { 4183 jQuery.ajax({ 4184 type: 'POST', 4185 url: td_ajax_url, 4186 data: { 4187 action: sent_action, 4188 email: sent_email, 4189 user: sent_user, 4190 pass: sent_pass 4191 }, 4192 success: function( data, textStatus, XMLHttpRequest ){ 4193 var td_data_object = jQuery.parseJSON( data ); //get the data object 4194 4195 //check the response from server 4196 switch( td_data_object[0] ) { 4197 case 'login': 4198 if ( 1 === td_data_object[1] ) { 4199 location.reload( true ); 4200 } else { 4201 tdLoginMob.addRemoveClass( ['.td_display_err', 0, 'td_display_msg_ok'] ); 4202 tdLoginMob.showHideMsg( td_data_object[2] ); 4203 } 4204 break; 4205 4206 case 'register': 4207 if ( 1 === td_data_object[1] ) { 4208 tdLoginMob.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 4209 } else { 4210 tdLoginMob.addRemoveClass( ['.td_display_err', 0, 'td_display_msg_ok'] ); 4211 } 4212 tdLoginMob.showHideMsg( td_data_object[2] ); 4213 break; 4214 4215 case 'remember_pass': 4216 if ( 1 === td_data_object[1] ) { 4217 tdLoginMob.addRemoveClass( ['.td_display_err', 1, 'td_display_msg_ok'] ); 4218 } else { 4219 tdLoginMob.addRemoveClass( ['.td_display_err', 0, 'td_display_msg_ok'] ); 4220 } 4221 tdLoginMob.showHideMsg( td_data_object[2] ); 4222 break; 4223 } 4224 }, 4225 error: function( MLHttpRequest, textStatus, errorThrown ){ 4226 //console.log(errorThrown); 4227 } 4228 }); 4229 } 4230 }; 4231 4232})(); 4233 4234 4235 4236/* ---------------------------------------------------------------------------- 4237 tagDiv live css compiler ( 2013 )
4238 - this script is used on our demo site to customize the theme live 4239 - not used on production sites 4240 */ 4241 4242/* global jQuery:{} */ 4243/* global td_read_site_cookie:Function */ 4244/* global td_set_cookies_life:Function */ 4245/* global tdDetect: {} */ 4246 4247var tdDemoMenu; 4248 4249(function(jQuery, undefined) { 4250 4251 'use strict'; 4252 4253 tdDemoMenu = { 4254 4255 // document - horizontal mouse position 4256 mousePosX: 0, 4257 4258 // document - vertical mouse position 4259 mousePosY: 0, 4260 4261 // The timer waiting to start de interval 4262 startTimeout: undefined, 4263 4264 // The interval that decreases the padding-left css value and increases the left css value of the screen demo (previewer of the demo) 4265 startInterval: undefined, 4266 4267 4268 4269 // Flag marks that it's possible to move the mouse to the original demo 4270 _extendedDemo: false, 4271 4272 // The current demo element (for which the counters have been applied) 4273 _currentElement: undefined, 4274 4275 // The timer waiting to start the interval for extended demo 4276 _startExtendedTimeout: undefined, 4277 4278 // The interval that decreases the width css value of the extended element 4279 _startExtendedInterval: undefined, 4280 4281 4282 4283 4284 4285 init: function () { 4286 4287 // Get document mouse position 4288 jQuery(document).mousemove(function (event) { 4289 if (event.pageX || event.pageY) { 4290 tdDemoMenu.mousePosX = event.pageX; 4291 tdDemoMenu.mousePosY = event.pageY; 4292 } else if (event.clientX || event.clientY) { 4293 tdDemoMenu.mousePosX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; 4294 tdDemoMenu.mousePosY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop; 4295 } 4296 }); 4297 4298 4299 // cloase the preview on mouse leave 4300 jQuery(document).mouseleave(function (event) { 4301 4302 // Any existing timeout is cleard to stop any further css settings 4303 if (undefined !== tdDemoMenu.startTimeout) { 4304 window.clearTimeout(tdDemoMenu.startTimeout); 4305 } 4306 4307 // Any existing interval is cleard to stop any further css settings 4308 if (undefined !== tdDemoMenu.startInterval) { 4309 window.clearInterval(tdDemoMenu.startInterval); 4310 } 4311 4312 jQuery('.td-screen-demo:first').css('visibility', 'hidden'); 4313 jQuery('.td-screen-demo-extend:first').hide(); 4314 }); 4315 4316 // Show/hide the arrow skin scroll element 4317 jQuery('#td-theme-settings').find('.td-skin-wrap:first').scroll(function (event) { 4318 //console.log( event ); 4319 4320 var theTarget = event.currentTarget, 4321 tdSkinScroll = jQuery(this).find('.td-skin-scroll:first'); 4322 4323 if (theTarget.clientHeight + theTarget.scrollTop < theTarget.scrollHeight) { 4324 tdSkinScroll.css({ 4325 bottom: 0 4326 }); 4327 } else { 4328 tdSkinScroll.css({ 4329 bottom: -40 4330 }); 4331 } 4332 }); 4333 4334 jQuery('#td-theme-settings').find('.td-skin-scroll:first').click(function (event) { 4335 //console.log( event ); 4336 4337 var theTarget = event.currentTarget, 4338 tdSkinWrap = jQuery(this).closest('.td-skin-wrap'); 4339 4340 tdSkinWrap.animate( 4341 {scrollTop: tdSkinWrap.scrollTop() + 200}, 4342 { 4343 duration: 800, 4344 easing: 'easeInOutQuart' 4345 }); 4346 }).mouseenter(function (event) { 4347 // Any existing timeout is cleard to stop any further css settings 4348 if (undefined !== tdDemoMenu.startTimeout) { 4349 window.clearTimeout(tdDemoMenu.startTimeout); 4350 } 4351 4352 // Any existing interval is cleard to stop any further css settings 4353 if (undefined !== tdDemoMenu.startInterval) { 4354 window.clearInterval(tdDemoMenu.startInterval); 4355 } 4356 4357 //jQuery( '#td-theme-settings' ).find( '.td-screen-demo:first' ).hide(); 4358 jQuery('#td-theme-settings').find('.td-screen-demo:first').css('visibility', 'hidden'); 4359 }); 4360 4361 4362 4363 4364 jQuery('.td-set-theme-style-link').hover( 4365 4366 // The mouse enter event handler 4367 function (event) { 4368 4369 //console.log( 'in MAIN ' + contor++); 4370 4371 // Any existing timeout is cleard to stop any further css settings 4372 if (undefined !== tdDemoMenu.startTimeout) { 4373 window.clearTimeout(tdDemoMenu.startTimeout); 4374 } 4375 4376 // Any existing interval is cleard to stop any further css settings 4377 if (undefined !== tdDemoMenu.startInterval) { 4378 window.clearInterval(tdDemoMenu.startInterval); 4379 } 4380 4381 var 4382 // The css class of the container element 4383 cssClassContainer = 'td-set-theme-style', 4384 4385 // The jquery object of the current element 4386 $this = jQuery(this), 4387 4388 // The jquery object of the container of the current element 4389 $thisContainer = $this.closest('.' + cssClassContainer), 4390 4391 // The demo previewer
4392 jQueryDisplayEl = jQuery('.td-screen-demo:first'), 4393 4394 // The ref top value considers the existing of the wpadminbar element 4395 refTopValue = 0, 4396 4397 // The top value set to the css top setting 4398 topValue = 0, 4399 4400 // The left value set to the css left setting 4401 rightValue = 0, 4402 4403 // The padding value set to the css padding-left setting 4404 paddingRightValue = 0, 4405 4406 // The extra value added to the css padding-left setting and removed from the css left setting (if we need to start earlier or later - does nothing with 0 value) 4407 extraRightValue = 0, 4408 4409 // The jquery wpadminbar element 4410 jqWPAdminBar = jQuery('#wpadminbar'); 4411 4412 4413 4414 // Show the image into the image previewer 4415 var imgElement = jQueryDisplayEl.find('img:first'), 4416 dataImgUrl = $this.data('img-url'); 4417 4418 if (imgElement.length) { 4419 imgElement.attr('src', dataImgUrl); 4420 } else { 4421 jQueryDisplayEl.html('<img src="' + dataImgUrl + '"/>'); 4422 } 4423 4424 4425 // The first column 4426 if ( 0 === jQuery( '.td-set-theme-style-link' ).index( this ) % 2 ) { 4427 rightValue = $thisContainer.outerWidth(true) * 2; 4428 4429 // The second column 4430 } else { 4431 var $thisPrevContainer = $thisContainer.prev('.' + cssClassContainer); 4432 4433 if ($thisPrevContainer.length) { 4434 rightValue = $thisPrevContainer.outerWidth(true) - extraRightValue; 4435 paddingRightValue = $thisPrevContainer.outerWidth(true) + extraRightValue; 4436 4437 } 4438 event.preventDefault(); 4439 event.stopPropagation(); 4440 } 4441 4442 topValue = event.pageY - document.body.scrollTop - ( jQueryDisplayEl.outerHeight( true ) / 2 ); 4443 4444 // Do not allow displaying the previewer demo below the bottom of the window screen 4445 if (topValue + jQueryDisplayEl.outerHeight(true) > window.innerHeight) { 4446 topValue -= (topValue + jQueryDisplayEl.outerHeight(true)) - window.innerHeight; 4447 } 4448 4449 // Do not allow displaying the previewer demo above the top of the window screen. It also checks if the wpadminbar exists. 4450 if (jqWPAdminBar.length) { 4451 refTopValue = jqWPAdminBar.outerHeight(true); 4452 } else { 4453 refTopValue = 0; 4454 } 4455 4456 if (refTopValue > topValue) { 4457 topValue = refTopValue; 4458 } 4459 4460 // The 'width' css property is used for Chrome and IE browsers which do not display the previewer image with auto width and auto height 4461 var cssSettings = { 4462 'top': topValue, 4463 'right': rightValue, 4464 'padding-right': paddingRightValue, 4465 'width': '' 4466 }, 4467 dataWidthPreview = jQueryDisplayEl.data('width-preview'); 4468 4469 4470 // For the first column of demos, the previewer has padding 4471 if (paddingRightValue > 0) { 4472 cssSettings.width = dataWidthPreview + paddingRightValue; 4473 } 4474 4475 4476 4477 4478 // Apply the computed css to the element 4479 jQueryDisplayEl.css(cssSettings); 4480 4481 // The 'right-value' data will be used to set 'right' css value when the computed padding is < 0 4482 jQueryDisplayEl.data('right-value', rightValue + paddingRightValue); 4483 4484 //jQueryDisplayEl.show(); 4485 jQueryDisplayEl.css('visibility', 'visible'); 4486 }, 4487 4488 // The mouse exit event handler 4489 function (event) { 4490 4491 //console.log('out MAIN '); 4492 4493 jQuery('.td-screen-demo-extend:first').hide(); 4494 4495 var 4496 // The jquery object of the previewer demo element 4497 jQueryDisplayEl = jQuery('.td-screen-demo:first'), 4498 4499 // The css right value 4500 existingRightValue = jQueryDisplayEl.css('right'), 4501 4502 // The css padding-right value 4503 existingExtraRightValue = jQueryDisplayEl.css('padding-right'), 4504 4505 // The css width value 4506 existingWidthValue = jQueryDisplayEl.css('width'), 4507 4508 // The integer css right value 4509 newRightValue = parseInt(existingRightValue.replace('px', '')), 4510 4511 // The integer css padding-right value 4512 newExtraRightValue = parseInt(existingExtraRightValue.replace('px', '')), 4513 4514 // The step value used to decrease the padding-left css value and to increase the left css value 4515 step = 10, 4516 4517 // The waiting time (ms) for the timeout 4518 startTimeoutWait = 50, 4519 4520 // The time (ms) for the interval 4521 //startIntervalWait = 15, 4522 startIntervalWait = 15, 4523 4524 newWidthValue = parseInt(existingWidthValue.replace('px', '')); 4525 4526 4527 var $this = jQuery(this); 4528 tdDemoMenu._currentElement = $this; 4529
4530 var tdThemeSettingsWidth = parseInt(jQuery('#td-theme-settings').css('width').replace('px', '')); 4531 4532 if (newExtraRightValue > 0) { 4533 4534 // Clear any timeout if there's one, because a new one will be created 4535 if (undefined !== tdDemoMenu.startTimeout) { 4536 window.clearTimeout(tdDemoMenu.startTimeout); 4537 tdDemoMenu.startTimeout = undefined; 4538 } 4539 4540 // Clear any interval if there's one, because a new one will be created 4541 if (undefined !== tdDemoMenu.startInterval) { 4542 window.clearInterval(tdDemoMenu.startInterval); 4543 tdDemoMenu.startInterval = undefined; 4544 } 4545 4546 tdDemoMenu.startTimeout = setTimeout(function () { 4547 4548 4549 // Extended demo is eligible to be shown (true) 4550 // The flag is set to false when the mouse is found in wrong position (mouse position is reached) 4551 // The flag is set to true when the counters (the timer and the interval) finish, there the extended demo element being shown 4552 tdDemoMenu._extendedDemo = true; 4553 4554 tdDemoMenu.startInterval = setInterval(function () { 4555 4556 var dataWidthPreview = jQueryDisplayEl.data('width-preview'); 4557 4558 newRightValue += step; 4559 newExtraRightValue -= step; 4560 newWidthValue -= step; 4561 4562 var mousePositionFound = false; 4563 4564 if (newExtraRightValue <= 0 || 4565 newWidthValue < dataWidthPreview || 4566 tdDemoMenu.mousePosX <= jQuery(window).width() - tdThemeSettingsWidth || 4567 tdDemoMenu.mousePosX >= jQuery(window).width() - newRightValue) { 4568 4569 // Clear any timeout, and we should have one, because we finished 4570 if (undefined !== tdDemoMenu.startTimeout) { 4571 window.clearTimeout(tdDemoMenu.startTimeout); 4572 tdDemoMenu.startTimeout = undefined; 4573 } 4574 4575 // Clear any interval, and we should have one, because we finished 4576 if (undefined !== tdDemoMenu.startInterval) { 4577 window.clearInterval(tdDemoMenu.startInterval); 4578 tdDemoMenu.startInterval = undefined; 4579 } 4580 4581 newExtraRightValue = 0; 4582 newRightValue = jQueryDisplayEl.data('right-value'); 4583 newWidthValue = dataWidthPreview; 4584 4585 if (tdDemoMenu.mousePosX >= jQuery(window).width() - newRightValue) { 4586 mousePositionFound = true; 4587 } 4588 } 4589 4590 jQueryDisplayEl.css({ 4591 'right': newRightValue, 4592 'padding-right': newExtraRightValue, 4593 'width': newWidthValue 4594 }); 4595 4596 // The timeout started and the interval are stopped (The mouse was reached or the css computation is done) 4597 if (mousePositionFound) { 4598 tdDemoMenu._extendedDemo = false; 4599 tdDemoMenu._checkMousePosition(); 4600 } else if (undefined === tdDemoMenu.startTimeout && undefined === tdDemoMenu.startInterval) { 4601 tdDemoMenu._extendedDemo = true; 4602 tdDemoMenu._showExtendedScreenDemo(); 4603 } 4604 4605 }, startIntervalWait 4606 ); 4607 }, startTimeoutWait); 4608 4609 } else { 4610 //jQueryDisplayEl.hide(); 4611 jQueryDisplayEl.css('visibility', 'hidden'); 4612 } 4613 } 4614 4615 ).mousemove(function(event) { 4616 tdDemoMenu._moveScreenDemo( event ); 4617 }); 4618 4619 jQuery('.td-screen-demo').hover( 4620 function (event) { 4621 //jQuery(this).show(); 4622 jQuery(this).css('visibility', 'visible'); 4623 4624 tdDemoMenu._resetTdScreeDemoExtendWidth(); 4625 }, 4626 function (event) { 4627 4628 // We are on mouseleave event, and because of this, if the main counters (the timer and the interval) are not finished, it means we 4629 // don't have any extended demo element, so it's okay to set its flag to false and hide the extended demo element and the previewer demo element (this element) 4630 4631 // The main counters (the timer and the interval) are cleared immediately, because their final step can make extend demo visible 4632 4633 // Clear any timeout, and we should have one, because we finished 4634 if (undefined !== tdDemoMenu.startTimeout) { 4635 window.clearTimeout(tdDemoMenu.startTimeout); 4636 tdDemoMenu.startTimeout = undefined; 4637 } 4638 4639 // Clear any interval, and we should have one, because we finished 4640 if (undefined !== tdDemoMenu.startInterval) { 4641 window.clearInterval(tdDemoMenu.startInterval); 4642 tdDemoMenu.startInterval = undefined; 4643 } 4644 4645 //jQuery(this).hide(); 4646 jQuery(this).css('visibility', 'hidden'); 4647 jQuery('.td-screen-demo-extend:first').hide(); 4648 } 4649 4650 ).mousemove(function(event) { 4651 //tdDemoMenu._moveScreenDemo( event ); 4652 }); 4653 4654 jQuery('.td-screen-demo-extend').hover( 4655 function (event) { 4656 4657 if ( tdDemoMenu._extendedDemo ) { 4658 4659 // Set the flag to false to not execute this routine twice on mouseenter event 4660 tdDemoMenu._extendedDemo = false; 4661 4662 var 4663 4664 // The jquery current element 4665 $this = jQuery(this), 4666 4667 // The jquery '.td-screen-demo' element 4668 $tdScreenDemo = jQuery('.td-screen-demo:first'), 4669 4670 // The css width value 4671 //columnWidth = $this.data('width-column'),
4672 columnWidth = parseInt(jQuery('#td-theme-settings').css('width').replace('px', '')) / 2, 4673 4674 // The step value used to decrease the padding-left css value and to increase the left css value 4675 step = 10, 4676 4677 // The waiting time (ms) for the timeout 4678 startTimeoutWait = 50, 4679 4680 // The time (ms) for the interval 4681 //startIntervalWait = 15, 4682 startIntervalWait = 15, 4683 4684 newWidthValue = columnWidth; 4685 4686 $this.css({ 4687 'width': columnWidth + 'px', 4688 'top': $tdScreenDemo.css('top') 4689 }); 4690 4691 $this.show(); 4692 //$tdScreenDemo.show(); 4693 $tdScreenDemo.css('visibility', 'visible'); 4694 4695 4696 tdDemoMenu._startExtendedTimeout = setTimeout(function () { 4697 4698 tdDemoMenu._startExtendedInterval = setInterval(function () { 4699 4700 newWidthValue -= step; 4701 4702 var mousePositionFound = false; 4703 4704 if (newWidthValue < 0 || 4705 tdDemoMenu.mousePosX <= jQuery(window).width() - columnWidth - newWidthValue) { 4706 4707 // Clear any timeout, and we should have one, because we finished 4708 if (undefined !== tdDemoMenu._startExtendedTimeout) { 4709 window.clearTimeout(tdDemoMenu._startExtendedTimeout); 4710 tdDemoMenu._startExtendedTimeout = undefined; 4711 } 4712 4713 // Clear any interval, and we should have one, because we finished 4714 if (undefined !== tdDemoMenu._startExtendedInterval) { 4715 window.clearInterval(tdDemoMenu._startExtendedInterval); 4716 tdDemoMenu._startExtendedInterval = undefined; 4717 } 4718 4719 if (tdDemoMenu.mousePosX <= jQuery(window).width() - columnWidth - newWidthValue) { 4720 mousePositionFound = true; 4721 } 4722 4723 newWidthValue = columnWidth; 4724 4725 $this.hide(); 4726 } 4727 4728 $this.css({ 4729 'width': newWidthValue, 4730 'top': $tdScreenDemo.css('top') 4731 }); 4732 4733 if (mousePositionFound) { 4734 tdDemoMenu._checkMousePosition(); 4735 } 4736 }, startIntervalWait); 4737 }, startTimeoutWait); 4738 } 4739 }, 4740 function (event) { 4741 4742 /** 4743 * 1. clear any extended timer/interval 4744 * 2. hide the element 4745 * 3. adjust its width to the initial value 4746 * 4. hide the previewer element (this will be shown by the a mouseenter event if it's the case) 4747 */ 4748 4749 // Clear any timeout, and we should have one, because we finished 4750 if (undefined !== tdDemoMenu._startExtendedTimeout) { 4751 window.clearTimeout(tdDemoMenu._startExtendedTimeout); 4752 tdDemoMenu._startExtendedTimeout = undefined; 4753 } 4754 4755 // Clear any interval, and we should have one, because we finished 4756 if (undefined !== tdDemoMenu._startExtendedInterval) { 4757 window.clearInterval(tdDemoMenu._startExtendedInterval); 4758 tdDemoMenu._startExtendedInterval = undefined; 4759 } 4760 4761 tdDemoMenu._resetTdScreeDemoExtendWidth(); 4762 4763 jQuery(this).hide(); 4764 4765 //jQuery( '.td-screen-demo:first').hide(); 4766 jQuery('.td-screen-demo:first').css('visibility', 'hidden'); 4767 } 4768 4769 ).mousemove(function(event) { 4770 //tdDemoMenu._moveScreenDemo( event ); 4771 }); 4772 }, 4773 4774 4775 4776 4777 /** 4778 * Position the '.td-screen-demo' element according to the mouse position 4779 * 4780 * @param event - mouse move 4781 * @private 4782 */ 4783 _moveScreenDemo: function( event ) { 4784 var 4785 // The jquery object of the previewer demo element 4786 $screenDemo = jQuery( '.td-screen-demo:first' ), 4787 4788 $WPAdminBar = jQuery( '#wpadminbar' ), 4789 4790 // new top value 4791 newTopValue = event.pageY - document.body.scrollTop - ( $screenDemo.outerHeight( true ) / 2 ), 4792 4793 // The reference top value used when #wpadminbar is enabled 4794 refTopValue = 0; 4795 4796 if ( $WPAdminBar.length ) { 4797 refTopValue = $WPAdminBar.outerHeight(true); 4798 } else { 4799 refTopValue = 0; 4800 } 4801 4802 if ( refTopValue >
4802 newTopValue ) { 4803 newTopValue = refTopValue; 4804 } 4805 4806 4807 if ( newTopValue < 0 ) { 4808 newTopValue = 0; 4809 } else if ( jQuery( window ).height() - $screenDemo.outerHeight( true ) / 2 < event.pageY - document.body.scrollTop ) { 4810 newTopValue = jQuery( window ).height() - $screenDemo.outerHeight( true ); 4811 } 4812 4813 $screenDemo.css( 'top', newTopValue ); 4814 }, 4815 4816 4817 4818 4819 4820 /** 4821 * Used when the width of the demo menu has changed (the width of the extended screen also changes) 4822 * @private 4823 */ 4824 _resetTdScreeDemoExtendWidth: function () { 4825 4826 var widthColumn = parseInt(jQuery('#td-theme-settings').css('width').replace('px', '')) / 2; 4827 4828 jQuery('.td-screen-demo-extend:first').css({ 4829 'width': widthColumn + 'px' 4830 }); 4831 }, 4832 4833 _showExtendedScreenDemo: function () { 4834 4835 if (tdDemoMenu._extendedDemo) { 4836 4837 jQuery('.td-screen-demo-extend:first').css({ 4838 top: jQuery('.td-screen-demo:first').css('top') 4839 }).show(); 4840 4841 } 4842 }, 4843 4844 _checkMousePosition: function () { 4845 4846 var theElement; 4847 4848 jQuery('.td-set-theme-style-link').each(function (index, element) { 4849 4850 tdDemoMenu._log(index); 4851 4852 var $this = jQuery(element), 4853 cssClassContainer = 'td-set-theme-style', 4854 $thisContainer = $this.closest('.' + cssClassContainer); 4855 4856 var verticalPosition = false; 4857 var horizontalPosition = false; 4858 4859 if (0 === jQuery('.td-set-theme-style-link').index(element) % 2) { 4860 4861 if (parseInt($thisContainer.position().top) + parseInt(jQuery(window).scrollTop()) < tdDemoMenu.mousePosY && tdDemoMenu.mousePosY < parseInt($thisContainer.position().top) + parseInt(jQuery(window).scrollTop()) + parseInt($thisContainer.outerHeight())) { 4862 verticalPosition = true; 4863 4864 if (parseInt(jQuery(window).width()) - 2 * parseInt($thisContainer.outerWidth()) < tdDemoMenu.mousePosX && tdDemoMenu.mousePosX < parseInt(jQuery(window).width()) - parseInt($thisContainer.outerWidth())) { 4865 horizontalPosition = true; 4866 } 4867 } 4868 //tdDemoMenu._log( 'caz A : ' + index + ' > vert: ' + verticalPosition + ' > hori: ' + horizontalPosition + ' > posY: ' + tdDemoMenu.mousePosY + ' > posX: ' + tdDemoMenu.mousePosX + 4869 // ' > top: ' + (parseInt($thisContainer.position().top) + parseInt(jQuery(window).scrollTop())) + ' > bottom: ' + (parseInt($thisContainer.position().top) + parseInt(jQuery(window).scrollTop()) + parseInt($thisContainer.outerHeight())) + 4870 // ' > left: ' + (parseInt(jQuery( window ).width()) - 2 * parseInt($thisContainer.outerWidth())) + ' > right: ' + (parseInt(jQuery( window ).width()) - parseInt($thisContainer.outerWidth())) ); 4871 4872 } else { 4873 var $thisPrevContainer = $thisContainer.prev('.' + cssClassContainer); 4874 4875 if ($thisPrevContainer.length) { 4876 if (parseInt($thisPrevContainer.position().top) + parseInt(jQuery(window).scrollTop()) < tdDemoMenu.mousePosY && tdDemoMenu.mousePosY < (parseInt($thisPrevContainer.position().top) + parseInt(jQuery(window).scrollTop()) + parseInt($thisPrevContainer.outerHeight()))) { 4877 verticalPosition = true; 4878 4879 if (parseInt(jQuery(window).width()) - parseInt($thisContainer.outerWidth()) < tdDemoMenu.mousePosX && tdDemoMenu.mousePosX < parseInt(jQuery(window).width())) { 4880 horizontalPosition = true; 4881 } 4882 } 4883 } 4884 //tdDemoMenu._log( 'caz B : ' + index + ' > vert: ' + verticalPosition + ' > hori: ' + horizontalPosition + ' > posY: ' + tdDemoMenu.mousePosY + ' > posX: ' + tdDemoMenu.mousePosX + 4885 // ' >
4885 top: ' + ($thisPrevContainer.position().top + parseInt(jQuery(window).scrollTop())) + ' > bottom: ' + (parseInt($thisPrevContainer.position().top) + parseInt(jQuery(window).scrollTop()) + parseInt($thisPrevContainer.outerHeight())) + 4886 // ' > left: ' + (parseInt(jQuery( window ).width()) - parseInt($thisContainer.outerWidth())) + ' > right: ' + parseInt(jQuery( window ).width()) ); 4887 } 4888 4889 // The element where the mouse is positioned, was found 4890 if (verticalPosition && horizontalPosition) { 4891 theElement = element; 4892 return false; 4893 } 4894 4895 }); 4896 4897 if (undefined === theElement) { 4898 //jQuery( '#td-theme-settings').find( '.td-screen-demo:first' ).hide(); 4899 jQuery('#td-theme-settings').find('.td-screen-demo:first').css('visibility', 'hidden'); 4900 } else { 4901 jQuery(theElement).mouseenter(); 4902 } 4903 }, 4904 4905 _log: function (msg) { 4906 4907 //window.console.log( msg ); 4908 } 4909 4910 }; 4911 4912})( jQuery ); 4913 4914 4915/** 4916 * show the panel if the cookie is set 4917 */ 4918(function() { 4919 'use strict'; 4920 var td_current_panel_stat = td_read_site_cookie( 'td_show_panel' ); 4921 if ( 'hide' === td_current_panel_stat ) { 4922 var jQueryObj = jQuery( '#td-theme-settings' ); 4923 if ( jQueryObj.length ) { 4924 jQueryObj.removeClass( 'td-theme-settings-small' ); 4925 jQuery( '#td-theme-set-hide' ).html( 'DEMOS' ); 4926 } 4927 } else { 4928 jQuery( '#td-theme-set-hide' ).html( 'CLOSE'); 4929 } 4930 4931})(); 4932 4933 4934 4935 4936 4937/* ---------------------------------------------------------------------------- 4938 On load 4939 */ 4940jQuery().ready(function() { 4941 4942 'use strict'; 4943 4944 // do not run on iOS 4945 if (tdDetect.isIos === false && tdDetect.isAndroid === false) { 4946 tdDemoMenu.init(); 4947 } 4948 4949 4950 4951 // Show/hide the demo menu panel 4952 jQuery( '#td-theme-set-hide' ).click(function(event) { 4953 event.preventDefault(); 4954 event.stopPropagation(); 4955 4956 var $this = jQuery(this), 4957 jQueryObj = jQuery( '#td-theme-settings' ); 4958 4959 if ( jQueryObj.hasClass( 'td-theme-settings-small' ) ) { 4960 // close 4961 jQueryObj.removeClass( 'td-theme-settings-small' ); 4962 jQueryObj.addClass( 'td-theme-settings-closed' ); 4963 $this.html( 'DEMOS' ); 4964 4965 setTimeout(function(){ 4966 jQueryObj.addClass( 'td-ts-closed-no-transition' ); // add the remove transition class after the animation has finished 4967 }, 450); 4968 4969 td_set_cookies_life( ['td_show_panel', 'hide', 86400000] );//86400000 is the number of milliseconds in a day 4970 4971 4972 } else { 4973 // open 4974 jQueryObj.removeClass( 'td-ts-closed-no-transition' ); // remove the remove transition class :) 4975 4976 4977 jQueryObj.addClass( 'td-theme-settings-small' ); 4978 jQueryObj.removeClass( 'td-theme-settings-closed' ); 4979 $this.html( 'CLOSE' ); 4980 td_set_cookies_life( ['td_show_panel', 'show', 86400000] );//86400000 is the number of milliseconds in a day 4981 } 4982 }); 4983 4984 4985}); //end on load 4986/** 4987 * Created by RADU on 6/24/14. 4988 */ 4989 4990/* global jQuery: {} */ 4991 4992//global object that holds each `trending-now-wrapper` list of posts 4993//var td_trending_now_object = {}; 4994 4995var tdTrendingNowObject = {}; 4996 4997(function() { 4998 4999 "use strict"; 5000 5001 tdTrendingNowObject = { 5002 5003 trendingNowAutostartBlocks: [], 5004 5005 //trending now function : creates the array of posts in each trend and add events to the nav buttons 5006 tdTrendingNow: function() { 5007 5008 //move thru all `trending-now-wrapper's` on the page 5009 jQuery('.td-trending-now-wrapper').each(function() { 5010 var wrapperId = jQuery(this).attr('id'); 5011 var wrapperIdNavigation = jQuery(this).data('start'); 5012 5013 if ('manual' !== wrapperIdNavigation) { 5014 tdTrendingNowObject.trendingNowAutostartBlocks.push(wrapperId); 5015 } 5016 5017 var trendingListPosts = []; 5018 var iCont = 0; 5019 5020 //take the text from each post from current trending-now-wrapper 5021 jQuery('#' + wrapperId + ' .td-trending-now-post').each(function() { 5022 //trending_list_posts[i_cont] = jQuery(this)[0].outerHTML; 5023 trendingListPosts[iCont] = jQuery(this); 5024 5025 //increment the counter 5026 iCont++; 5027 }); 5028 5029 //add this array to `tdTrendingNowObject` 5030 tdTrendingNowObject[wrapperId] = trendingListPosts; 5031 tdTrendingNowObject[wrapperId + '_position'] = 0; 5032 }); 5033 5034 jQuery('.td-trending-now-nav-left').click( function(event) { 5035 event.preventDefault(); 5036 var wrapperIdForNav = jQuery(this).data('wrapper-id'); 5037 5038 // if there's just a single post to be shown, there's no need for next/prev/autostart 5039 if ((undefined !== wrapperIdForNav) && (1 >= tdTrendingNowObject[wrapperIdForNav].length)) { 5040 return; 5041 } 5042 5043 //var data_moving = jQuery(this).data('moving'); 5044 var controlStart = jQuery(this).data('control-start'); 5045 5046 /** 5047 * used when the trending now block is used on auto mod and we click on show prev or show next article title 5048 * this will make the auto mode wait another xx seconds before displaying the next article title 5049 */ 5050 if ('manual' !== controlStart) { 5051 clearInterval(tdTrendingNowObject[wrapperIdForNav + '_timer']); 5052 tdTrendingNowObject[wrapperIdForNav + '_timer'] = setInterval(function() { 5053 tdTrendingNowObject.tdTrendingNowChangeText([wrapperIdForNav, 'left'], true); 5054 }, 3000); 5055 } 5056 5057 5058 //call to change the text 5059 tdTrendingNowObject.tdTrendingNowChangeText([wrapperIdForNav, 'right'], false); 5060 }); 5061 5062 5063 jQuery('.td-trending-now-nav-right').click(function(event) { 5064 event.preventDefault(); 5065 var wrapperIdForNav = jQuery(this).data('wrapper-id'); 5066 5067 // if there's just a single post to be shown, there's no need for next/prev/autostart 5068 if ((undefined !== wrapperIdForNav) && (1 >= tdTrendingNowObject[wrapperIdForNav].length)) { 5069 return; 5070 } 5071 5072 //var data_moving = jQuery(this).data('moving'); 5073 var controlStart = jQuery(this).data('control-start'); 5074 5075 /** 5076 * used when the trending now block is used on auto mod and we click on show prev or show next article title 5077 * this will make the auto mode wait another xx seconds before displaying the next article title 5078 */ 5079 if ('manual' !== controlStart) { 5080 clearInterval(tdTrendingNowObject[wrapperIdForNav + '_timer']); 5081 tdTrendingNowObject[wrapperIdForNav + '_timer'] = setInterval(function() { 5082 tdTrendingNowObject.tdTrendingNowChangeText([wrapperIdForNav, 'left' ], true); 5083 }, 3000); 5084 } 5085 5086 //call to change the text 5087 tdTrendingNowObject.tdTrendingNowChangeText([wrapperIdForNav, 'left'], true); 5088 }); 5089 5090 //console.log(tdTrendingNowObject); 5091 }, 5092 5093 5094 /* 5095 function for changing the posts in `trending now` display area 5096 * 5097 *array_param[0] : the id of current `trending now wrapper` 5098 *array_param[1] : moving direction (left or right) 5099 */ 5100 tdTrendingNowChangeText: function(array_param, to_right) { 5101 5102 //for consistency use the same variables names as thh parent function 5103 var wrapperIdForNav = array_param[0]; 5104 var dataMoving = array_param[1]; 5105 5106 //get the list of post and position for this trending now block 5107 var postsArrayListForThisTrend = tdTrendingNowObject[wrapperIdForNav]; 5108 5109 5110 // the following method is not so good because using it, many timers are already created 5111 // 5112 // if there's just a single post to be shown, there's no need for next/prev/autostart 5113 //if (posts_array_list_for_this_trend.length <= 1) { 5114 // return; 5115 //} 5116 5117 var postsArrayListPosition = tdTrendingNowObject[wrapperIdForNav + '_position']; 5118 5119 var previousPostArrayListPosition = postsArrayListPosition; 5120 5121 //count how many post are in the list 5122 var post_count = postsArrayListForThisTrend.length - 1; 5123 5124 if ('left' === dataMoving) { 5125 postsArrayListPosition += 1;
5126 5127 if (postsArrayListPosition > post_count) { 5128 postsArrayListPosition = 0; 5129 } 5130 5131 } else { 5132 postsArrayListPosition -= 1; 5133 5134 if (postsArrayListPosition < 0) { 5135 postsArrayListPosition = post_count; 5136 } 5137 } 5138 5139 //update the new position in the global `tdTrendingNowObject` 5140 tdTrendingNowObject[wrapperIdForNav + '_position'] = postsArrayListPosition; 5141 5142 postsArrayListForThisTrend[previousPostArrayListPosition].css('opacity', 0); 5143 postsArrayListForThisTrend[previousPostArrayListPosition].css('z-index', 0); 5144 5145 for (var trending_post in postsArrayListForThisTrend) { 5146 if (true === postsArrayListForThisTrend.hasOwnProperty(trending_post)) { 5147 postsArrayListForThisTrend[trending_post].removeClass('td_animated_xlong td_fadeInLeft td_fadeInRight td_fadeOutLeft td_fadeOutRight'); 5148 } 5149 } 5150 5151 postsArrayListForThisTrend[postsArrayListPosition].css('opacity', 1); 5152 postsArrayListForThisTrend[postsArrayListPosition].css('z-index', 1); 5153 5154 if (true === to_right) { 5155 5156 postsArrayListForThisTrend[previousPostArrayListPosition].addClass('td_animated_xlong td_fadeOutLeft'); 5157 postsArrayListForThisTrend[postsArrayListPosition].addClass('td_animated_xlong td_fadeInRight'); 5158 } else { 5159 5160 postsArrayListForThisTrend[previousPostArrayListPosition].addClass('td_animated_xlong td_fadeOutRight'); 5161 postsArrayListForThisTrend[postsArrayListPosition].addClass('td_animated_xlong td_fadeInLeft'); 5162 } 5163 }, 5164 5165 5166 //trending now function to auto start 5167 tdTrendingNowAutoStart: function() { 5168 5169 var list = tdTrendingNowObject.trendingNowAutostartBlocks; 5170 5171 for (var i = 0, len = list.length; i < len; i += 1) { 5172 5173 // if there's just a single post to be shown, there's no need for next/prev/autostart 5174 if (1 >= tdTrendingNowObject[list[i]].length) { 5175 return; 5176 } 5177 5178 tdTrendingNowObject[list[i] + '_timer'] = tdTrendingNowObject.setTimerChangingText(list[i]); 5179 } 5180 }, 5181 5182 setTimerChangingText: function(autoStartItem) { 5183 return setInterval(function () { 5184 //console.log(i + "=>" + list[i] + "\n"); 5185 tdTrendingNowObject.tdTrendingNowChangeText([autoStartItem, 'left'], true); 5186 }, 3000); 5187 } 5188 }; 5189 5190})(); 5191"use strict"; 5192 5193 5194/* ---------------------------------------------------------------------------- 5195 history js 5196 */ 5197 5198var td_history = { 5199 td_history_change_event: false, 5200 5201 // static class init 5202 init: function() { 5203 //hook the popstate event 5204 window.addEventListener('popstate', function(event) { 5205 td_history.td_history_change_event = true; 5206 if (typeof(event.state) != "undefined" && event.state != null) { 5207 jQuery("#" + event.state.slide_id).iosSlider("goToSlide", event.state.current_slide); 5208 } 5209 }); 5210 }, 5211 5212 5213 /** 5214 * generally used on load 5215 * @param data 5216 */ 5217 replace_history_entry: function (data) { 5218 if (tdDetect.hasHistory === false) { 5219 return; //no history support 5220 } 5221 history.replaceState(data, null); 5222 }, 5223 5224 5225 /** 5226 * ads an history entry - it also knows if we are using mod rewrite or not 5227 * @param data - the history data (state) 5228 * @param query_parm_id - 'slide' or other 5229 * @param query_parm_value - the value for slide 5230 */ 5231 add_history_entry: function (data, query_parm_id, query_parm_value) { 5232 5233 if (tdDetect.hasHistory === false) { 5234 return; //no history support 5235 } 5236 5237 5238 if (query_parm_value == '') { 5239 history.pushState(data, null, null); //add the hash via history api 5240 return; 5241 } 5242 5243 // @todo - detect other types of pages ex: ?page_id 5244 var td_query_page_id = td_history.get_query_parameter('p'); 5245 if (td_query_page_id != '') { 5246 //no mod rewrite, we go with ?p= etc 5247 if (query_parm_value == 1) { 5248 history.pushState(data, null, '?p=' + td_query_page_id); //remove the parm for the first item 5249 } else { 5250 history.pushState(data, null, '?p=' + td_query_page_id + '&' + query_parm_id + '=' + query_parm_value);
5250 //add the hash via history api 5251 } 5252 5253 } else { 5254 //mod rewrite 5255 if (query_parm_value == 1) { 5256 history.pushState(data, null, td_history.get_mod_rewrite_base_url()); //add the hash via history api 5257 } else { 5258 history.pushState(data, null, td_history.get_mod_rewrite_base_url() + query_parm_value + '/'); //add the hash via history api 5259 } 5260 } 5261 5262 }, 5263 5264 5265 5266 /** 5267 * returns the base url of urls with mod rewrite + pagination 5268 * @returns {string} 5269 */ 5270 get_mod_rewrite_base_url: function () { 5271 var full_url = document.URL; 5272 5273 //trim the last "/" in the url 5274 if (full_url.charAt(full_url.length - 1) == '/') { 5275 full_url = full_url.slice(0, - 1); 5276 } 5277 5278 if (td_history.get_mod_rewrite_pagination(document.URL) === false) { 5279 // no pagination present 5280 return document.URL; 5281 } 5282 5283 // we have pagination so we have to parse the url to remove it 5284 return full_url.substring(0, full_url.lastIndexOf("/"))+ '/'; 5285 5286 }, 5287 5288 5289 5290 /** 5291 * get the pagination from the urls with mod rewrite on 5292 * @returns {*} 5293 */ 5294 get_mod_rewrite_pagination: function () { 5295 var full_url = document.URL; 5296 5297 //trim the last "/" in the url 5298 if (full_url.charAt(full_url.length - 1) == '/') { 5299 full_url = full_url.slice(0, - 1); 5300 } 5301 5302 var last_url_parameter = full_url.substring(full_url.lastIndexOf("/")+1, full_url.length); 5303 5304 // return the page if it's indeed an integer 5305 if (td_history.isInt(last_url_parameter)) { 5306 return last_url_parameter; 5307 } 5308 5309 //return false if we don't have a page 5310 return false; 5311 }, 5312 5313 5314 /** 5315 * used by the iosslider @startAtSlide, it return 1 if there is no pagination or returns the pagination 5316 * @param query_parm_id 5317 * @returns {*} 5318 */ 5319 get_current_page: function (query_parm_id) { 5320 var td_query_page_id = td_history.get_query_parameter('p'); 5321 if (td_query_page_id != '') { 5322 //no mod rewrite, we go with ?p= etc 5323 var cur_page = td_history.get_query_parameter(query_parm_id); 5324 if (cur_page != '') { 5325 return cur_page; 5326 } else { 5327 return 1; 5328 } 5329 } else { 5330 //mod rewrite 5331 var cur_page = td_history.get_mod_rewrite_pagination(); 5332 if (cur_page !== false) { 5333 return cur_page; 5334 } else { 5335 return 1; 5336 } 5337 } 5338 }, 5339 5340 5341 /** 5342 * used to check if a number is an integer 5343 * @param n 5344 * @returns {boolean} 5345 */ 5346 isInt: function (n) { 5347 return n % 1 === 0; 5348 }, 5349 5350 5351 /** 5352 * returns a query parameter from the current url - we use it for ?p= 5353 * @param name 5354 * @returns {string} 5355 */ 5356 get_query_parameter: function (name) { 5357 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); 5358 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 5359 results = regex.exec(location.search); 5360 return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 5361 }, 5362 5363 /** 5364 * callback for slides with history 5365 * @param args 5366 */ 5367 slide_changed_callback: function(args) { 5368 //do not add another history entry if the slide moved due to the history change event 5369 if (td_history.td_history_change_event === true) { 5370 td_history.td_history_change_event = false; 5371 return; 5372 } 5373 var current_slide = args.currentSlideNumber; 5374 var slide_id = args.sliderContainerObject.attr('id'); 5375 5376 td_history.add_history_entry({current_slide:current_slide, slide_id:slide_id}, 'slide', current_slide); 5377 } 5378 5379}; 5380 5381/** 5382 * ie8 does not have pushState and history 5383 */ 5384if (window.history && window.history.pushState) { 5385 td_history.init(); 5386} 5387 5388/** 5389 * @depends on: 5390 * td_util 5391 * td_events 5392 * tdAffix 5393 */ 5394 5395/* global jQuery:{} */ 5396/* global tdUtil:{} */ 5397/* global tdViewport:{} */ 5398/* global tdAffix:{} */ 5399 5400 5401var tdSmartSidebar = {}; 5402 5403(function(){ 5404 5405 'use strict'; 5406 5407 tdSmartSidebar = { 5408 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 5409 items: [], //the array that has all the items 5410 scroll_window_scrollTop_last: 0, //last scrollTop position, used to calculate the scroll direction 5411 5412 5413 tds_snap_menu: tdUtil.getBackendVar( 'tds_snap_menu' ), //read the snap menu setting from theme panel 5414 5415 5416 /** 5417 * @see tdSmartSidebar.td_events_resize 5418 */ 5419 is_enabled: true, //if the smart sidebar is not needed (ex on mobile) put this flag to true 5420 is_enabled_state_run_once: false, // make sure that we dun enable and disable only once 5421 is_disabled_state_run_once: false, 5422 5423 5424 is_tablet_grid: false, //we detect if the current grid is the tablet portrait one 5425 5426 5427 _view_port_current_interval_index: tdViewport.getCurrentIntervalIndex(), 5428 5429 5430 item: function() { 5431 this.content_jquery_obj = ''; 5432 this.sidebar_jquery_obj = ''; 5433 5434 5435 // the position variables 5436 this.sidebar_top = 0; 5437 this.sidebar_bottom = 0; 5438 this.sidebar_height = 0; 5439 5440 5441 this.content_top = 0; 5442 this.content_bottom = 0; 5443 5444 // the sidebar state 5445 this.sidebar_state = ''; 5446 5447 this.case_1_run_once = false; 5448 this.case_2_run_once = false; 5449 this.case_3_run_once = false; 5450 this.case_3_last_sidebar_height = 0; // case 3 has to be recalculated if the sidebar height changes 5451 this.case_3_last_content_height = 0; // recalculate case 3 if content height has changed 5452 this.case_4_run_once = false; 5453 this.case_4_last_menu_offset = 0; 5454 this.case_5_run_once = false; 5455 this.case_6_run_once = false; 5456 }, 5457 5458 5459 //add item to the array 5460 add_item: function( item ) { 5461 tdSmartSidebar.hasItems = true; //put the flag that we have items 5462 5463 /** 5464 * add clear fix to the content and sidebar. 5465 * we need the clear fix to clear the margin of the first and last element 5466 */ 5467 item.sidebar_jquery_obj 5468 .prepend( '<div class="clearfix"></div>' ) 5469 .append( '<div class="clearfix"></div>' ); 5470 5471 item.content_jquery_obj 5472 .prepend( '<div class="clearfix"></div>' ) 5473 .append( '<div class="clearfix"></div>' ); 5474 5475 5476 tdSmartSidebar.items.push( item ); 5477 }, 5478 5479 5480 td_events_scroll: function( scrollTop ) { 5481 5482 5483 // we don't have any smart sidebars, return 5484 if ( false === tdSmartSidebar.hasItems ) { 5485 return; 5486 } 5487 5488 5489 // check if the smart sidebar is enabled ( the sidebar can be enabled / disabled on runtime ) 5490 if ( false === tdSmartSidebar.is_enabled ) { 5491 5492 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 5493 tdSmartSidebar.is_disabled_state_run_once = true; 5494 for ( var item_index = 0; item_index < tdSmartSidebar.items.length; item_index++ ) { 5495 tdSmartSidebar.items[ item_index ].sidebar_jquery_obj.css({ 5496 width: 'auto', 5497 position: 'static', 5498 top: 'auto', 5499 bottom: 'auto' 5500 }); 5501 } 5502 tdSmartSidebar.log( 'smart_sidebar_disabled' ); 5503 } 5504 5505 return; 5506 } 5507 5508 5509 // all is done in an animation frame 5510 window.requestAnimationFrame(function() { 5511 5512 5513 /** 5514 * this is the height of the menu, computed live. We 5515 * @type {number} 5516 */ 5517 var td_affix_menu_computed_height = 0;
5518 if ( '' !== tdSmartSidebar.tds_snap_menu ) { // if the menu is not snapping in any way - do not calculate this 5519 5520 // The main_menu_height was replaced with the _get_menu_affix_height(), because we need the size of the 5521 // affix menu. In the 'Newspaper' the menu has different sizes when it is affix 'on' and 'off'. 5522 td_affix_menu_computed_height = tdAffix._get_menu_affix_height(); 5523 5524 // Menu offset value is added when we are on 'smart_snap_always' case 5525 if ('smart_snap_always' === tdAffix.tds_snap_menu) { 5526 td_affix_menu_computed_height += tdAffix.menu_offset; 5527 } 5528 } 5529 // The following height is added just for Newspaper theme. 5530 // In the Newsmag theme, the sidebar elements have already a 'padding-top' of 20px 5531 5532 if ( ( 'undefined' !== typeof window.tdThemeName ) && ( 'Newspaper' === window.tdThemeName ) ) { 5533 td_affix_menu_computed_height += 20; 5534 } 5535 5536 5537 5538 5539 5540 // compute the scrolling direction 5541 var scroll_direction = ''; 5542 //check the direction 5543 if ( scrollTop !== tdSmartSidebar.scroll_window_scrollTop_last ) { // compute direction only if we have different last scroll top 5544 // compute the direction of the scroll 5545 if ( scrollTop > tdSmartSidebar.scroll_window_scrollTop_last ) { 5546 scroll_direction = 'down'; 5547 } else { 5548 scroll_direction = 'up'; 5549 } 5550 } 5551 tdSmartSidebar.scroll_window_scrollTop_last = scrollTop; 5552 5553 5554 5555 /** 5556 * scrollTop - is the distance that is scrolled from the top of the document PLUS the height of the menu 5557 */ 5558 5559 5560 5561 var view_port_height = jQuery( window ).height(); // ~ we can get this only once + on resize 5562 var view_port_bottom = scrollTop + view_port_height; 5563 5564 scrollTop = scrollTop + td_affix_menu_computed_height; 5565 5566 // go in all the sidebar items 5567 for ( var item_index = 0; item_index < tdSmartSidebar.items.length; item_index++ ) { 5568 5569 var cur_item_ref = tdSmartSidebar.items[ item_index ]; 5570 5571 cur_item_ref.content_top = cur_item_ref.content_jquery_obj.offset().top; 5572 cur_item_ref.content_height = cur_item_ref.content_jquery_obj.height(); 5573 cur_item_ref.content_bottom = cur_item_ref.content_top + cur_item_ref.content_height; 5574 5575 cur_item_ref.sidebar_top = cur_item_ref.sidebar_jquery_obj.offset().top; 5576 cur_item_ref.sidebar_height = cur_item_ref.sidebar_jquery_obj.height(); 5577 cur_item_ref.sidebar_bottom = cur_item_ref.sidebar_top + cur_item_ref.sidebar_height; 5578 5579 5580 5581 5582 5583 /** 5584 * Is the sidebar smaller than the content ? 5585 */ 5586 if ( cur_item_ref.content_height <= cur_item_ref.sidebar_height ) { 5587 cur_item_ref.sidebar_state = 'case_6_content_too_small'; 5588 5589 5590 5591 /** 5592 * the sidebar is smaller than the view port? that means that we have to switch to a more simpler sidebar AKA affix 5593 */ 5594 5595 } else if ( cur_item_ref.sidebar_height < view_port_height ) { 5596 5597 // ref value used to compare the scroll top 5598 var ref_value = cur_item_ref.content_top; 5599 5600 // For 'Newsmag' the ref value is incremented with td_affix_menu_computed_height 5601 // It solves a case when the affix menu leaves the 'case_2_top_of_content' phase to 'case_4_fixed_up' too early 5602 // It's because of how the grid, and smart sidebar, are built on Newspaper vs Newsmag 5603 if ( ! tdAffix.is_menu_affix && ( 'undefined' !== typeof window.tdThemeName ) && ( 'Newsmag' === window.tdThemeName ) && ( 'smart_snap_always' === tdAffix.tds_snap_menu ) ) { 5604 ref_value += td_affix_menu_computed_height; 5605 } 5606 5607 //if (tdSmartSidebar._is_smaller_or_equal(scrollTop, cur_item_ref.content_top)) { 5608 if ( tdSmartSidebar._is_smaller_or_equal( scrollTop, ref_value ) ) { 5609 // not affix - we did not scroll to reach the sidebar 5610 cur_item_ref.sidebar_state = 'case_2_top_of_content'; 5611 } 5612 5613 // [1] if the sidebar is visible and we have enough space in the sidebar, place it at the top affix top 5614 // [2] if the sidebar is above the view port and n
5614othing is visible, place the sidebar at the bottom of the column 5615 5616 else if ( true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, scrollTop ) ) { 5617 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. 5618 cur_item_ref.sidebar_state = 'case_4_fixed_up'; // [1]87 5619 } else { 5620 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; // [2] 5621 } 5622 5623 5624 } else { 5625 5626 // affix 5627 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 5628 if ( 'up' === scroll_direction && tdSmartSidebar._is_smaller_or_equal( scrollTop, cur_item_ref.sidebar_top ) ) { 5629 cur_item_ref.sidebar_state = 'case_4_fixed_up'; // get out of the case_3_bottom_of_content state 5630 } else { 5631 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 5632 } 5633 5634 } else { 5635 if ( cur_item_ref.content_bottom - scrollTop >= cur_item_ref.sidebar_height ) { 5636 // Make sure that we have space for the sidebar to affix it to the top 5637 cur_item_ref.sidebar_state = 'case_4_fixed_up'; // we are not at the bottom of the content 5638 } else { 5639 5640 // 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 5641 5642 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 5643 } 5644 //console.log(cur_item_ref.content_bottom + ' >= ' + cur_item_ref.sidebar_bottom); //@todo fix this case pe ? @20may2016 era un url aici dar l-am sters din motive de securitate 5645 } 5646 } 5647 5648 5649 5650 /** 5651 * the sidebar is larger than the view port and the content is bigger 5652 */ 5653 5654 5655 } else { 5656 5657 //// if the sidebar is above the view port and nothing is visible, place the sidebar at the bottom of the column 5658 //if (tdSmartSidebar._is_smaller(cur_item_ref.sidebar_bottom, scrollTop) === true) { 5659 // cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 5660 // tdSmartSidebar.log(cur_item_ref.sidebar_bottom + ' ~ ' + scrollTop); 5661 //} 5662 5663 5664 // if the sidebar is above the view port and nothing is visible, place the sidebar fixed up if it's smaller than the viewport, 5665 // fixed down, meaning that a possible previous operation could be 'scroll down' 5666 // if none of the above operations meets the conditions, the sidebar is placed at the bottom of the content 5667 if ( true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, scrollTop ) ) { 5668 5669 if ( true === tdSmartSidebar._is_smaller_or_equal(scrollTop, cur_item_ref.sidebar_top ) && 5670 5671 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 5672 ) { 5673 //console.log('sidebar_top' + cur_item_ref.sidebar_top + ' content top:' + cur_item_ref.content_top); 5674 cur_item_ref.sidebar_state = 'case_4_fixed_up'; 5675 } 5676 else if ( 5677 true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, view_port_bottom ) && 5678 true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, cur_item_ref.content_bottom ) && 5679 cur_item_ref.content_bottom >= view_port_bottom 5680 ) { 5681 cur_item_ref.sidebar_state = 'case_1_fixed_down'; 5682 } 5683 else { 5684 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 5685 } 5686 } 5687 5688 5689 5690 // position:fixed; bottom:0 5691 else if ( 5692 true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, view_port_bottom ) && 5693 true === tdSmartSidebar._is_smaller( cur_item_ref.sidebar_bottom, cur_item_ref.content_bottom ) && 5694 'down' === scroll_direction && 5695 cur_item_ref.content_bottom >= view_port_bottom 5696 ) { 5697 //console.log(cur_item_ref.sidebar_bottom + ' < ' + cur_item_ref.content_bottom); 5698 cur_item_ref.sidebar_state = 'case_1_fixed_down'; 5699 } 5700 5701 // the sidebar is at the top of the content ( position:static ) 5702 else if ( 5703 true === tdSmartSidebar._is_smaller_or_equal( cur_item_ref.sidebar_top, cur_item_ref.content_top ) && 5704 'up' === scroll_direction && 5705 cur_item_ref.content_bottom >= view_port_bottom 5706 ) { 5707 cur_item_ref.sidebar_state = 'case_2_top_of_content'; 5708 } 5709 5710 5711 5712 5713 // the sidebar reached the bottom of the content 5714 else if ( 5715 ( true === tdSmartSidebar._is_smaller_or_equal(cur_item_ref.content_bottom, cur_item_ref.sidebar_bottom) && 'down' === scroll_direction ) || 5716 cur_item_ref.content_bottom < view_port_bottom 5717 5718 ) { 5719 cur_item_ref.sidebar_state = 'case_3_bottom_of_content'; 5720 5721 } 5722 // scrolling up, the sidebar is fixed up ( position:fixed; top:0 ) 5723 else if ( true === tdSmartSidebar._is_smaller_or_equal( scrollTop, cur_item_ref.sidebar_top ) && 'up' === scroll_direction && 5724 5725 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 5726 ) { 5727 //console.log('sidebar_top' + cur_item_ref.sidebar_top + ' content top:' + cur_item_ref.content_top); 5728 cur_item_ref.sidebar_state = 'case_4_fixed_up'; 5729 } 5730 5731 5732 5733 5734 /** 5735 * This is the case when the scroll direction is 'up', but the sidebar is above the viewport (it could be left behind by a fast operation like typing HOME key) 5736 */ 5737 else if ('up' === scroll_direction && true === tdSmartSidebar._is_smaller_or_equal( view_port_bottom, cur_item_ref.sidebar_top )) 5738 { 5739 cur_item_ref.sidebar_state = 'case_2_top_of_content'; 5740 } 5741 5742 5743 5744 // when to put absolute? 5745 if ( 5746 ( 'case_1_fixed_down' === cur_item_ref.sidebar_state && 'up' === scroll_direction ) || 5747 ( 'case_4_fixed_up' === cur_item_ref.sidebar_state && 'down' === scroll_direction ) 5748 ) { 5749 cur_item_ref.sidebar_state = 'case_5_absolute'; //absolute while going up? 5750 } 5751 5752 } // end sidebar length check cur_item_ref.sidebar_height < view_port_height 5753 5754 5755 5756 5757 /** 5758 * after we have the state, we enter this switch that makes sure that we only have one state change 5759 */ 5760 5761 // we have to set the content width via JS 5762 //var column_content_width = 339; 5763 //if (tdSmartSidebar.is_tablet_grid) { 5764 // column_content_width = 251; 5765 //} 5766 5767 5768 var column_content_width = 0; 5769 5770 var view_port_current_item = tdViewport.getCurrentIntervalItem(); 5771 5772 if ( null !== view_port_current_item ) { 5773 column_content_width = view_port_current_item.sidebarWidth; 5774 //tdSmartSidebar.log("column sidebar width : " + column_content_width); 5775 } 5776 5777 5778 5779 switch ( cur_item_ref.sidebar_state ) { 5780 case 'case_1_fixed_down': 5781 5782 if ( true === cur_item_ref.case_1_run_once ) { 5783 break; 5784 } 5785 5786 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 5787 5788 cur_item_ref.case_1_run_once = true; 5789 cur_item_ref.case_2_run_once = false; 5790 cur_item_ref.case_3_run_once = false; 5791 cur_item_ref.case_4_run_once = false; 5792 cur_item_ref.case_5_run_once = false; 5793 cur_item_ref.case_6_run_once = false; 5794 5795 5796 cur_item_ref.sidebar_jquery_obj.css({ 5797 width: column_content_width, 5798 position: 'fixed', 5799 top: 'auto', 5800 bottom: '0', 5801 'z-index': '1' 5802 }); 5803 5804 5805 break; 5806 5807 case 'case_2_top_of_content': 5808 5809 if ( true === cur_item_ref.case_2_run_once ) { 5810 break; 5811 } 5812 5813 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 5814 5815 cur_item_ref.case_1_run_once = false; 5816 cur_item_ref.case_2_run_once = true; 5817 cur_item_ref.case_3_run_once = false; 5818 cur_item_ref.case_4_run_once = false; 5819 cur_item_ref.case_5_run_once = false; 5820 cur_item_ref.case_6_run_once = false; 5821 5822 5823 cur_item_ref.sidebar_jquery_obj.css({ 5824 width: 'auto', 5825 position: 'static', 5826 top: 'auto', 5827 bottom: 'auto' 5828 }); 5829 break; 5830 5831 case 'case_3_bottom_of_content': 5832 // case 3 has to be recalculated if the sidebar height changes 5833 5834 if ( true === cur_item_ref.case_3_run_once && 5835 cur_item_ref.case_3_last_sidebar_height === cur_item_ref.sidebar_height && 5836 cur_item_ref.case_3_last_content_height === cur_item_ref.content_height 5837 ) { //if the case already runned AND the sidebar height did n
5837ot change 5838 break; 5839 } 5840 5841 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 5842 5843 cur_item_ref.case_1_run_once = false; 5844 cur_item_ref.case_2_run_once = false; 5845 cur_item_ref.case_3_run_once = true; 5846 cur_item_ref.case_3_last_sidebar_height = cur_item_ref.sidebar_height; 5847 cur_item_ref.case_3_last_content_height = cur_item_ref.content_height; 5848 cur_item_ref.case_4_run_once = false; 5849 cur_item_ref.case_5_run_once = false; 5850 cur_item_ref.case_6_run_once = false; 5851 5852 5853 cur_item_ref.sidebar_jquery_obj.css({ 5854 width: column_content_width, 5855 position: 'absolute', 5856 top: cur_item_ref.content_bottom - cur_item_ref.sidebar_height - cur_item_ref.content_top, 5857 bottom: 'auto' 5858 }); 5859 break; 5860 5861 case 'case_4_fixed_up': 5862 5863 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 5864 break; 5865 } 5866 5867 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 5868 5869 cur_item_ref.case_1_run_once = false; 5870 cur_item_ref.case_2_run_once = false; 5871 cur_item_ref.case_3_run_once = false; 5872 cur_item_ref.case_4_run_once = true; 5873 cur_item_ref.case_4_last_menu_offset = td_affix_menu_computed_height; 5874 cur_item_ref.case_5_run_once = false; 5875 cur_item_ref.case_6_run_once = false; 5876 5877 5878 cur_item_ref.sidebar_jquery_obj.css({ 5879 width: column_content_width, 5880 position: 'fixed', 5881 top: td_affix_menu_computed_height, 5882 bottom: 'auto' 5883 }); 5884 break; 5885 5886 case 'case_5_absolute': 5887 5888 if ( true === cur_item_ref.case_5_run_once ) { 5889 break; 5890 } 5891 5892 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 5893 5894 cur_item_ref.case_1_run_once = false; 5895 cur_item_ref.case_2_run_once = false; 5896 cur_item_ref.case_3_run_once = false; 5897 cur_item_ref.case_4_run_once = false; 5898 cur_item_ref.case_5_run_once = true; 5899 cur_item_ref.case_6_run_once = false; 5900 5901 5902 cur_item_ref.sidebar_jquery_obj.css({ 5903 width: column_content_width, 5904 position: 'absolute', 5905 top: cur_item_ref.sidebar_top - cur_item_ref.content_top, 5906 bottom: 'auto' 5907 }); 5908 break; 5909 5910 case 'case_6_content_too_small': 5911 5912 if ( true === cur_item_ref.case_6_run_once ) { 5913 break; 5914 } 5915 5916 tdSmartSidebar.log( 'sidebar_id: ' + item_index + ' ' + cur_item_ref.sidebar_state ); 5917 5918 cur_item_ref.case_1_run_once = false; 5919 cur_item_ref.case_2_run_once = false; 5920 cur_item_ref.case_3_run_once = false; 5921 cur_item_ref.case_4_run_once = false; 5922 cur_item_ref.case_5_run_once = false; 5923 cur_item_ref.case_6_run_once = true; 5924 5925 cur_item_ref.sidebar_jquery_obj.css({ 5926 width: 'auto', 5927 position: 'static', 5928 top: 'auto', 5929 bottom: 'auto' 5930 }); 5931 break; 5932 } 5933 } // end for loop 5934 }); // end request animation frame 5935 }, // end td_events_scroll 5936 5937 5938 compute: function() { 5939 5940 tdSmartSidebar.td_events_scroll( jQuery( window ).scrollTop() ); 5941 }, 5942 5943 5944 // resets the run once flags. It may fail sometimes due to case_3_last_sidebar_height & case_4_last_menu_offset 5945 reset_run_once_flags: function () { 5946 for ( var item_index = 0; item_index < tdSmartSidebar.items.length; item_index++ ) { 5947 tdSmartSidebar.items[ item_index ].case_1_run_once = false; 5948 tdSmartSidebar.items[ item_index ].case_2_run_once = false; 5949 tdSmartSidebar.items[ item_index ].case_3_run_once = false; 5950 tdSmartSidebar.items[ item_index ].case_3_last_sidebar_height = 0; 5951 tdSmartSidebar.items[ item_index ].case_3_last_content_height = 0; 5952 tdSmartSidebar.items[ item_index ].case_4_run_once = false; 5953 tdSmartSidebar.items[ item_index ].case_4_last_menu_offset = 0; 5954 tdSmartSidebar.items[ item_index ].case_5_run_once = false; 5955 tdSmartSidebar.items[ item_index ].case_6_run_once = false; 5956 } 5957 }, 5958 5959 5960 5961 td_events_resize: function() { 5962 // enable and disable the smart sidebar 5963 5964 tdSmartSidebar._view_port_current_interval_index = tdViewport.getCurrentIntervalIndex(); 5965 5966 switch ( tdSmartSidebar._view_port_current_interval_index ) { 5967 5968 case 0 : 5969 5970 tdSmartSidebar.is_enabled = false; 5971 5972 // flag marked false to be made true only once, when the view port has not the first interval index [0] 5973 tdSmartSidebar.is_enabled_state_run_once = false; 5974 5975 break; 5976 5977 case 1 : 5978 if ( false === tdSmartSidebar.is_tablet_grid ) { // we switched 5979 5980 tdSmartSidebar.reset_run_once_flags();
5981 5982 tdSmartSidebar.is_tablet_grid = true; 5983 tdSmartSidebar.is_desktop_grid = false; 5984 5985 tdSmartSidebar.log( 'view port tablet' ); 5986 } 5987 tdSmartSidebar.is_enabled = true; 5988 tdSmartSidebar.is_disabled_state_run_once = false; 5989 5990 if ( false === tdSmartSidebar.is_enabled_state_run_once ) { 5991 tdSmartSidebar.is_enabled_state_run_once = true; 5992 tdSmartSidebar.log( 'smart_sidebar_enabled' ); 5993 } 5994 break; 5995 5996 case 2 : 5997 case 3 : 5998 if ( true === tdSmartSidebar.is_tablet_grid ) { // we switched 5999 6000 tdSmartSidebar.reset_run_once_flags(); 6001 6002 tdSmartSidebar.is_tablet_grid = false; 6003 tdSmartSidebar.is_desktop_grid = true; 6004 6005 tdSmartSidebar.log( 'view port desktop' ); 6006 } 6007 tdSmartSidebar.is_enabled = true; 6008 tdSmartSidebar.is_disabled_state_run_once = false; 6009 6010 if ( false === tdSmartSidebar.is_enabled_state_run_once ) { 6011 tdSmartSidebar.is_enabled_state_run_once = true; 6012 tdSmartSidebar.log( 'smart_sidebar_enabled' ); 6013 } 6014 break; 6015 } 6016 6017 // @todo we may be able to delay the compute a bit (aka run it on the 500ms timer) 6018 tdSmartSidebar.compute(); 6019 }, 6020 6021 6022 log: function( msg ) { 6023 //console.log(msg); 6024 }, 6025 6026 6027 /** 6028 * check if the two numbers are approximately equal OR the number1 is smaller. 6029 * This function is used to compensate for differences in the offset top reported by IE, FF but not chrome 6030 * IE and FF have an error for offset top of +- 0.5 6031 * @param number1 - this has to be smaller or approximately equal with number2 to return true 6032 * @param number2 6033 * @returns {boolean} 6034 * @private 6035 */ 6036 _is_smaller_or_equal: function( number1, number2 ) { 6037 // check if the two numbers are approximately equal 6038 // - first we check if the difference between the numbers is bigger than 1 unit 6039 // - second we check if the first number is bigger than the second one 6040 // if the two conditions are met, we return false 6041 6042 6043 if ( Math.abs( number1 - number2 ) >= 1) { 6044 // we have a difference that is bigger than 1 unit (px), check if the numbers are smaller or bigger 6045 if ( number1 < number2 ) { 6046 return true; 6047 } else { 6048 return false; 6049 } 6050 } else { 6051 // the difference between the two numbers is smaller than one unit (1 px), this means that the two numbers are the same 6052 return true; 6053 } 6054 }, 6055 6056 6057 /** 6058 * Checks to see if number1 < number2 by at least one unit! 6059 * @param number1 6060 * @param number2 6061 * @returns {boolean} 6062 * @private 6063 */ 6064 _is_smaller: function( number1, number2 ) { 6065 if ( Math.abs( number1 - number2 ) >= 1) { 6066 if ( number1 < number2 ) { 6067 return true; 6068 } else { 6069 return false; 6070 } 6071 } else { 6072 // the difference between the two numbers is smaller than one unit (1 px), this means that the two numbers are the same 6073 return false; 6074 } 6075 } 6076 }; 6077 6078 //console.log(tdSmartSidebar.items); 6079})(); 6080 6081 6082 6083/** 6084 * Infinite loader v1.0 by Radu O. / tagDiv 6085 * USES: 6086 * - tdEvents.js 6087 * - for blocks: 6088 * - td_block::get_block_pagination - custom load more 6089 * - 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 6090 * 6091 */ 6092 6093/* global jQuery:false */ 6094/* global tdBlocks:false */ 6095 6096 6097/** 6098 * Global infinite loader object 6099 */ 6100var tdInfiniteLoader = {}; 6101 6102(function () { 6103 "use strict"; 6104 6105 /** 6106 * - register and keep track of dom elements 6107 * - calculate position from the top of each element 6108 * - monitor on scroll event 6109 * - if one or more of the dom elements is visible 6110 * - fire the callback for that dom element! only ONCE 6111 */ 6112 6113 6114 tdInfiniteLoader = { 6115 6116 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 6117 6118 items: [], //the array that has all the items 6119 6120 // one item object (instantiable) 6121 item: function() { 6122 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 6123 this.jqueryObj = ''; //find the item easily for animation ?? 6124 this.bottomTop = 0; //distance from the bottom of the dom element to top - computed in - @see tdInfiniteLoader.compute_top_distances(); 6125 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 6126 this.isVisibleCallback = function () { //callback when the item's bottom is visible :) 6127 }; 6128 }, 6129 6130 addItem: function(item) { 6131 tdInfiniteLoader.hasItems = true; //put the flag that we have items 6132 tdInfiniteLoader.items.push(item); 6133 }, 6134 6135 6136 /** 6137 * foreach element from items, compute the distances from the top 6138 * - this is done only on load or when the page is resized 6139 */ 6140 computeTopDistances: function() { 6141 6142 //check the flag to see if we have any items 6143 if ( tdInfiniteLoader.hasItems === false ) { 6144 return; 6145 } 6146 6147 jQuery.each(tdInfiniteLoader.items, function(index, v_event) { 6148 var topTop = tdInfiniteLoader.items[index].jqueryObj.offset().top; 6149 //top of document to bottom of element 6150 tdInfiniteLoader.items[index].bottomTop = topTop + tdInfiniteLoader.items[index].jqueryObj.height(); 6151 }); 6152 6153 //also calculate the events 6154 tdInfiniteLoader.computeEvents(); 6155 6156 }, 6157 6158 6159 /** 6160 * calculate if we have to fire an event like isVisibleCallback() 6161 * - this is done on scroll and on resize! 6162 */ 6163 computeEvents: function() { 6164 //check the flag to see if we have any items 6165 if ( tdInfiniteLoader.hasItems === false ) { 6166 return; 6167 } 6168 6169 var topToViewportBottom = jQuery(window).height() + jQuery(window).scrollTop(); 6170 6171 6172 jQuery.each(tdInfiniteLoader.items, function(index, item) { 6173 if ( tdInfiniteLoader.items[index].bottomTop < topToViewportBottom + 700 ) { 6174 6175 //check to see if we can call the callback again 6176 if ( tdInfiniteLoader.items[index].isVisibleCallbackEnabled === true ) { 6177 tdInfiniteLoader.items[index].isVisibleCallbackEnabled = false; 6178 //the call 6179 tdInfiniteLoader.items[index].isVisibleCallback(); 6180 } 6181 } 6182 6183 6184 }); 6185 }, 6186 6187 6188 /** 6189 * enables the isVisibleCallback - it is called by td_blocks.js only when a block receives an infinite loading ajax reply 6190 * @param $item_uid - an unique id of the item, usually is the block id! 6191 * @see tdBlocks.tdBlockAjaxLoadingEnd 6192 */
6193 enable_is_visible_callback: function($item_uid) { 6194 jQuery.each(tdInfiniteLoader.items, function(index, item) { 6195 if ( item.uid === $item_uid ) { 6196 tdInfiniteLoader.items[index].isVisibleCallbackEnabled = true; 6197 return false; //brake jquery each 6198 } 6199 }); 6200 } 6201 6202 }; 6203 6204 6205 6206 6207 6208 6209 /** 6210 * we are using td_ajax_infinite to know when to trigger a block loading 6211 */ 6212 jQuery('.td_ajax_infinite').each( function() { 6213 6214 // create a new infinite loader item 6215 var tdInfiniteLoaderItem = new tdInfiniteLoader.item(); 6216 6217 tdInfiniteLoaderItem.jqueryObj = jQuery(this); 6218 tdInfiniteLoaderItem.uid = jQuery(this).data('td_block_id'); 6219 6220 6221 /** 6222 * the callback when the bottom of the element is visible on screen and we need to do something - like load another page 6223 * - the callback does not fire again until tdInfiniteLoader.enable_is_visible_callback is called @see tdInfiniteLoader.js:95 6224 */ 6225 tdInfiniteLoaderItem.isVisibleCallback = function () { // the is_visible callback is called when we have to pull new content up because the element is visible 6226 6227 // get the current block object 6228 var currentBlockObj = tdBlocks.tdGetBlockObjById(tdInfiniteLoaderItem.jqueryObj.data('td_block_id')); 6229 6230 // if we don't have a infinite stop limit or if we have one we dint' hit it yet 6231 if ( currentBlockObj.ajax_pagination_infinite_stop === '' || 6232 currentBlockObj.td_current_page < (parseInt(currentBlockObj.ajax_pagination_infinite_stop) + 1) ) { 6233 6234 // get the block data and increment the pagination 6235 currentBlockObj.td_current_page++; 6236 tdBlocks.tdAjaxDoBlockRequest(currentBlockObj, 'infinite_load'); 6237 6238 } else { 6239 /** 6240 * show the load more button. The button is already there, hidden - do not know if it's the best solution :) 6241 * @see td_block::get_block_pagination in td_block.php 6242 */ 6243 if ( currentBlockObj.td_current_page < currentBlockObj.max_num_pages ) { 6244 setTimeout( function(){ 6245 jQuery('#infinite-lm-' + currentBlockObj.id) 6246 .css('display', 'block') 6247 .css('visibility', 'visible') 6248 ; 6249 }, 400); 6250 } 6251 } 6252 }; 6253 tdInfiniteLoader.addItem(tdInfiniteLoaderItem); 6254 }); 6255 6256 6257 6258 6259 6260 6261 6262 6263 //compute to 6264 jQuery(window).load( function() { 6265 tdInfiniteLoader.computeTopDistances(); 6266 }); 6267 6268 jQuery().ready( function() { 6269 tdInfiniteLoader.computeTopDistances(); 6270 }); 6271})(); 6272/* 6273* used by vimeo in td_video shortcode 6274* */ 6275 6276"use strict"; 6277 6278var 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!== 6279 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|| 6280 !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}
6280,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= 6281 !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}(); 6282/* td_custom_events.js - handles the booster td_events that require throttling 6283 * v 1.0 - wp_011 6284 */ 6285 6286/* global tdAnimationScroll:{} */ 6287/* global tdAnimationStack:{} */ 6288/* global tdPullDown:{} */ 6289/* global tdBackstr:{} */ 6290/* global td_backstretch_items:Array */ 6291/* global td_compute_backstretch_item:Function */ 6292 6293/* global setMenuMinHeight:Function */ 6294 6295var tdCustomEvents = {}; 6296 6297(function(){ 6298 6299 'use strict'; 6300 6301 tdCustomEvents = { 6302 6303 6304 /** 6305 * - callback real scroll called from td_events 6306 * @private 6307 */ 6308 _callback_scroll: function() { 6309 tdAnimationScroll.compute_all_items(); 6310 }, 6311 6312 6313 /** 6314 * - callback real resize called from td_events 6315 * @private 6316 */ 6317 _callback_resize: function() { 6318 6319 }, 6320 6321 6322 /** 6323 * - callback lazy scroll called from td_events at 100ms 6324 * @private 6325 */ 6326 _lazy_callback_scroll_100: function() { 6327 if ( true === tdAnimationStack.activated ) { 6328 tdAnimationStack.td_events_scroll(); 6329 } 6330 }, 6331 6332 6333 /** 6334 * - callback lazy scroll called from td_events at 500ms 6335 * @private 6336 */ 6337 _lazy_callback_scroll_500: function() { 6338 6339 }, 6340 6341 6342 6343 /** 6344 * - callback lazy resize called from td_events at 100ms 6345 * @private 6346 */ 6347 _lazy_callback_resize_100: function() { 6348 tdPullDown.td_events_resize(); 6349 tdBackstr.td_events_resize(); 6350 tdAnimationScroll.td_events_resize(); 6351 }, 6352 6353 6354 /** 6355 * - callback lazy resize called from td_events at 500ms 6356 * @private 6357 */ 6358 _lazy_callback_resize_500: function() { 6359 if ( true === tdAnimationStack.activated ) { 6360 tdAnimationStack.td_events_resize(); 6361 } 6362 6363 // - every tdAnimationScroll.item item of the td_backstretch_items array must be reinitialized and repositioned for parallax effect 6364 for ( var i = 0; i < td_backstretch_items.length; i++ ) { 6365 tdAnimationScroll.reinitialize_item( td_backstretch_items[ i ], true ); 6366 td_compute_backstretch_item( td_backstretch_items[ i ] ); 6367 6368 // compute_all_items is used instead, for requestAnimationFrame 6369 //tdAnimationScroll.compute_item(td_backstretch_items[i]); 6370 } 6371 6372 // for better performance it's used tdAnimationScroll.compute_all_items, because it uses requestAnimationFrame 6373 tdAnimationScroll.compute_all_items(); 6374 6375 // @todo It will be refactorized when td_site will be 6376 setMenuMinHeight(); 6377 } 6378 }; 6379})(); 6380 6381/* tdEvents.js - handles the events that require throttling 6382 * v 2.0 - wp_010 6383 * 6384 * moved in theme from wp_booster 6385 */ 6386 6387/* global jQuery:{} */ 6388/* global tdAffix:{} */ 6389/* global tdSmartSidebar:{} */ 6390/* global tdViewport:{} */ 6391/* global tdInfiniteLoader:{} */ 6392/* global td_more_articles_box:{} */ 6393/* global tdDetect:{} */ 6394/* global tdCustomEvents:{} */ 6395 6396/* global td_events_scroll_scroll_to_top:Function */ 6397 6398var tdEvents = {}; 6399 6400(function(){ 6401 'use strict'; 6402 6403 tdEvents = { 6404 6405 //the events - we have timers that look at the variables and fire the event if the flag is true 6406 scroll_event_slow_run: false, 6407 scroll_event_medium_run: false, 6408 6409 resize_event_slow_run: false, //when true, fire up the resize event 6410 resize_event_medium_run: false, 6411 6412 6413 scroll_window_scrollTop: 0, //used to store the scrollTop 6414 6415 window_pageYOffset: window.pageYOffset, // @todo see if it can replace scroll_window_scrollTop [used by others]
6416 window_innerHeight: window.innerHeight, // used to store the window height 6417 window_innerWidth: window.innerWidth, // used to store the window width 6418 6419 init: function() { 6420 6421 jQuery( window ).scroll(function() { 6422 tdEvents.scroll_event_slow_run = true; 6423 tdEvents.scroll_event_medium_run = true; 6424 6425 //read the scroll top 6426 tdEvents.scroll_window_scrollTop = jQuery( window ).scrollTop(); 6427 tdEvents.window_pageYOffset = window.pageYOffset; 6428 6429 /* ---------------------------------------------------------------------------- 6430 Run affix menu event 6431 */ 6432 6433 tdAffix.td_events_scroll( tdEvents.scroll_window_scrollTop ); //main menu 6434 6435 tdSmartSidebar.td_events_scroll( tdEvents.scroll_window_scrollTop ); //smart sidebar scroll 6436 6437 6438 // call real tdCustomEvents scroll 6439 tdCustomEvents._callback_scroll(); 6440 }); 6441 6442 6443 jQuery( window ).resize(function() { 6444 tdEvents.resize_event_slow_run = true; 6445 tdEvents.resize_event_medium_run = true; 6446
6447 tdEvents.window_innerHeight = window.innerHeight; 6448 tdEvents.window_innerWidth = window.innerWidth; 6449 6450 //var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 6451 6452 //w = jQuery(document).width(); 6453 //console.log(w); 6454 6455 6456 // call real tdCustomEvents resize 6457 tdCustomEvents._callback_resize(); 6458 }); 6459 6460 6461 6462 //medium resolution timer for rest? 6463 setInterval(function() { 6464 6465 // it must run before any others 6466 tdViewport.detectChanges(); 6467 6468 //scroll event 6469 if ( tdEvents.scroll_event_medium_run ) { 6470 tdEvents.scroll_event_medium_run = false; 6471 //compute events for the infinite scroll 6472 tdInfiniteLoader.computeEvents(); 6473 6474 6475 // call lazy tdCustomEvents scroll 6476 tdCustomEvents._lazy_callback_scroll_100(); 6477 } 6478 6479 if ( tdEvents.resize_event_medium_run ) { 6480 tdEvents.resize_event_medium_run = false; 6481 tdSmartSidebar.td_events_resize(); 6482 6483 6484 // call lazy tdCustomEvents resize 6485 tdCustomEvents._lazy_callback_resize_100(); 6486 } 6487 }, 100); 6488 6489 6490 6491 //low resolution timer for rest? 6492 setInterval(function() { 6493 //scroll event 6494 if ( tdEvents.scroll_event_slow_run ) { 6495 tdEvents.scroll_event_slow_run = false; 6496 6497 //back to top 6498 td_events_scroll_scroll_to_top( tdEvents.scroll_window_scrollTop ); 6499 6500 //more articles box 6501 td_more_articles_box.td_events_scroll( tdEvents.scroll_window_scrollTop ); 6502 6503 6504 // call lazy tdCustomEvents scroll 6505 tdCustomEvents._lazy_callback_scroll_500(); 6506 } 6507 6508 //resize event 6509 if ( tdEvents.resize_event_slow_run ) { 6510 tdEvents.resize_event_slow_run = false; 6511 tdAffix.compute_wrapper(); 6512 tdAffix.compute_top(); 6513 tdDetect.runIsPhoneScreen(); 6514 6515 6516 // call lazy tdCustomEvents resize 6517 tdCustomEvents._lazy_callback_resize_500(); 6518 } 6519 }, 500); 6520 } 6521 }; 6522 6523 tdEvents.init(); 6524})(); 6525 6526/** 6527 * updates the view counter thru ajax 6528 */ 6529 6530/* global jQuery:{} */ 6531/* global td_ajax_url:string */ 6532 6533var tdAjaxCount = {}; 6534 6535(function(){ 6536 6537 'use strict'; 6538 6539 tdAjaxCount = { 6540 6541 //td_get_views_counts_ajax : function( page_type, array_ids ) { 6542 tdGetViewsCountsAjax : function( postType, arrayIds ) { 6543 6544 //what function to call based on postType 6545 var pageTypeAction = 'td_ajax_get_views';//postType = page 6546 if ( 'post' === postType ) { 6547 pageTypeAction = 'td_ajax_update_views'; 6548 } 6549 6550 jQuery.ajax({ 6551 type: 'POST', 6552 url: td_ajax_url, 6553 cache: true, 6554 data: { 6555 action: pageTypeAction, 6556 td_post_ids: arrayIds 6557 }, 6558 success: function( data, textStatus, XMLHttpRequest ) { 6559 var tdAjaxPostCounts = jQuery.parseJSON( data );//get the return dara 6560 6561 //check the return var to be object 6562 if ( tdAjaxPostCounts instanceof Object ) { 6563 //alert('value is Object!'); 6564 6565 //iterate throw the object 6566 jQuery.each( tdAjaxPostCounts, function( idPost, value ) { 6567 //alert(id_post + ": " + value); 6568 6569 //this is the count placeholder in witch we write the post count 6570 var currentPostCount = '.td-nr-views-' + idPost; 6571 6572 jQuery( currentPostCount ).html( value ); 6573 //console.log(current_post_count + ': ' + value); 6574 }); 6575 } 6576 }, 6577 error: function( MLHttpRequest, textStatus, errorThrown ) { 6578 //console.log(errorThrown); 6579 } 6580 }); 6581 } 6582 }; 6583})(); 6584 6585/* 6586 td_video_playlist.js 6587 v1.1 6588 */ 6589 6590 6591/* global jQuery:{} */ 6592/* global YT:{} */ 6593/* global tdDetect:{} */ 6594/* global $f:{} */ 6595 6596/* jshint -W069 */
6597/* jshint -W116 */ 6598 6599var tdYoutubePlayers = {}; 6600var tdVimeoPlayers = {}; 6601 6602// @todo this ready hook function must be moved from here 6603jQuery().ready(function() { 6604 6605 'use strict'; 6606 6607 tdYoutubePlayers.init(); 6608 tdVimeoPlayers.init(); 6609}); 6610 6611 6612 6613(function() { 6614 6615 'use strict'; 6616 6617 6618 // the youtube list players (the init() method should be called before using the list) 6619 tdYoutubePlayers = { 6620 6621 // the part name of the player id (they will be ex 'player_youtube_1', 'player_youtube_1', 'player_youtube_2', ...) 6622 tdPlayerContainer: 'player_youtube', 6623 6624 // the internal list 6625 players: [], 6626 6627 6628 // the initialization of the youtube list players 6629 init: function() { 6630 6631 var jqWrapperPlaylistPlayerYoutube = jQuery( '.td_wrapper_playlist_player_youtube' ); 6632 6633 for ( var i = 0; i < jqWrapperPlaylistPlayerYoutube.length; i++ ) { 6634 6635 var jqPlayerWrapper = jQuery( jqWrapperPlaylistPlayerYoutube[ i ] ), 6636 youtubePlayer = tdYoutubePlayers.addPlayer( jqPlayerWrapper), 6637 playerId = youtubePlayer.tdPlayerContainer; 6638 6639 jqPlayerWrapper.parent().find( '.td_youtube_control').data( 'player-id', playerId ); 6640 6641 var videoYoutubeElements = jqPlayerWrapper.parent().find( '.td_click_video_youtube'); 6642 for ( var j = 0; j < videoYoutubeElements.length; j++ ) { 6643 jQuery( videoYoutubeElements[ j ] ).data( 'player-id', playerId ); 6644 6645 if ( j + 1 < videoYoutubeElements.length) { 6646 jQuery( videoYoutubeElements[ j ] ).data( 'next-video-id', jQuery(videoYoutubeElements[ j + 1 ] ).data( 'video-id' ) ); 6647 } else { 6648 jQuery( videoYoutubeElements[ j ] ).data( 'next-video-id', jQuery(videoYoutubeElements[0]).data( 'video-id' ) ); 6649 } 6650 } 6651 6652 6653 if ( '1' == jqPlayerWrapper.data( 'autoplay' ) ) { 6654 youtubePlayer.autoplay = 1; 6655 } 6656 6657 var firstVideo = jqPlayerWrapper.data( 'first-video' ); 6658 6659 if ( '' !== firstVideo ) { 6660 youtubePlayer.tdPlaylistIdYoutubeVideoRunning = firstVideo; 6661 youtubePlayer.playVideo( firstVideo ); 6662 } 6663 } 6664 6665 //click on a youtube movie 6666 jQuery( '.td_click_video_youtube' ).click(function(){ 6667 6668 var videoId = jQuery( this ).data( 'video-id' ), 6669 playerId = jQuery( this ).data( 'player-id' ); 6670 6671 if ( undefined !== playerId && '' !== playerId && undefined !== videoId && '' !== videoId ) { 6672 tdYoutubePlayers.operatePlayer( playerId, 'play', videoId ); 6673 } 6674 }); 6675 6676 6677 6678 //click on youtube play control 6679 jQuery( '.td_youtube_control' ).click(function(){ 6680 6681 var playerId = jQuery( this ).data( 'player-id' ); 6682 6683 if ( undefined !== playerId && '' !== playerId ) { 6684 if ( jQuery( this ).hasClass( 'td-sp-video-play' ) ){ 6685 tdYoutubePlayers.operatePlayer( playerId, 'play' ); 6686 } else { 6687 tdYoutubePlayers.operatePlayer( playerId, 'pause' ); 6688 } 6689 } 6690 }); 6691 }, 6692 6693 6694 addPlayer: function( jqPlayerWrapper ) { 6695 6696 var containerId = tdYoutubePlayers.tdPlayerContainer + '_' + tdYoutubePlayers.players.length, 6697 tdPlayer = tdYoutubePlayers.createPlayer( containerId, jqPlayerWrapper ); 6698 6699 tdYoutubePlayers.players.push( tdPlayer ); 6700 6701 return tdPlayer; 6702 }, 6703 6704 operatePlayer: function( playerId, option, videoId ) { 6705 for ( var i = 0; i < tdYoutubePlayers.players.length; i++ ) { 6706 if (tdYoutubePlayers.players[i].tdPlayerContainer == playerId ) { 6707 6708 var youtubePlayer = tdYoutubePlayers.players[ i ]; 6709 6710 // This status is necessary just for mobile 6711 youtubePlayer.playStatus();
6712 6713 if ( 'play' === option ) { 6714 6715 youtubePlayer.autoplay = 1; 6716 6717 if ( undefined === videoId ) { 6718 youtubePlayer.playerPlay(); 6719 } else { 6720 youtubePlayer.playVideo(videoId); 6721 } 6722 } else if ( 'pause' == option ) { 6723 tdYoutubePlayers.players[i].playerPause(); 6724 } 6725 break; 6726 } 6727 } 6728 }, 6729 6730 6731 // create and return the youtube player object 6732 createPlayer: function( containerId, jqPlayerWrapper ) { 6733 6734 var youtubePlayer = { 6735 6736 tdYtPlayer: '', 6737 6738 tdPlayerContainer: containerId, 6739 6740 autoplay: 0, 6741 6742 tdPlaylistIdYoutubeVideoRunning: '', 6743 6744 jqTDWrapperVideoPlaylist: jqPlayerWrapper.closest( '.td_wrapper_video_playlist' ), 6745 6746 jqPlayerWrapper: jqPlayerWrapper, 6747 6748 jqControlPlayer: '', 6749 6750 _videoId: '', 6751 6752 playVideo: function( videoId ) { 6753 6754 youtubePlayer._videoId = videoId; 6755 6756 if ( 'undefined' === typeof( YT ) || 'undefined' === typeof( YT.Player ) ) { 6757 6758 window.onYouTubePlayerAPIReady = function () { 6759 6760 for ( var i = 0; i < tdYoutubePlayers.players.length; i++ ) { 6761 tdYoutubePlayers.players[ i ].loadPlayer( ); 6762 } 6763 }; 6764 6765 jQuery.getScript('https://www.youtube.com/player_api').done(function( script, textStatus ) { 6766 //alert(textStatus); 6767 }); 6768 } else { 6769 youtubePlayer.loadPlayer( videoId ); 6770 } 6771 }, 6772 6773 6774 loadPlayer: function (videoId) { 6775 6776 var videoIdToPlay = youtubePlayer._videoId; 6777 6778 if ( undefined !== videoId ) { 6779 videoIdToPlay = videoId; 6780 } 6781 6782 if ( undefined === videoIdToPlay ) { 6783 return; 6784 } 6785 6786 //container is here in case we need to add multiple players on page 6787 youtubePlayer.tdPlaylistIdYoutubeVideoRunning = videoIdToPlay; 6788 6789 var current_video_name = window.td_youtube_list_ids['td_' + youtubePlayer.tdPlaylistIdYoutubeVideoRunning]['title'], 6790 current_video_time = window.td_youtube_list_ids['td_' + youtubePlayer.tdPlaylistIdYoutubeVideoRunning]['time']; 6791 6792 //remove focus from all videos from playlist 6793 youtubePlayer.jqTDWrapperVideoPlaylist.find( '.td_click_video_youtube' ).removeClass( 'td_video_currently_playing' ); 6794 6795 //add focus class on current playing video 6796 youtubePlayer.jqTDWrapperVideoPlaylist.find( '.td_' + videoIdToPlay ).addClass( 'td_video_currently_playing' ); 6797 6798 //ading the current video playing title and time to the control area 6799 youtubePlayer.jqTDWrapperVideoPlaylist.find( '.td_current_video_play_title_youtube' ).html( current_video_name ); 6800 youtubePlayer.jqTDWrapperVideoPlaylist.find( '.td_current_video_play_time_youtube' ).html( current_video_time ); 6801 6802 youtubePlayer.jqPlayerWrapper.html('<div id=' + youtubePlayer.tdPlayerContainer + '></div>'); 6803 6804 youtubePlayer.jqControlPlayer = youtubePlayer.jqTDWrapperVideoPlaylist.find( '.td_youtube_control' ); 6805 6806 youtubePlayer.tdYtPlayer = new YT.Player(youtubePlayer.tdPlayerContainer, {//window.myPlayer = new YT.Player(container, { 6807 playerVars: { 6808 //modestbranding: 1, 6809 //rel: 0, 6810 //showinfo: 0, 6811 autoplay: youtubePlayer.autoplay 6812 }, 6813 height: '100%', 6814 width: '100%', 6815 videoId: videoIdToPlay, 6816 events: { 6817 'onStateChange': youtubePlayer.onPlayerStateChange 6818 } 6819 }); 6820 }, 6821 6822 6823 onPlayerStateChange: function (event) { 6824 if (event.data === YT.PlayerState.PLAYING) { 6825 6826 //add pause to playlist control 6827 youtubePlayer.pauseStatus();
6828 6829 } else if (event.data === YT.PlayerState.ENDED) { 6830 6831 youtubePlayer.playStatus(); 6832 6833 //if a video has ended then make auto play = 1; This is the case when the user set autoplay = 0 but start watching videos 6834 youtubePlayer.autoplay = 1; 6835 6836 6837 //get the next video 6838 var nextVideoId = '', 6839 tdVideoCurrentlyPlaying = youtubePlayer.jqTDWrapperVideoPlaylist.find( '.td_video_currently_playing' ); 6840 6841 if ( tdVideoCurrentlyPlaying.length ) { 6842 var nextSibling = jQuery( tdVideoCurrentlyPlaying ).next( '.td_click_video_youtube' ); 6843 if ( nextSibling.length ) { 6844 nextVideoId = jQuery( nextSibling ).data( 'video-id' ); 6845 } 6846 //else { 6847 // var firstSibling = jQuery(tdVideoCurrentlyPlaying).siblings( '.td_click_video_youtube:first' ); 6848 // if ( firstSibling.length ) { 6849 // nextVideoId = jQuery( firstSibling ).data( 'video-id' ); 6850 // } 6851 //} 6852 } 6853 6854 if ('' !== nextVideoId) { 6855 youtubePlayer.playVideo(nextVideoId); 6856 } 6857 6858 } else if (YT.PlayerState.PAUSED) { 6859 //add play to playlist control 6860 youtubePlayer.playStatus(); 6861 } 6862 }, 6863 6864 //tdPlaylistYoutubeStopVideo: function () { 6865 // youtubePlayer.tdYtPlayer.stopVideo(); 6866 //}, 6867 6868 playerPlay: function () { 6869 youtubePlayer.tdYtPlayer.playVideo(); 6870 }, 6871 6872 playerPause: function () { 6873 youtubePlayer.tdYtPlayer.pauseVideo(); 6874 }, 6875 6876 playStatus: function() { 6877 youtubePlayer.jqControlPlayer.removeClass( 'td-sp-video-pause' ).addClass( 'td-sp-video-play' ); 6878 }, 6879 6880 pauseStatus: function() { 6881 youtubePlayer.jqControlPlayer.removeClass( 'td-sp-video-play' ).addClass( 'td-sp-video-pause' ); 6882 } 6883 }; 6884 6885 return youtubePlayer; 6886 } 6887 }; 6888 6889 6890 6891 6892 // the vimeo list players (to use it, the init() method should be called) 6893 // !Important. Usually, because of froogaloop implementation, there couldn't be multiple vimeo players running all at once on page. 6894 tdVimeoPlayers = { 6895 6896 // the part name of the player id (they will be ex 'player_vimeo_0', 'player_vimeo_1', 'player_vimeo_2', ...) 6897 tdPlayerContainer: 'player_vimeo', 6898 6899 // the internal list 6900 players: [], 6901 6902 // Set to true at the first autoplayed player created 6903 // It's used to avoid the autoplay setting of the next players (multiple players can't have autoplay = 1 ) 6904 existingAutoplay: false, 6905 6906 6907 // init the vimeo list players 6908 init: function() { 6909 var jqTDWrapperPlaylistPlayerVimeo = jQuery( '.td_wrapper_playlist_player_vimeo' ); 6910 6911 for ( var i = 0; i < jqTDWrapperPlaylistPlayerVimeo.length; i++ ) { 6912 var vimeoPlayer = tdVimeoPlayers.addPlayer( jQuery(jqTDWrapperPlaylistPlayerVimeo[i]) ); 6913 if ( 0 !== vimeoPlayer.autoplay ) { 6914 tdVimeoPlayers.existingAutoplay = true; 6915 } 6916 } 6917 6918 6919 //click on a vimeo 6920 jQuery( '.td_click_video_vimeo' ).click(function(){ 6921 6922 var videoId = jQuery( this ).data( 'video-id' ), 6923 playerId = jQuery( this ).data( 'player-id' ); 6924 6925 if ( undefined !== playerId && '' !== playerId && undefined !== videoId && '' !== videoId ) { 6926 tdVimeoPlayers.operatePlayer( playerId, 'play', videoId ); 6927 } 6928 }); 6929 6930 6931 //click on vimeo play control 6932 jQuery( '.td_vimeo_control' ).click(function(){ 6933 6934 var playerId = jQuery( this ).data( 'player-id' ); 6935 6936 if ( undefined !== playerId && '' !== playerId ) { 6937 if ( jQuery( this ).hasClass( 'td-sp-video-play' ) ){ 6938 tdVimeoPlayers.operatePlayer( playerId, 'play' ); 6939 } else { 6940 tdVimeoPlayers.operatePlayer( playerId, 'pause' ); 6941 } 6942 } 6943 }); 6944 }, 6945 6946 6947 // create and add player to the vimeo list players 6948 addPlayer: function( jqPlayerWrapper ) { 6949 var playerId = tdVimeoPlayers.tdPlayerContainer + '_' + tdVimeoPlayers.players.length, 6950 vimeoPlayer = tdVimeoPlayers.createPlayer( playerId, jqPlayerWrapper ); 6951 6952 jqPlayerWrapper.parent().find( '.td_vimeo_control').data( 'player-id', playerId ); 6953 6954 var vimeoVideoElements = jqPlayerWrapper.parent().find( '.td_click_video_vimeo'); 6955 for ( var j = 0; j < vimeoVideoElements.length; j++ ) { 6956 jQuery( vimeoVideoElements[ j ] ).data( 'player-id', playerId ); 6957 6958 if ( j + 1 < vimeoVideoElements.length ) { 6959 jQuery( vimeoVideoElements[ j ] ).data( 'next-video-id', jQuery( vimeoVideoElements[ j + 1 ] ).data( 'video-id' ) ); 6960 } else { 6961 jQuery( vimeoVideoElements[ j ] ).data( 'next-video-id', jQuery( vimeoVideoElements[ 0 ] ).data( 'video-id' ) ); 6962 } 6963 } 6964 6965 if ( '1' == jqPlayerWrapper.data( 'autoplay' ) ) { 6966 vimeoPlayer.autoplay = 1; 6967 } 6968 6969 var firstVideo = jqPlayerWrapper.data( 'first-video' ); 6970 6971 if ( undefined !== firstVideo && '' !== firstVideo ) { 6972 vimeoPlayer.createPlayer( firstVideo ); 6973 } 6974 6975 tdVimeoPlayers.players.push( vimeoPlayer ); 6976 6977 return vimeoPlayer; 6978 }, 6979 6980 6981 // play or pause a video or the current (first) video 6982 operatePlayer: function( playerId, option, videoId ) { 6983 for ( var i = 0; i < tdVimeoPlayers.players.length; i++ ) { 6984 6985 if ( tdVimeoPlayers.players[ i ].playerId == playerId ) { 6986 6987 var vimeoPlayer = tdVimeoPlayers.players[ i ]; 6988 6989 if ( 'play' === option ) { 6990 6991 vimeoPlayer.autoplay = 1; 6992 6993 if ( undefined !== videoId ) { 6994 6995 // the existing autoplay is reset to allow auto
6995play when we have videoId (a video from the playlist was clicked) 6996 tdVimeoPlayers.existingAutoplay = false; 6997 6998 vimeoPlayer.createPlayer( videoId ); 6999 } else { 7000 vimeoPlayer.playerPlay(); 7001 } 7002 7003 } else if ( 'pause' === option ) { 7004 vimeoPlayer.playerPause(); 7005 } 7006 7007 break; 7008 } 7009 } 7010 }, 7011 7012 7013 // create and return the vimeo player object 7014 createPlayer: function( playerId, jqPlayerWrapper ) { 7015 7016 var vimeoPlayer = { 7017 7018 playerId: playerId, 7019 7020 // the jq td playlist wrapper ( the player and the playlist) 7021 jqTDWrapperVideoPlaylist: jqPlayerWrapper.closest( '.td_wrapper_video_playlist' ), 7022 7023 // the jq player wrapper 7024 jqPlayerWrapper: jqPlayerWrapper, 7025 7026 currentVideoPlaying : '', // not used for the moment 7027 7028 player: '',//a copy of the vimeo player : needed when playing or pausing the vimeo pleyer from the playlist control 7029 7030 // main control button of the player 7031 jqControlPlayer: '', 7032 7033 autoplay: 0,//autoplay 7034 7035 createPlayer: function ( videoId ) { 7036 if ( '' !== videoId ) { 7037 7038 this.currentVideoPlaying = videoId; 7039 7040 var autoplay = '', 7041 current_video_name = window.td_vimeo_list_ids['td_' + videoId]['title'], 7042 current_video_time = window.td_vimeo_list_ids['td_' + videoId]['time']; 7043 7044 //remove focus from all videos from playlist 7045 vimeoPlayer.jqTDWrapperVideoPlaylist.find( '.td_click_video_vimeo' ).removeClass( 'td_video_currently_playing' ); 7046 7047 //add focus class on current playing video 7048 vimeoPlayer.jqTDWrapperVideoPlaylist.find( '.td_' + videoId ).addClass( 'td_video_currently_playing' ); 7049 7050 //ading the current video playing title and time to the control area 7051 vimeoPlayer.jqTDWrapperVideoPlaylist.find( '.td_current_video_play_title_vimeo' ).html( current_video_name ); 7052 vimeoPlayer.jqTDWrapperVideoPlaylist.find( '.td_current_video_play_time_vimeo' ).html( current_video_time ); 7053 7054 vimeoPlayer.jqControlPlayer = vimeoPlayer.jqTDWrapperVideoPlaylist.find( '.td_vimeo_control' ); 7055 7056 //check autoplay 7057 if ( !tdVimeoPlayers.existingAutoplay && 0 !== vimeoPlayer.autoplay ) { 7058 autoplay = '&autoplay=1'; 7059 7060 if ( tdDetect.isMobileDevice ) { 7061 vimeoPlayer.playStatus(); 7062 } else { 7063 vimeoPlayer.pauseStatus(); 7064 } 7065 } else { 7066 vimeoPlayer.playStatus(); 7067 } 7068 vimeoPlayer.jqPlayerWrapper.html( '<iframe id="' + vimeoPlayer.playerId + '" src="https://player.vimeo.com/video/' + videoId + '?api=1&player_id=' + vimeoPlayer.playerId + '' + autoplay + '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>' ); 7069 vimeoPlayer.createVimeoObjectPlayer( jQuery ); 7070 } 7071 }, 7072 7073 createVimeoObjectPlayer : function( $ ) { 7074 var player = '', 7075 iframe = $( '#' + vimeoPlayer.playerId ); 7076 7077 if ( iframe.length ) { 7078 player = $f( iframe[0] ); 7079 7080 //a copy of the vimeo player : needed when playing or pausing the vimeo pleyer from the playlist control 7081 vimeoPlayer.player = player; 7082 7083 // When the player is ready, add listeners for pause, finish, and playProgress 7084 player.addEvent( 'ready', function() { 7085 7086 player.addEvent( 'play', function( data ) { 7087 vimeoPlayer.pauseStatus();
7088 vimeoPlayer.autoplay = 1; 7089 }); 7090 7091 player.addEvent( 'pause', function( data ) { 7092 vimeoPlayer.playStatus(); 7093 }); 7094 7095 player.addEvent( 'finish', function( data ) { 7096 7097 var nextVideoId = '', 7098 tdVideoCurrentlyPlaying = vimeoPlayer.jqTDWrapperVideoPlaylist.find( '.td_video_currently_playing' ); 7099 7100 if ( tdVideoCurrentlyPlaying.length ) { 7101 var nextSibling = jQuery( tdVideoCurrentlyPlaying ).next( '.td_click_video_vimeo' ); 7102 if ( nextSibling.length ) { 7103 nextVideoId = jQuery( nextSibling ).data( 'video-id' ); 7104 } 7105 } 7106 7107 if ( '' !== nextVideoId ) { 7108 vimeoPlayer.createPlayer( nextVideoId ); 7109 7110 if ( tdDetect.isMobileDevice ) { 7111 vimeoPlayer.playStatus(); 7112 } else { 7113 vimeoPlayer.pauseStatus(); 7114 } 7115 } else { 7116 vimeoPlayer.playStatus(); 7117 } 7118 }); 7119 }); 7120 } 7121 }, 7122 7123 // play the current video 7124 playerPlay: function () { 7125 vimeoPlayer.autoplay = 1; 7126 vimeoPlayer.player.api( 'play' ); 7127 }, 7128 7129 // pause the current video 7130 playerPause: function () { 7131 vimeoPlayer.player.api( 'pause' ); 7132 }, 7133 7134 // change status to 'play' 7135 playStatus: function() { 7136 vimeoPlayer.jqControlPlayer.removeClass( 'td-sp-video-pause' ).addClass( 'td-sp-video-play' ); 7137 }, 7138 7139 // change status to 'pause' 7140 pauseStatus: function() { 7141 vimeoPlayer.jqControlPlayer.removeClass( 'td-sp-video-play' ).addClass( 'td-sp-video-pause' ); 7142 } 7143 }; 7144 7145 return vimeoPlayer; 7146 } 7147 }; 7148 7149})(); 7150/*
7151 td_slide.js 7152 */ 7153 7154"use strict"; 7155 7156//call function to resize the smartlist on ready (for safary) 7157jQuery(window).load(function() { 7158 td_resize_smartlist_sliders_and_update(); 7159}); 7160 7161//call function to resize the smartlist on ready 7162jQuery().ready(function() { 7163 td_resize_smartlist_sliders_and_update(); 7164}); 7165 7166 7167 7168//function to resize the height of the smartlist slide 7169function td_resize_smartlist_slides(args) { 7170 var slide_displayd = args.currentSlideNumber; 7171 7172 7173 //console.log(args.sliderObject[0]); 7174 //console.log(args.data.obj[0]); 7175 7176 var current_slider = jQuery(args.data.obj[0]).attr("id"); 7177 7178 if(!tdDetect.isIe8) { 7179 jQuery("#" + current_slider).css("overflow", "none"); 7180 jQuery("#" + current_slider + " .td-item").css("overflow", "visible"); 7181 } 7182 7183 var setHeight = 0; 7184 setHeight = jQuery("#" + current_slider + "_item_" + slide_displayd).outerHeight(true); 7185 7186 7187 jQuery("#" + current_slider + ", #" + current_slider + " .td-slider").css({ 7188 height: setHeight 7189 }); 7190} 7191 7192 7193 7194 7195 7196//function to resize and update the height of the smartlist slide 7197function td_resize_smartlist_sliders_and_update() { 7198 jQuery(document).find('.td-smart-list-slider').each(function() { 7199 var current_slider = jQuery(this).attr("id"); 7200 7201 if(!tdDetect.isIe8) { 7202 jQuery("#" + current_slider).css("overflow", "none"); 7203 jQuery("#" + current_slider + " .td-item").css("overflow", "visible"); 7204 } 7205 7206 var setHeight = 0; 7207 setHeight = jQuery("#" + current_slider + "_item_" + td_history.get_current_page("slide")).outerHeight(true); 7208 7209 jQuery("#" + current_slider + ", #" + current_slider + " .td-slider").css({ 7210 height: setHeight 7211 }); 7212 7213 if(tdDetect.isAndroid) { 7214 setTimeout(function () { 7215 jQuery("#" + current_slider).iosSlider("update"); 7216 }, 2000); 7217 } 7218 }); 7219} 7220 7221 7222//function to resize the height of the normal slide 7223function td_resize_normal_slide(args) { 7224 var slide_displayd = 0;//args.currentSlideNumber; 7225 7226 var current_slider = jQuery(args.data.obj[0]).attr("id"); 7227 7228 //get window width 7229 var window_wight = td_get_document_width(); 7230 7231 if (!tdDetect.isIe8) { 7232 jQuery("#" + current_slider).css("overflow", "none"); 7233 jQuery("#" + current_slider + " .td-item").css("overflow", "visible"); 7234 } 7235 7236 var setHeight = 0; 7237 var slide_outer_width = jQuery("#" + current_slider + "_item_" + slide_displayd).outerWidth(true); 7238 7239 //only for android, width of the screen to start changing the height of the slide 7240 var max_wight_resize = 780; 7241 if(tdDetect.isAndroid) { 7242 max_wight_resize = 1000; 7243 } 7244 7245 if (window_wight < max_wight_resize && !tdDetect.isIpad) {//problem because we cannot get an accurate page width 7246 if(slide_outer_width > 300) { 7247 setHeight = slide_outer_width * 0.5; 7248 } else { 7249 setHeight = slide_outer_width; 7250 } 7251 7252 //console.log(window_wight); 7253 jQuery("#" + current_slider + ", #" + current_slider + " .td-slider, #" + current_slider + " .td-slider .td-module-thumb").css({ 7254 height: setHeight 7255 }); 7256 } 7257 7258} 7259 7260 7261 7262//function to resize and update the height of the slide for normal sliders 7263function td_resize_normal_slide_and_update(args) { 7264 7265 7266 //console.log('resize 2'); 7267 var slide_displayd = 0;//args.currentSlideNumber; 7268 7269 var current_slider = jQuery(args.data.obj[0]).attr("id"); 7270 7271 //get window width 7272 var window_wight = td_get_document_width(); 7273 7274 if(!tdDetect.isIe8) { 7275 jQuery("#" + current_slider).css("overflow", "none"); 7276 jQuery("#" + current_slider + " .td-item").css("overflow", "visible"); 7277 } 7278 7279 var setHeight = 0; 7280 var slide_outer_width = jQuery("#" + current_slider + "_item_" + slide_displayd).outerWidth(true); 7281 7282 //only for android, width of the screen to start changing the height of the slide 7283 var max_wight_resize = 780; 7284 if(tdDetect.isAndroid) { 7285 max_wight_resize = 1000; 7286 } 7287 7288 if (window_wight < max_wight_resize && !tdDetect.isIpad) {//problem because we cannot get an accurate page width 7289 if(slide_outer_width > 300) { 7290 setHeight = slide_outer_width * 0.5; 7291 } else { 7292 setHeight = slide_outer_width; 7293 } 7294 7295 //console.log(window_wight); 7296 jQuery("#" + current_slider + ", #" + current_slider + " .td-slider, #" + current_slider + " .td-slider .td-module-thumb").css({ 7297 height: setHeight 7298 }); 7299 7300 setTimeout(function () { 7301 jQuery("#" + current_slider).iosSlider("update"); 7302 7303 7304 7305 }, 2000); 7306 7307 } 7308} 7309/** 7310 * Created by tagdiv on 16.02.2015. 7311 */ 7312 7313 7314/* global tdViewport:{} */ 7315/* global jQuery:{} */ 7316 7317var tdPullDown = {}; 7318 7319( function(){ 7320 7321 'use strict'; 7322 7323 tdPullDown = { 7324 7325 7326 // - keeps internally the current interval index 7327 // - it's set at init() 7328 _view_port_interval_index : tdViewport.INTERVAL_INITIAL_INDEX, 7329 7330 7331 7332 // this flag mark that the tdPullDown.items must be reinitialized at the changing view port size 7333 reinitialize_items_at_change_view_port: false, 7334 7335 7336 7337 // - the list of items 7338 items: [], 7339 7340 7341 7342 // - the item represents a pair of lists (a horizontal and a vertical one) 7343 // - to be initialized, every property with 'IT MUST BE SPECIFIED' is mandatory 7344 item: function item() { 7345 7346 7347 // OPTIONAL - here we store the block Unique ID. This enables us to delete the item via this id @see tdPullDown.deleteItem 7348 this.blockUid = ''; 7349 7350 // - the jquery object of the horizontal list. 7351 // IT MUST BE SPECIFIED. 7352 this.horizontal_jquery_obj = ''; 7353 7354 // - the jquery object of the vertical list. 7355 // IT MUST BE SPECIFIED 7356 this.vertical_jquery_obj = ''; 7357 7358 // - the jquery container object. 7359 // - it contains the horizontal and the vertical jquery objects 7360 // IT MUST BE SPECIFIED. 7361 this.container_jquery_obj = ''; 7362 7363 // - the css class of an horizontal element. 7364 // IT MUST BE SPECIFIED 7365 this.horizontal_element_css_class = ''; 7366 7367 7368 7369 // the minimum no. of elements to be shown by the horizontal list 7370 // - IT CAN BE SPECIFIED 7371 this.minimum_elements = 2; 7372 7373 7374 7375 // - the array of jquery elements whose widths must be excluded from the width of the container object 7376 // IT CAN BE SPECIFIED 7377 this.excluded_jquery_elements = []; 7378 7379 // - the extra space of the horizontal jquery object occupied by the excluded jquery elements 7380 // - it's not initialized with 0 because widths of the elements can not be integer values 7381 // - now, it's set to 1px 7382 this._horizontal_extra_space = 1; 7383 7384 7385 7386 // - the array of objects from the horizontal list 7387 this._horizontal_elements = []; 7388 7389 // - the array of objects from the vertical list 7390 this._vertical_elements = []; 7391 7392 7393 7394 // - the jquery object of the first ul container in the vertical list 7395 // - it is calculated as the first 'ul' of the vertical jquery object 7396 this._vertical_ul_jquery_obj = ''; 7397 7398 7399 7400 // - the outer width of the vertical top header (ex.'More') 7401 // - it's used to calculate if the last vertical element has enough space in the horizontal list, 7402 // without considering the vertical top header width 7403 this._vertical_jquery_obj_outer_width = 0; 7404 7405 7406 7407 // flag used to mark the initialization item 7408 this._is_initialized = false; 7409 }, 7410 7411 7412 7413 7414 /** 7415 * - function used to init the tdPullDown object 7416 * - it must be called before any item adding 7417 * - it initializes the _view_port_interval_index 7418 * - the items list is initialized 7419 */ 7420 init: function() { 7421 7422 tdPullDown._view_port_interval_index = tdViewport.getCurrentIntervalIndex(); 7423 7424 tdPullDown.items = []; 7425 }, 7426 7427 7428 7429 7430 /** 7431 * - add an item to the item list and initialize it 7432 * 7433 * @param item The item to be added and initialized 7434 */ 7435 add_item: function( item ) { 7436 7437 // check to see if the item is ok 7438 if (item.vertical_jquery_obj.length !== 1) { 7439 throw 'item.vertical_jquery_obj is more or less than one!'; 7440 } 7441 if (item.horizontal_jquery_obj.length !== 1) { 7442 throw 'item.horizontal_jquery_obj is more or less than one!'; 7443 } 7444 if (item.container_jquery_obj.length !== 1) { 7445 throw 'item.container_jquery_obj is more or less than one!'; 7446 } 7447 if (item.horizontal_element_css_class === '') { 7448 throw 'item.horizontal_element_css_class is empty'; 7449 } 7450 7451 // the item is added in the item list 7452 tdPullDown.items.push( item ); 7453 7454 // the item is initialized only once when it is added 7455 tdPullDown._initialize_item( item ); 7456 7457 // the item is ready to be computed 7458 tdPullDown._compute_item( item ); 7459 }, 7460 7461 7462 /** 7463 * Deletes an item base on blockUid. Note that blockUid is optional (this library is also used outside of blocks)! 7464 * Make sure that you add blockUid to items that you expect to be deleted 7465 * @param blockUid 7466 */ 7467 deleteItem: function(blockUid) { 7468 for (var cnt = 0; cnt < tdPullDown.items.length; cnt++) { 7469 if (tdPullDown.items[cnt].blockUid === blockUid) { 7470 tdPullDown.items.splice(cnt, 1); // remove the item from the "array" 7471 return true; 7472 } 7473 } 7474 return false; 7475 }, 7476 7477 7478 7479 7480 /** 7481 * - internal utility function used to initialize an item 7482 * - an item must be initialized only once 7483 * - every element having a specified css class is added in the horizontal list 7484 * 7485 * @param item {tdPullDown.item} The item to be initialized 7486 * @private 7487 */ 7488 _initialize_item: function( item ) { 7489 7490 // an item must be initialized only once 7491 if ( true === item._is_initialized ) { 7492 return; 7493 } 7494 7495 7496 //// the mandatory item properties are verified 7497 // @20/4/2016 - i've moved all the checks to add_item -ra 7498 //if ( ( '' === item.horizontal_jquery_obj ) || 7499 // ( '' === item.vertical_jquery_obj ) || 7500 // ( '' === item.container_jquery_obj ) || 7501 // ( '' === item.horizontal_element_css_class ) ) { 7502 // 7503 // tdPullDown.log( 'Item can\' be initialized. It doesn\'t have all the mandatory properties' ); 7504 // return; 7505 //} 7506 7507 7508 // the jquery object of the first ul container in the vertical list is initialized 7509 item._vertical_ul_jquery_obj = item.vertical_jquery_obj.find( 'ul:first' ); 7510 7511 if ( 0 === item._vertical_ul_jquery_obj.length ) { 7512 7513 tdPullDown.log( 'Item can\' be initialized. The vertical list doesn\'t have an \'ul\' container' ); 7514 return; 7515 } 7516 7517 7518 // the elements of the horizontal jquery object, having a specified css class 7519 var elements = item.horizontal_jquery_obj.find( '.' + item.horizontal_element_css_class ); 7520 7521 var local_jquery_element = null; 7522 var local_object = null; 7523 7524 // for each element an object is added in the horizontal list 7525 elements.each( function ( index, element ) { 7526 7527 local_jquery_element = jQuery( element ); 7528 7529 // @todo here we need a css class 7530 local_jquery_element.css( '-webkit-transition', 'opacity 0.2s' ); 7531 local_jquery_element.css( '-moz-transition', 'opacity 0.2s' ); 7532 local_jquery_element.css( '-o-transition', 'opacity 0.2s' ); 7533 local_jquery_element.css( 'transition', 'opacity 0.2s' ); 7534 7535 local_jquery_element.css( 'opacity', '1' ); 7536 7537 7538 // the cached object used to keep the jquery object and its outerWidth 7539 local_object = { 7540 7541 // the jquery element 7542 jquery_object: local_jquery_element, 7543 7544 // the outer width including border 7545 calculated_width: local_jquery_element.outerWidth( true ) 7546 }; 7547 7548 // the horizontal list is populated 7549 item._horizontal_elements.push( local_object ); 7550 }); 7551 7552 7553 // the outer width of the vertical top header (ex.'More') is initialized 7554 item._vertical_jquery_obj_outer_width = item.vertical_jquery_obj.outerWidth( true ); 7555 7556 7557 // by default, the vertical jquery object is hidden, being shown when at least one element is moved in it 7558 item.vertical_jquery_obj.css( 'display', 'none' ); 7559 7560 7561 7562 // the the extra space occupied by the horizontal jquery object is calculated 7563 7564 var horizontal_jquery_obj_padding_left = item.horizontal_jquery_obj.css( 'padding-left' ); 7565 if ( ( undefined !== horizontal_jquery_obj_padding_left ) && ( '' !== horizontal_jquery_obj_padding_left ) ) { 7566 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_padding_left.replace( 'px', '' ) ); 7567 } 7568 7569 var horizontal_jquery_obj_padding_right = item.horizontal_jquery_obj.css( 'padding-right' ); 7570 if ( ( undefined !== horizontal_jquery_obj_padding_right ) && ( '' !== horizontal_jquery_obj_padding_right ) ) { 7571 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_padding_right.replace( 'px', '' ) ); 7572 } 7573 7574 7575 var horizontal_jquery_obj_margin_left = item.horizontal_jquery_obj.css( 'margin-left' ); 7576 if ( ( undefined !== horizontal_jquery_obj_margin_left ) && ( '' !== horizontal_jquery_obj_margin_left ) ) { 7577 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_margin_left.replace( 'px', '' ) ); 7578 } 7579 7580 var horizontal_jquery_obj_margin_right = item.horizontal_jquery_obj.css( 'margin-right' ); 7581 if ( ( undefined !== horizontal_jquery_obj_margin_right ) && ( '' !== horizontal_jquery_obj_margin_right ) ) { 7582 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_margin_right.replace( 'px', '' ) ); 7583 } 7584 7585 7586 var horizontal_jquery_obj_border_left = item.horizontal_jquery_obj.css( 'border-left' ); 7587 if ( ( undefined !== horizontal_jquery_obj_border_left ) && ( '' !== horizontal_jquery_obj_border_left ) ) { 7588 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_border_left.replace( 'px', '' ) ); 7589 } 7590 7591 var horizontal_jquery_obj_border_right = item.horizontal_jquery_obj.css( 'border-right' ); 7592 if ( ( undefined !== horizontal_jquery_obj_border_right ) && ( '' !== horizontal_jquery_obj_border_right ) ) { 7593 item._horizontal_extra_space += parseInt( horizontal_jquery_obj_border_right.replace( 'px', '' ) ); 7594 } 7595 7596 7597 // the item is marked as initialized, being ready to be computed 7598 item._is_initialized = true; 7599 }, 7600 7601 7602 7603 7604 /** 7605 * - internal utility function used to summarize width of the horizontal elements 7606 * 7607 * @param item {tdPullDown.item} The item whose horizontal list is processed 7608 * @returns {number} 7609 * @private 7610 */ 7611 _get_horizontal_elements_width: function( item ) { 7612 7613 var sum_width = 0; 7614 7615 for ( var i = item._horizontal_elements.length - 1; i >= 0; i-- ) { 7616 sum_width +
7616= item._horizontal_elements[ i ].calculated_width; 7617 } 7618 return sum_width; 7619 }, 7620 7621 7622 7623 7624 /** 7625 * - internal utility function used to reinitialize all items at the view resolution changing 7626 */ 7627 _reinitialize_all_items: function() { 7628 7629 for ( var i = tdPullDown.items.length - 1; i >= 0; i-- ) { 7630 tdPullDown._reinitialize_item( tdPullDown.items[ i ] ); 7631 } 7632 }, 7633 7634 7635 7636 7637 /** 7638 * - internal utility function used to reinitialize an item at the view resolution changing 7639 * 7640 * @param item The item being reinitialized 7641 */ 7642 _reinitialize_item: function( item ) { 7643 7644 // a not initialized item can't be reinitialized 7645 if ( false === item._is_initialized ) { 7646 return; 7647 } 7648 7649 // the flag is marked, so any further operation on this item is stopped 7650 item._is_initialized = false; 7651 7652 // the html elements of the vertical list are all moved into the horizontal jquery object 7653 item.horizontal_jquery_obj.html( item.horizontal_jquery_obj.html() + item._vertical_ul_jquery_obj.html() ); 7654 7655 // the html content of the vertical list is cleared 7656 item._vertical_ul_jquery_obj.html( '' ); 7657 7658 // the horizontal list is empty initialized 7659 item._horizontal_elements = []; 7660 7661 // the vertical list is empty initialized 7662 item._vertical_elements = []; 7663 7664 // the extra space is initialized 7665 item._horizontal_extra_space = 1; 7666 7667 // the item is ready to be initialized again 7668 tdPullDown._initialize_item( item ); 7669 }, 7670 7671 7672 7673 7674 /** 7675 * - an internal function used to move elements from the horizontal to the vertical list and vice versa, in according with 7676 * the space for horizontal elements. 7677 * - it's called every time at the viewport resize, when the space for horizontal elements is modified 7678 * 7679 * @param item - the item being computed 7680 * @private 7681 */ 7682 _compute_item: function( item ) { 7683 7684 // the item must be initialized first 7685 if ( false === item._is_initialized ) { 7686 return; 7687 } 7688 7689 7690 7691 // the horizontal header margin is set 0 and the horizontal space is computing without its margin 7692 // @see tdPullDown._prepare_horizontal_header 7693 tdPullDown._prepare_horizontal_header( item, true ); 7694 7695 7696 7697 // - the space where horizontal elements lie 7698 // - it is the container width minus any extra horizontal space 7699 var space_for_horizontal_elements = 0; 7700 7701 // the object container width 7702 var container_jquery_width = item.container_jquery_obj.css( 'width' ); 7703 7704 if ( ( undefined !== container_jquery_width ) && ( '' !== container_jquery_width ) ) { 7705 7706 // the space for new horizontal elements is initialized by the container width 7707 space_for_horizontal_elements = container_jquery_width.replace( 'px', '' ); 7708
7709 // then this space is reduced by the widths of the excluded elements 7710 for ( var i = item.excluded_jquery_elements.length - 1; i >= 0; i-- ) { 7711 space_for_horizontal_elements -= item.excluded_jquery_elements[ i ].contents().outerWidth( true ); 7712 } 7713 } 7714 7715 7716 // if the vertical list is empty, the space for horizontal elements does not contain the width of the vertical head list 7717 if ( item._vertical_elements.length > 0 ) { 7718 space_for_horizontal_elements -= item._vertical_jquery_obj_outer_width; 7719 } 7720 7721 // the space occupied by the horizontal elements is removed 7722 space_for_horizontal_elements -= tdPullDown._get_horizontal_elements_width( item ); 7723 7724 // 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 7725 space_for_horizontal_elements -= item._horizontal_extra_space; 7726 7727 7728 // the current element being moved between the lists 7729 var local_current_element; 7730 7731 7732 // if there's not enough space for the horizontal elements, then the last of them are moved to the vertical list 7733 while ( space_for_horizontal_elements < 0 ) { 7734 7735 // if there's specified a minimum number of horizontal elements, this must be considered 7736 if ( ( item.minimum_elements !== 0 ) && ( item._horizontal_elements.length <= item.minimum_elements ) ) { 7737 7738 // all elements are moved to the vertical list 7739 tdPullDown._make_all_elements_vertical( item ); 7740 7741 7742 7743 7744 // the horizontal header margin is set before return 7745 tdPullDown._prepare_horizontal_header( item ); 7746 7747 7748 7749 // the following checks are not more eligible to do 7750 return; 7751 7752 } else { 7753 7754 // If the vertical list does not contain any elements yet, 7755 // the space for horizontal elements is minimized by the vertical top header width 7756 if ( 0 === item._vertical_elements.length ) { 7757 space_for_horizontal_elements -= item._vertical_jquery_obj_outer_width; 7758 } 7759 7760 local_current_element = tdPullDown._make_element_vertical( item ); 7761 space_for_horizontal_elements += local_current_element.calculated_width; 7762 } 7763 } 7764 7765 7766 7767 // This is the case when there's specified a no. of minimum horizontal elements and the horizontal list is empty. 7768 // If the following conditions are accomplished the horizontal list is refilled with elements from the vertical list 7769 // 7770 // - if there's specified a no. of minimum horizontal elements 7771 // - if there is no horizontal elements 7772 // - if there are vertical elements 7773 // - if there's enough horizontal space for the first vertical element 7774 7775 if ( ( 0 !== item.minimum_elements ) && 7776 ( 0 === item._horizontal_elements.length ) && 7777 ( item._vertical_elements.length > 0 ) && 7778 ( space_for_horizontal_elements >= item._vertical_elements[ 0 ].calculated_width ) ) { 7779 7780 // the necessary space needed for the minimum no. of horizontal elements 7781 var local_necessary_space = 0; 7782 7783 for ( var j = 0; ( j < item.minimum_elements ) && ( j < item._vertical_elements.length ); j++ ) { 7784 local_necessary_space += item._vertical_elements[ j ].calculated_width; 7785 } 7786 7787 // the necessary space really occupied by the minimum no. of horizontal elements 7788 var local_space = 0; 7789 var local_minimum_elements = item.minimum_elements; 7790 7791 while ( ( local_minimum_elements > 0 ) && 7792 ( item._vertical_elements.length > 0 ) && 7793 ( space_for_horizontal_elements >= local_necessary_space ) ) { 7794 7795 local_current_element = tdPullDown._make_element_horizontal( item ); 7796 7797 if ( null !== local_current_element ) { 7798 local_space += local_current_element.calculated_width; 7799 local_minimum_elements--; 7800 } else { 7801 7802 // the horizontal header margin is set before return 7803 tdPullDown._prepare_horizontal_header( item ); 7804 7805 return; 7806 } 7807 7808 } 7809 space_for_horizontal_elements -= local_space; 7810 } 7811 7812 7813 7814 // It's the case when there isn't specified a no. of minimum horizontal elements or it is specified and the 7815 // horizontal list is not empty, and in the same time there's enough horizontal space for more elements 7816 while ( ( ( item._horizontal_elements.length > 0 ) || ( 0 === item._horizontal_elements.length && 0 === item.minimum_elements ) ) && 7817 ( item._vertical_elements.length > 0 ) && 7818 ( space_for_horizontal_elements >= item._vertical_elements[ 0 ].calculated_width ) ) { 7819 7820 local_current_element = tdPullDown._make_element_horizontal( item ); 7821 7822 if ( null !== local_current_element ) { 7823 space_for_horizontal_elements -= local_current_element.calculated_width; 7824 } else { 7825 7826 // the horizontal header margin is set before return 7827 tdPullDown._prepare_horizontal_header( item ); 7828 7829 return; 7830 } 7831 } 7832 7833 7834
7835 // 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') 7836 if ( ( 1 === item._vertical_elements.length ) && 7837 ( space_for_horizontal_elements + item._vertical_jquery_obj_outer_width >= item._vertical_elements[ 0 ].calculated_width ) ) { 7838 tdPullDown._make_element_horizontal( item ); 7839 } 7840 7841 7842 // the horizontal header margin is set before return 7843 tdPullDown._prepare_horizontal_header( item ); 7844 }, 7845 7846 7847 /** 7848 * - add margin to the element with '.block-title' css class, to keep the vertical_jquery_obj not overlapping over it when 7849 * there are no horizontal elements and it is too wide [more strings in name] 7850 * @param item tdPullDown.item 7851 * @param clear_margin boolean True to just clear margin, or false to check the horizontal elements length and then set the margin 7852 * @private 7853 */ 7854 _prepare_horizontal_header: function _prepare_horizontal_header( item, clear_margin ) { 7855 var block_title_jquery_obj = item.horizontal_jquery_obj.parent().siblings( '.block-title:first' ); 7856 7857 if ( 1 === block_title_jquery_obj.length ) { 7858 var content_element = block_title_jquery_obj.find( 'span:first' ); 7859 7860 if ( 1 === content_element.length ) { 7861 7862 if ( 'undefined' !== typeof( clear_margin ) && true === clear_margin ) { 7863 content_element.css( 'margin-right', 0 ); 7864 } else { 7865 if ( 0 === item._horizontal_elements.length ) { 7866 content_element.css( 'margin-right', item._vertical_jquery_obj_outer_width + 'px' ); 7867 } else { 7868 content_element.css( 'margin-right', 0 ); 7869 } 7870 } 7871 } 7872 } 7873 }, 7874 7875 7876 7877 7878 /** 7879 * - function used to compute all items in the item list 7880 * 7881 * @private 7882 */ 7883 _compute_all_items: function() { 7884 for ( var i = tdPullDown.items.length - 1; i >= 0; i-- ) { 7885 7886 // a type check is done for every item in the item list 7887 if ( tdPullDown.items[ i ].constructor === tdPullDown.item ) { 7888 tdPullDown._compute_item( tdPullDown.items[ i ] ); 7889 } 7890 } 7891 }, 7892 7893 7894 7895 7896 /** 7897 * - function used to move one element from the vertical list to the horizontal one 7898 * - the function returns the element that has been moved, otherwise null 7899 * - the last element moving hides the vertical top header 7900 * 7901 * @param item - the item whose element is moved 7902 * @returns {T} - the moved element 7903 * @private 7904 */ 7905 _make_element_horizontal: function( item ) { 7906 7907 // the item must be initialized and the vertical list must contain at least an element 7908 if ( false === item._is_initialized || 0 === item._vertical_elements.length ) { 7909 return null; 7910 } 7911 7912 // the first element of the vertical list is shifted 7913 var local_element = item._vertical_elements.shift(); 7914 7915 // the vertical list is shown when there's at least one vertical element 7916 if ( 0 === item._vertical_elements.length ) { 7917 item.vertical_jquery_obj.css( 'display', 'none' ); 7918 } 7919 7920 // the element is added on the last position in the horizontal list 7921 item._horizontal_elements.push( local_element ); 7922 7923 local_element.jquery_object.css( 'opacity', '0' ); 7924 7925 // the DOM is changing 7926 local_element.jquery_object.detach().appendTo( item.horizontal_jquery_obj ); 7927 7928 setTimeout( function() { 7929 local_element.jquery_object.css( 'opacity', '1' ); 7930 }, 50); 7931 7932 //tdPullDown.log('horizontal'); 7933 7934 return local_element; 7935 }, 7936 7937 7938 7939 7940 /** 7941 * - function used to move one element from the horizontal list to the vertical one 7942 * - the function returns the element that has been moved, otherwise null 7943 * - the first element moving shows the vertical top header 7944 * 7945 * @param item - the item whose element is moved 7946 * @returns {T} - the moved element 7947 * @private 7948 */ 7949 _make_element_vertical: function( item ) { 7950 7951 // the item must be initialized and the horizontal list must contain at least an element 7952 if ( false === item._is_initialized || 0 === item._horizontal_elements.length ) { 7953 return null; 7954 } 7955 7956 // the last element of the horizontal list is popped out 7957 var local_element = item._horizontal_elements.pop(); 7958 7959 // the vertical list is hidden when there are no vertical elements 7960 if ( 0 === item._vertical_elements.length ) { 7961 item.vertical_jquery_obj.css( 'display', '' ); 7962 } 7963 7964 //the element is added on the first position into the vertical list 7965 item._vertical_elements.unshift( local_element ); 7966 7967 // the DOM is changed 7968 local_element.jquery_object.detach().prependTo( item._vertical_ul_jquery_obj ); 7969 7970 //tdPullDown.log('vertical'); 7971 7972 return local_element; 7973 }, 7974 7975 7976 7977 7978 /** 7979 * - function used to move all elements to the vertical list 7980 * - it's used when the minimum horizontal elements is greater than 0 7981 * 7982 * @param item - the item whose elements are moved 7983 * @private 7984 */ 7985 _make_all_elements_vertical: function( item ) { 7986 while ( item._horizontal_elements.length > 0 ) { 7987 tdPullDown._make_element_vertical( item ); 7988 } 7989 }, 7990 7991 7992 7993 7994 7995 7996 /** 7997 * - function necessary to be called when the window is being resized 7998 */ 7999 td_events_resize: function() { 8000 8001 if ( 0 === tdPullDown.items.length ) { 8002 return; 8003 } 8004 8005 if ( true === tdPullDown.reinitialize_items_at_change_view_port && tdPullDown._view_port_interval_index !== tdViewport.getCurrentIntervalIndex() ) { 8006 tdPullDown._reinitialize_all_items();
8007 } 8008 8009 tdPullDown._compute_all_items(); 8010 }, 8011 8012 8013 8014 8015 log: function log( msg ) { 8016 //console.log(msg); 8017 } 8018 }; 8019 8020 8021 tdPullDown.init(); 8022 8023})(); 8024 8025 8026 8027 8028 8029 8030 8031 8032var td_fps = { 8033 8034 start_time: 0, 8035 8036 current_time: 0, 8037 8038 frame_number: 0, 8039 8040 init: function init() { 8041 td_fps.start_time = 0; 8042 8043 var previous_result = 0, 8044 result = 0, 8045 elapsed_time = 0; 8046 8047 var td_fps_table = jQuery("#fps_table"); 8048 8049 if (td_fps_table.length == 0) { 8050 td_fps_table = jQuery('<div>').css({ 8051 "position": "fixed", 8052 "top": "120px", 8053 "left": "10px", 8054 "width": "100px", 8055 "height": "20px", 8056 "border": "1px solid black", 8057 "font-size": "11px", 8058 "z-index": "100000", 8059 "background-color": "white" 8060 }); 8061 8062 td_fps_table.appendTo('body'); 8063 } 8064 8065 var get_fps = function() { 8066 td_fps.frame_number++;
8067 td_fps.current_time = Date.now(); 8068 8069 elapsed_time = (td_fps.current_time - td_fps.start_time) / 1000; 8070 8071 result = (td_fps.frame_number / elapsed_time).toPrecision(2); 8072 8073 if (result != previous_result) { 8074 previous_result = result; 8075 td_fps_table.html(previous_result + ' fps'); 8076 //console.log(previous_result); 8077 } 8078 8079 if (elapsed_time > 1) { 8080 td_fps.start_time = td_fps.current_time; 8081 td_fps.frame_number = 0; 8082 } 8083 8084 requestAnimationFrame(get_fps); 8085 }; 8086 8087 get_fps(); 8088 } 8089}; 8090 8091/** 8092 * Created by tagdiv on 16.02.2015. 8093 */ 8094 8095/* global jQuery: {} */ 8096/* global tdEvents: {} */ 8097 8098var tdAnimationScroll = {}; 8099 8100(function() { 8101 8102 'use strict'; 8103 8104 tdAnimationScroll = { 8105 8106 8107 // the bunch of tdAnimationScroll items 8108 items: [], 8109 8110 8111 8112 // the current request animation frame id 8113 rAFIndex: 0, 8114 8115 8116 8117 // flag used to not call 'requestAnimationFrame' when it's steel running 8118 animation_running: false, 8119 8120 8121 8122 item: function item() { 8123 8124 // the computed percent value of the jquery object in the viewport 8125 // - 0 when the top of object enters into the viewport 8126 // - 100 when the bottom of the object goes outside of the viewport 8127 this.percent_value = 0; 8128 8129 // the animation callback function 8130 this.animation_callback = null; 8131 8132 // the jquery object of the tdAnimationScroll.item 8133 this.jqueryObj = ''; 8134 8135 // optional - a jquery object that wraps the current item. Used in callback 8136 this.wrapper_jquery_obj = undefined; 8137 8138 // a jquery span obj added dynamically added at the top of jqueryObj 8139 this.top_marker_jquery_obj = ''; 8140 8141 // the full outer height of the item 8142 this.full_height = 0; 8143 8144 // the offset top of the top_marker_jquery_obj 8145 this.offset_top = ''; 8146 8147 // the offset top of the top_marker_jquery_obj and the full_height 8148 this.offset_bottom_top = ''; 8149 8150 // the properties registered with the item 8151 this.properties = {}; 8152 8153 // the computed properties that probably will be applied by animation callback function over the jquery object 8154 this.computed_item_properties = {}; 8155 8156 // flag made 'true' for items having at least one computed property 8157 this.redraw = false; 8158 8159 // top is out of screen 8160 this.top_is_out = false; 8161 8162 // flag used to mark the initialization item 8163 this._is_initialized = false; 8164 8165 // flag used to stop an item to be computed 8166 this.computation_stopped = false; 8167 8168 8169 8170 8171 /** 8172 * - when a new item property is added, it's added as a real property in the item.properties object. 8173 * - if it's already added, the settings of the property are appended 8174 * - the settings for an item property must be added in order of the percents 8175 * - the percent intervals must not be overloaded (ex. 10-30 and 20-40) 8176 * - it doesn't matter how many settings are added to an item property 8177 * - after an adding the space of percentage is full, that means after adding 8178 * ex: add_item_property('opacity', 10, 30, 0, 1, easing) 8179 * 8180 * item.properties.opacity.settings : 8181 * [ 8182 * [0, 10, 0, 0, ''] 8183 * [10, 30, 0, 1, easing] - property added 8184 * [30, 100, 1, 1, ''] 8185 * ] 8186 * 8187 * ex: add_item_property('opacity', 40, 50, 1, 0) 8188 * 8189 * item.properties.opacity.settings : 8190 * [ 8191 * [0, 10, 0, 0, ''] 8192 * [10, 30, 0, 1, easing] - property added 8193 * [30, 40, 1, 1, ''] 8194 * [40, 50, 1, 0, easing] - property added 8195 * [50, 100, 0, 0, ''] 8196 * ] 8197 * 8198 * - callable jQuery easing functions: 8199 * swing 8200 * easeInQuad 8201 * easeOutQuad 8202 * easeInOutQuad 8203 * easeInCubic 8204 * easeOutCubic 8205 * easeInOutCubic 8206 * easeInQuart 8207 * easeOutQuart 8208 * easeInOutQuart 8209 * easeInQuint 8210 * easeOutQuint 8211 * easeInOutQuint 8212 * easeInSine 8213 * easeOutSine 8214 * easeInOutSine 8215 * easeInExpo 8216 * easeOutExpo 8217 * easeInOutExpo 8218 * easeInCirc 8219 * easeOutCirc 8220 * easeInOutCirc 8221 * easeInElastic 8222 * easeOutElastic 8223 * easeInOutElastic 8224 * easeInBack 8225 * easeOutBack 8226 * easeInOutBack 8227 * easeInBounce 8228 * easeOutBounce 8229 * easeInOutBounce 8230 * 8231 * @param name string 8232 * @param start_percent numeric 8233 * @param end_percent numeric 8234 * @param start_value numeric 8235 * @param end_value numeric
8236 * @param easing string [optional] 8237 */ 8238 this.add_item_property = function add_item_property(name, start_percent, end_percent, start_value, end_value, easing) { 8239 8240 if (start_percent >= end_percent) { 8241 return; 8242 } 8243 8244 if (undefined === this.properties[name]) { 8245 8246 this.properties[name] = { 8247 computed_value: '', 8248 settings: [] 8249 }; 8250 8251 if (0 !== start_percent) { 8252 this.properties[name].settings[this.properties[name].settings.length] = { 8253 start_percent: 0, 8254 end_percent: start_percent, 8255 start_value: start_value, 8256 end_value: start_value, 8257 easing: '' 8258 }; 8259 } 8260 8261 this.properties[name].settings[this.properties[name].settings.length] = { 8262 start_percent: start_percent, 8263 end_percent: end_percent, 8264 start_value: start_value, 8265 end_value: end_value, 8266 easing: easing 8267 }; 8268 8269 this.properties[name].settings[this.properties[name].settings.length] = { 8270 start_percent: end_percent, 8271 end_percent: 100, 8272 start_value: end_value, 8273 end_value: end_value, 8274 easing: '' 8275 }; 8276 8277 } else { 8278 8279 var last_setting = this.properties[name].settings[this.properties[name].settings.length - 1]; 8280 8281 if (last_setting.start_percent !== start_percent) { 8282 this.properties[name].settings[this.properties[name].settings.length - 1] = { 8283 start_percent: last_setting.start_percent, 8284 end_percent: start_percent, 8285 start_value: last_setting.end_value, 8286 end_value: last_setting.end_value, 8287 easing: '' 8288 }; 8289 8290 this.properties[name].settings[this.properties[name].settings.length] = { 8291 start_percent: start_percent, 8292 end_percent: end_percent, 8293 start_value: start_value, 8294 end_value: end_value, 8295 easing: easing 8296 }; 8297 } else { 8298 this.properties[name].settings[this.properties[name].settings.length - 1] = { 8299 start_percent: start_percent, 8300 end_percent: end_percent, 8301 start_value: start_value, 8302 end_value: end_value, 8303 easing: easing 8304 }; 8305 } 8306 8307 if (100 !== end_percent) { 8308 this.properties[name].settings[this.properties[name].settings.length] = { 8309 start_percent: end_percent, 8310 end_percent: 100, 8311 start_value: end_value, 8312 end_value: end_value, 8313 easing: '' 8314 }; 8315 } 8316 } 8317 }; 8318 8319 8320 /** 8321 * remove an item property 8322 * 8323 * @param name {String} The name of the property 8324 * @returns {boolean} 8325 */ 8326 this.remove_item_property = function remove_item_property(name) { 8327 if (undefined === this.properties[name]) { 8328 return false; 8329 } 8330 8331 delete this.properties[name]; 8332 8333 return true; 8334 }; 8335 }, 8336 8337 8338 8339 8340 /** 8341 * - function used to init the tdAnimationScroll object 8342 * - it must be called before adding any item 8343 * - the _view_port_interval_index flag is initialized 8344 * - the items list is empty initialized 8345 */
8346 init: function init() { 8347 8348 tdAnimationScroll.items = []; 8349 }, 8350 8351 8352 8353 8354 /** 8355 * - used to add an item to the item list and initialize it 8356 * 8357 * @param item The item to be added and initialized 8358 */ 8359 add_item: function add_item(item) { 8360 8361 if (item.constructor !== tdAnimationScroll.item) { 8362 return; 8363 } 8364 8365 // the item is added in the item list 8366 tdAnimationScroll.items.push(item); 8367 8368 // the item is initialized only once when it is added 8369 tdAnimationScroll._initialize_item(item); 8370 8371 // for efficiently rendering all items are computed at once, so do not compute item individually 8372 }, 8373 8374 8375 8376 8377 /** 8378 * - used to initialize an item 8379 * - an item must be initialized only once 8380 * 8381 * @param item 8382 * @private 8383 */ 8384 _initialize_item: function _initialize_item(item) { 8385 8386 // an item must be initialized only once 8387 if (true === item._is_initialized) { 8388 return; 8389 } 8390 8391 // the item full height is computed 8392 if (undefined === item.wrapper_jquery_obj) { 8393 item.full_height = item.jqueryObj.outerHeight(true); 8394 } else { 8395 item.full_height = item.wrapper_jquery_obj.height(); 8396 } 8397 8398 if (0 === item.full_height) { 8399 return; 8400 } 8401 8402 var new_jquery_obj_reference = jQuery('<div class="td_marker_animation" style="height: 0; width: 0">'); 8403 8404 new_jquery_obj_reference.insertBefore(item.jqueryObj); 8405 8406 item.top_marker_jquery_obj = new_jquery_obj_reference; 8407 8408 item.offset_top = item.top_marker_jquery_obj.offset().top; 8409 8410 //console.log("initializare " + tdAnimationScroll.items.length + " : " + item.top_marker_jquery_obj.offset().top); 8411 8412 item.offset_bottom_top = item.offset_top + item.full_height; 8413 8414 item.top_is_out = tdEvents.window_pageYOffset > item.offset_top; 8415 8416 // the item is marked as initialized, being ready to be computed 8417 // for efficiently rendering all items are computed at once 8418 item._is_initialized = true; 8419 8420 8421 // maybe it's better to try a request animation frame after every initialization, for computing the already added items 8422 //tdAnimationScroll.compute_all_items(); 8423 }, 8424 8425 8426 8427 8428 /** 8429 * - used to reinitialize all items at the view resolution changing 8430 * 8431 * @param recompute_height boolean True if it's necessary to recompute the item's height [when view port changes] 8432 */ 8433 reinitialize_all_items: function reinitialize_all_items(recompute_height) { 8434 8435 for (var i = tdAnimationScroll.items.length - 1; i >= 0; i--) { 8436 tdAnimationScroll.reinitialize_item(tdAnimationScroll.items[i], recompute_height); 8437 } 8438 }, 8439 8440 8441 8442 8443 8444 8445 /** 8446 * - used to reinitialize an item at the view resolution changing 8447 * 8448 * @param item tdAnimationScroll.item 8449 * @param recompute_height boolean True if it's necessary to recompute the item height [when view port changes] 8450 * @private 8451 */ 8452 reinitialize_item: function reinitialize_item(item, recompute_height) { 8453 8454 // a not initialized item can't be reinitialized 8455 if (false === item._is_initialized) { 8456 return; 8457 } 8458 8459 // prevent the following item computing, till the reinitialization is finished 8460 item._is_initialized = false; 8461 8462 item.offset_top = item.top_marker_jquery_obj.offset().top; 8463 8464 //console.log("reinitializare " + tdAnimationScroll.items.length + " : " + item.top_marker_jquery_obj.offset().top); 8465 8466 if (true === recompute_height) { 8467 if (undefined === item.wrapper_jquery_obj) { 8468 item.full_height = item.jqueryObj.outerHeight(true); 8469 } else { 8470 item.full_height = item.wrapper_jquery_obj.height(); 8471 } 8472 8473 if (0 === item.full_height) { 8474 return; 8475 } 8476 } 8477 8478 item.offset_bottom_top = item.offset_top + item.full_height; 8479 8480 item._is_initialized = true; 8481 }, 8482 8483 8484 8485 8486 /**
8487 * - used for computing item properties 8488 * 8489 * @param item The item whose properties are computed 8490 * @private 8491 */ 8492 _compute_item_properties: function _compute_item_properties(item) { 8493 8494 var computed_properties = {}, 8495 current_item_property; 8496 8497 for (var property in item.properties) { 8498 8499 if (true === item.properties.hasOwnProperty(property)) { 8500 8501 current_item_property = item.properties[property]; 8502 8503 var current_setting, 8504 new_computed_value, 8505 local_computed_value, 8506 easing_step, 8507 easing_computed_value, 8508 easing_division_interval = 1000; 8509 8510 for (var i = 0; i < current_item_property.settings.length; i++) { 8511 8512 current_setting = current_item_property.settings[i]; 8513 8514 // the check is done using this form [...) of the interval or the last position 100% 8515 if ((current_setting.start_percent <= item.percent_value && item.percent_value < current_setting.end_percent) || 8516 (item.percent_value === current_setting.end_percent && 100 === item.percent_value)) { 8517 8518 if (current_setting.start_value === current_setting.end_value) { 8519 8520 new_computed_value = current_setting.start_value; 8521 8522 } else { 8523 8524 // local computed value can have a positive value or a negative value, it depends of the difference end_value - start_value 8525 // for a linear easing function, the new computed value is the start_value + local_computed_value 8526 // if start_value < end_value, the variable local_computed_value is positive 8527 // if start_value > end_value, the variable local_computed_value is negative 8528 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); 8529 8530 8531 // if there's specified an easing function, it's applied over the computed_value 8532 if ((undefined === current_setting.easing) || ('' === current_setting.easing)) { 8533 8534 // linear easing function 8535 8536 new_computed_value = current_setting.start_value + local_computed_value; 8537 8538 } else { 8539 8540 // specifying an easing function 8541 8542 easing_step = Math.abs(current_setting.start_value - current_setting.end_value) / easing_division_interval; 8543 8544 if (current_setting.start_value < current_setting.end_value) { 8545 8546 easing_computed_value = current_setting.start_value + jQuery.easing[current_setting.easing]( 8547 null, 8548 local_computed_value, 8549 0, 8550 easing_step, 8551 current_setting.end_value - current_setting.start_value) * easing_division_interval; 8552 8553 } else { 8554 8555 easing_computed_value = current_setting.start_value - jQuery.easing[current_setting.easing]( 8556 null, 8557 -local_computed_value, 8558 0, 8559 easing_step, 8560 current_setting.start_value - current_setting.end_value) * easing_division_interval; 8561 } 8562 8563 new_computed_value = easing_computed_value; 8564 8565 //console.log(current_setting.easing + ' : ' + easing_step + ' ~ ' + easing_computed_value + ' ~ ' + (current_setting.start_value + computed_value) + ' & ' + current_setting.start_value + ' $ ' + current_setting.end_value); 8566 } 8567 } 8568 8569 // if the existing computed value is different, the new computed value is cached 8570 if (current_item_property.computed_value !== new_computed_value) { 8571 current_item_property.computed_value = new_computed_value; 8572 computed_properties[property] = new_computed_value; 8573 8574 // the item is marked that it has at least one property that need to be redraw 8575 // the animation callback functions are called just for the marked items 8576 item.redraw = true; 8577 } 8578 break; 8579 } 8580 } 8581 } 8582 } 8583 8584 // a plain javascript object is added if there is no computed property 8585 item.computed_item_properties = computed_properties; 8586 }, 8587 8588 8589 8590 8591 /**
8592 * - used for computing item 8593 * - the item properties are computed only when the item is in the view port and it is moving 8594 * 8595 * @param item The tdAnimationScroll.item to be computed 8596 */ 8597 compute_item: function compute_item(item) { 8598 //console.clear(); 8599 8600 // the item must be initialized first 8601 if (false === item._is_initialized) { 8602 return; 8603 } 8604 8605 var percent_display_value = 0; 8606 8607 if (tdEvents.window_pageYOffset + tdEvents.window_innerHeight >= item.offset_top) { 8608 8609 if (tdEvents.window_pageYOffset > item.offset_bottom_top) { 8610 percent_display_value = 100; 8611 } else { 8612 percent_display_value = (tdEvents.window_pageYOffset + tdEvents.window_innerHeight - item.offset_top) * 100 / (tdEvents.window_innerHeight + item.full_height); 8613 } 8614 } 8615 8616 //console.log(window.pageYOffset + ' : ' + item.offset_top + ' : ' + item.offset_bottom_top); 8617 8618 if (item.percent_value !== percent_display_value) { 8619 item.percent_value = percent_display_value; 8620 tdAnimationScroll._compute_item_properties(item); 8621 } 8622 8623 item.top_is_out = tdEvents.window_pageYOffset > item.offset_top; 8624 8625 8626 //console.log(percent_display_value); 8627 }, 8628 8629 8630 8631 8632 /** 8633 * - used to request an animation frame for computing all items 8634 * - the flag animation_running is set to false by the last requestAnimationFrame callback (the last animation call), 8635 * so a new call to requestAnimationFrame can be done 8636 */ 8637 compute_all_items: function compute_all_items() { 8638 //tdAnimationScroll.animate(); 8639 8640 if (false === tdAnimationScroll.animation_running) { 8641 tdAnimationScroll.rAFIndex = window.requestAnimationFrame( tdAnimationScroll._animate_all_items ); 8642 } 8643 8644 tdAnimationScroll.animation_running = true; 8645 }, 8646 8647 8648 8649 8650 /** 8651 * - used to call the existing callback animate functions 8652 * 8653 * @private 8654 */ 8655 _animate_all_items: function _animate_all_items() { 8656 //var start_time = Date.now(); 8657 8658 for (var i = 0; i < tdAnimationScroll.items.length; i++) { 8659 if ( false === tdAnimationScroll.items[i].computation_stopped) { 8660 tdAnimationScroll.compute_item(tdAnimationScroll.items[i]); 8661 } 8662 } 8663 8664 for (var j = 0; j < tdAnimationScroll.items.length; j++) { 8665 if (true === tdAnimationScroll.items[j].redraw) { 8666 tdAnimationScroll.items[j].animation_callback(); 8667 } 8668 } 8669 8670 tdAnimationScroll.animation_running = false; 8671 8672 //var end_time = Date.now(); 8673 // 8674 //var debug_table = jQuery("#debug_table"); 8675 //debug_table.html((end_time - start_time) + ' ms'); 8676 }, 8677 8678 8679 8680 8681 8682 /** @todo we'll see if it's necessary to make reinitialization just at the view port changing. Now, it's not 8683 * - necessary to be called when the window is being resized 8684 */ 8685 td_events_resize: function td_events_resize() { 8686 8687 if (0 === tdAnimationScroll.items.length) { 8688 return; 8689 } 8690 8691 // this will be applied if it depends just by view port changing 8692 8693 //if (tdAnimationScroll._changed_view_port_width()) { 8694 // tdAnimationScroll.reinitialize_all_items(); 8695 //} 8696 8697 tdAnimationScroll.reinitialize_all_items(false); 8698 8699 tdAnimationScroll.compute_all_items(); 8700 }, 8701 8702 8703 8704 8705 8706 8707 log: function log(msg) { 8708 //console.log(msg); 8709 } 8710 }; 8711 8712 tdAnimationScroll.init(); 8713 8714})(); 8715 8716 8717 8718/** 8719 * Created by tagdiv on 23.02.2015. 8720 */ 8721 8722var tdBackstr = {}; 8723 8724(function(){ 8725 8726 'use strict'; 8727 8728 tdBackstr = { 8729 8730 8731 items: [], 8732 8733 8734 item: function() { 8735 8736 // check if is necessary to apply modification (css) 8737 this.previous_value = 0; 8738 8739 // the image aspect ratio 8740 this.image_aspect_rate = 0; 8741 8742 // the wrapper jquery object 8743 this.wrapper_image_jquery_obj = ''; 8744 8745 // the image jquery object 8746 this.image_jquery_obj = ''; 8747 }, 8748 8749 8750 /** 8751 * 8752 * @param item 8753 */ 8754 add_item: function( item ) { 8755 8756 if ( item.constructor !== tdBackstr.item ) { 8757 return; 8758 } 8759 8760 //if ((item.image_jquery_obj.complete) 8761 // 8762 // // this is a case when the image is still not loaded but the height() and width() return both 24px 8763 // // @todo it must be modified. It's used because for backstretch are usually used large images 8764 // && ((item.image_jquery_obj.height() != 24) && (item.image_jquery_obj.width() != 24)) 8765 //) 8766
8767 if ( item.image_jquery_obj.get( 0 ).complete ) { 8768 tdBackstr._load_item_image( item ); 8769 8770 } else { 8771 8772 item.image_jquery_obj.on( 'load', function() { 8773 tdBackstr._load_item_image( item ); 8774 }); 8775 8776 8777 //var currentTimeStart = Date.now(); 8778 // 8779 //var loaded_image_jquery_ojb = false; 8780 // 8781 //item.image_jquery_obj.on('load', function() { 8782 // 8783 // loaded_image_jquery_ojb = true; 8784 // 8785 // 8786 // tdBackstr._load_item_image(item); 8787 // console.log('backstr tarziu ' + item.image_jquery_obj.height() + ' > timp : ' + (Date.now() - currentTimeStart)); 8788 //}); 8789 // 8790 // 8791 //var indexInterval = setInterval(function() { 8792 // if (loaded_image_jquery_ojb) { 8793 // clearInterval(indexInterval); 8794 // console.log('imagine incarcata ' + item.image_jquery_obj.height() + ' > timp : ' + (Date.now() - currentTimeStart)); 8795 // } 8796 //}, 0); 8797 } 8798 }, 8799 8800 8801 _load_item_image: function( item ) { 8802 item.image_aspect_rate = item.image_jquery_obj.width() / item.image_jquery_obj.height(); 8803 tdBackstr.items.push( item ); 8804 tdBackstr._compute_item( item ); 8805 8806 item.image_jquery_obj.css( 'opacity', '1' ); 8807 }, 8808 8809 8810 /** 8811 * 8812 * @param item 8813 * @private 8814 */ 8815 _compute_item: function( item ) { 8816 8817 // the wrapper aspect ratio can vary, so it's recomputed at computing item 8818 var wrapper_aspect_rate = item.wrapper_image_jquery_obj.width() / item.wrapper_image_jquery_obj.height(); 8819 8820 var current_value = 0; 8821 8822 if ( wrapper_aspect_rate < item.image_aspect_rate ) { 8823 8824 current_value = 1; 8825 8826 if ( item.previous_value !== current_value ) { 8827 item.image_jquery_obj.removeClass( 'td-stretch-width' ); 8828 item.image_jquery_obj.addClass( 'td-stretch-height' ); 8829 8830 item.previous_value = current_value; 8831 } 8832 } else { 8833 8834 current_value = 2; 8835 8836 if ( item.previous_value !== current_value ) { 8837 item.image_jquery_obj.removeClass( 'td-stretch-height' ); 8838 item.image_jquery_obj.addClass( 'td-stretch-width' ); 8839 8840 item.previous_value = current_value; 8841 } 8842 } 8843 }, 8844 8845 8846 /** 8847 * 8848 * @private 8849 */ 8850 _compute_all_items: function() { 8851 for ( var i = 0; i < tdBackstr.items.length; i++ ) { 8852 tdBackstr._compute_item( tdBackstr.items[ i ] ); 8853 } 8854 }, 8855 8856 8857 td_events_resize: function() { 8858 8859 if ( 0 === tdBackstr.items.length ) { 8860 return; 8861 } 8862 8863 tdBackstr._compute_all_items(); 8864 }, 8865 8866 8867 8868 8869 log: function( msg ) { 8870 window.console.log( msg ); 8871 } 8872 }; 8873 8874 8875})(); 8876 8877 8878 8879 8880/** 8881 * Created by tagdiv on 11.03.2015. 8882 */ 8883 8884/** 8885 * abstract: 8886 * - check all items in page, sort them using one of a sorted methods and add them in the items array 8887 * - at every scroll the items are verified if they are in view port or above 8888 * - every item in view port is added into the _items_in_view_port array and they are ready for animation 8889 * - items above view port are animated all at once 8890 * - items in view port are animated at crescendo intervals [interval / remaining items] 8891 * - there's a max and a min interval 8892 * - td_block ajax request response use a sort method and add founded items into view port array or into items array 8893 */ 8894 8895 8896/* global jQuery:false */ 8897/* global tdDetect:false */ 8898/* global tdEvents:{} */ 8899 8900var tdAnimationStack = {}; 8901 8902( function() { 8903 8904 "use strict"; 8905 8906 tdAnimationStack = { 8907 8908 /* 8909 Important: 8910 1. The first animation step is produced by the the body selector @see animation-stack.less 8911 2. The second animation step can be applied by the animation_css_class1 8912 3. The final (the main) animation step is applied by the animation_css_class2 8913 */ 8914 8915 8916 8917 8918 // - flag css class used by the non 'type0' animation effect 8919 // - flag used just to look for not yet computed item 8920 // - it's set by ready_init (on ready) 8921 // - all dom components that need to be animated will be marked with this css class in ready_init 8922 // - it can be used for a precomputed style, but carefully, because it's applied at ready_init (on ready) 8923 _animation_css_class1: '', 8924 8925 8926 8927 // - flag css class used by the non 'type0' animation effect 8928 // - flag css class used to animate custom 8929 // - this css class applies the final animation 8930 _animation_css_class2: '', 8931 8932 8933 8934 // - the default animation effect 'type0' is applied if the global window.td_animation_stack_effect is the empty string
8935 // - it's used for consistency of animation effects presented into the animation-stack.less [all types have a name (...type...)] 8936 _animation_default_effect: 'type0', 8937 8938 8939 8940 // - tdAnimationStack runs just only when this flag is true 8941 // - it's done true by the init function 8942 activated: false, 8943 8944 8945 8946 // flag checked by the major animation operations 8947 _ready_for_initialization: true, 8948 8949 // interval used by ready_init to check tdAnimationStack state 8950 _ready_init_timeout: undefined, 8951 8952 8953 // max time[ms] interval waiting for first tdAnimationStack.init call 8954 max_waiting_for_init: 3000, 8955 8956 8957 8958 // the specific selectors are used to look for new elements inside of the specific sections 8959 _specific_selectors: '', 8960 8961 // the general selectors are used to look for elements over extend areas in DOM 8962 _general_selectors: '', 8963 8964 8965 8966 8967 8968 8969 /** 8970 * - wait for tdAnimationStack.init() for max_waiting_for_init time 8971 * - if time is elapsed, the animation is canceled 8972 * - the ready_init is canceled by a fast tdAnimationStack.init call 8973 */ 8974 ready_init: function() { 8975 8976 // - special case for IE8 and IE9 (and if Visual Composer image carousel exists) 8977 // 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 8978 // - the animation is forced removed and the altered css body is cleaned 8979 if ( tdDetect.isIe8 || tdDetect.isIe9 || ( jQuery( '.vc_images_carousel' ).length > 0 ) ) { 8980 tdAnimationStack._ready_for_initialization = false; 8981 8982 if ( undefined !== window.td_animation_stack_effect ) { 8983 if ( '' === window.td_animation_stack_effect ) { 8984 window.td_animation_stack_effect = tdAnimationStack._animation_default_effect; 8985 } 8986 jQuery( 'body' ).removeClass( 'td-animation-stack-' + window.td_animation_stack_effect ); 8987 } 8988 return; 8989 } 8990 8991 8992 if ( undefined === window.tds_animation_stack || undefined === window.td_animation_stack_effect ) { 8993 8994 // lock any further operation using the _ready_for_initialization flag 8995 tdAnimationStack._ready_for_initialization = false; 8996 8997 } else { 8998 8999 // the tdAnimationStack._specific_selectors is set by the global variable window.td_animation_stack_specific_selectors 9000 if ( undefined !== window.td_animation_stack_specific_selectors ) { 9001 tdAnimationStack._specific_selectors = window.td_animation_stack_specific_selectors; 9002 } 9003 9004 9005 // if the global variable window.td_animation_stack_effect has the empty string value, the 'full fade' (type0) effect is prepared to be applied 9006 if ( '' === window.td_animation_stack_effect ) { 9007 window.td_animation_stack_effect = tdAnimationStack._animation_default_effect; 9008 } 9009 9010 tdAnimationStack._animation_css_class1 = 'td-animation-stack-' + window.td_animation_stack_effect + '-1'; 9011 tdAnimationStack._animation_css_class2 = 'td-animation-stack-' + window.td_animation_stack_effect + '-2'; 9012 9013 9014 // - the tdAnimationStack._general_selectors is set by the global variable window.td_animation_stack_general_selectors 9015 if ( undefined !== window.td_animation_stack_general_selectors ) { 9016 tdAnimationStack._general_selectors = window.td_animation_stack_general_selectors; 9017 } 9018 9019 // the tdAnimationStack._animation_css_class1 css class is applied for all elements need to be animated later 9020 jQuery( tdAnimationStack._general_selectors ).addClass( tdAnimationStack._animation_css_class1 ); 9021 9022 9023 // - timeout used by the ready_init function, to cut down tdAnimationStack.init calling at loading page, when the call comes too late 9024 // - if tdAnimationStack.init comes earlier, it does a clearTimeout call over the tdAnimationStack._ready_init_timeout variable 9025 tdAnimationStack._ready_init_timeout = setTimeout( function() { 9026 9027 // if tdAnimationStack is activated, do nothing 9028 if ( true === tdAnimationStack.activated ) { 9029 return; 9030 } 9031 9032 // lock any further operation using the _ready_for_initialization flag 9033 tdAnimationStack._ready_for_initialization = false; 9034 9035 // remove the loading animation css class effect from the body 9036 // this class is applied from the theme settings 9037 if ( undefined !== window.td_animation_stack_effect ) { 9038 jQuery( 'body' ).removeClass( 'td-animation-stack-' + window.td_animation_stack_effect ); 9039 } 9040 9041 }, tdAnimationStack.max_waiting_for_init ); 9042 } 9043 }, 9044 9045 9046 // flag marks items where they are 9047 _ITEM_TO_VIEW_PORT: { 9048 9049 ITEM_ABOVE_VIEW_PORT: 0, 9050 9051 ITEM_IN_VIEW_PORT: 1, 9052 9053 ITEM_UNDER_VIEW_PORT: 2 9054 }, 9055 9056 9057 // predefined sorting methods 9058 SORTED_METHOD: { 9059 9060 sort_left_to_right: function sort_left_to_right( item1, item2 ) { 9061 if ( item1.offset_top > item2.offset_top ) { 9062 return 1; 9063 } else if ( item1.offset_top < item2.offset_top ) { 9064 return -1; 9065 } else if ( item1._order > item2._order ) { 9066 return 1; 9067 } else if ( item1._order < item2._order ) { 9068 return -1; 9069 } 9070 return 0; 9071 }, 9072 9073 9074 sort_right_to_left: function sort_right_to_left( item1, item2 ) { 9075 if ( item1.offset_top > item2.offset_top ) { 9076 return 1; 9077 } else if ( item1.offset_top < item2.offset_top ) { 9078 return -1; 9079 } else if ( item1._order > item2._order ) { 9080 return -1; 9081 } else if ( item1._order < item2._order ) { 9082 return 1; 9083 } 9084 return -1; 9085 } 9086 }, 9087 9088 9089 // keeps the DOM reading order, used in the sorting methods 9090 _order: 0, 9091 9092 9093 // interval divided to animate items 9094 // 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 9095 interval: 70, 9096 9097 // min interval of a set timer 9098 min_interval: 17, 9099 9100 // max interval of a set timer 9101 max_interval: 40, 9102 9103 9104 9105 // keep current setInterval 9106 _current_interval: undefined, 9107 9108 // items in view port are moved here 9109 _items_in_view_port: [], 9110 9111 // items above the view port are moved here 9112 _items_above_view_port: [], 9113 9114 // all items that will be processed 9115 items: [], 9116 9117 9118 9119 9120 9121 9122 9123 9124 /** 9125 * - tdAnimationStack.item 9126 */ 9127 item: function() { 9128 // offset from the top of the item, to the top 9129 // it's set at the initialization item 9130 this.offset_top = undefined; 9131 9132 9133 // offset from the bottom of the item, to the top 9134 // it's set at the initialization item 9135 this.offset_bottom_to_top = undefined; 9136 9137 9138 // jquery object reference 9139 // it's set before the initialization of the item 9140 this.jqueryObj = undefined; 9141 9142 9143 // the reading order from DOM 9144 // it's set at the initialization item 9145 this._order = undefined; 9146 }, 9147 9148 9149 9150 9151 /** 9152 * - initialize a tdAnimationStack.item and add it in tdAnimationStack.items 9153 * @param item tdAnimationStack.item 9154 */ 9155 //add_item: function add_item(item) { 9156 // 9157 // if (item.constructor != tdAnimationStack.item) { 9158 // return; 9159 // } 9160 // 9161 // tdAnimationStack.items.push(item); 9162 //}, 9163 9164 9165 9166 /** 9167 * - initialize the offset top of the tdAnimationStack.item parameter 9168 * @param item tdAnimationStack.item 9169 * @private 9170 */ 9171 _initialize_item: function( item ) { 9172 item._order = tdAnimationStack._order++; 9173 9174 item.offset_top = item.jqueryObj.offset().top; 9175 //item.offset_relative = Math.sqrt(Math.pow(item.jqueryObj.offset().top, 2) + Math.pow(item.jqueryObj.offset().left, 2)); 9176 9177 item.offset_bottom_to_top = item.offset_top + item.jqueryObj.height(); 9178 9179 //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>'); 9180 }, 9181 9182 9183 /** 9184 * - dynamically search for new elements to create new tdAnimationStack.item 9185 * - the items are added in the tdAnimationStack._items_in_view_port, that means they are ready to be animated, 9186 * or in the tdAnimationStack.items to be computed later (checked if they are in the view port and animated) 9187 * @param selector {string} - jQuery selector 9188 * @param sort_type {tdAnimationStack.SORTED_METHOD} - a preferred tdAnimationStack.SORTED_METHOD 9189 * @param in_view_port {boolean} - add an item in the tdAnimationStack._items_in_view_port or in the tdAnimationStack.items 9190 */ 9191 check_for_new_items: function( selector, sort_type, in_view_port ) { 9192 9193 // tdAnimationStack must be activated and not stopped for initialization by the ready_init checker 9194 if ( ( false === tdAnimationStack.activated ) || ( false === tdAnimationStack._ready_for_initialization ) ) { 9195 return; 9196 } 9197 9198 9199 if ( undefined === selector ) { 9200 selector = ''; 9201 } 9202 9203 9204 9205 // the local stack of searched items 9206 var local_stack = []; 9207 9208 9209 9210 //if (window.td_animation_stack_effect === 'type0') { 9211 // // for every founded element there's an instantiated tdAnimationStack.item, then initialized and added to the local stack 9212 // var founded_elements = jQuery(selector + ', .post').find(tdAnimationStack._specific_selectors).filter(function() { 9213 // return jQuery(this).css('opacity') === '0'; 9214 // });
9215 // 9216 //} else { 9217 jQuery( tdAnimationStack._general_selectors).not( '.' + tdAnimationStack._animation_css_class2 ).addClass( tdAnimationStack._animation_css_class1 ); 9218 9219 // for every founded element there's an instantiated tdAnimationStack.item, then initialized and added to the local stack 9220 var founded_elements = jQuery( selector + ', .post' ).find( tdAnimationStack._specific_selectors ).filter( function() { 9221 return jQuery( this ).hasClass( tdAnimationStack._animation_css_class1 ); 9222 }); 9223 //} 9224 9225 9226 9227 founded_elements.each( function( index, element ) { 9228 9229 var item_animation_stack = new tdAnimationStack.item(); 9230 9231 item_animation_stack.jqueryObj = jQuery( element ); 9232 9233 tdAnimationStack.log( index ); 9234 9235 tdAnimationStack._initialize_item( item_animation_stack ); 9236 9237 local_stack.push( item_animation_stack ); 9238 }); 9239 9240 9241 9242 // new scope having its own timer used for checking not yet loaded images 9243 ( function(){ 9244 9245 var images_loaded = true; 9246 9247 for ( var i = 0; i < local_stack.length; i++ ) { 9248 9249 // for every image element the 'complete' property is checked 9250 // "If the image is finished loading, the complete property returns true" 9251 // when tdAnimationStack.init is called on load, as normally, it calls tdAnimationStack.check_for_new_items and all these element has 'complete' property true 9252 // 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 9253 if ( false === founded_elements[ i ].complete ) { 9254 images_loaded = false; 9255 break; 9256 } 9257 } 9258 9259 // if there's at least one element not loaded, a timer is started to wait for 9260 if ( false === images_loaded ) { 9261 9262 var date = new Date(); 9263 var start_time = date.getTime(); 9264 9265 9266 tdAnimationStack.log( 'TIMER - started' ); 9267 9268 9269 // the timer is started 9270 var interval_check_loading_image = setInterval( function() { 9271 9272 // if there's too much time waiting for image loading, they are made visible 9273 var date = new Date(); 9274 9275 var i = 0; 9276 9277 if ( ( date.getTime() - start_time ) > tdAnimationStack.max_waiting_for_init ) { 9278 9279 clearInterval( interval_check_loading_image ); 9280 9281 for ( i = 0; i < local_stack.length; i++ ) { 9282 9283 9284 9285 9286 //if (window.td_animation_stack_effect === 'type0') { 9287 // local_stack[i].jqueryObj.css('opacity', 1); 9288 //} else { 9289 local_stack[ i ].jqueryObj.removeClass( tdAnimationStack._animation_css_class1 ); 9290 local_stack[ i ].jqueryObj.addClass( tdAnimationStack._animation_css_class2 ); 9291 //} 9292 9293 9294 9295 9296 9297 9298 } 9299 return; 9300 } 9301 9302 9303 // at every interval step, the element's 'complete' property is checked again 9304 images_loaded = true; 9305 9306 for ( i = 0; i < local_stack.length; i++ ) { 9307 9308 if ( false === founded_elements[ i ].complete ) { 9309 images_loaded = false; 9310 break; 9311 } 9312 } 9313 9314 if ( true === images_loaded ) { 9315 9316 clearInterval( interval_check_loading_image ); 9317 9318 tdAnimationStack.log( 'TIMER - stopped' ); 9319 9320 tdAnimationStack._precompute_items( local_stack, sort_type, in_view_port ); 9321 tdAnimationStack.compute_items();
9322 } 9323 9324 }, 100); 9325 9326 } else { 9327 tdAnimationStack._precompute_items( local_stack, sort_type, in_view_port ); 9328 tdAnimationStack.compute_items(); 9329 } 9330 9331 })(); 9332 9333 tdAnimationStack.log( 'checked for new items finished' ); 9334 }, 9335 9336 9337 /** 9338 * - _precompute_items sorts and adds items in the tdAnimationStack.items array or even in the 9339 * tdAnimationStack._items_in_view_port array 9340 * - this function is necessary because at scroll just the tdAnimationStack.compute_items function is called 9341 * 9342 * @param stack_items {[]} founded items 9343 * @param sort_type {function} sorting method 9344 * @param in_view_port {boolean} add in view port to be already computed, or in the general items array 9345 * @private 9346 */ 9347 _precompute_items: function( stack_items, sort_type, in_view_port ) { 9348 9349 stack_items.sort( sort_type ); 9350 9351 if ( true === in_view_port ) { 9352 9353 while ( stack_items.length > 0 ) { 9354 tdAnimationStack.log( 'add item 1 : ' + stack_items.length ); 9355 tdAnimationStack._items_in_view_port.push( stack_items.shift() ); 9356 } 9357 9358 } else { 9359 9360 while (stack_items.length > 0) { 9361 tdAnimationStack.log( 'add item 2 : ' + stack_items.length ); 9362 tdAnimationStack.items.push( stack_items.shift() ); 9363 } 9364 } 9365 }, 9366 9367 9368 9369 /** 9370 * - IT'S CALLED ON PAGE LOAD [actually in tdLastInit.js] 9371 * - the general init function 9372 * - the items are added to the tdAnimationStack.items using check_for_new_items method, and then computed 9373 * - the arrays are cleared to be prepared for a reinitialization 9374 */ 9375 init: function() { 9376 if ( undefined === window.tds_animation_stack ) { 9377 return; 9378 } 9379 9380 // tdAnimationStack must not be already stopped for initialization by a pre_init checker 9381 if ( false === tdAnimationStack._ready_for_initialization ) { 9382 return; 9383 } 9384 9385 // clear the _ready_init_timeout, to stop it doing more checking 9386 clearTimeout( tdAnimationStack._ready_init_timeout ); 9387 9388 // the tdAnimationStack is activated 9389 tdAnimationStack.activated = true; 9390 9391 tdAnimationStack.check_for_new_items( '.td-animation-stack', tdAnimationStack.SORTED_METHOD.sort_left_to_right, false ); 9392 }, 9393 9394 9395 /** 9396 * - the arrays are cleared to be prepared for a reinitialization 9397 * - the init call is done 9398 */ 9399 reinit: function() { 9400 9401 // tdAnimationStack must not be already stopped for initialization by a pre_init checker 9402 if ( false === tdAnimationStack._ready_for_initialization ) { 9403 return; 9404 } 9405 9406 tdAnimationStack.items = []; 9407 tdAnimationStack._items_in_view_port = []; 9408 tdAnimationStack._items_above_view_port = []; 9409 9410 tdAnimationStack.init(); 9411 }, 9412 9413 9414 /** 9415 * - compute all items 9416 */ 9417 compute_items: function() { 9418 9419 // tdAnimationStack must be activated and not stopped for initialization by the ready_init checker 9420 if ( ( false === tdAnimationStack.activated ) || ( false === tdAnimationStack._ready_for_initialization ) ) { 9421 return; 9422 } 9423 9424 // the tdAnimationStack.items are processed 9425 tdAnimationStack._separate_items(); 9426 9427 // the items above the port view are animated 9428 while ( tdAnimationStack._items_above_view_port.length > 0 ) { 9429 tdAnimationStack.log( 'animation - above the view port' ); 9430 9431 var item_above_view_port = tdAnimationStack._items_above_view_port.shift(); 9432 9433 9434 9435 //if (window.td_animation_stack_effect === 'type0') { 9436 // item_above_view_port.jqueryObj.css('opacity', 1); 9437 //} else { 9438 item_above_view_port.jqueryObj.removeClass( tdAnimationStack._animation_css_class1 ); 9439 item_above_view_port.jqueryObj.addClass( tdAnimationStack._animation_css_class2 ); 9440 //} 9441 9442 9443 9444 9445 } 9446 9447 9448 // the items in the port view are prepared to be animated 9449 if ( tdAnimationStack._items_in_view_port.length > 0 ) { 9450 9451 // clear any opened interval by a previous compute_items call 9452 clearInterval( tdAnimationStack._current_interval ); 9453 9454 var current_animation_item = tdAnimationStack._get_item_from_view_port(); 9455 9456 9457 9458 9459 //if (window.td_animation_stack_effect === 'type0') { 9460 // current_animation_item.jqueryObj.css('opacity', 1); 9461 //} else { 9462 current_animation_item.jqueryObj.removeClass( tdAnimationStack._animation_css_class1 ); 9463 current_animation_item.jqueryObj.addClass( tdAnimationStack._animation_css_class2 ); 9464 // } 9465 9466 9467 9468 9469 9470 if ( tdAnimationStack._items_in_view_port.length > 0 ) { 9471 9472 tdAnimationStack.log( 'start animation timer' ); 9473 9474 tdAnimationStack._to_timer( tdAnimationStack._get_right_interval( tdAnimationStack.interval * ( 1 / tdAnimationStack._items_in_view_port.length ) ) ); 9475 } 9476 } 9477 }, 9478 9479 9480 /** 9481 * - timer function initially called by a tdAnimationStack.compute_items function, and then it's auto called 9482 * - it calls a setInterval using the interval parameter 9483 * @param interval {int} - interval ms 9484 */ 9485 _to_timer: function( interval ) { 9486 9487 tdAnimationStack._current_interval = setInterval( function () { 9488 9489 if ( tdAnimationStack._items_in_view_port.length > 0 ) { 9490 9491 var current_animation_item = tdAnimationStack._get_item_from_view_port(); 9492 9493 tdAnimationStack.log( 'animation at interval: ' + interval ); 9494 9495 9496 9497 9498 //if (window.td_animation_stack_effect === 'type0') { 9499 // current_animation_item.jqueryObj.css('opacity', 1); 9500 //} else { 9501 current_animation_item.jqueryObj.removeClass( tdAnimationStack._animation_css_class1 ); 9502 current_animation_item.jqueryObj.addClass( tdAnimationStack._animation_css_class2 ); 9503 //} 9504 9505 9506 9507 9508 clearInterval( tdAnimationStack._current_interval ); 9509 9510 if ( tdAnimationStack._items_in_view_port.length > 0 ) { 9511 tdAnimationStack._to_timer( tdAnimationStack._get_right_interval( tdAnimationStack.interval * ( 1 / tdAnimationStack._items_in_view_port.length ) ) ); 9512 } 9513 } 9514 }, interval ); 9515 }, 9516 9517 9518 /** 9519 * - get an item from the tdAnimationStack._items_in_view_port array 9520 * @returns {tdAnimationStack.item} 9521 * @private 9522 */ 9523 _get_item_from_view_port: function() { 9524 9525 return tdAnimationStack._items_in_view_port.shift(); 9526 }, 9527 9528 9529 9530 /** 9531 * - get the interval considering tdAnimationStack.min_interval and tdAnimationStack.max_interval 9532 * @param interval {int} - the checked interval value 9533 * @returns {int} - the result interval value 9534 * @private 9535 */ 9536 _get_right_interval: function( interval ) { 9537 9538 if ( interval < tdAnimationStack.min_interval ) { 9539 return tdAnimationStack.min_interval; 9540 9541 } else if ( interval > tdAnimationStack.max_interval ) { 9542 return tdAnimationStack.max_interval; 9543 } 9544 return interval; 9545 }, 9546 9547 9548 /** 9549 * - check where the item is to the view port 9550 * @param item {tdAnimationStack.item} 9551 * @returns {number} _ITEM_TO_VIEW_PORT value 9552 * @private 9553 */ 9554 _item_to_view_port: function( item ) { 9555 9556 tdAnimationStack.log( 'position item relative to the view port >>
9556 ' + tdEvents.window_pageYOffset + tdEvents.window_innerHeight + ' : ' + item.offset_top ); 9557 9558 if ( tdEvents.window_pageYOffset + tdEvents.window_innerHeight < item.offset_top ) { 9559 return tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_UNDER_VIEW_PORT; 9560 9561 } else if ( ( tdEvents.window_pageYOffset + tdEvents.window_innerHeight >= item.offset_top ) && ( tdEvents.window_pageYOffset <= item.offset_bottom_to_top ) ) { 9562 return tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_IN_VIEW_PORT; 9563 9564 } 9565 return tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_ABOVE_VIEW_PORT; 9566 }, 9567 9568 9569 /** 9570 * - check the sorted tdAnimationStack.items and move them into the _items_above_view_port array or into the _items_in_view_port 9571 * - the remaining items are kept by the tdAnimationStack.items for next processing 9572 * @private 9573 */ 9574 _separate_items: function() { 9575 if ( 0 === tdAnimationStack.items.length ) { 9576 return; 9577 } 9578 9579 while ( tdAnimationStack.items.length > 0 ) { 9580 var item_to_view_port = tdAnimationStack._item_to_view_port( tdAnimationStack.items[ 0 ] ); 9581 9582 switch ( item_to_view_port ) { 9583 case tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_ABOVE_VIEW_PORT : 9584 tdAnimationStack._items_above_view_port.push( tdAnimationStack.items.shift() ); 9585 break; 9586 9587 case tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_IN_VIEW_PORT : 9588 tdAnimationStack._items_in_view_port.push( tdAnimationStack.items.shift() ); 9589 break; 9590 9591 case tdAnimationStack._ITEM_TO_VIEW_PORT.ITEM_UNDER_VIEW_PORT : 9592 tdAnimationStack.log( 'after separation items >> above: ' + tdAnimationStack._items_above_view_port.length + ' in: ' + tdAnimationStack._items_in_view_port.length + ' under: ' + tdAnimationStack.items.length ); 9593 return; 9594 } 9595 } 9596 }, 9597 9598 9599 /** 9600 * - scroll event usually called by tdCustomEvents 9601 */ 9602 td_events_scroll: function() { 9603 tdAnimationStack.compute_items(); 9604 }, 9605 9606 9607 9608 /** 9609 * - resize event usually called by tdCustomEvents 9610 */ 9611 td_events_resize: function() { 9612 // clear an existing interval 9613 clearInterval( tdAnimationStack._current_interval ); 9614 9615 // reinitialize tdAnimationStack searching in page for not already animated items [which were already repositioned by resize] 9616 tdAnimationStack.reinit(); 9617 }, 9618 9619 9620 9621 log: function( msg ) { 9622 //console.log(msg); 9623 } 9624 9625 }; 9626})(); 9627 9628/* global jQuery:{} */ 9629/* global tdSmartSidebar:{} */ 9630/* global tdUtil:{} */ 9631/* global tdDetect:{} */ 9632/* global tdPullDown:{} */ 9633/* global tdAnimationScroll:{} */ 9634/* global tdAnimationStack:{} */ 9635/* global tdEvents:{} */ 9636/* global tdAffix:{} */ 9637 9638'use strict'; 9639 9640/** 9641 * affix menu 9642 */ 9643tdAffix.init({ 9644 menu_selector: '.td-header-menu-wrap', 9645 menu_wrap_selector: '.td-header-menu-wrap-full', 9646 tds_snap_menu: tdUtil.getBackendVar('tds_snap_menu'), 9647 tds_snap_menu_logo: tdUtil.getBackendVar('tds_logo_on_sticky'), 9648 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 9649 menu_affix_height_on_mobile: 54 9650}); 9651 9652 9653 9654/** 9655 * sidebar init 9656 */ 9657if (tdUtil.getBackendVar('tds_smart_sidebar') == 'enabled' && tdDetect.isIos === false) { 9658 jQuery(window).load(function() { 9659 // find the rows and the sidebars objects and add them to the magic sidebar object array 9660 jQuery('.td-ss-row').each(function () { 9661 //@todo check to see if the sidebar + content is pressent 9662 var td_smart_sidebar_item = new tdSmartSidebar.item(); 9663 td_smart_sidebar_item.sidebar_jquery_obj = jQuery(this).children('.td-pb-span4').children('.wpb_wrapper'); 9664 td_smart_sidebar_item.content_jquery_obj = jQuery(this).children('.td-pb-span8').children('.wpb_wrapper'); 9665 tdSmartSidebar.add_item(td_smart_sidebar_item); 9666 }); 9667 9668 9669 9670 // check the page to see if we have smart sidebar classes (.td-ss-main-content and .td-ss-main-sidebar) 9671 if (jQuery('.td-ss-main-content').length > 0 && jQuery('.td-ss-main-sidebar').length > 0) { 9672 var td_smart_sidebar_item = new tdSmartSidebar.item(); 9673 td_smart_sidebar_item.sidebar_jquery_obj = jQuery('.td-ss-main-sidebar'); 9674 td_smart_sidebar_item.content_jquery_obj = jQuery('.td-ss-main-content'); 9675 tdSmartSidebar.add_item(td_smart_sidebar_item); 9676 } 9677 9678 tdSmartSidebar.td_events_resize(); 9679 });
9680} 9681 9682 9683/** 9684 * pulldown lists 9685 * 9686 */ 9687 9688// block subcategory ajax filters! 9689jQuery('.td-subcat-filter').each(function(index, element) { 9690 var jquery_object_container = jQuery(element); 9691 var horizontal_jquery_obj = jquery_object_container.find('.td-subcat-list:first'); 9692 9693 var pulldown_item_obj = new tdPullDown.item(); 9694 pulldown_item_obj.blockUid = jquery_object_container.parent().data('td-block-uid'); // get the block UID 9695 pulldown_item_obj.horizontal_jquery_obj = horizontal_jquery_obj; 9696 pulldown_item_obj.vertical_jquery_obj = jquery_object_container.find('.td-subcat-dropdown:first'); 9697 pulldown_item_obj.horizontal_element_css_class = 'td-subcat-item'; 9698 pulldown_item_obj.container_jquery_obj = horizontal_jquery_obj.parents('.td_block_wrap:first'); 9699 pulldown_item_obj.excluded_jquery_elements = [horizontal_jquery_obj.parent().siblings('.block-title:first')]; 9700 tdPullDown.add_item(pulldown_item_obj); 9701}); 9702 9703 9704// on category pages 9705jQuery('.td-category-siblings').each(function(index, element) { 9706 var jquery_object_container = jQuery(element); 9707 var horizontal_jquery_obj = jquery_object_container.find('.td-category:first'); 9708 9709 var pulldown_item_obj = new tdPullDown.item(); 9710 pulldown_item_obj.horizontal_jquery_obj = horizontal_jquery_obj; 9711 pulldown_item_obj.vertical_jquery_obj = jquery_object_container.find('.td-subcat-dropdown:first'); 9712 pulldown_item_obj.horizontal_element_css_class = 'entry-category'; 9713 pulldown_item_obj.container_jquery_obj = horizontal_jquery_obj.parents('.td-category-siblings:first'); 9714 tdPullDown.add_item(pulldown_item_obj); 9715 9716}); 9717 9718 9719 9720 9721 9722/** 9723 * parallax effect 9724 */ 9725 9726// array keeping the tdAnimationScroll.item items used for backstretch 9727var td_backstretch_items = []; 9728 9729 9730jQuery(window).ready(function() { 9731 9732 jQuery('.td-backstretch').each(function (index, element) { 9733 9734 if (!jQuery(element).hasClass('not-parallax')) { 9735 9736 var item = new tdAnimationScroll.item(); 9737 item.jqueryObj = jQuery(element); 9738 item.wrapper_jquery_obj = item.jqueryObj.parent(); 9739 9740 // - ideal translation is when the top of wrapper_jquery_obj is at the top of the view port, the jqueryObj image 9741 // is also already translated at the top of the view port 9742 // - the start_value should be item.wrapper_jquery_obj.offset().top + how much the jqueryObj was translated 9743 9744 tdAnimationScroll.add_item(item); 9745 9746 // we keep the tdAnimationScroll.item to change operation settings when the viewport is changing 9747 td_backstretch_items.push(item); 9748 9749 td_compute_backstretch_item(item); 9750 } 9751 }); 9752 9753 9754 jQuery('.td-parallax-header').each(function (index, element) { 9755 9756 var item = new tdAnimationScroll.item(); 9757 item.jqueryObj = jQuery(element); 9758 9759 item.add_item_property('move_y', 50, 100, 0, 100, ''); 9760 item.add_item_property('opacity', 50, 100, 1, 0, ''); 9761 9762 item.animation_callback = function () { 9763 9764 var move_y_property = parseFloat(item.computed_item_properties['move_y']).toFixed(); 9765 var opacity_property = parseFloat(item.computed_item_properties['opacity']); 9766 9767 item.jqueryObj.css({ 9768 '-webkit-transform': 'translate3d(0px,' + move_y_property + 'px, 0px)', 9769 'transform': 'translate3d(0px,' + move_y_property + 'px, 0px)' 9770 }); 9771 9772 item.jqueryObj.css('transform', 'translate3d(0px,' + move_y_property + 'px, 0px)'); 9773 9774 item.jqueryObj.css('opacity', opacity_property); 9775 9776 item.redraw = false; 9777 } 9778 9779 tdAnimationScroll.add_item(item); 9780 }); 9781 9782 9783 tdAnimationScroll.compute_all_items(); 9784 9785 9786 9787 9788 // load animation stack 9789 tdAnimationStack.ready_init(); 9790}); 9791 9792 9793 9794 9795/** 9796 * Function used to register the 'move_y' property for every td_animations_scroll.item item of the td_backstretch_items array. 9797 * It scales the object image and translate it. At first it is translated so its bottom is at the bottom of the viewport, 9798 * but considering the backstretch css classes applied 9799 * 9800 * @param item tdAnimationScroll.item 9801 */ 9802function td_compute_backstretch_item(item) { 9803 9804 // Important! The following variables must be computed after add_item calling function, because they need item.full_height, item.offset_top, etc 9805 9806 // percent when the object is in initial position 9807 // Important! It doesn't matter if the document is scrolled
9808 var initial_percent = (tdEvents.window_innerHeight - item.offset_top) * 100 / (tdEvents.window_innerHeight + item.full_height); 9809 9810 // percent when the object has its top at the top of the window 9811 var intermediary_top_percent = (tdEvents.window_innerHeight) * 100 / (tdEvents.window_innerHeight + item.full_height); 9812 9813 9814 // IMPORTANT! We suppose the item.offset_top is positive 9815 9816 9817 // the value used to compute the scale_factor 9818 // Important! It can be any value 9819 var scale_seed = item.offset_top / 4; 9820 9821 // if item.offset_top is zero, we set the scale_seed at a custom value 9822 if (scale_seed == 0) { 9823 scale_seed = 100; 9824 } 9825 9826 // 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 9827 var start_value = - scale_seed / 2; 9828 9829 9830 // 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 9831 // and so we are sure the object is not translated more than needed when is at the top of the window 9832 // 9833 // 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. 9834 // 9835 //var end_value = ((100 - initial_percent) * scale_seed) / (intermediary_top_percent - initial_percent);; 9836 // 9837 //or actually 9838 // 9839 //var end_value = ((100 - initial_percent) * (item.offset_top / 2)) / (intermediary_top_percent - initial_percent);; 9840 9841 var end_value = ((100 - initial_percent) * (scale_seed / 1.2)) / (intermediary_top_percent - initial_percent); 9842 9843 // fix for firefox. It rounds up and loose 1 pixel 9844 start_value += 0.5; 9845 9846 9847 // if there already exists a 'move_y' property, it is removed 9848 item.remove_item_property('move_y'); 9849 9850 item.add_item_property('move_y', initial_percent, 100, start_value, end_value, ''); 9851 9852 9853 var scale_factor = parseFloat(1 + Math.abs(scale_seed) / item.full_height).toFixed(2); 9854 9855 9856 // if there's already registered an 'animation_callback' function, it is removed 9857 delete item.animation_callback; 9858 9859 item.animation_callback = function () { 9860 9861 var property_value = parseFloat(item.computed_item_properties['move_y']).toFixed(); 9862 9863 item.jqueryObj.css({ 9864 'left': '50%', 9865 '-webkit-transform': 'translate3d(-50%,' + property_value + 'px, 0px) scale(' + scale_factor + ',' + scale_factor + ')', 9866 'transform': 'translate3d(-50%,' + property_value + 'px, 0px) scale(' + scale_factor + ',' + scale_factor + ')' 9867 }); 9868 9869 item.redraw = false; 9870 }; 9871} 9872 9873/** 9874 * Created by ra on 8/12/2015. 9875 */ 9876 9877/* global jQuery:false */ 9878/* global tdInfiniteLoader:false */ 9879/* global tdAnimationStack:{} */ 9880/* global tdSmartSidebar:false */ 9881/* global tdLoadingBox:{} */ 9882/* global tds_theme_color_site_wide:string */ 9883 9884 9885/* global td_ajax_url:false */ 9886 9887/** 9888 * tdAjaxLoop.init() is called from: @see includes/wp_booster/td_page_generator::render_infinite_pagination 9889 */ 9890var tdAjaxLoop = {}; 9891 9892(function () { 9893 'use strict'; 9894 9895 tdAjaxLoop = { 9896 loopState: { 9897 'sidebarPosition': '', 9898 'moduleId': 1, 9899 'currentPage': 1, 9900 'max_num_pages': 0, 9901 'atts' : {}, 9902 'ajax_pagination_infinite_stop' : 0, 9903 'server_reply_html_data': '' 9904 }, 9905 9906 9907 /** 9908 * tdAjaxLoop.init() is called from: @see includes/wp_booster/td_page_generator::render_infinite_pagination 9909 * only when needed 9910 */ 9911 init: function () { 9912 jQuery('.td-ajax-loop-infinite').each( function() { 9913 // create a new infinite loader item 9914 var tdInfiniteLoaderItem = new tdInfiniteLoader.item(); 9915 9916 tdInfiniteLoaderItem.jqueryObj = jQuery(this); 9917 tdInfiniteLoaderItem.uid = 'tdAjaxLoop'; 9918 9919 9920 /** 9921 * the callback when the bottom of the element is visible on screen and we need to do something - like load another page 9922 * - the callback does not fire again until tdInfiniteLoader.enable_is_visible_c
9922allback is called @see tdInfiniteLoader.js:95 9923 */ 9924 tdInfiniteLoaderItem.isVisibleCallback = function () { // the is_visible callback is called when we have to pull new content up because the element is visible 9925 9926 if ( 9927 0 !== tdAjaxLoop.loopState.ajax_pagination_infinite_stop && 9928 tdAjaxLoop.loopState.currentPage >= tdAjaxLoop.loopState.ajax_pagination_infinite_stop && 9929 tdAjaxLoop.loopState.currentPage + 1 < tdAjaxLoop.loopState.max_num_pages // do we have a next page? 9930 ) { 9931 // stop the callback and show the load more button 9932 jQuery('.td-load-more-infinite-wrap') 9933 .css('display', 'block') 9934 .css('visibility', 'visible') 9935 ; 9936 9937 } else { 9938 // load up the next page 9939 tdAjaxLoop.infiniteNextPage(false); 9940 } 9941 }; 9942 tdInfiniteLoader.addItem(tdInfiniteLoaderItem); 9943 }); 9944 9945 9946 // click on load more - the button should not be visible only when the ajax_pagination_infinite_stop limit is reached 9947 jQuery('.td-load-more-infinite-wrap').click(function(event) { 9948 event.preventDefault(); 9949 9950 9951 jQuery('.td-load-more-infinite-wrap').css('visibility', 'hidden'); 9952 9953 tdAjaxLoop.infiniteNextPage(true); 9954 }); 9955 }, 9956 9957 9958 infiniteNextPage: function (isLoadMoreButton) { 9959 9960 // prepare the request object 9961 tdAjaxLoop.loopState.currentPage++ ; 9962 tdAjaxLoop.loopState.server_reply_html_data = ''; 9963 9964 // check here to avoid making an unnecessary ajax request when using infinite loading without button 9965 if ( tdAjaxLoop.loopState.currentPage > tdAjaxLoop.loopState.max_num_pages ) { 9966 //console.log('END' + tdAjaxLoop.loopState.currentPage + ' max: ' + tdAjaxLoop.loopState.max_num_pages); 9967 return; 9968 } 9969 9970 9971 9972 jQuery('.td-ss-main-content').append('<div class="td-loader-gif td-loader-infinite td-loader-animation-start"></div>'); 9973 tdLoadingBox.init(tds_theme_color_site_wide, 45); //init the loading box 9974 setTimeout(function () { 9975 jQuery('.td-loader-gif') 9976 .removeClass('td-loader-animation-start') 9977 .addClass('td-loader-animation-mid'); 9978 }, 50); 9979 9980 9981 var requestData = { 9982 action: 'td_ajax_loop', 9983 loopState: tdAjaxLoop.loopState 9984 }; 9985 9986 //console.log('request:'); 9987 //console.log(tdAjaxLoop.loopState); 9988 jQuery.ajax({ 9989 type: 'POST', 9990 url: td_ajax_url, 9991 cache:true, 9992 data: requestData, 9993 success: function(data, textStatus, XMLHttpRequest) { 9994 tdAjaxLoop._processAjaxRequest(data, isLoadMoreButton); 9995 }, 9996 error: function(MLHttpRequest, textStatus, errorThrown) { 9997 //console.log(errorThrown); 9998 } 9999 }); 10000 }, 10001 10002 _processAjaxRequest: function (data, isLoadMoreButton) { 10003 // stop the loader 10004 jQuery('.td-loader-gif').remove(); 10005 tdLoadingBox.stop(); 10006 10007 var dataObj = jQuery.parseJSON(data); 10008 10009 10010 10011 // empty reply - stop everything 10012 if ( '' === dataObj.server_reply_html_data ) { 10013 jQuery('.td-load-more-infinite-wrap').css('visibility', 'hidden'); 10014 return; 10015 } 10016 10017 10018 /** 10019 * @var {tdAjaxLoop.loopState} 10020 */ 10021 10022 jQuery('.td-ajax-loop-infinite').before(dataObj.server_reply_html_data); 10023 10024 //console.log('reply:'); 10025 //console.log(dataObj); 10026 10027 if ( parseInt( dataObj.currentPage ) >= parseInt(dataObj.max_num_pages) ) { 10028 jQuery('.td-load-more-infinite-wrap').css('visibility', 'hidden'); 10029 } else { 10030 if ( true === isLoadMoreButton ) { 10031 jQuery('.td-load-more-infinite-wrap').css('visibility', 'visible'); 10032 } 10033 } 10034 10035 setTimeout( function () { 10036 tdAnimationStack.check_for_new_items('.td-main-content' + ' .td-animation-stack', tdAnimationStack.SORTED_METHOD.sort_left_to_right, true); 10037 //tdSmartSidebar.compute(); 10038 }, 200); 10039 10040 10041 // on load more button, we don't have to compute the infinite loader event 10042 if ( true === isLoadMoreButton ) { 10043 return; 10044 } 10045 10046 setTimeout( function() { 10047 //refresh waypoints for infinit scroll tdInfiniteLoader 10048 tdInfiniteLoader.computeTopDistances();
10049 tdInfiniteLoader.enable_is_visible_callback('tdAjaxLoop'); 10050 //tdSmartSidebar.compute(); 10051 }, 500); 10052 10053 10054 setTimeout( function() { 10055 tdInfiniteLoader.computeTopDistances(); 10056 }, 1000); 10057 10058 setTimeout( function() { 10059 tdInfiniteLoader.computeTopDistances(); 10060 }, 1500); 10061 10062 } 10063 }; 10064 10065})(); 10066/** 10067 * Created by ra on 9/30/2015. 10068 */ 10069 10070/* 10071 tdWeather.js 10072 v1.0 10073 */ 10074/* global jQuery:false */ 10075/* global tdDetect:false */ 10076/* global tdUtil:false */ 10077/* global alert:false */ 10078/* global tdLocalCache:false */ 10079 10080 10081 10082 10083var tdWeather = {}; 10084 10085( function(){ 10086 "use strict"; 10087 10088 tdWeather = { 10089 10090 // used to translate the OWM code to icon 10091 _icons: { 10092 // day 10093 '01d' : 'clear-sky-d', 10094 '02d' : 'few-clouds-d', 10095 '03d' : 'scattered-clouds-d', 10096 '04d' : 'broken-clouds-d', 10097 '09d' : 'shower-rain-d', // ploaie hardcore 10098 '10d' : 'rain-d', // ploaie light 10099 '11d' : 'thunderstorm-d', 10100 '13d' : 'snow-d', 10101 '50d' : 'mist-d', 10102 10103 //night: 10104 '01n' : 'clear-sky-n', 10105 '02n' : 'few-clouds-n', 10106 '03n' : 'scattered-clouds-n', 10107 '04n' : 'broken-clouds-n', 10108 '09n' : 'shower-rain-n', // ploaie hardcore 10109 '10n' : 'rain-n', // ploaie light 10110 '11n' : 'thunderstorm-n', 10111 '13n' : 'snow-n', 10112 '50n' : 'mist-n' 10113 }, 10114 10115 _currentRequestInProgress: false, // prevent multiple parallel requests 10116 _currentItem: '', // current weather object, it is set on click and after we modify it, it will be displayed 10117 10118 // latitude and longitude position, used in callback hell 10119 _currentLatitude: 0, 10120 _currentLongitude: 0, 10121 _currentPositionCacheKey: '', 10122 10123 // all the weather items 10124 items: [], /** an item is json encoded from this in PHP: @see td_weather::$weather_data */ 10125 10126 10127 10128 /** 10129 * Init the class, we hook the click event 10130 */ 10131 init: function () { 10132 10133 // weather location button click 10134 jQuery('.td-icons-location').click(function() { 10135 if (tdWeather._currentRequestInProgress === true) { 10136 return; 10137 } 10138 tdWeather._currentRequestInProgress = true; 10139 10140 // get the block id 10141 tdWeather._currentItem = tdWeather._getItemByBlockID(jQuery(this).data('block-uid')); 10142 10143 // get the position + callback 10144 var timeoutVal = 10 * 1000 * 1000; 10145 if (navigator.geolocation) { 10146 navigator.geolocation.getCurrentPosition(tdWeather._updateLocationCallback, tdWeather._displayLocationApiError, {enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 600000}); 10147 } 10148 10149 tdWeather._currentRequestInProgress = false; 10150 10151 }); 10152 10153 jQuery('.td-weather-now').click(function(){ 10154 if (tdWeather._currentRequestInProgress === true) { 10155 return; 10156 } 10157 tdWeather._currentRequestInProgress = true; 10158 10159 // get the block id 10160 tdWeather._currentItem = tdWeather._getItemByBlockID(jQuery(this).data('block-uid')); 10161 10162 if (tdWeather._currentItem.current_unit === 1) { 10163 tdWeather._currentItem.current_unit = 0; 10164 } else { 10165 tdWeather._currentItem.current_unit = 1; 10166 } 10167 tdWeather._renderCurrentItem(); 10168 }); 10169 }, 10170 10171 10172 /** 10173 * adds a new weather item 10174 * item.block_uid is REQUIERED, based on that id, we delete the item from the array *as of 27.4.2016 the id is not used 10175 * @param item object - an item is json encoded from this in PHP: @see td_weather::$weather_data 10176 */ 10177 addItem: function (item) { 10178 tdWeather.items.push(item); 10179 }, 10180 10181 /// 10182 // For now it's not needed because td_weater.php does not add js if it detects td-composer 10183 // ** 10184 // * Deletes an item base on blockUid. 10185 // * Make sure that you add block_uid to items that you expect to be deleted 10186 // * @param blockUid 10187 // */ 10188 //deleteItem: function(blockUid) { 10189 // for (var cnt = 0; cnt < tdWeather.items.length; cnt++) { 10190 // if (tdWeather.items[cnt].block_uid === blockUid) { 10191 // tdWeather.items.splice(cnt, 1); // remove the item from the "array" 10192 // return true; 10193 // } 10194 // } 10195 // return false; 10196 //}, 10197 10198 10199 /** 10200 * 1. LOCATION api - position callback 10201 * @param position 10202 * @private 10203 */ 10204 _updateLocationCallback: function(position) { 10205 tdWeather._currentLatitude = position.coords.latitude; 10206 tdWeather._currentLongitude = position.coords.longitude; 10207 tdWeather._currentPositionCacheKey = position.coords.latitude + '_' + position.coords.longitude; // update the cache key for current position 10208 10209 // check the cache first and avoid doing the same ajax request again 10210 if (tdLocalCache.exist(tdWeather._currentPositionCacheKey + '_today')) { 10211 tdWeather._owmGetTodayDataCallback(tdLocalCache.get(tdWeather._currentPositionCacheKey + '_today')); 10212 } else { 10213 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; 10214 jQuery.ajax({ 10215 dataType: "jsonp", 10216 url: weather, 10217 success: tdWeather._owmGetTodayDataCallback, 10218 cache: true 10219 }); 10220 } 10221 10222 //alert(position.coords.latitude + ' ' + position.coords.longitude); 10223 10224 }, 10225 10226 10227 /** 10228 * 2. AJAX callback for today forecast, this also makes a call to ajax 5 days forecast 10229 * @param data - OWM api response - NOTICE: We don't check anything if it's correct :) 10230 * @private 10231 */ 10232 _owmGetTodayDataCallback: function (data) { 10233 // save the data to localCache 10234 tdLocalCache.set(tdWeather._currentPositionCacheKey + '_today', data); 10235 10236 10237 // prepare the tdWeather._currentItem object, notice that tdWeather._currentItem is a reference to an object stored in tdWeather.items 10238 tdWeather._currentItem.api_location = data.name; 10239 tdWeather._currentItem.today_clouds = tdUtil.round(data.clouds.all); 10240 tdWeather._currentItem.today_humidity = tdUtil.round(data.main.humidity); 10241 tdWeather._currentItem.today_icon = tdWeather._icons[data.weather[0].icon]; 10242 tdWeather._currentItem.today_icon_text = data.weather[0].description; 10243 tdWeather._currentItem.today_max[0] = tdUtil.round(data.main.temp_max, 1); //celsius 10244 tdWeather._currentItem.today_max[1] = tdWeather._celsiusToFahrenheit(data.main.temp_max); //imperial 10245 tdWeather._currentItem.today_min[0] = tdUtil.round(data.main.temp_min, 1); //celsius 10246 tdWeather._currentItem.today_min[1] = tdWeather._celsiusToFahrenheit(data.main.temp_min); //imperial 10247 tdWeather._currentItem.today_temp[0] = tdUtil.round(data.main.temp, 1); //celsius 10248 tdWeather._currentItem.today_temp[1] = tdWeather._celsiusToFahrenheit(data.main.temp); //imperial 10249 tdWeather._currentItem.today_wind_speed[0] = tdUtil.round(data.wind.speed, 1); //metric 10250 tdWeather._currentItem.today_wind_speed[1] = tdWeather._kmphToMph(data.wind.speed); //imperial 10251 10252 //console.log(tdWeather._currentItem); 10253 //console.log(data); 10254 10255 // check the cache first and avoid doing the same ajax request again 10256 if (tdLocalCache.exist(tdWeather._currentPositionCacheKey)) { 10257 tdWeather._owmGetFiveDaysData(tdLocalCache.get(tdWeather._currentPositionCacheKey)); 10258 } else { 10259 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; 10260 jQuery.ajax({ 10261 dataType: "jsonp", 10262 url: weather, 10263 success: tdWeather._owmGetFiveDaysData, 10264 cache:true 10265 }); 10266 } 10267 10268 }, 10269 10270 10271 /** 10272 * 3. AJAX callback for the 5 days forecast 10273 * @param data - OWM api response NOTICE: We don't check anything if it's correct :) 10274 * @private 10275 */ 10276 _owmGetFiveDaysData: function (data) { 10277 // save the data to localCache 10278 tdLocalCache.set(tdWeather._currentPositionCacheKey, data); 10279 10280 // process the data 10281 for (var item_index = 0; item_index < tdWeather._currentItem.forecast.length ; item_index++) { 10282 var current_forecast = tdWeather._currentItem.forecast[item_index]; 10283 current_forecast.day_temp[0] = tdUtil.round(data.list[current_forecast.owm_day_index].temp.day); //celsius 10284 current_forecast.day_temp[1] = tdWeather._celsiusToFahrenheit(current_forecast.day_temp[0]); //imperial 10285 } 10286 tdWeather._renderCurrentItem(); 10287 }, 10288 10289 10290 /** 10291 * 4. Here we render the global tdWeather._currentItem object to the screen. The object already contains all the needed information 10292 * about where and what we have to render. 10293 * @private 10294 */ 10295 _renderCurrentItem: function () { 10296 10297 //console.log('.' + tdWeather._currentItem.block_uid + ' .td-weather-city'); 10298 10299 var blockInner = jQuery('#' + tdWeather._currentItem.block_uid); 10300 10301 // city 10302 blockInner.find('.td-weather-city').html(tdWeather._currentItem.api_location); 10303 10304 // conditions 10305 blockInner.find('.td-weather-condition').html(tdWeather._currentItem.today_icon_text); 10306 10307 // animation 10308 // we remove all the classes! including the animation ones 10309 var icon_el = blockInner.find('.td-w-today-icon'); 10310 icon_el.removeClass(); 10311 icon_el.addClass('td-w-today-icon'); 10312 icon_el.addClass(tdWeather._currentItem.today_icon); 10313 10314 var currentTempUnit = tdWeather._currentItem.current_unit; 10315 var currentSpeedLabel = 'kmh'; 10316 var currentTempLabel = 'C'; 10317 10318 // preapare the labels 10319 if (currentTempUnit === 1) { 10320 currentSpeedLabel = 'mph'; 10321 currentTempLabel = 'F'; 10322 } 10323 10324 10325 // main temp 10326 blockInner.find('.td-big-degrees').html(tdWeather._currentItem.today_temp[currentTempUnit]); 10327 10328 // main temp units 10329 blockInner.find('.td-weather-unit').html(currentTempLabel); 10330 10331 10332 // high 10333 blockInner.find('.td-w-high-temp').html(tdWeather._currentItem.today_max[currentTempUnit]); 10334 10335 // low 10336 blockInner.find('.td-w-low-temp').html(tdWeather._currentItem.today_min[currentTempUnit]); 10337 10338 // humidity 10339 blockInner.find('.td-w-today-humidity').html(tdWeather._currentItem.today_humidity + '%'); 10340 10341 // wind speed 10342 blockInner.find('.td-w-today-wind-speed').html(tdWeather._currentItem.today_wind_speed[currentTempUnit] + currentSpeedLabel); 10343 10344 // clouds 10345 blockInner.find('.td-w-today-clouds').html(tdWeather._currentItem.today_clouds + '%'); 10346 10347 // full list of items! - just the temperature 10348 for (var item_index = 0; item_index < tdWeather._currentItem.forecast.length ; item_index++) { 10349 blockInner.find('.td-degrees-' + item_index).html(tdWeather._currentItem.forecast[item_index].day_temp[currentTempUnit]); 10350 } 10351 10352 10353 tdWeather._currentRequestInProgress = false; // allow other requests to take place 10354 }, 10355 10356 10357 /** 10358 * gets a weather item based on block_uid 10359 * @param block_uid 10360 * @returns {*} 10361 * @private 10362 */ 10363 _getItemByBlockID: function (block_uid) { 10364 for (var item_index = 0; item_index < tdWeather.items.length; item_index++) { 10365 if (tdWeather.items[item_index].block_uid === block_uid) { 10366 return tdWeather.items[item_index]; 10367 } 10368 } 10369 return false; 10370 }, 10371 10372 10373 /**
10374 * Displays a friendly error when the location api fails 10375 * @param error - a location api error object? 10376 * @private 10377 */ 10378 _displayLocationApiError: function (error) { 10379 10380 if (error.code === 1) { 10381 if (tdDetect.isAndroid) { 10382 alert('Please enable your gps and reload the page.'); 10383 return; 10384 } 10385 10386 else if (tdDetect.isIos) { 10387 alert("Please enable Location services for Safari Websites and reload the page. \n ---------------------- \nSettings > Privacy > Location Services"); 10388 return; 10389 } 10390 10391 10392 alert("Permission denied. Enable GPS or Location services and reload the page"); 10393 return; 10394 10395 } 10396 10397 // the rest of the errors 10398 var errors = { 10399 2: 'Position unavailable', 10400 3: 'Request timeout' 10401 }; 10402 alert("Error: " + errors[error.code]); 10403 }, 10404 10405 10406 /** 10407 * C to F converter. It rounds on big F numbers because we don't have space on the UI. 10408 * @param celsiusDegrees 10409 * @returns {*} 10410 * @private 10411 */ 10412 _celsiusToFahrenheit: function (celsiusDegrees) { 10413 var f_degrees = celsiusDegrees * 9 / 5 + 32; 10414 10415 var rounded_val = tdUtil.round(f_degrees, 1); 10416 if (rounded_val > 99.9) { // if the value is bigger than 100, round it 10417 return tdUtil.round(f_degrees); 10418 } 10419 10420 return rounded_val; 10421 }, 10422 10423 /** 10424 * converter for KMH -> MPH ex: 2.3 10425 * @param $kmph 10426 * @returns {*} 10427 * @private 10428 */ 10429 _kmphToMph: function ($kmph) { 10430 return tdUtil.round($kmph * 0.621371192, 1); 10431 } 10432 10433 }; // end tdWeather 10434})(); 10435 10436tdWeather.init(); //init the class 10437/* global jQuery:{} */ 10438/* global tdUtil:{} */ 10439/* global tdTrendingNowObject:{} */ 10440 10441jQuery( window ).load(function() { 10442 10443 'use strict'; 10444 10445 jQuery( 'body' ).addClass( 'td-js-loaded' ); 10446 10447 window.tdAnimationStack.init(); 10448}); 10449 10450jQuery( window ).ready(function() { 10451 10452 'use strict'; 10453 10454 /* 10455 - code used to allow external links from td_smart_list, when the Google Yoast "Track outbound click and downloads" is checked 10456 - internal links ("#with-hash") are allowed too 10457 - test the links on incognito, by default Google analytics by yoast ignores the Administrator and Editor users 10458 */ 10459 10460 jQuery( '.td_smart_list_1 a, .td_smart_list_3 a').click(function( event ) { 10461 if ( event.target === event.currentTarget ) { 10462 var targetAttributeContent = jQuery( this ).attr( 'target' ); 10463 var donwloadAttributeIsSet = jQuery( this )[0].hasAttribute( 'download' ); 10464 var currentUrl = jQuery( this ).attr( 'href' ); 10465 //if target is _blank open the link in a new window 10466 if (donwloadAttributeIsSet) { 10467 //link contains download attribute - do nothing, let it download 10468 } else if (targetAttributeContent == '_blank') { 10469 event.preventDefault(); 10470 window.open(currentUrl); 10471 } else { 10472 //regular links 10473 if (( window.location.href !== currentUrl ) && tdUtil.isValidUrl(currentUrl)) { 10474 window.location.href = currentUrl; 10475 } 10476 } 10477 } 10478 }); 10479 10480 //trending now 10481 tdTrendingNowObject.tdTrendingNow(); 10482 10483 //call to trending now function to start auto scroll 10484 tdTrendingNowObject.tdTrendingNowAutoStart(); 10485}); 10486 10487/** 10488 * Created by tagdiv on 29.09.2015. 10489 */ 10490 10491/* global jQuery:{} */ 10492 10493var tdAnimationSprite = {}; 10494 10495(function(){ 10496 'use strict'; 10497 10498 tdAnimationSprite = { 10499 10500 items: [], 10501 10502 // flag used to not call requestAnimationFrame until the previous requestAnimationFrame callback runs 10503 isInRequestAnimation: false, 10504 10505 10506 // The item that needs animation 10507 item: function item() { 10508 10509 10510 10511 // here we store the block Unique ID. This enables us to delete the item via this id @see tdPullDown.deleteItem 10512 this.blockUid = ''; 10513 10514 // boolean - an item must be initialized only once 10515 this._isInitialized = false; 10516 10517 // boolean - an item can be paused and restarted 10518 this.paused = false; 10519 10520 // boolean - the animation automatically starts at the computing item 10521 this.automatStart = true; 10522 10523 // object - css properties that will be changed (key - value; ex: 'color' : '#00FFCC') 10524 this.properties = []; 10525 10526 // boolean - flag used by the requestAnimationFrame callback to know which items have properties to apply 10527 this.readyToAnimate = false; 10528 10529 // the index of the current frame 10530 this.nextFrame = 1; 10531 10532 // number - the current interval id set for the animation 10533 this.interval = undefined; 10534 10535 // the jquery obj whose background will be animated 10536 this.jqueryObj = undefined; 10537 10538 // the css class selector of the jqueryObj 10539 this.animationSpriteClass = undefined; 10540 10541 // string - default direction for parsing the sprite img 10542 this._currentDirection = 'right'; 10543 10544 // number - the executed loops 10545 this._executedLoops = 0; 10546 10547 10548 // string - css background position 10549 this._prop_background_position = undefined; 10550 10551 10552 // The followings will be set from the class selector 10553 10554 // int - number of frames (it must be greater than 1 to allow animation) 10555 this.frames = undefined; 10556 10557 // the width(px) of a frame 10558 this.frameWidth = undefined; 10559 10560 // int - the interval time (ms) the animation runs 10561 this.velocity = undefined; 10562 10563 // boolean - to the right and vice versa 10564 this.reverse = undefined; 10565 10566 // number - number of loops to animate 10567 this.loops = undefined; 10568 10569 10570 // Function actually compute the params for animation, prepare the params for next animation and calls t 10571 // he requestAnimationFrame with a callback function to animate all items ready for animation 10572 this.animate = function() { 10573 10574 this._prop_background_position = ( -1 * this.nextFrame * this.frameWidth ) + 'px 0'; 10575 this.readyToAnimate = true; 10576 10577 10578 // The nextFrame value is computed for next frame 10579 if ( true === this.reverse) { 10580 10581 if ( 'right' === this._currentDirection ) { 10582 10583 if ( this.nextFrame === this.frames - 1 ) { 10584 this._currentDirection = 'left'; 10585 this.nextFrame--; 10586 } else { 10587 this.nextFrame++; 10588 } 10589 10590 } else if ( 'left' === this._currentDirection ) { 10591 if ( 0 === this.nextFrame ) { 10592 10593 this._currentDirection = 'right'; 10594 this.nextFrame++; 10595 this._executedLoops++; 10596 10597 if ( ( 0 !== this.loops ) && ( this._executedLoops === this.loops ) ) { 10598 clearInterval( this.interval ); 10599 } 10600 } else { 10601 this.nextFrame--; 10602 } 10603 } 10604 10605 } else { 10606 10607 if ( this.nextFrame === this.frames - 1 ) { 10608 10609 this._executedLoops++; 10610 10611 // complete tour ( once to the right ), so we stop 10612 if ( ( 0 !== this.loops ) && ( this._executedLoops === this.loops ) ) { 10613 clearInterval( this.interval ); 10614 } 10615 10616 this.nextFrame = 0; 10617 } else { 10618 this.nextFrame++; 10619 } 10620 } 10621 10622 10623 //this.jqueryObj.css('background-position', horizontalPosition + 'px 0'); 10624 10625 // Any calls to requestAnimationFrame are stopped. Anyway, the settings of the current item are ready, 10626 // so the callback will consider it. 10627 if ( false === tdAnimationSprite.isInRequestAnimation ) { 10628 tdAnimationSprite.isInRequestAnimation = true; 10629 window.requestAnimationFrame( tdAnimationSprite.animateAllItems ); 10630 } 10631 }; 10632 }, 10633 10634 /** 10635 * The css class selector must be some like this 'td_animation_sprite-10-50-500-0-1-1' 10636 * It must start with 'td_animation_sprite' 10637 * Fields order: 10638 * - number of frames 10639 * - width of a frame 10640 * - velocity in ms 10641 * - loops (number) : reload the animation cycle at infinity or specify the number of loops 10642 * - reverse (0 or 1) : the loop include, or not, the reverse path 10643 * - automatstart (0 or 1) : the item animation starts, or not, automatically 10644 * 10645 * @param item 10646 * @private 10647 */ 10648 _initializeItem: function( item ) { 10649 if ( ( true === item._isInitialized ) ) { 10650 return; 10651 } 10652 10653 // get all strings containing 'td_animation_sprite' 10654 var regex = /(td_animation_sprite\S*)/gi; 10655 10656 // resultMatch is an array of matches, or null if there's no matching 10657 var resultMatch = item.jqueryObj.attr( 'class' ).match( regex ); 10658 10659 if ( null !== resultMatch ) { 10660 10661 item.offsetTop = item.jqueryObj.offset().top; 10662 item.offsetBottomToTop = item.offsetTop + item.jqueryObj.height(); 10663 10664 // the last matching is considered, because new css classes that matches, can be added before recomputing an item 10665 item.animationSpriteClass = resultMatch[ resultMatch.length - 1 ]; 10666 10667 var sceneParams = item.animationSpriteClass.split( '-' ); 10668
10669 if ( 7 === sceneParams.length ) { 10670 10671 item.frames = parseInt( sceneParams[1] ); 10672 item.frameWidth = parseInt( sceneParams[2] ); 10673 item.velocity = parseInt( sceneParams[3] ); 10674 item.loops = parseInt( sceneParams[4] ); 10675 10676 if ( 1 === parseInt( sceneParams[5] ) ) { 10677 item.reverse = true; 10678 } else { 10679 item.reverse = false; 10680 } 10681 10682 if ( 1 === parseInt( sceneParams[6] ) ) { 10683 item.automatStart = true; 10684 } else { 10685 item.automatStart = false; 10686 } 10687 10688 item._isInitialized = true; 10689 } 10690 } 10691 }, 10692 10693 10694 10695 addItem: function( item ) { 10696 10697 if ( item.constructor === tdAnimationSprite.item ) { 10698 tdAnimationSprite.items.push( item ); 10699 tdAnimationSprite._initializeItem( item ); 10700 10701 if ( true === item.automatStart ) { 10702 tdAnimationSprite.computeItem( item ); 10703 } 10704 } 10705 }, 10706 10707 10708 /** 10709 * Deletes an item base on blockUid. 10710 * Make sure that you add blockUid to items that you expect to be deleted 10711 * @param blockUid 10712 */ 10713 deleteItem: function(blockUid) { 10714 for (var cnt = 0; cnt < tdAnimationSprite.items.length; cnt++) { 10715 if (tdAnimationSprite.items[cnt].blockUid === blockUid) { 10716 tdAnimationSprite.items.splice(cnt, 1); // remove the item from the "array" 10717 return true; 10718 } 10719 } 10720 return false; 10721 }, 10722 10723 computeItem: function( item ) { 10724 10725 // set interval just for frames greater than 1 10726 if ( item.frames > 1 ) { 10727 10728 // Check the item interval to not be set 10729 if ( undefined !== item.interval ) { 10730 return; 10731 } 10732 10733 item.interval = setInterval(function(){ 10734 10735 if ( false === item.paused ) { 10736 item.animate(); 10737 } 10738 10739 }, item.velocity ); 10740 } 10741 }, 10742 10743 // At recomputing, an item will check again its last css class selector and it is reinitialized. So, if a new 10744 // css class selector is added, it will use it. This way the animation can be modified 10745 recomputeItem: function( item ) { 10746 10747 // stop any animation 10748 clearInterval( item.interval ); 10749 10750 // reset the item interval 10751 item.interval = undefined; 10752 10753 // reset the _isInitialized flag 10754 item._isInitialized = false; 10755 10756 // reinitialize item 10757 tdAnimationSprite._initializeItem( item ); 10758 10759 // compute the item again 10760 tdAnimationSprite.computeItem( item ); 10761 }, 10762 10763 // Clear the interval set for an item. 10764 stopItem: function( item ) { 10765 if ( ( item.constructor === tdAnimationSprite.item ) && ( true === item._isInitialized ) ) { 10766 clearInterval( item.interval ); 10767 10768 // reset the item interval 10769 item.interval = undefined; 10770 } 10771 }, 10772 10773 // Start animation of a paused item 10774 startItem: function( item ) { 10775 if ( ( item.constructor === tdAnimationSprite.item ) && ( true === item._isInitialized ) ) { 10776 item.paused = false; 10777 } 10778 }, 10779 10780 // Pause animation of an item 10781 pauseItem: function( item ) { 10782 if ( ( item.constructor === tdAnimationSprite.item ) && ( true === item._isInitialized ) ) { 10783 item.paused = true; 10784 } 10785 }, 10786 10787 10788 10789 10790 computeAllItems: function() { 10791 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 10792 tdAnimationSprite.computeItem( tdAnimationSprite.items[i] ); 10793 } 10794 }, 10795 10796 recomputeAllItems: function() { 10797 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 10798 tdAnimationSprite.recomputeItem( tdAnimationSprite.items[i] ); 10799 } 10800 }, 10801 10802 stopAllItems: function() { 10803 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 10804 tdAnimationSprite.stopItem( tdAnimationSprite.items[i] ); 10805 } 10806 }, 10807 10808 pauseAllItems: function() { 10809 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 10810 tdAnimationSprite.pauseItem( tdAnimationSprite.items[i] ); 10811 } 10812 }, 10813 10814 startAllItems: function() { 10815 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 10816 tdAnimationSprite.startItem( tdAnimationSprite.items[i] ); 10817 } 10818 }, 10819 10820 10821 // The requestAnimationFrame callback function. 10822 // The 'background-position' is set and then the 'readyToAnimate' flag is set to false 10823 animateAllItems: function() { 10824 var currentItem; 10825 10826 for ( var i = 0; i < tdAnimationSprite.items.length; i++ ) { 10827 currentItem = tdAnimationSprite.items[i]; 10828 if ( true === currentItem.readyToAnimate ) { 10829 currentItem.jqueryObj.css( 'background-position', currentItem._prop_background_position ); 10830 currentItem.readyToAnimate = false; 10831 } 10832 } 10833 tdAnimationSprite.isInRequestAnimation = false; 10834 } 10835 }; 10836 10837 /* 10838 <div class="td_animation_sprite-a-b-c-d-e-f"></div> 10839 10840 @note - we should have used the data- html attribute here! 10841 10842 a - number of frames 10843 b - width(px) of a frame 10844 c - velocity 10845 d - loops number (0 for infinity) 10846 e - loop include reverse 10847 f - animation start automatically 10848 */ 10849 10850 var tdAnimationSpriteElements = jQuery( 'span[class^="td_animation_sprite"]' ); 10851 10852 for ( var i = 0; i < tdAnimationSpriteElements.length; i++ ) { 10853 var tdAnimationSpriteItem = new tdAnimationSprite.item(); 10854 10855 10856 tdAnimationSpriteItem.jqueryObj = jQuery( tdAnimationSpriteElements[i] ); 10857 tdAnimationSpriteItem.blockUid = tdAnimationSpriteItem.jqueryObj.data('td-block-uid'); // the block uid is used on the front end editor when we want to delete this item via it's blockuid 10858 tdAnimationSprite.addItem( tdAnimationSpriteItem ); 10859 } 10860})(); 10861 10862function td_date_i18n(format, timestamp) { 10863 // http://kevin.vanzonneveld.net 10864 // + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com) 10865 // + parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html) 10866 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 10867 // + improved by: MeEtc (http://yass.meetcweb.com) 10868 // + improved by: Brad Touesnard 10869 // + improved by: Tim Wiel 10870 // + improved by: Bryan Elliott 10871 // + improved by: David Randall 10872 // + input by: Brett Zamir (http://brett-zamir.me) 10873 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 10874 // + improved by: Theriault 10875 // + derived from: gettimeofday 10876 // + input by: majak 10877 // + bugfixed by: majak 10878 // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 10879 // + input by: Alex 10880 // + bugfixed by: Brett Zamir (http://brett-zamir.me) 10881 // + improved by: Theriault 10882 // + improved by: Brett Zamir (http://brett-zamir.me) 10883 // + improved by: Theriault 10884 // + improved by: Thomas Beaucourt (http://www.webapp.fr) 10885 // + improved by: JT 10886 // + improved by: Theriault 10887 // + improved by: RafaÅ Kukawski (http://blog.kukawski.pl) 10888 // + bugfixed by: omid (http://phpjs.org/functions/380:380#comment_137122) 10889 // + input by: Martin 10890 // + input by: Alex Wilson 10891 // + input by: Haravikk 10892 // + improved by: Theriault 10893 // + bugfixed by: Chris (http://www.devotis.nl/) 10894 // + improved by: Jari Pennanen (https://github.com/ciantic/) - date_i18n from WordPress 10895 // % note 1: Uses global: php_js to store the default timezone 10896 // % note 2: Although the function potentially allows timezone info (see notes), it currently does not set 10897 // % note 2: per a timezone specified by date_default_timezone_set(). Implementers might use 10898 // % note 2: this.php_js.currentTimezoneOffset and this.php_js.currentTimezoneDST set by that function 10899 // % note 2: in order to adjust the dates in this function (or our other date functions!) accordingly 10900 // * example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400); 10901 // * returns 1: '09:09:40 m is month' 10902 // * example 2: date('F j, Y, g:i a', 1062462400); 10903 // * returns 2: 'September 2, 2003, 2:26 am' 10904 // * example 3: date('Y W o', 1062462400); 10905 // * returns 3: '2003 36 2003' 10906 // * example 4: x = date('Y m d', (new Date()).getTime()/1000); 10907 // * example 4: (x+'').length == 10 // 2009 01 09 10908 // * returns 4: true 10909 // * example 5: date('W', 1104534000); 10910 // * returns 5: '53' 10911 // * example 6: date('B t', 1104534000); 10912 // * returns 6: '999 31' 10913 // * example 7: date('W U', 1293750000.82); // 2010-12-31 10914 // * returns 7: '52 1293750000' 10915 // * example 8: date('W', 1293836400); // 2011-01-01 10916 // * returns 8: '52' 10917 // * example 9: date('W Y-m-d', 1293974054); // 2011-01-02 10918 // * returns 9: '52 2011-01-02' 10919 var that = this, 10920 jsdate, 10921 f, 10922 // Keep this here (works, but for code commented-out 10923 // below for file size reasons) 10924 //, tal= [], 10925 // trailing backslash -> (dropped) 10926 // a backslash followed by any character (including backslash) -> the character 10927 // empty string -> empty string 10928 formatChr = /\\?(.?)/gi, 10929 formatChrCb = function (t, s) { 10930 return f[t] ? f[t]() : s; 10931 }, 10932 _pad = function (n, c) { 10933 n = String(n); 10934 while (n.length < c) { 10935 n = '0' + n; 10936 } 10937 return n; 10938 }; 10939 f = { 10940 // Day 10941 d: function () { // Day of month w/leading 0; 01..31 10942 return _pad(f.j(), 2); 10943 }, 10944 D: function () { // Shorthand day name; Mon...Sun 10945 return tdDateNamesI18n.day_names_short[f.w()]; 10946 }, 10947 j: function () { // Day of month; 1..31 10948 return jsdate.getDate(); 10949 }, 10950 l: function () { // Full day name; Monday...Sunday 10951 return tdDateNamesI18n.day_names[f.w()]; 10952 }, 10953 N: function () { // ISO-8601 day of week; 1[Mon]..7[Sun] 10954 return f.w() || 7; 10955 }, 10956 S: function(){ // Ordinal suffix for day of month; st, nd, rd, th 10957 var j = f.j(), 10958 i = j%10; 10959 if (i <= 3 && parseInt((j%100)/10, 10) == 1) { 10960 i = 0; 10961 } 10962 return ['st', 'nd', 'rd'][i - 1] || 'th'; 10963 }, 10964 w: function () { // Day of week; 0[Sun]..6[Sat] 10965 return jsdate.getDay(); 10966 }, 10967 z: function () { // Day of year; 0..365 10968 var a = new Date(f.Y(), f.n() - 1, f.j()), 10969 b = new Date(f.Y(), 0, 1); 10970 return Math.round((a - b) / 864e5); 10971 }, 10972 10973 // Week 10974 W: function () { // ISO-8601 week number 10975 var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3), 10976 b = new Date(a.getFullYear(), 0, 4); 10977 return _pad(1 + Math.round((a - b) / 864e5 / 7), 2); 10978 }, 10979 10980 // Month 10981 F: function () { // Full month name; January...December 10982 return tdDateNamesI18n.month_names[f.n() - 1]; 10983 }, 10984 m: function () { // Month w/leading 0; 01...12 10985 return _pad(f.n(), 2); 10986 }, 10987 M: function () { // Shorthand month name; Jan...Dec 10988 return tdDateNamesI18n.month_names_short[f.n() - 1]; 10989 }, 10990 n: function () { // Month; 1...12 10991 return jsdate.getMonth() + 1; 10992 }, 10993 t: function () { // Days in month; 28...31 10994 return (new Date(f.Y(), f.n(), 0)).getDate(); 10995 }, 10996 10997 // Year 10998 L: function () { // Is leap year?; 0 or 1 10999 var j = f.Y(); 11000 return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0; 11001 }, 11002 o: function () { // ISO-8601 year 11003 var n = f.n(), 11004 W = f.W(), 11005 Y = f.Y(); 11006 return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0); 11007 }, 11008 Y: function () { // Full year; e.g. 1980...2010 11009 return jsdate.getFullYear(); 11010 }, 11011 y: function () { // Last two digits of year; 00...99 11012 return f.Y().toString().slice(-2); 11013 }, 11014 11015 // Time 11016 a: function () { // am or pm 11017 return jsdate.getHours() > 11 ? "pm" : "am"; 11018 }, 11019 A: function () { // AM or PM 11020 return f.a().toUpperCase(); 11021 }, 11022 B: function () { // Swatch Internet time; 000..999 11023 var H = jsdate.getUTCHours() * 36e2, 11024 // Hours 11025 i = jsdate.getUTCMinutes() * 60, 11026 // Minutes 11027 s = jsdate.getUTCSeconds(); // Seconds 11028 return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3); 11029 }, 11030 g: function () { // 12-Hours; 1..12 11031 return f.G() % 12 || 12; 11032 }, 11033 G: function () { // 24-Hours; 0..23 11034 return jsdate.getHours(); 11035 }, 11036 h: function () { // 12-Hours w/leading 0; 01..12 11037 return _pad(f.g(), 2); 11038 }, 11039 H: function () { // 24-Hours w/leading 0; 00..23 11040 return _pad(f.G(), 2); 11041 }, 11042 i: function () { // Minutes w/leading 0; 00..59 11043 return _pad(jsdate.getMinutes(), 2); 11044 }, 11045 s: function () { // Seconds w/leading 0; 00..59 11046 return _pad(jsdate.getSeconds(), 2); 11047 }, 11048 u: function () { // Microseconds; 000000-999000 11049 return _pad(jsdate.getMilliseconds() * 1000, 6); 11050 }, 11051 11052 // Timezone 11053 e: function () { // Timezone identifier; e.g. Atlantic/Azores, ... 11054 // The following works, but requires inclusion of the very large 11055 // timezone_abbreviations_list() function. 11056 /* return that.date_default_timezone_get(); 11057 */ 11058 throw 'Not supported (see source code of date() for timezone on how to add support)'; 11059 }, 11060 I: function () { // DST observed?; 0 or 1 11061 // Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC. 11062 // If they are not equal, then DST is observed. 11063 var a = new Date(f.Y(), 0), 11064 // Jan 1 11065 c = Date.UTC(f.Y(), 0), 11066 // Jan 1 UTC 11067 b = new Date(f.Y(), 6), 11068 // Jul 1 11069 d = Date.UTC(f.Y(), 6); // Jul 1 UTC 11070 return ((a - c) !== (b - d)) ? 1 : 0; 11071 }, 11072 O: function () { // Difference to GMT in hour format; e.g. +0200 11073 var tzo = jsdate.getTimezoneOffset(), 11074 a = Math.abs(tzo); 11075 return (tzo > 0 ? "-" : "+") + _pad(Math.floor(a / 60) * 100 + a % 60, 4); 11076 }, 11077 P: function () { // Difference to GMT w/colon; e.g. +02:00 11078 var O = f.O(); 11079 return (O.substr(0, 3) + ":" + O.substr(3, 2)); 11080 }, 11081 T: function () { // Timezone abbreviation; e.g. EST, MDT, ... 11082 // The following works, but requires inclusion of the very 11083 // large timezone_abbreviations_list() function. 11084 /* var abbr = '', i = 0, os = 0, default = 0; 11085 if (!tal.length) { 11086 tal = that.timezone_abbreviations_list(); 11087 } 11088 if (that.php_js && that.php_js.default_timezone) { 11089 default = that.php_js.default_timezone; 11090
11090 for (abbr in tal) { 11091 for (i=0; i < tal[abbr].length; i++) { 11092 if (tal[abbr][i].timezone_id === default) { 11093 return abbr.toUpperCase(); 11094 } 11095 } 11096 } 11097 } 11098 for (abbr in tal) { 11099 for (i = 0; i < tal[abbr].length; i++) { 11100 os = -jsdate.getTimezoneOffset() * 60; 11101 if (tal[abbr][i].offset === os) { 11102 return abbr.toUpperCase(); 11103 } 11104 } 11105 } 11106 */ 11107 return 'UTC'; 11108 }, 11109 Z: function () { // Timezone offset in seconds (-43200...50400) 11110 return -jsdate.getTimezoneOffset() * 60; 11111 }, 11112 11113 // Full Date/Time 11114 c: function () { // ISO-8601 date. 11115 return 'Y-m-d\\TH:i:sP'.replace(formatChr, formatChrCb); 11116 }, 11117 r: function () { // RFC 2822 11118 return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb); 11119 }, 11120 U: function () { // Seconds since UNIX epoch 11121 return jsdate / 1000 | 0; 11122 } 11123 }; 11124 this.date = function (format, timestamp) { 11125 that = this; 11126 jsdate = (timestamp === undefined ? new Date() : // Not provided 11127 (timestamp instanceof Date) ? new Date(timestamp) : // JS Date() 11128 new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int) 11129 ); 11130 return format.replace(formatChr, formatChrCb); 11131 }; 11132 return this.date(format, timestamp); 11133}
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.