mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 04:59:21 +03:00
Small refactoring (popup key scope optimization)
This commit is contained in:
parent
77cdc4690b
commit
a96e1d80c3
22 changed files with 226 additions and 254 deletions
|
|
@ -11,6 +11,9 @@ function KnoinAbstractViewModel(sPosition, sTemplate)
|
|||
this.sPosition = Utils.pString(sPosition);
|
||||
this.sTemplate = Utils.pString(sTemplate);
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.None;
|
||||
this.sCurrentKeyScope = this.sDefaultKeyScope;
|
||||
|
||||
this.viewModelName = '';
|
||||
this.viewModelVisibility = ko.observable(false);
|
||||
if ('Popups' === this.sPosition)
|
||||
|
|
@ -61,13 +64,27 @@ KnoinAbstractViewModel.prototype.cancelCommand = KnoinAbstractViewModel.prototyp
|
|||
{
|
||||
};
|
||||
|
||||
KnoinAbstractViewModel.prototype.storeAndSetKeyScope = function ()
|
||||
{
|
||||
this.sCurrentKeyScope = RL.data().keyScope();
|
||||
RL.data().keyScope(this.sDefaultKeyScope);
|
||||
};
|
||||
|
||||
KnoinAbstractViewModel.prototype.restoreKeyScope = function ()
|
||||
{
|
||||
RL.data().keyScope(this.sCurrentKeyScope);
|
||||
};
|
||||
|
||||
KnoinAbstractViewModel.prototype.registerPopupEscapeKey = function ()
|
||||
{
|
||||
key('esc', _.bind(function () {
|
||||
if (this.modalVisibility && this.modalVisibility())
|
||||
var self = this;
|
||||
$window.on('keydown', function (oEvent) {
|
||||
if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility && self.modalVisibility())
|
||||
{
|
||||
Utils.delegateRun(this, 'cancelCommand');
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
return false;
|
||||
}
|
||||
}, this));
|
||||
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue