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