diff options
author | Rigel Kent <par@rigelk.eu> | 2018-08-28 09:32:03 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-28 09:32:03 +0200 |
commit | ee1fc23a8794364687ea06cbb738bc5f6ce70d7f (patch) | |
tree | 2c6002a44984211f2290e8a4d5d3e60836c090d5 /client/src/app/app.component.ts | |
parent | f74c294a0d5e9f61f13d64f3f7c028b512431995 (diff) | |
download | PeerTube-ee1fc23a8794364687ea06cbb738bc5f6ce70d7f.tar.gz PeerTube-ee1fc23a8794364687ea06cbb738bc5f6ce70d7f.tar.zst PeerTube-ee1fc23a8794364687ea06cbb738bc5f6ce70d7f.zip |
keyboard shortcuts and key map view (#974)
Diffstat (limited to 'client/src/app/app.component.ts')
-rw-r--r-- | client/src/app/app.component.ts | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 2149768a2..a69f419be 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts | |||
@@ -5,6 +5,7 @@ import { AuthService, RedirectService, ServerService } from '@app/core' | |||
5 | import { is18nPath } from '../../../shared/models/i18n' | 5 | import { is18nPath } from '../../../shared/models/i18n' |
6 | import { ScreenService } from '@app/shared/misc/screen.service' | 6 | import { ScreenService } from '@app/shared/misc/screen.service' |
7 | import { skip } from 'rxjs/operators' | 7 | import { skip } from 'rxjs/operators' |
8 | import { HotkeysService, Hotkey } from 'angular2-hotkeys' | ||
8 | 9 | ||
9 | @Component({ | 10 | @Component({ |
10 | selector: 'my-app', | 11 | selector: 'my-app', |
@@ -35,7 +36,8 @@ export class AppComponent implements OnInit { | |||
35 | private serverService: ServerService, | 36 | private serverService: ServerService, |
36 | private domSanitizer: DomSanitizer, | 37 | private domSanitizer: DomSanitizer, |
37 | private redirectService: RedirectService, | 38 | private redirectService: RedirectService, |
38 | private screenService: ScreenService | 39 | private screenService: ScreenService, |
40 | private hotkeysService: HotkeysService | ||
39 | ) { } | 41 | ) { } |
40 | 42 | ||
41 | get serverVersion () { | 43 | get serverVersion () { |
@@ -120,6 +122,33 @@ export class AppComponent implements OnInit { | |||
120 | this.customCSS = this.domSanitizer.bypassSecurityTrustHtml(styleTag) | 122 | this.customCSS = this.domSanitizer.bypassSecurityTrustHtml(styleTag) |
121 | } | 123 | } |
122 | }) | 124 | }) |
125 | |||
126 | this.hotkeysService.add([ | ||
127 | new Hotkey('/', (event: KeyboardEvent): boolean => { | ||
128 | document.getElementById('search-video').focus() | ||
129 | return false // Prevent bubbling | ||
130 | }, undefined, 'Focus the search bar'), | ||
131 | new Hotkey('g+s', (event: KeyboardEvent): boolean => { | ||
132 | this.router.navigate([ '/videos/subscriptions' ]) | ||
133 | return false | ||
134 | }, undefined, 'Go to the subscriptions videos page'), | ||
135 | new Hotkey('g+t', (event: KeyboardEvent): boolean => { | ||
136 | this.router.navigate([ '/videos/trending' ]) | ||
137 | return false | ||
138 | }, undefined, 'Go to the trending videos page'), | ||
139 | new Hotkey('g+r', (event: KeyboardEvent): boolean => { | ||
140 | this.router.navigate([ '/videos/recently-added' ]) | ||
141 | return false | ||
142 | }, undefined, 'Go to the recently added videos page'), | ||
143 | new Hotkey('g+l', (event: KeyboardEvent): boolean => { | ||
144 | this.router.navigate([ '/videos/local' ]) | ||
145 | return false | ||
146 | }, undefined, 'Go to the local videos page'), | ||
147 | new Hotkey('g+u', (event: KeyboardEvent): boolean => { | ||
148 | this.router.navigate([ '/videos/upload' ]) | ||
149 | return false | ||
150 | }, undefined, 'Go to the videos upload page') | ||
151 | ]) | ||
123 | } | 152 | } |
124 | 153 | ||
125 | isUserLoggedIn () { | 154 | isUserLoggedIn () { |