blob: 6ac5fffb4135fb407f95b047ab0cdec0b2ac12b3 [file] [log] [blame]
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001window.angular && (function(angular) {
2 'use strict';
Iftekharul Islamcd789502017-04-19 14:37:55 -05003
Yoshie Muranakae6bc9b22019-06-14 12:21:19 -05004 angular.module('app.common.directives').directive('toggleFlag', [
5 '$document',
6 function($document) {
7 return {
8 restrict: 'A',
9 link: function(scope, element, attrs) {
10 function elementClick(e) {
11 e.stopPropagation();
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070012 }
Yoshie Muranakae6bc9b22019-06-14 12:21:19 -050013
14 function documentClick(e) {
15 scope[attrs.toggleFlag] = false;
16 scope.$apply();
17 }
18
19 element.on('click', elementClick);
20 $document.on('click', documentClick);
21
22 // remove event handlers when directive is destroyed
23 scope.$on('$destroy', function() {
24 element.off('click', elementClick);
25 $document.off('click', documentClick);
26 });
27 }
28 };
29 }
30 ]);
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070031})(window.angular);