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 | |
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')
-rw-r--r-- | client/src/app/app.component.html | 2 | ||||
-rw-r--r-- | client/src/app/app.component.ts | 31 | ||||
-rw-r--r-- | client/src/app/app.module.ts | 4 |
3 files changed, 36 insertions, 1 deletions
diff --git a/client/src/app/app.component.html b/client/src/app/app.component.html index 09b2c15be..697abec8e 100644 --- a/client/src/app/app.component.html +++ b/client/src/app/app.component.html | |||
@@ -1,5 +1,7 @@ | |||
1 | <div *ngIf="customCSS" [innerHTML]="customCSS"></div> | 1 | <div *ngIf="customCSS" [innerHTML]="customCSS"></div> |
2 | 2 | ||
3 | <hotkeys-cheatsheet></hotkeys-cheatsheet> | ||
4 | |||
3 | <div [ngClass]="{ 'user-logged-in': isUserLoggedIn(), 'user-not-logged-in': !isUserLoggedIn() }"> | 5 | <div [ngClass]="{ 'user-logged-in': isUserLoggedIn(), 'user-not-logged-in': !isUserLoggedIn() }"> |
4 | <div class="header"> | 6 | <div class="header"> |
5 | 7 | ||
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 () { |
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 118831ed3..b484a89e8 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts | |||
@@ -5,6 +5,7 @@ import { ResetPasswordModule } from '@app/reset-password' | |||
5 | 5 | ||
6 | import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' | 6 | import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' |
7 | import { ClipboardModule } from 'ngx-clipboard' | 7 | import { ClipboardModule } from 'ngx-clipboard' |
8 | import { HotkeyModule, IHotkeyOptions } from 'angular2-hotkeys' | ||
8 | 9 | ||
9 | import { AppRoutingModule } from './app-routing.module' | 10 | import { AppRoutingModule } from './app-routing.module' |
10 | import { AppComponent } from './app.component' | 11 | import { AppComponent } from './app.component' |
@@ -45,6 +46,9 @@ export function metaFactory (serverService: ServerService): MetaLoader { | |||
45 | BrowserModule, | 46 | BrowserModule, |
46 | // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133 | 47 | // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133 |
47 | ClipboardModule, | 48 | ClipboardModule, |
49 | HotkeyModule.forRoot({ | ||
50 | cheatSheetCloseEsc: true | ||
51 | } as IHotkeyOptions), | ||
48 | 52 | ||
49 | CoreModule, | 53 | CoreModule, |
50 | SharedModule, | 54 | SharedModule, |