1cd789508SIftekharul Islamwindow.angular && (function(angular) { 2cd789508SIftekharul Islam 'use strict'; 3cd789508SIftekharul Islam 4*e6bc9b21SYoshie Muranaka angular.module('app.common.directives').directive('toggleFlag', [ 5*e6bc9b21SYoshie Muranaka '$document', 6*e6bc9b21SYoshie Muranaka function($document) { 7cd789508SIftekharul Islam return { 8cd789508SIftekharul Islam restrict: 'A', 9cd789508SIftekharul Islam link: function(scope, element, attrs) { 10cd789508SIftekharul Islam function elementClick(e) { 11cd789508SIftekharul Islam e.stopPropagation(); 12cd789508SIftekharul Islam } 13cd789508SIftekharul Islam 14cd789508SIftekharul Islam function documentClick(e) { 15cd789508SIftekharul Islam scope[attrs.toggleFlag] = false; 16cd789508SIftekharul Islam scope.$apply(); 17cd789508SIftekharul Islam } 18cd789508SIftekharul Islam 19cd789508SIftekharul Islam element.on('click', elementClick); 20cd789508SIftekharul Islam $document.on('click', documentClick); 21cd789508SIftekharul Islam 22cd789508SIftekharul Islam // remove event handlers when directive is destroyed 23cd789508SIftekharul Islam scope.$on('$destroy', function() { 24cd789508SIftekharul Islam element.off('click', elementClick); 25cd789508SIftekharul Islam $document.off('click', documentClick); 26cd789508SIftekharul Islam }); 27cd789508SIftekharul Islam } 28cd789508SIftekharul Islam }; 29*e6bc9b21SYoshie Muranaka } 30*e6bc9b21SYoshie Muranaka ]); 31cd789508SIftekharul Islam})(window.angular); 32