mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 09:02:45 +08:00
Centralize tryToClose() for all popups
This commit is contained in:
parent
fa15742edb
commit
c33dd8f856
5 changed files with 8 additions and 13 deletions
|
@ -60,10 +60,9 @@ export class AbstractViewPopup extends AbstractView
|
||||||
this.keyScope.scope = name;
|
this.keyScope.scope = name;
|
||||||
this.modalVisible = ko.observable(false).extend({ rateLimit: 0 });
|
this.modalVisible = ko.observable(false).extend({ rateLimit: 0 });
|
||||||
this.close = () => this.modalVisible(false);
|
this.close = () => this.modalVisible(false);
|
||||||
|
this.tryToClose = () => (false === this.onClose()) || this.close();
|
||||||
addShortcut('escape,close', '', name, () => {
|
addShortcut('escape,close', '', name, () => {
|
||||||
if (this.modalVisible() && false !== this.onClose()) {
|
this.modalVisible() && this.tryToClose();
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
// return true; Issue with supported modal close
|
// return true; Issue with supported modal close
|
||||||
});
|
});
|
||||||
|
|
|
@ -167,7 +167,7 @@ const
|
||||||
if (screenName && fireEvent('sm-show-screen', screenName + (subPart ? '/' + subPart : ''), 1)) {
|
if (screenName && fireEvent('sm-show-screen', screenName + (subPart ? '/' + subPart : ''), 1)) {
|
||||||
// Close all popups
|
// Close all popups
|
||||||
for (let vm of visiblePopups) {
|
for (let vm of visiblePopups) {
|
||||||
(false === vm.onClose()) || vm.close();
|
vm.tryToClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
let vmScreen = screen(screenName);
|
let vmScreen = screen(screenName);
|
||||||
|
|
|
@ -298,7 +298,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
this.tryToClose = this.tryToClose.debounce(200);
|
this.doClose = this.doClose.debounce(200);
|
||||||
|
|
||||||
this.iTimer = 0;
|
this.iTimer = 0;
|
||||||
|
|
||||||
|
@ -665,7 +665,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
this.saveCommand();
|
this.saveCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tryToClose();
|
this.doClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
contactsCommand() {
|
contactsCommand() {
|
||||||
|
@ -1072,7 +1072,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
tryToClose() {
|
doClose() {
|
||||||
if (AskPopupView.hidden()) {
|
if (AskPopupView.hidden()) {
|
||||||
if (ComposePopupView.inEdit() || (this.isEmptyForm() && !this.draftUid())) {
|
if (ComposePopupView.inEdit() || (this.isEmptyForm() && !this.draftUid())) {
|
||||||
this.close();
|
this.close();
|
||||||
|
@ -1218,7 +1218,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
});
|
});
|
||||||
|
|
||||||
addShortcut('escape,close', 'shift', ScopeCompose, () => {
|
addShortcut('escape,close', 'shift', ScopeCompose, () => {
|
||||||
this.tryToClose();
|
this.doClose();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -314,10 +314,6 @@ export class ContactsPopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tryToClose() {
|
|
||||||
(false === this.onClose()) || this.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
const contact = this.contact();
|
const contact = this.contact();
|
||||||
if (AskPopupView.hidden() && contact?.hasChanges()) {
|
if (AskPopupView.hidden() && contact?.hasChanges()) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<header class="g-ui-user-select-none">
|
<header class="g-ui-user-select-none">
|
||||||
<a href="#" class="close" data-bind="click: close">×</a>
|
<a href="#" class="close" data-bind="click: tryToClose">×</a>
|
||||||
<h3 data-bind="visible: !edit()" data-i18n="POPUPS_IDENTITY/TITLE_ADD_IDENTITY"></h3>
|
<h3 data-bind="visible: !edit()" data-i18n="POPUPS_IDENTITY/TITLE_ADD_IDENTITY"></h3>
|
||||||
<h3 data-bind="visible: edit" data-i18n="POPUPS_IDENTITY/TITLE_UPDATE_IDENTITY"></h3>
|
<h3 data-bind="visible: edit" data-i18n="POPUPS_IDENTITY/TITLE_UPDATE_IDENTITY"></h3>
|
||||||
</header>
|
</header>
|
||||||
|
|
Loading…
Reference in a new issue