snappymail/vendors/jquery-finger/jquery.finger.min.js
RainLoop Team 5877ff77dd Add jQuery finger lib
Add autofocus in "to" field 
+ small inputosaurus improvement
2013-12-13 14:11:30 +04:00

4 lines
No EOL
2.1 KiB
JavaScript

/*! jquery.finger - v0.1.0-alpha - 2013-07-01
* https://github.com/ngryman/jquery.finger
* Copyright (c) 2013 Nicolas Gryman; Licensed MIT */
(function(t){function e(t,e){return(r?e.originalEvent.touches[0]:e)["page"+t.toUpperCase()]}function a(a){var r={},v=a.timeStamp||+new Date,m=t.data(this,u);i!=v&&(i=v,r.move={x:e("x",a),y:e("y",a)},r.start=t.extend({time:v,target:a.target},r.move),r.timeout=setTimeout(t.proxy(function(){t.event.trigger(t.Event("press",r.move),null,a.target),t.event.remove(this,d+"."+u,o),t.event.remove(this,s+"."+u,n)},this),t.Finger.pressDuration),t.event.add(this,d+"."+u,o,r),t.event.add(this,s+"."+u,n,r),(l.preventDefault||m.options.preventDefault)&&a.preventDefault())}function o(a){var o=a.data,i=o.start,r=o.move;return r.x=e("x",a),r.y=e("y",a),r.dx=r.x-i.x,r.dy=r.y-i.y,r.adx=Math.abs(r.dx),r.ady=Math.abs(r.dy),o.motion=r.adx>l.motionThreshold||r.ady>l.motionThreshold,o.motion?(clearTimeout(o.timeout),r.orientation||(r.adx>o.move.ady?(r.orientation="horizontal",r.direction=r.dx>0?1:-1):(r.orientation="vertical",r.direction=r.dy>0?1:-1)),a.target!==i.target?(a.target=i.target,n.call(this,t.Event(s+"."+u,a)),void 0):(t.event.trigger(t.Event("drag",r),null,a.target),void 0)):void 0}function n(e){var a,i=e.data,r=e.timeStamp||+new Date,v=t.data(this,u),m=r-i.start.time;clearTimeout(i.timeout),e.target===i.start.target&&(i.motion?(a=l.flickDuration>m?"flick":"drag",i.move.end=!0):(a=l.pressDuration>m&&!v.prev||v.prev&&r-v.prev>l.doubleTapInterval?"tap":"doubletap",v.prev=r),t.event.trigger(t.Event(a,i.move),null,e.target),t.event.remove(this,d+"."+u,o),t.event.remove(this,s+"."+u,n))}var i,r="ontouchstart"in window,v=r?"touchstart":"mousedown",s=r?"touchend touchcancel":"mouseup mouseleave",d=r?"touchmove":"mousemove",u="finger",l=t.Finger={pressDuration:300,doubleTapInterval:300,flickDuration:150,motionThreshold:5},m={add:function(e){t.data(this,u)||(t.event.add(this,v+"."+u,a),t.data(this,u,{options:e.data||{}}))},teardown:function(){t.data(this,u)&&(t.event.remove(this,v+"."+u,a),t.data(this,u,null))}};t.event.special.tap=m,t.event.special.press=m,t.event.special.doubletap=m,t.event.special.drag=m,t.event.special.flick=m})(jQuery);