mail/src/lib/angular/angular-touch.min.js

15 lines
3.1 KiB
JavaScript
Executable File

/*
AngularJS v1.2.0rc1
(c) 2010-2012 Google, Inc. http://angularjs.org
License: MIT
*/
(function(y,v,z){'use strict';function t(f,a,c){q.directive(f,["$parse","$swipe",function(l,n){var r=75,e=0.3,g=30;return function(p,m,k){function d(d){if(!u)return!1;var b=Math.abs(d.y-u.y);d=(d.x-u.x)*a;return h&&b<r&&0<d&&d>g&&b/d<e}var b=l(k[f]),u,h;n.bind(m,{start:function(d){u=d;h=!0},cancel:function(){h=!1},end:function(a){d(a)&&p.$apply(function(){m.triggerHandler(c);b(p)})}})}}])}var q=v.module("ngTouch",[]);q.factory("$swipe",[function(){function f(a){var c=a.touches&&a.touches.length?a.touches:
[a];a=a.changedTouches&&a.changedTouches[0]||a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches[0]||c[0].originalEvent||c[0];return{x:a.clientX,y:a.clientY}}return{bind:function(a,c){var l,n,r,e,g=!1;a.on("touchstart mousedown",function(a){r=f(a);g=!0;n=l=0;e=r;c.start&&c.start(r)});a.on("touchcancel",function(a){g=!1;c.cancel&&c.cancel()});a.on("touchmove mousemove",function(a){if(g&&r){var m=f(a);l+=Math.abs(m.x-e.x);n+=Math.abs(m.y-e.y);e=m;10>l&&10>n||(n>l?(g=!1,c.cancel&&
c.cancel()):(a.preventDefault(),c.move&&c.move(m)))}});a.on("touchend mouseup",function(a){g&&(g=!1,c.end&&c.end(f(a)))})}}}]);q.config(["$provide",function(f){f.decorator("ngClickDirective",["$delegate",function(a){a.shift();return a}])}]);q.directive("ngClick",["$parse","$timeout","$rootElement",function(f,a,c){function l(d,a,c){for(var h=0;h<d.length;h+=2)if(Math.abs(d[h]-a)<g&&Math.abs(d[h+1]-c)<g)return d.splice(h,h+2),!0;return!1}function n(a){if(!(Date.now()-m>e)){var b=a.touches&&a.touches.length?
a.touches:[a],c=b[0].clientX,b=b[0].clientY;1>c&&1>b||l(k,c,b)||(a.stopPropagation(),a.preventDefault(),a.target&&a.target.blur())}}function r(d){d=d.touches&&d.touches.length?d.touches:[d];var b=d[0].clientX,c=d[0].clientY;k.push(b,c);a(function(){for(var a=0;a<k.length;a+=2)if(k[a]==b&&k[a+1]==c){k.splice(a,a+2);break}},e,!1)}var e=2500,g=25,p="ng-click-active",m,k;return function(a,b,g){function h(){q=!1;b.removeClass(p)}var e=f(g.ngClick),q=!1,s,t,w,x;b.on("touchstart",function(a){q=!0;s=a.target?
a.target:a.srcElement;3==s.nodeType&&(s=s.parentNode);b.addClass(p);t=Date.now();a=a.touches&&a.touches.length?a.touches:[a];a=a[0].originalEvent||a[0];w=a.clientX;x=a.clientY});b.on("touchmove",function(a){h()});b.on("touchcancel",function(a){h()});b.on("touchend",function(a){var d=Date.now()-t,e=a.changedTouches&&a.changedTouches.length?a.changedTouches:a.touches&&a.touches.length?a.touches:[a],f=e[0].originalEvent||e[0],e=f.clientX,f=f.clientY,p=Math.sqrt(Math.pow(e-w,2)+Math.pow(f-x,2));q&&(750>
d&&12>p)&&(k||(c[0].addEventListener("click",n,!0),c[0].addEventListener("touchstart",r,!0),k=[]),m=Date.now(),l(k,e,f),s&&s.blur(),v.isDefined(g.disabled)&&!1!==g.disabled||b.triggerHandler("click",a));h()});b.onclick=function(a){};b.on("click",function(b){a.$apply(function(){e(a,{$event:b})})});b.on("mousedown",function(a){b.addClass(p)});b.on("mousemove mouseup",function(a){b.removeClass(p)})}}]);t("ngSwipeLeft",-1,"swipeleft");t("ngSwipeRight",1,"swiperight")})(window,window.angular);
/*
//@ sourceMappingURL=angular-touch.min.js.map
*/