forked from OdyseeTeam/odysee-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboardShortcutsMenuItem.js
More file actions
54 lines (46 loc) · 1.49 KB
/
KeyboardShortcutsMenuItem.js
File metadata and controls
54 lines (46 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import videojs from 'video.js';
import { VJS_COMP } from 'constants/player';
import { platform } from 'util/platform';
const SettingMenuItem = videojs.getComponent('SettingMenuItem');
class KeyboardShortcutsMenuItem extends SettingMenuItem {
constructor(player, options) {
super(player, {
...options,
label: __('Keyboard shortcuts'),
name: VJS_COMP.KEYBOARD_SHORTCUTS_MENU_ITEM,
icon: '',
});
this.addClass('vjs-setting-keyboard-shortcuts');
this.updateVisibility();
}
createEl() {
const { icon, label } = this.options_;
return videojs.dom.createEl('li', {
className: 'vjs-menu-item vjs-setting-menu-item',
innerHTML: `
<div class="vjs-icon-placeholder ${icon || ''}"></div>
<div class="vjs-setting-menu-label">${this.localize(label)}</div>
<div class="vjs-spacer"></div>
`,
});
}
handleClick() {
const player = this.player_;
if (player && typeof player.toggleKeyboardShortcutsOverlay === 'function') {
player.toggleKeyboardShortcutsOverlay(true);
}
const menuButton = this.menu && this.menu.options_ && this.menu.options_.menuButton;
if (menuButton && typeof menuButton.hideMenu === 'function') {
menuButton.hideMenu();
}
}
updateVisibility() {
if (platform.isMobile()) {
this.hide();
} else {
this.show();
}
}
}
videojs.registerComponent(VJS_COMP.KEYBOARD_SHORTCUTS_MENU_ITEM, KeyboardShortcutsMenuItem);
export default KeyboardShortcutsMenuItem;