1(function(e,t,n){typeof define=="function"&&define.amd?define(["jquery"],function(r){return n(r,e,t),r.mobile}):n(e.jQuery,e,t)})(this,document,function(e,t,n,r){(function(e,t){var r={touch:"ontouchend"in n};e.mobile=e.mobile||{},e.mobile.support=e.mobile.support||{},e.extend(e.support,r),e.extend(e.mobile.support,r)})(e),function(e,t,n,r){function i(e){while(e&&typeof e.originalEvent!="undefined")e=e.originalEvent;return e}function s(t,n){var s=t.type,o,u,a,f,l,c,h,p,d;t=e.Event(t),t.type=n,o=t.originalEvent,u=e.event.props,s.search(/^(mouse|click)/)>-1&&(u=L);if(o)for(h=u.length,f;h;)f=u[--h],t[f]=o[f];s.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1);if(s.search(/^touch/)!==-1){a=i(o),s=a.touches,l=a.changedTouches,c=s&&s.length?s[0]:l&&l.length?l[0]:r;if(c)for(p=0,d=C.length;p<d;p++)f=C[p],t[f]=c[f]}return t}function o(t){var n={},r,i;while(t){r=e.data(t,x);for(i in r)r[i]&&(n[i]=n.hasVirtualBinding=!0);t=t.parentNode}return n}function u(t,n){var r;while(t){r=e.data(t,x);if(r&&(!n||r[n]))return t;t=t.parentNode}return null}function a(){B=!1}function f(){B=!0}function l(){q=0,P.length=0,H=!1,f()}function c(){a()}function h(){p(),O=setTimeout(function(){O=0,l()},e.vmouse.resetTimerDuration)}function p(){O&&(clearTimeout(O),O=0)}function d(t,n,r){var i;if(r&&r[t]||!r&&u(n.target,t))i=s(n,t),e(n.target).trigger(i);return i}function v(t){var n=e.data(t.target,T);if(!H&&(!q||q!==n)){var r=d("v"+t.type,t);r&&(r.isDefaultPrevented()&&t.preventDefault(),r.isPropagationStopped()&&t.stopPropagation(),r.isImmediatePropagationStopped()&&t.stopImmediatePropagation())}}function m(t){var n=i(t).touches,r,s;if(n&&n.length===1){r=t.target,s=o(r);if(s.hasVirtualBinding){q=I++,e.data(r,T,q),p(),c(),D=!1;var u=i(t).touches[0];M=u.pageX,_=u.pageY,d("vmouseover",t,s),d("vmousedown",t,s)}}}function g(e){if(B)return;D||d("vmousecancel",e,o(e.target)),D=!0,h()}function y(t){if(B)return;var n=i(t).touches[0],r=D,s=e.vmouse.moveDistanceThreshold,u=o(t.target);D=D||Math.abs(n.pageX-M)>s||Math.abs(n.pageY-_)>s,D&&!r&&d("vmousecancel",t,u),d("vmousemove",t,u),h()}function b(e){if(B)return;f();var t=o(e.target),n;d("vmouseup",e,t);if(!D){var r=d("vclick",e,t);r&&r.isDefaultPrevented()&&(n=i(e).changedTouches[0],P.push({touchID:q,x:n.clientX,y:n.clientY}),H=!0)}d("vmouseout",e,t),D=!1,h()}function w(t){var n=e.data(t,x),r;if(n)for(r in n)if(n[r])return!0;return!1}function E(){}function S(t){var n=t.substr(1);return{setup:function(r,i){w(this)||e.data(this,x,{});var s=e.data(this,x);s[t]=!0,A[t]=(A[t]||0)+1,A[t]===1&&F.bind(n,v),e(this).bind(n,E),j&&(A.touchstart=(A.touchstart||0)+1,A.touchstart===1&&F.bind("touchstart",m).bind("touchend",b).bind("touchmove",y).bind("scroll",g))},teardown:function(r,i){--A[t],A[t]||F.unbind(n,v),j&&(--A.touchstart,A.touchstart||F.unbind("touchstart",m).unbind("touchmove",y).unbind("touchend",b).unbind("scroll",g));var s=e(this),o=e.data(this,x);o&&(o[t]=!1),s.unbind(n,E),w(this)||s.removeData(x)}}}var x="virtualMouseBindings",T="virtualTouchID",N="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),C="clientX clientY pageX pageY screenX screenY".split(" "),k=e.event.mouseHooks?e.event.mouseHooks.props:[],L=e.event.props.concat(k),A={},O=0,M=0,_=0,D=!1,P=[],H=!1,B=!1,j="addEventListener"in n,F=e(n),I=1,q=0,R;e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500};for(var U=0;U<N.length;U++)e.event.special[N[U]]=S(N[U]);j&&n.addEventListener("click",function(t){var n=P.length,r=t.target,i,s,o,u,a,f;if(n){i=t.clientX,s=t.clientY,R=e.vmouse.clickDistanceThreshold,o=r;while(o){for(u=0;u<n;u++){a=P[u],f=0;if(o===r&&Math.abs(a.x-i)<R&&Math.abs(a.y-s)<R||e.data(o,T)===a.touchID){t.preventDefault(),t.stopPropagation();return}}o=o.parentNode}}},!0)}(e,t,n),function(e,t,r){function i(t,n,r){var i=r.type;r.type=n,e.event.handle.call(t,r),r.type=i}e.each("touchstart touchmove touchend tap taphold swipe swipeleft swiperight scrollstart scrollstop".split(" "),function(t,n){e.fn[n]=function(e){return e?this.bind(n,e):this.trigger(n)},e.attrFn&&(e.attrFn[n]=!0)});var s=e.mobile.support.touch,o="touchmove scroll",u=s?"touchstart":"mousedown",a=s?"touchend":"mouseup",f=s?"touchmove":"mousemove";e.event.special.scrollstart={enabled:!0,setup:function(){function t(e,t){s=t,i(n,s?"scrollstart":"scrollstop",e)}var n=this,r=e(n),s,u;r.bind(o,function(n){if(!e.event.special.scrollstart.enabled)return;s||t(n,!0),clearTimeout(u),u=setTimeout(function(){t(n,!1)},50)})}},e.event.special.tap={tapholdThreshold:750,setup:function(){var t=this,r=e(t);r.bind("vmousedown",function(s){function o(){clearTimeout(h)}function u(){o(),r.unbind("vclick",a).unbind("vmouseup",o),e(n).unbind("vmousecancel",u)}function a(e){u(),f===e.target&&i(t,"tap",e)}if(s.which&&s.which!==1)return!1;var f=s.target,l=s.originalEvent,h;r.bind("vmouseup",o).bind("vclick",a),e(n).bind("vmousecancel",u),h=setTimeout(function(){i(t,"taphold",e.Event("taphold",{target:f}))},e.event.special.tap.tapholdThreshold)})}},e.event.special.swipe={scrollSupressionThreshold:30,durationThreshold:1e3,horizontalDistanceThreshold:30,verticalDistanceThreshold:75,setup:function(){var t=this,n=e(t);n.bind(u,function(t){function i(t){if(!o)return;var n=t.originalEvent.touches?t.originalEvent.touches[0]:t;u={time:(new Date).getTime(),coords:[n.pageX,n.pageY]},Math.abs(o.coords[0]-u.coords[0])>e.event.special.swipe.scrollSupressionThreshold&&t.preventDefault()}var s=t.originalEvent.touches?t.originalEvent.touches[0]:t,o={time:(new Date).getTime(),coords:[s.pageX,s.pageY],origin:e(t.target)},u;n.bind(f,i).one(a,function(t){n.unbind(f,i),o&&u&&u.time-o.time<e.event.special.swipe.durationThreshold&&Math.abs(o.coords[0]-u.coords[0])>e.event.special.swipe.horizontalDistanceThreshold&&Math.abs(o.coords[1]-u.coords[1])<e.event.special.swipe.verticalDistanceThreshold&&o.origin.trigger("swipe").trigger(o.coords[0]>u.coords[0]?"swipeleft":"swiperight"),o=u=r})})}},e.each({scrollstop:"scrollstart",taphold:"tap",swipeleft:"swipe",swiperight:"swipe"},function(t,n){e.event.special[t]={setup:function(){e(this).bind(n,e.noop)}}})}(e,this)})