mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 07:20:12 +01:00
Implement a new system to handle "escape actions"
The new EscapeActions object decide what to do when the user press the Escape key (such as closing a opened popup or inlined form). This commit also re-introduced the sidebar current view as a sidebar component local state.
This commit is contained in:
parent
1b4fcc67f4
commit
40c2411f2a
13 changed files with 148 additions and 53 deletions
|
|
@ -15,7 +15,9 @@
|
|||
// We can only have one inlined form element opened at a time
|
||||
// XXX Could we avoid using a global here ? This is used in Mousetrap
|
||||
// keyboard.js
|
||||
currentlyOpenedForm = new ReactiveVar(null);
|
||||
var currentlyOpenedForm = new ReactiveVar(null);
|
||||
|
||||
var inlinedFormEscapePriority = 30;
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
template: function() {
|
||||
|
|
@ -32,9 +34,10 @@ BlazeComponent.extendComponent({
|
|||
|
||||
open: function() {
|
||||
// Close currently opened form, if any
|
||||
if (currentlyOpenedForm.get() !== null) {
|
||||
currentlyOpenedForm.get().close();
|
||||
}
|
||||
// if (currentlyOpenedForm.get() !== null) {
|
||||
// currentlyOpenedForm.get().close();
|
||||
// }
|
||||
EscapeActions.executeLowerThan(inlinedFormEscapePriority);
|
||||
this.isOpen.set(true);
|
||||
currentlyOpenedForm.set(this);
|
||||
},
|
||||
|
|
@ -46,7 +49,8 @@ BlazeComponent.extendComponent({
|
|||
},
|
||||
|
||||
getValue: function() {
|
||||
return this.isOpen.get() && this.find('textarea,input[type=text]').value;
|
||||
var input = this.find('textarea,input[type=text]');
|
||||
return this.isOpen.get() && input && input.value;
|
||||
},
|
||||
|
||||
saveValue: function() {
|
||||
|
|
@ -66,7 +70,7 @@ BlazeComponent.extendComponent({
|
|||
'keydown form input, keydown form textarea': function(evt) {
|
||||
if (evt.keyCode === 27) {
|
||||
evt.preventDefault();
|
||||
this.close();
|
||||
EscapeActions.executeLowest();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -91,3 +95,9 @@ BlazeComponent.extendComponent({
|
|||
}];
|
||||
}
|
||||
}).register('inlinedForm');
|
||||
|
||||
// Press escape to close the currently opened inlinedForm
|
||||
EscapeActions.register(inlinedFormEscapePriority,
|
||||
function() { return currentlyOpenedForm.get() !== null; },
|
||||
function() { currentlyOpenedForm.get().close(); }
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue