From 880d4a05e96d9ec6c3ab9e222e5b422c48091765 Mon Sep 17 00:00:00 2001 From: djmaze Date: Sat, 6 Nov 2021 22:08:45 +0100 Subject: [PATCH] Drop the ko.bindingHandlers.modal as click.koModal is never used And replace hideScreenPopup() with this.closeCommand(); --- dev/External/ko.js | 12 ------- dev/Knoin/AbstractViews.js | 3 +- dev/Knoin/Knoin.js | 35 ++++++++++++------- dev/View/Popup/Compose.js | 8 ++--- dev/View/Popup/Contacts.js | 4 +-- snappymail/v/0.0.0/app/templates/Index.html | 2 +- .../templates/Views/Admin/PopupsDomain.html | 2 +- .../Views/Admin/PopupsDomainAlias.html | 2 +- .../templates/Views/Admin/PopupsPlugin.html | 2 +- .../app/templates/Views/Common/Paginator.html | 4 +-- .../app/templates/Views/Common/PopupsAsk.html | 2 +- .../Views/Common/PopupsLanguages.html | 2 +- .../templates/Views/User/MailFolderList.html | 13 ++++++- .../Views/User/MailFolderListSystemItem.html | 10 ------ .../templates/Views/User/MailMessageList.html | 4 ++- .../templates/Views/User/PopupsAccount.html | 2 +- .../Views/User/PopupsAddOpenPgpKey.html | 2 +- .../Views/User/PopupsAdvancedSearch.html | 2 +- .../templates/Views/User/PopupsCompose.html | 2 +- .../Views/User/PopupsComposeOpenPgp.html | 2 +- .../templates/Views/User/PopupsFilter.html | 2 +- .../Views/User/PopupsFolderClear.html | 2 +- .../Views/User/PopupsFolderCreate.html | 2 +- .../Views/User/PopupsFolderSystem.html | 2 +- .../templates/Views/User/PopupsIdentity.html | 2 +- .../User/PopupsKeyboardShortcutsHelp.html | 2 +- .../Views/User/PopupsMessageOpenPgp.html | 2 +- .../Views/User/PopupsNewOpenPgpKey.html | 2 +- .../Views/User/PopupsSieveScript.html | 2 +- .../Views/User/PopupsViewOpenPgpKey.html | 2 +- 30 files changed, 66 insertions(+), 69 deletions(-) delete mode 100644 snappymail/v/0.0.0/app/templates/Views/User/MailFolderListSystemItem.html diff --git a/dev/External/ko.js b/dev/External/ko.js index f3772699a..6107a3a43 100644 --- a/dev/External/ko.js +++ b/dev/External/ko.js @@ -45,18 +45,6 @@ ko.bindingHandlers.onSpace = { } }; -ko.bindingHandlers.modal = { - init: (element, fValueAccessor) => { - const close = element.querySelector('.close'), - click = () => fValueAccessor()(false); - close && close.addEventListener('click.koModal', click); - - ko.utils.domNodeDisposal.addDisposeCallback(element, () => - close.removeEventListener('click.koModal', click) - ); - } -}; - ko.bindingHandlers.i18nInit = { init: element => i18nToNodes(element) }; diff --git a/dev/Knoin/AbstractViews.js b/dev/Knoin/AbstractViews.js index 5ddff917c..027cd573c 100644 --- a/dev/Knoin/AbstractViews.js +++ b/dev/Knoin/AbstractViews.js @@ -13,8 +13,6 @@ class AbstractView { this.viewType = type; this.viewModelDom = null; - this.modalVisibility = ko.observable(false).extend({ rateLimit: 0 }); - this.keyScope = { scope: Scope.None, previous: Scope.None, @@ -62,6 +60,7 @@ export class AbstractViewPopup extends AbstractView this.keyScope.scope = Scope[name]; } this.bDisabeCloseOnEsc = false; + this.modalVisibility = ko.observable(false).extend({ rateLimit: 0 }); } /* onShowWithDelay() {} diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index cb1a0f850..10d616390 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -45,9 +45,7 @@ const ViewModelClass.__dom = vmDom; if (ViewType.Popup === position) { - vm.cancelCommand = vm.closeCommand = createCommand(() => { - hideScreenPopup(ViewModelClass); - }); + vm.cancelCommand = vm.closeCommand = createCommand(() => hideScreenPopup(ViewModelClass)); // show/hide popup/modal const endShowHide = e => { @@ -81,6 +79,17 @@ const arePopupsVisible(0 < visiblePopups.size); } vmDom.setAttribute('aria-hidden', !value); +/* + // the old ko.bindingHandlers.modal + const close = vmDom.querySelector('.close'), + click = () => vm.modalVisibility(false); + if (close) { + close.addEventListener('click.koModal', click); + ko.utils.domNodeDisposal.addDisposeCallback(vmDom, () => + close.removeEventListener('click.koModal', click) + ); + } +*/ }); if ('ontransitionend' in vmDom) { vmDom.addEventListener('transitionend', endShowHide); @@ -134,6 +143,16 @@ const }); }, + /** + * @param {Function} ViewModelClassToHide + * @returns {void} + */ + hideScreenPopup = ViewModelClassToHide => { + if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) { + ViewModelClassToHide.__vm.modalVisibility(false); + } + }, + /** * @param {string} screenName * @param {string} subPart @@ -236,16 +255,6 @@ export const return fResult; }, - /** - * @param {Function} ViewModelClassToHide - * @returns {void} - */ - hideScreenPopup = ViewModelClassToHide => { - if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) { - ViewModelClassToHide.__vm.modalVisibility(false); - } - }, - getScreenPopupViewModel = ViewModelClassToShow => (buildViewModel(ViewModelClassToShow) && ViewModelClassToShow.__dom) && ViewModelClassToShow.__vm, diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 1cd4e4f4f..e25b8bc1f 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -35,7 +35,7 @@ import Remote from 'Remote/User/Fetch'; import { ComposeAttachmentModel } from 'Model/ComposeAttachment'; -import { decorateKoCommands, isPopupVisible, showScreenPopup, hideScreenPopup } from 'Knoin/Knoin'; +import { decorateKoCommands, isPopupVisible, showScreenPopup } from 'Knoin/Knoin'; import { AbstractViewPopup } from 'Knoin/AbstractViews'; import { FolderSystemPopupView } from 'View/Popup/FolderSystem'; @@ -500,7 +500,7 @@ class ComposePopupView extends AbstractViewPopup { () => { if (this.modalVisibility()) { rl.app.deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]); - hideScreenPopup(ComposePopupView); + this.closeCommand(); } } ]); @@ -1064,9 +1064,7 @@ class ComposePopupView extends AbstractViewPopup { } else { showScreenPopup(AskPopupView, [ i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), - () => { - this.modalVisibility() && this.closeCommand(); - } + () => this.closeCommand() ]); } } diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index b6eb202ee..07e1920ec 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -23,7 +23,7 @@ import { EmailModel } from 'Model/Email'; import { ContactModel } from 'Model/Contact'; import { ContactPropertyModel, ContactPropertyType } from 'Model/ContactProperty'; -import { decorateKoCommands, hideScreenPopup } from 'Knoin/Knoin'; +import { decorateKoCommands } from 'Knoin/Knoin'; import { AbstractViewPopup } from 'Knoin/AbstractViews'; const CONTACTS_PER_PAGE = 50, @@ -183,7 +183,7 @@ class ContactsPopupView extends AbstractViewPopup { if (arrayLength(aE)) { this.bBackToCompose = false; - hideScreenPopup(ContactsPopupView); + this.closeCommand(); switch (this.sLastComposeFocusedField) { case 'cc': diff --git a/snappymail/v/0.0.0/app/templates/Index.html b/snappymail/v/0.0.0/app/templates/Index.html index 2aafa5648..c3edcf976 100644 --- a/snappymail/v/0.0.0/app/templates/Index.html +++ b/snappymail/v/0.0.0/app/templates/Index.html @@ -32,8 +32,8 @@ -
{{BaseTemplates}} diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/PopupsDomain.html b/snappymail/v/0.0.0/app/templates/Views/Admin/PopupsDomain.html index 555c8dfc5..c62a42d7b 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/PopupsDomain.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/PopupsDomain.html @@ -1,5 +1,5 @@