mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49:20 +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
|
|
@ -588,20 +588,6 @@ MailBoxMessageListViewModel.prototype.onBuild = function (oDom)
|
|||
})
|
||||
;
|
||||
|
||||
ko.computed(function () {
|
||||
|
||||
var
|
||||
oData = RL.data(),
|
||||
bViewModelVisibility = this.viewModelVisibility(),
|
||||
bPopupVisibility = RL.popupVisibility(),
|
||||
bUseKeyboardShortcuts = oData.useKeyboardShortcuts(),
|
||||
bMessageFullScreenMode = oData.messageFullScreenMode()
|
||||
;
|
||||
|
||||
this.selector.useKeyboard(bViewModelVisibility && bUseKeyboardShortcuts && !bMessageFullScreenMode && !bPopupVisibility);
|
||||
|
||||
}, this).extend({'notify': 'always'});
|
||||
|
||||
this.initUploaderForAppend();
|
||||
this.initShortcuts();
|
||||
|
||||
|
|
|
|||
|
|
@ -496,8 +496,7 @@ MailBoxMessageViewViewModel.prototype.initShortcuts = function ()
|
|||
self.deleteCommand();
|
||||
if (handler && 'shift+delete' === handler.shortcut)
|
||||
{
|
||||
// self.deleteWithoutMoveCommand();
|
||||
self.deleteCommand();
|
||||
self.deleteWithoutMoveCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -511,7 +510,7 @@ MailBoxMessageViewViewModel.prototype.initShortcuts = function ()
|
|||
key('tab', Enums.KeyState.MessageView, function () {
|
||||
if (oData.useKeyboardShortcuts())
|
||||
{
|
||||
if (self.message())
|
||||
if (!self.fullScreenMode() && self.message())
|
||||
{
|
||||
self.message.focused(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ function PopupsAskViewModel()
|
|||
this.fNoAction = null;
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
|
||||
|
||||
this.sKeyScope = Enums.KeyState.MessageList;
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
|
|
@ -83,9 +85,6 @@ PopupsAskViewModel.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYe
|
|||
{
|
||||
this.yesButton(sNoButton);
|
||||
}
|
||||
|
||||
this.sKeyScope = RL.data().keyScope();
|
||||
RL.data().keyScope(Enums.KeyState.PopupAsk);
|
||||
};
|
||||
|
||||
PopupsAskViewModel.prototype.onFocus = function ()
|
||||
|
|
@ -93,27 +92,18 @@ PopupsAskViewModel.prototype.onFocus = function ()
|
|||
this.yesFocus(true);
|
||||
};
|
||||
|
||||
PopupsAskViewModel.prototype.onHide = function ()
|
||||
{
|
||||
RL.data().keyScope(this.sKeyScope);
|
||||
};
|
||||
|
||||
PopupsAskViewModel.prototype.onBuild = function ()
|
||||
{
|
||||
key('tab, right, left', Enums.KeyState.PopupAsk, _.bind(function () {
|
||||
if (this.modalVisibility())
|
||||
if (this.yesFocus())
|
||||
{
|
||||
if (this.yesFocus())
|
||||
{
|
||||
this.noFocus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.yesFocus(true);
|
||||
}
|
||||
|
||||
return false;
|
||||
this.noFocus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.yesFocus(true);
|
||||
}
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ function PopupsComposeViewModel()
|
|||
// this.driveCallback = _.bind(this.driveCallback, this);
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sKeyScope = Enums.KeyState.MessageList;
|
||||
this.sDefaultKeyScope = Enums.KeyState.Compose;
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
|
@ -569,8 +569,6 @@ PopupsComposeViewModel.prototype.onHide = function ()
|
|||
{
|
||||
this.reset();
|
||||
kn.routeOn();
|
||||
|
||||
RL.data().keyScope(this.sKeyScope);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -643,9 +641,6 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
|
|||
{
|
||||
kn.routeOff();
|
||||
|
||||
this.sKeyScope = RL.data().keyScope();
|
||||
RL.data().keyScope(Enums.KeyState.Compose);
|
||||
|
||||
var
|
||||
self = this,
|
||||
sFrom = '',
|
||||
|
|
@ -922,7 +917,7 @@ PopupsComposeViewModel.prototype.tryToClosePopup = function ()
|
|||
|
||||
PopupsComposeViewModel.prototype.useShortcuts = function ()
|
||||
{
|
||||
return this.modalVisibility() && RL.data().useKeyboardShortcuts();
|
||||
return RL.data().useKeyboardShortcuts();
|
||||
};
|
||||
|
||||
PopupsComposeViewModel.prototype.onBuild = function ()
|
||||
|
|
@ -931,11 +926,12 @@ PopupsComposeViewModel.prototype.onBuild = function ()
|
|||
|
||||
var
|
||||
self = this,
|
||||
oData = RL.data(),
|
||||
oScript = null
|
||||
;
|
||||
|
||||
key('ctrl+s, command+s', Enums.KeyState.Compose, function () {
|
||||
if (self.useShortcuts())
|
||||
if (oData.useKeyboardShortcuts())
|
||||
{
|
||||
self.saveCommand();
|
||||
return false;
|
||||
|
|
@ -943,7 +939,7 @@ PopupsComposeViewModel.prototype.onBuild = function ()
|
|||
});
|
||||
|
||||
key('ctrl+enter, command+enter', Enums.KeyState.Compose, function () {
|
||||
if (self.useShortcuts())
|
||||
if (oData.useKeyboardShortcuts())
|
||||
{
|
||||
self.sendCommand();
|
||||
return false;
|
||||
|
|
@ -951,8 +947,11 @@ PopupsComposeViewModel.prototype.onBuild = function ()
|
|||
});
|
||||
|
||||
key('esc', Enums.KeyState.Compose, function () {
|
||||
self.tryToClosePopup();
|
||||
return false;
|
||||
if (oData.useKeyboardShortcuts())
|
||||
{
|
||||
self.tryToClosePopup();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$window.on('resize', function () {
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ function PopupsContactsViewModel()
|
|||
}
|
||||
}, this);
|
||||
|
||||
this.sKeyScope = Enums.KeyState.MessageList;
|
||||
this.sDefaultKeyScope = Enums.KeyState.ContactList;
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
|
@ -587,14 +587,6 @@ PopupsContactsViewModel.prototype.onBuild = function (oDom)
|
|||
}
|
||||
});
|
||||
|
||||
ko.computed(function () {
|
||||
var
|
||||
bModalVisibility = this.modalVisibility(),
|
||||
bUseKeyboardShortcuts = RL.data().useKeyboardShortcuts()
|
||||
;
|
||||
this.selector.useKeyboard(bModalVisibility && bUseKeyboardShortcuts);
|
||||
}, this).extend({'notify': 'always'});
|
||||
|
||||
oDom
|
||||
.on('click', '.e-pagenator .e-page', function () {
|
||||
var oPage = ko.dataFor(this);
|
||||
|
|
@ -613,9 +605,6 @@ PopupsContactsViewModel.prototype.onShow = function ()
|
|||
{
|
||||
kn.routeOff();
|
||||
this.reloadContactList(true);
|
||||
|
||||
this.sKeyScope = RL.data().keyScope();
|
||||
RL.data().keyScope(Enums.KeyState.ContactList);
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.onHide = function ()
|
||||
|
|
@ -628,6 +617,4 @@ PopupsContactsViewModel.prototype.onHide = function ()
|
|||
_.each(this.contacts(), function (oItem) {
|
||||
oItem.checked(false);
|
||||
});
|
||||
|
||||
RL.data().keyScope(this.sKeyScope);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,20 +8,7 @@ function PopupsKeyboardShortcutsHelpViewModel()
|
|||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsKeyboardShortcutsHelp');
|
||||
|
||||
this.sKeyScope = Enums.KeyState.None;
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsKeyboardShortcutsHelpViewModel', PopupsKeyboardShortcutsHelpViewModel);
|
||||
|
||||
PopupsKeyboardShortcutsHelpViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.sKeyScope = RL.data().keyScope();
|
||||
RL.data().keyScope(Enums.KeyState.None);
|
||||
};
|
||||
|
||||
PopupsKeyboardShortcutsHelpViewModel.prototype.onHide = function ()
|
||||
{
|
||||
RL.data().keyScope(this.sKeyScope);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ function PopupsPluginViewModel()
|
|||
}, this.hasConfiguration);
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.All;
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
|
@ -127,11 +128,11 @@ PopupsPluginViewModel.prototype.tryToClosePopup = function ()
|
|||
|
||||
PopupsPluginViewModel.prototype.onBuild = function ()
|
||||
{
|
||||
key('esc', _.bind(function () {
|
||||
key('esc', Enums.KeyState.All, _.bind(function () {
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
this.tryToClosePopup();
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
}, this));
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue