mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-30 10:16:44 +03:00
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
|
|
var
|
|
_ = require('_'),
|
|
key = require('key'),
|
|
|
|
Enums = require('Common/Enums'),
|
|
|
|
kn = require('Knoin/Knoin'),
|
|
AbstractView = require('Knoin/AbstractView');
|
|
|
|
/**
|
|
* @constructor
|
|
* @extends AbstractView
|
|
*/
|
|
function KeyboardShortcutsHelpPopupView()
|
|
{
|
|
AbstractView.call(this, 'Popups', 'PopupsKeyboardShortcutsHelp');
|
|
|
|
this.sDefaultKeyScope = Enums.KeyState.PopupKeyboardShortcutsHelp;
|
|
|
|
kn.constructorEnd(this);
|
|
}
|
|
|
|
kn.extendAsViewModel(['View/Popup/KeyboardShortcutsHelp', 'PopupsKeyboardShortcutsHelpViewModel'], KeyboardShortcutsHelpPopupView);
|
|
_.extend(KeyboardShortcutsHelpPopupView.prototype, AbstractView.prototype);
|
|
|
|
KeyboardShortcutsHelpPopupView.prototype.onBuild = function(oDom)
|
|
{
|
|
key('tab, shift+tab, left, right', Enums.KeyState.PopupKeyboardShortcutsHelp, _.throttle(_.bind(function(event, handler) {
|
|
if (event && handler)
|
|
{
|
|
var
|
|
$tabs = oDom.find('.nav.nav-tabs > li'),
|
|
bNext = handler && ('tab' === handler.shortcut || 'right' === handler.shortcut),
|
|
iIndex = $tabs.index($tabs.filter('.active'));
|
|
|
|
if (!bNext && 0 < iIndex)
|
|
{
|
|
iIndex -= 1;
|
|
}
|
|
else if (bNext && iIndex < $tabs.length - 1)
|
|
{
|
|
iIndex += 1;
|
|
}
|
|
else
|
|
{
|
|
iIndex = bNext ? 0 : $tabs.length - 1;
|
|
}
|
|
|
|
$tabs.eq(iIndex).find('a[data-toggle="tab"]').tab('show');
|
|
return false;
|
|
}
|
|
}, this), 100));
|
|
};
|
|
|
|
module.exports = KeyboardShortcutsHelpPopupView;
|