summaryrefslogtreecommitdiffstats
path: root/client/lib/popup.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-06-07 10:30:27 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-06-07 10:34:19 +0200
commit92dd05d06ddeb2a9434df6038c432e6b167c1c99 (patch)
treeecb93138c1dd0ab0c1fcf2682a6eae600a4bbca9 /client/lib/popup.js
parent12919cbfc6c3fd0793624776b3afb70e3a0cdd1a (diff)
downloadwekan-92dd05d06ddeb2a9434df6038c432e6b167c1c99.tar.gz
wekan-92dd05d06ddeb2a9434df6038c432e6b167c1c99.tar.bz2
wekan-92dd05d06ddeb2a9434df6038c432e6b167c1c99.zip
Click on the page to escape the last action
This is a generalization of what we had for closing a popup by clicking outside of it. It now works for inlinedForms and detailsPane as well.
Diffstat (limited to 'client/lib/popup.js')
-rw-r--r--client/lib/popup.js25
1 files changed, 7 insertions, 18 deletions
diff --git a/client/lib/popup.js b/client/lib/popup.js
index fe8b581b..a1f4def2 100644
--- a/client/lib/popup.js
+++ b/client/lib/popup.js
@@ -40,11 +40,8 @@ Popup = {
self._stack = [];
openerElement = evt.currentTarget;
}
- $(openerElement).addClass('is-active');
- // We modify the event to prevent the popup being closed when the event
- // bubble up to the document element.
- evt.originalEvent.clickInPopup = true;
+ $(openerElement).addClass('is-active');
evt.preventDefault();
// We push our popup data to the stack. The top of the stack is always
@@ -201,19 +198,11 @@ Popup = {
}
};
-// We automatically close a potential opened popup on any left click on the
-// document. To avoid closing it unexpectedly we modify the bubbled event in
-// case the click event happen in the popup or in a button that open a popup.
-$(document).on('click', function(evt) {
- if (evt.which === 1 && ! (evt.originalEvent &&
- evt.originalEvent.clickInPopup)) {
- Popup.close();
- }
-});
-
-// Press escape to go back, or close the popup.
-var bindPopup = function(f) { return _.bind(f, Popup); };
+// We close a potential opened popup on any left click on the document, or go
+// one step back by pressing escape.
EscapeActions.register('popup',
- bindPopup(Popup.back),
- bindPopup(Popup.isOpen)
+ function(evt) { Popup[evt.type === 'click' ? 'close' : 'back'](); },
+ _.bind(Popup.isOpen, Popup), {
+ noClickEscapeOn: '.js-pop-over'
+ }
);