summaryrefslogtreecommitdiffstats
path: root/app/common/directives/click-outside.js
diff options
context:
space:
mode:
authorRyan Arnell <iffy.ryan@ibm.com>2018-12-13 10:50:17 -0600
committerGunnar Mills <gmills@us.ibm.com>2018-12-21 15:40:50 +0000
commit84e7a936db2addc3c10be97c3b348b9ffdb3601b (patch)
treeb27b7d6c7a3a8d6a45cd653354f084a8dd0356b3 /app/common/directives/click-outside.js
parent0b0e26deda16a86b316f1cda631f18a45608d5bf (diff)
downloadphosphor-webui-84e7a936db2addc3c10be97c3b348b9ffdb3601b.tar.gz
phosphor-webui-84e7a936db2addc3c10be97c3b348b9ffdb3601b.zip
Fix issue about menu not disappearing on firmware page
In firmware update page "More info” dialog did not disappear until it is clicked again. With this push users can click anywhere outside the menu and it disappears. Resolves openbmc/phosphor-webui#32 Change-Id: I1519caf2428c702af03fb0e4dd8a08d0c0588abf Signed-off-by: Ryan Arnell <iffy.ryan@ibm.com>
Diffstat (limited to 'app/common/directives/click-outside.js')
-rw-r--r--app/common/directives/click-outside.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/common/directives/click-outside.js b/app/common/directives/click-outside.js
new file mode 100644
index 0000000..ffe1464
--- /dev/null
+++ b/app/common/directives/click-outside.js
@@ -0,0 +1,24 @@
+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);
+ });
+ }
+ }
+ $document.bind('click', clickEvent);
+
+ scope.$on('$destroy', function() {
+ $document.unbind('click', clickEvent);
+ });
+ }
+ }
+ });
+})(window.angular); \ No newline at end of file
OpenPOWER on IntegriCloud