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