!function(e,t,n){"function"==typeof define&&define.amd?define(["jquery"],(function(e){return n(e,0,t),e.mobile})):n(e.jQuery,0,t)}(this,document,(function(e,t,n,o){(function(e,t,n){function o(e){for(;e&&void 0!==e.originalEvent;)e=e.originalEvent;return e}function i(t){for(var n,o,i={};t;){for(o in n=e.data(t,T))n[o]&&(i[o]=i.hasVirtualBinding=!0);t=t.parentNode}return i}function s(t,n){for(var o;t;){if((o=e.data(t,T))&&(!n||o[n]))return t;t=t.parentNode}return null}function a(){O=!0}function r(){c(),k=setTimeout((function(){k=0,z=0,S.length=0,L=!1,a()}),e.vmouse.resetTimerDuration)}function c(){k&&(clearTimeout(k),k=0)}function u(t,n,i){var a;return(i&&i[t]||!i&&s(n.target,t))&&(a=function(t,n){var i,s,a,r,c,u,l,p,h,v=t.type;if((t=e.Event(t)).type=n,i=t.originalEvent,s=e.event.props,v.search(/^(mouse|click)/)>-1&&(s=X),i)for(l=s.length;l;)t[r=s[--l]]=i[r];if(v.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1),-1!==v.search(/^touch/)&&(v=(a=o(i)).touches,c=a.changedTouches,u=v&&v.length?v[0]:c&&c.length?c[0]:void 0))for(p=0,h=E.length;pa||Math.abs(n.pageY-I)>a)&&!s&&u("vmousecancel",t,c),u("vmousemove",t,c),r()}}function d(e){if(!O){a();var t,n,s=i(e.target);u("vmouseup",e,s),x||(t=u("vclick",e,s))&&t.isDefaultPrevented()&&(n=o(e).changedTouches[0],S.push({touchID:z,x:n.clientX,y:n.clientY}),L=!0),u("vmouseout",e,s),x=!1,r()}}function f(t){var n,o=e.data(t,T);if(o)for(n in o)if(o[n])return!0;return!1}function m(){}function g(t){var n=t.substr(1);return{setup:function(){f(this)||e.data(this,T,{}),e.data(this,T)[t]=!0,Y[t]=(Y[t]||0)+1,1===Y[t]&&N.bind(n,l),e(this).bind(n,m),B&&(Y.touchstart=(Y.touchstart||0)+1,1===Y.touchstart&&N.bind("touchstart",p).bind("touchend",d).bind("touchmove",v).bind("scroll",h))},teardown:function(){--Y[t],Y[t]||N.unbind(n,l),B&&(--Y.touchstart,Y.touchstart||N.unbind("touchstart",p).unbind("touchmove",v).unbind("touchend",d).unbind("scroll",h));var o=e(this),i=e.data(this,T);i&&(i[t]=!1),o.unbind(n,m),f(this)||o.removeData(T)}}}var w,b,T="virtualMouseBindings",D="virtualTouchID",y="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),E="clientX clientY pageX pageY screenX screenY".split(" "),P=e.event.mouseHooks?e.event.mouseHooks.props:[],X=e.event.props.concat(P),Y={},k=0,M=0,I=0,x=!1,S=[],L=!1,O=!1,B="addEventListener"in n,N=e(n),j=1,z=0;for(e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500},b=0;bMath.floor(e.pageY)||0===e.pageX&&Math.floor(i)>Math.floor(e.pageX)?(i-=n,s-=o):(se.event.special.swipe.horizontalDistanceThreshold&&Math.abs(t.coords[1]-n.coords[1])n.coords[0]?"swipeleft":"swiperight";return o(i,"swipe",e.Event("swipe",{target:s,swipestart:t,swipestop:n}),!0),o(i,a,e.Event(a,{target:s,swipestart:t,swipestop:n}),!0),!0}return!1},eventInProgress:!1,setup:function(){var t,n=this,o=e(n),s={};(t=e.data(this,"mobile-events"))||(t={length:0},e.data(this,"mobile-events",t)),t.length++,t.swipe=s,s.start=function(t){if(!e.event.special.swipe.eventInProgress){e.event.special.swipe.eventInProgress=!0;var o,a=e.event.special.swipe.start(t),r=t.target,l=!1;s.move=function(t){a&&!t.isDefaultPrevented()&&(o=e.event.special.swipe.stop(t),l||(l=e.event.special.swipe.handleSwipe(a,o,n,r))&&(e.event.special.swipe.eventInProgress=!1),Math.abs(a.coords[0]-o.coords[0])>e.event.special.swipe.scrollSupressionThreshold&&t.preventDefault())},s.stop=function(){l=!0,e.event.special.swipe.eventInProgress=!1,i.off(u,s.move),s.move=null},i.on(u,s.move).one(c,s.stop)}},o.on(r,s.start)},teardown:function(){var t,n;(t=e.data(this,"mobile-events"))&&(n=t.swipe,delete t.swipe,t.length--,0===t.length&&e.removeData(this,"mobile-events")),n&&(n.start&&e(this).off(r,n.start),n.move&&i.off(u,n.move),n.stop&&i.off(c,n.stop))}},e.each({scrollstop:"scrollstart",taphold:"tap",swipeleft:"swipe.left",swiperight:"swipe.right"},(function(t,n){e.event.special[t]={setup:function(){e(this).bind(n,e.noop)},teardown:function(){e(this).unbind(n)}}}))}(e,this)}));