snappymail/dev/View/Popup/KeyboardShortcutsHelp.js

34 lines
815 B
JavaScript
Raw Normal View History

import { addShortcut } from 'Common/Globals';
import { AbstractViewPopup } from 'Knoin/AbstractViews';
2016-06-30 08:02:45 +08:00
2021-08-13 16:03:13 +08:00
export class KeyboardShortcutsHelpPopupView extends AbstractViewPopup {
constructor() {
super('KeyboardShortcutsHelp');
2021-08-13 16:03:13 +08:00
this.metaKey = shortcuts.getMetaKey();
}
2016-06-30 08:02:45 +08:00
onBuild(dom) {
const tabs = dom.querySelectorAll('.tabs input'),
last = tabs.length - 1;
// addShortcut('tab', 'shift',
addShortcut('tab,arrowleft,arrowright', '',
'KeyboardShortcutsHelp',
event => {
let next = 0;
tabs.forEach((node, index) => {
if (node.matches(':checked')) {
if (['Tab','ArrowRight'].includes(event.key)) {
next = index < last ? index+1 : 0;
} else {
next = index ? index-1 : last;
}
}
});
tabs[next].checked = true;
return false;
}
2019-07-05 03:19:24 +08:00
);
}
}