aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/hotkeys/hotkeys.component.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-09-11 15:07:31 +0200
committerRigel Kent <sendmemail@rigelk.eu>2018-09-11 21:33:22 +0200
commit7aba23d13fe56835b07ebb00c0b4c2a929551ec3 (patch)
treee67f5a28ec12d6250231d2450354390cd8ae9ce0 /client/src/app/core/hotkeys/hotkeys.component.ts
parent5284d4028c5db6e32b73b13731622ba477597561 (diff)
downloadPeerTube-7aba23d13fe56835b07ebb00c0b4c2a929551ec3.tar.gz
PeerTube-7aba23d13fe56835b07ebb00c0b4c2a929551ec3.tar.zst
PeerTube-7aba23d13fe56835b07ebb00c0b4c2a929551ec3.zip
wrap the hotkeys component to allow templating :art:
Diffstat (limited to 'client/src/app/core/hotkeys/hotkeys.component.ts')
-rw-r--r--client/src/app/core/hotkeys/hotkeys.component.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/client/src/app/core/hotkeys/hotkeys.component.ts b/client/src/app/core/hotkeys/hotkeys.component.ts
new file mode 100644
index 000000000..f6f299965
--- /dev/null
+++ b/client/src/app/core/hotkeys/hotkeys.component.ts
@@ -0,0 +1,46 @@
1import { Component, OnInit, OnDestroy, Input } from '@angular/core'
2import { Subscription } from 'rxjs'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { HotkeysService, Hotkey } from 'angular2-hotkeys'
5
6@Component({
7 selector : 'my-hotkeys-cheatsheet',
8 templateUrl : './hotkeys.component.html',
9 styleUrls: [ './hotkeys.component.scss' ]
10})
11export class CheatSheetComponent implements OnInit, OnDestroy {
12 helpVisible = false
13 @Input() title = this.i18n('Keyboard Shortcuts:')
14 subscription: Subscription
15
16 hotkeys: Hotkey[]
17
18 constructor (
19 private hotkeysService: HotkeysService,
20 private i18n: I18n
21 ) {}
22
23 public ngOnInit (): void {
24 this.subscription = this.hotkeysService.cheatSheetToggle.subscribe((isOpen) => {
25 if (isOpen !== false) {
26 this.hotkeys = this.hotkeysService.hotkeys.filter(hotkey => hotkey.description)
27 }
28
29 if (isOpen === false) {
30 this.helpVisible = false
31 } else {
32 this.toggleCheatSheet()
33 }
34 })
35 }
36
37 public ngOnDestroy (): void {
38 if (this.subscription) {
39 this.subscription.unsubscribe()
40 }
41 }
42
43 public toggleCheatSheet (): void {
44 this.helpVisible = !this.helpVisible
45 }
46}