/* * touchswipe - jquery plugin * https://github.com/mattbryson/touchswipe-jquery-plugin * http://labs.skinkers.com/touchswipe/ * http://plugins.jquery.com/project/touchswipe * * copyright (c) 2010 matt bryson (www.skinkers.com) * dual licensed under the mit or gpl version 2 licenses. * * $version: 1.3.3 */ (function(g){function p(c){if(c&&void 0===c.allowpagescroll&&(void 0!==c.swipe||void 0!==c.swipestatus))c.allowpagescroll=g;c||(c={});c=g.extend({},g.fn.swipe.defaults,c);return this.each(function(){var b=g(this),f=b.data(w);f||(f=new w(this,c),b.data(w,f))})}function w(c,b){var f,p,r,s;function h(a){var a=a.originalevent,c,q=n?a.touches[0]:a;d=r;n?h=a.touches.length:a.preventdefault();i=0;j=null;k=0;!n||h===b.fingers||b.fingers===x?(r=f=q.pagex,s=p=q.pagey,y=(new date).gettime(),b.swipestatus&&(c= l(a,d))):t(a);if(!1===c)return d=m,l(a,d),c;e.bind(i,j);e.bind(k,l)}function j(a){a=a.originalevent;if(!(d===q||d===m)){var c,e=n?a.touches[0]:a;f=e.pagex;p=e.pagey;u=(new date).gettime();j=s();n&&(h=a.touches.length);d=z;var e=a,g=j;if(b.allowpagescroll===g)e.preventdefault();else{var o=b.allowpagescroll===t;switch(g){case v:(b.swipeleft&&o||!o&&b.allowpagescroll!=m)&&e.preventdefault();break;case a:(b.swiperight&&o||!o&&b.allowpagescroll!=m)&&e.preventdefault();break;case b:(b.swipeup&&o||!o&&b.allowpagescroll!= n)&&e.preventdefault();break;case c:(b.swipedown&&o||!o&&b.allowpagescroll!=n)&&e.preventdefault()}}h===b.fingers||b.fingers===x||!n?(i=u(),k=u-y,b.swipestatus&&(c=l(a,d,j,i,k)),b.triggerontouchend||(e=!(b.maxtimethreshold?!(k>=b.maxtimethreshold):1),!0===d()?(d=q,c=l(a,d)):e&&(d=m,l(a,d)))):(d=m,l(a,d));!1===c&&(d=m,l(a,d))}}function l(a){a=a.originalevent;a.preventdefault();u=(new date).gettime();i=u();j=s();k=u-y;if(b.triggerontouchend||!1===b.triggerontouchend&&d===z)if(d=q,(h===b.fingers||b.fingers=== x||!n)&&0!==f){var c=!(b.maxtimethreshold?!(k>=b.maxtimethreshold):1);if((!0===d()||null===d())&&!c)l(a,d);else if(c||!1===d())d=m,l(a,d)}else d=m,l(a,d);else d===z&&(d=m,l(a,d));e.unbind(i,j,!1);e.unbind(k,l,!1)}function t(){y=u=p=f=s=r=h=0}function l(a,c){var d=void 0;b.swipestatus&&(d=b.swipestatus.call(e,a,c,j||null,i||0,k||0,h));if(c===m&&b.click&&(1===h||!n)&&(isnan(i)||0===i))d=b.click.call(e,a,a.target);if(c==q)switch(b.swipe&&(d=b.swipe.call(e,a,j,i,k,h)),j){case v:b.swipeleft&&(d=b.swipeleft.call(e, a,j,i,k,h));break;case a:b.swiperight&&(d=b.swiperight.call(e,a,j,i,k,h));break;case b:b.swipeup&&(d=b.swipeup.call(e,a,j,i,k,h));break;case c:b.swipedown&&(d=b.swipedown.call(e,a,j,i,k,h))}(c===m||c===q)&&t(a);return d}function d(){return null!==b.threshold?i>=b.threshold:null}function u(){return math.round(math.sqrt(math.pow(f-r,2)+math.pow(p-s,2)))}function s(){var a;a=math.atan2(p-s,r-f);a=math.round(180*a/math.pi);0>a&&(a=360-math.abs(a));return 45>=a&&0<=a?v:360>=a&&315<=a?v:135<=a&&225>=a? a:45a?c:b}function v(){e.unbind(e,h);e.unbind(f,t);e.unbind(i,j);e.unbind(k,l)}var o=n||!b.fallbacktomouseevents,e=o?"touchstart":"mousedown",i=o?"touchmove":"mousemove",k=o?"touchend":"mouseup",f="touchcancel",i=0,j=null,k=0,e=g(c),d="start",h=0,y=p=f=s=r=0,u=0;try{e.bind(e,h),e.bind(f,t)}catch(p){g.error("events not supported "+e+","+f+" on jquery.swipe")}this.enable=function(){e.bind(e,h);e.bind(f,t);return e};this.disable=function(){v();return e};this.destroy=function(){v();e.data(w,null); return e}}var v="left",a="right",b="up",c="down",g="none",t="auto",m="horizontal",n="vertical",x="all",r="start",z="move",q="end",m="cancel",n="ontouchstart"in window,w="touchswipe";g.fn.swipe=function(c){var b=g(this),f=b.data(w);if(f&&"string"===typeof c){if(f[c])return f[c].apply(this,array.prototype.slice.call(arguments,1));g.error("method "+c+" does not exist on jquery.swipe")}else if(!f&&("object"===typeof c||!c))return p.apply(this,arguments);return b};g.fn.swipe.defaults={fingers:1,threshold:75, maxtimethreshold:null,swipe:null,swipeleft:null,swiperight:null,swipeup:null,swipedown:null,swipestatus:null,click:null,triggerontouchend:!0,allowpagescroll:"auto",fallbacktomouseevents:!0};g.fn.swipe.phases={phase_start:r,phase_move:z,phase_end:q,phase_cancel:m};g.fn.swipe.directions={left:v,right:a,up:b,down:c};g.fn.swipe.pagescroll={none:g,horizontal:m,vertical:n,auto:t};g.fn.swipe.fingers={one:1,two:2,three:3,all:x}})(jquery);