Files
snappymail/dev/View/Popup/KeyboardShortcutsHelp.js
djmaze ea48f5060b isArray to native Array.isArray
isUnd(*) to native undefined === *
isFunc to native typeof * === 'function'
isObject to native typeof * === 'object'
microtime() to native Date().getTime();
noop to native ()=>{}
noopFalse to native ()=>false
noopTrue to native ()=>true
boolToAjax to native *?'1':'0'
Underscore.js to native
2020-07-29 21:49:41 +02:00

57 lines
1.3 KiB
JavaScript

import key from 'key';
import { KeyState, Magics } from 'Common/Enums';
import { popup } from 'Knoin/Knoin';
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
@popup({
name: 'View/Popup/KeyboardShortcutsHelp',
templateID: 'PopupsKeyboardShortcutsHelp'
})
class KeyboardShortcutsHelpPopupView extends AbstractViewNext {
constructor() {
super();
this.sDefaultKeyScope = KeyState.PopupKeyboardShortcutsHelp;
}
onBuild(dom) {
var t;
key(
'tab, shift+tab, left, right',
KeyState.PopupKeyboardShortcutsHelp,
(event, handler)=>{
// throttle
if (!t) {
t = setTimeout(()=>{
t = 0;
if (event && handler) {
const $tabs = dom.find('.nav.nav-tabs > li'),
isNext = handler && ('tab' === handler.shortcut || 'right' === handler.shortcut);
let index = $tabs.index($tabs.filter('.active'));
if (!isNext && 0 < index) {
index -= 1;
} else if (isNext && index < $tabs.length - 1) {
index += 1;
} else {
index = isNext ? 0 : $tabs.length - 1;
}
$tabs
.eq(index)
.find('a[data-toggle="tab"]')
.tab('show');
return false;
}
return true;
}, Magics.Time100ms);
}
}
);
}
}
export { KeyboardShortcutsHelpPopupView, KeyboardShortcutsHelpPopupView as default };