mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
Drop the ko.bindingHandlers.modal as click.koModal is never used
And replace hideScreenPopup() with this.closeCommand();
This commit is contained in:
parent
2e34f98c80
commit
880d4a05e9
30 changed files with 66 additions and 69 deletions
12
dev/External/ko.js
vendored
12
dev/External/ko.js
vendored
|
|
@ -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)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue