mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 07:20:12 +01:00
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.
This commit is contained in:
parent
12919cbfc6
commit
92dd05d06d
17 changed files with 199 additions and 145 deletions
|
|
@ -1,6 +1,6 @@
|
|||
template(name='inlinedForm')
|
||||
if isOpen.get
|
||||
form(id=id class=classNames)
|
||||
form.js-inlined-form(id=id class=classNames)
|
||||
+Template.contentBlock
|
||||
else
|
||||
+Template.elseBlock
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ BlazeComponent.extendComponent({
|
|||
|
||||
open: function() {
|
||||
// Close currently opened form, if any
|
||||
EscapeActions.executeLowerThan('inlinedForm');
|
||||
EscapeActions.executeUpTo('inlinedForm');
|
||||
this.isOpen.set(true);
|
||||
currentlyOpenedForm.set(this);
|
||||
},
|
||||
|
|
@ -61,18 +61,6 @@ BlazeComponent.extendComponent({
|
|||
'click .js-close-inlined-form': this.close,
|
||||
'click .js-open-inlined-form': this.open,
|
||||
|
||||
// Close the inlined form by pressing escape.
|
||||
//
|
||||
// Keydown (and not keypress) in necessary here because the `keyCode`
|
||||
// property is consistent in all browsers, (there is not keyCode for the
|
||||
// `keypress` event in firefox)
|
||||
'keydown form input, keydown form textarea': function(evt) {
|
||||
if (evt.keyCode === 27) {
|
||||
evt.preventDefault();
|
||||
EscapeActions.executeLowest();
|
||||
}
|
||||
},
|
||||
|
||||
// Pressing Ctrl+Enter should submit the form
|
||||
'keydown form textarea': function(evt) {
|
||||
if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
|
||||
|
|
@ -98,5 +86,7 @@ BlazeComponent.extendComponent({
|
|||
// Press escape to close the currently opened inlinedForm
|
||||
EscapeActions.register('inlinedForm',
|
||||
function() { currentlyOpenedForm.get().close(); },
|
||||
function() { return currentlyOpenedForm.get() !== null; }
|
||||
function() { return currentlyOpenedForm.get() !== null; }, {
|
||||
noClickEscapeOn: '.js-inlined-form'
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue