2021-03-16 23:06:16 +08:00
|
|
|
import { Scope } from 'Common/Enums';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
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
|
|
|
|
2020-09-26 06:02:29 +08:00
|
|
|
// shortcuts.add('tab', 'shift',
|
2020-09-26 16:20:24 +08:00
|
|
|
shortcuts.add('tab,arrowleft,arrowright', '',
|
2021-03-16 23:06:16 +08:00
|
|
|
Scope.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
|
|
|
}
|
|
|
|
}
|