(function(){var g="ontouchstart"in window,h=g?"touchstart":"mousedown",m=g?"touchmove":"mousemove",p=g?"touchend":"mouseup",c,d;zk.Swipe=zk.$extends(zk.Object,{$init:function(a,b,c){this.widget=a;this.node=b=b?jq(b,zk)[0]:a.node||(a.$n?a.$n():null);if(!b)throw"Handle required for "+a;this.opts=zk.$default(c,{scrollThreshold:5,duration:500,minDisplacement:30,maxDisplacement:75});jq(this.node).bind(h,this.proxy(this._swipeStart))},destroy:function(a){jq(a).unbind(h,this.proxy(this._swipeStart));this.widget=
this.node=this.opts=null},_swipeStart:function(a){a=a.originalEvent;var b=a.touches?a.touches[0]:a;c={time:a.timeStamp||Date.now(),coords:[b.pageX,b.pageY]};jq(this.node).bind(m,this.proxy(this._swipeMove)).one(p,this.proxy(this._swipeEnd))},_swipeMove:function(a){if(c){a=a.originalEvent;var b=a.touches?a.touches[0]:a;a.stopPropagation();d={time:a.timeStamp||Date.now(),coords:[b.pageX,b.pageY]};b=Math.abs(c.coords[1]-d.coords[1]);var e=this.opts.scrollThreshold;(Math.abs(c.coords[0]-d.coords[0])>
e||b>e)&&a.preventDefault()}},_swipeEnd:function(a){jq(this.node).unbind(m,this.proxy(this._swipeMove));if(c&&d){var b=d.time-c.time,e;if(b<this.opts.duration){var l=c.coords[0]-d.coords[0],g=c.coords[1]-d.coords[1],h=this.opts.minDisplacement,n=this.opts.maxDisplacement;var f=Math.abs(l);var k=Math.abs(g);f>h&&k<n?e=0<l?"left":"right":k>h&&f<n&&(e=0<g?"up":"down")}if(l=this.widget)a=new zk.Event(l,"onSwipe",{dispX:f,dispY:k,dispT:b,dir:e},{start:c,stop:d,dir:e},a),(f=a.target)&&!f.$weave&&(k=a.name,
a.stopped||f["do"+k.substring(2)+"_"].call(f,a))}c=d=null}})})();
