mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Drop cancelCommand in favor of closeCommand and improve AbstractViewPopup handling
This commit is contained in:
parent
06b5b83588
commit
2edd55f01f
36 changed files with 82 additions and 118 deletions
|
|
@ -57,36 +57,30 @@ export class AbstractViewPopup extends AbstractView
|
|||
constructor(name)
|
||||
{
|
||||
super('Popups' + name, ViewType.Popup);
|
||||
if (name in Scope) {
|
||||
this.keyScope.scope = Scope[name];
|
||||
}
|
||||
this.bDisabeCloseOnEsc = false;
|
||||
this.keyScope.scope = name;
|
||||
this.modalVisibility = ko.observable(false).extend({ rateLimit: 0 });
|
||||
}
|
||||
/*
|
||||
onShowWithDelay() {}
|
||||
onHideWithDelay() {}
|
||||
|
||||
cancelCommand() {}
|
||||
closeCommand() {}
|
||||
*/
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
registerPopupKeyDown() {
|
||||
addEventListener('keydown', event => {
|
||||
if (event && this.modalVisibility()) {
|
||||
if (!this.bDisabeCloseOnEsc && 'Escape' == event.key) {
|
||||
this.cancelCommand();
|
||||
return false;
|
||||
} else if ('Backspace' == event.key && !inFocus()) {
|
||||
return false;
|
||||
}
|
||||
this.onClose = this.onClose.debounce(200);
|
||||
shortcuts.add('escape,close', '', name, () => {
|
||||
if (this.modalVisibility() && this.onClose()) {
|
||||
this.closeCommand();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
shortcuts.add('backspace', '', name, inFocus());
|
||||
}
|
||||
|
||||
onClose() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
afterShow() {}
|
||||
afterHide() {}
|
||||
|
||||
closeCommand() {}
|
||||
*/
|
||||
}
|
||||
|
||||
AbstractViewPopup.showModal = function(params = []) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue