diff options
Diffstat (limited to 'app/common/directives/click-outside.js')
-rw-r--r-- | app/common/directives/click-outside.js | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/app/common/directives/click-outside.js b/app/common/directives/click-outside.js index ffe1464..35248ee 100644 --- a/app/common/directives/click-outside.js +++ b/app/common/directives/click-outside.js @@ -1,24 +1,26 @@ window.angular && (function(angular) { 'use strict'; - angular.module('app.common.directives') - .directive('clickOutside', function($document) { - return { - restrict: 'A', scope: {clickOutside: '&'}, - link: function(scope, el, attr) { - function clickEvent(e) { - if (el !== e.target && !el[0].contains(e.target)) { - scope.$apply(function() { - scope.$eval(scope.clickOutside); - }); - } + angular.module('app.common.directives').directive('clickOutside', [ + '$document', + function($document) { + return { + restrict: 'A', scope: {clickOutside: '&'}, + link: function(scope, el, attr) { + function clickEvent(e) { + if (el !== e.target && !el[0].contains(e.target)) { + scope.$apply(function() { + scope.$eval(scope.clickOutside); + }); } - $document.bind('click', clickEvent); - - scope.$on('$destroy', function() { - $document.unbind('click', clickEvent); - }); } - } - }); + $document.bind('click', clickEvent); + + scope.$on('$destroy', function() { + $document.unbind('click', clickEvent); + }); + } + } + } + ]); })(window.angular);
\ No newline at end of file |