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