passman/js/vendor/angular-off-click/angular-off-click.min.js
2016-09-11 22:14:11 +02:00

1 line
1.7 KiB
JavaScript

"use strict";angular.module("offClick",[]),angular.module("offClick").directive("offClick",["$rootScope","$parse","OffClickFilterCache",function(n,e,t){var c=0,o={},i=!1,r=function(n,e){if(!n||!e)return!1;for(var t=e.length,c=0;c<t;++c){var o=e[c],i=!1;try{i=o.contains(n)}catch(r){"undefined"!=typeof o.compareDocumentPosition&&(i=o===n||Boolean(16&o.compareDocumentPosition(n)))}if(i)return!0}return!1},f=function(e){if("touchmove"===e.type)return i=!0,!1;if(i)return i=!1,!1;var c=e.target||e.srcElement;angular.forEach(o,function(o,i){var f=t["*"]||[];o.elm.id&&""!==o.elm.id&&t["#"+o.elm.id]&&(f=f.concat(t["#"+o.elm.id])),angular.forEach(o.elm.classList,function(n){t["."+n]&&(f=f.concat(t["."+n]))}),o.elm.contains(c)||r(c,f)||n.$evalAsync(function(){o.cb(o.scope,{$event:e})})})};return document.addEventListener("touchmove",f,!0),document.addEventListener("touchend",f,!0),document.addEventListener("click",f,!0),{restrict:"A",compile:function(t,i){var r=e(i.offClick);return function(t,f){var u=c++,l=void 0,a=function(){o[u]={elm:f[0],cb:r,scope:t}},d=function(){o[u]=null,delete o[u]};i.offClickIf?l=n.$watch(function(){return e(i.offClickIf)(t)},function(n){n&&a()||!n&&d()}):a(),t.$on("$destroy",function(){d(),l&&l(),f=null})}}}}]),angular.module("offClick").directive("offClickFilter",["OffClickFilterCache","$parse",function(n,e){var t=void 0;return{restrict:"A",compile:function(c,o){return function(c,i){t=e(o.offClickFilter)(c).split(",").map(function(n){return n.trim()}),t.forEach(function(e){n[e]?n[e].push(i[0]):n[e]=[i[0]]}),c.$on("$destroy",function(){t.forEach(function(e){n[e].length>1?n[e].splice(n[e].indexOf(i[0]),1):(n[e]=null,delete n[e])}),i=null})}}}}]),angular.module("offClick").factory("OffClickFilterCache",function(){var n={};return n});