2022-03-09 22:08:22 +08:00
|
|
|
import { addShortcut } from 'Common/Globals';
|
2021-01-24 17:25:23 +08:00
|
|
|
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 {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
2021-01-24 17:25:23 +08:00
|
|
|
super('KeyboardShortcutsHelp');
|
2021-08-13 16:03:13 +08:00
|
|
|
this.metaKey = shortcuts.getMetaKey();
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
onBuild(dom) {
|
2021-08-26 14:10:56 +08:00
|
|
|
const tabs = dom.querySelectorAll('.tabs input'),
|
|
|
|
last = tabs.length - 1;
|
2020-08-30 16:30:50 +08:00
|
|
|
|
2022-03-09 22:08:22 +08:00
|
|
|
// addShortcut('tab', 'shift',
|
|
|
|
addShortcut('tab,arrowleft,arrowright', '',
|
2022-02-24 18:19:19 +08:00
|
|
|
'KeyboardShortcutsHelp',
|
2021-08-13 02:33:13 +08:00
|
|
|
event => {
|
|
|
|
let next = 0;
|
|
|
|
tabs.forEach((node, index) => {
|
2021-08-26 14:10:56 +08:00
|
|
|
if (node.matches(':checked')) {
|
2021-08-13 02:33:13 +08:00
|
|
|
if (['Tab','ArrowRight'].includes(event.key)) {
|
|
|
|
next = index < last ? index+1 : 0;
|
|
|
|
} else {
|
|
|
|
next = index ? index-1 : last;
|
2020-08-30 16:30:50 +08:00
|
|
|
}
|
2021-08-13 02:33:13 +08:00
|
|
|
}
|
|
|
|
});
|
2021-08-26 14:10:56 +08:00
|
|
|
tabs[next].checked = true;
|
2021-08-13 02:33:13 +08:00
|
|
|
return false;
|
|
|
|
}
|
2019-07-05 03:19:24 +08:00
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
}
|