From def1ced5351ec66d6d7ad6c42510c4b7128f68e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Thu, 13 Jul 2017 16:04:56 +0200 Subject: [PATCH 1/5] #39: Add option to close cheat sheet on ESC, update angular dependencies to 4.2.5 and fix tsconfig --- package.json | 18 +++++++++--------- src/cheatsheet.component.ts | 13 ++++++++++--- src/hotkey.options.ts | 5 +++++ src/hotkeys.service.ts | 14 +++++++++++++- tsconfig.json | 6 +++++- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 1c51168..44b4d3a 100644 --- a/package.json +++ b/package.json @@ -33,16 +33,16 @@ "mousetrap": "^1.6.0" }, "devDependencies": { - "@angular/common": "4.0.0-beta.6", - "@angular/compiler": "4.0.0-beta.6", - "@angular/compiler-cli": "4.0.0-beta.6", - "@angular/core": "4.0.0-beta.6", - "@types/core-js": "^0.9.35", - "codelyzer": "^0.0.28", - "rxjs": "^5.0.1", + "@angular/common": "4.2.5", + "@angular/compiler": "4.2.5", + "@angular/compiler-cli": "4.2.5", + "@angular/core": "4.2.5", + "@types/core-js": "0.9.41", + "codelyzer": "~3.0.1", + "rxjs": "^5.4.0", "tslint": "^3.15.1", - "typescript": "2.1.5", - "zone.js": "0.7.2" + "typescript": "~2.3.3", + "zone.js": "^0.8.4" }, "engines": { "node": ">=0.8.0" diff --git a/src/cheatsheet.component.ts b/src/cheatsheet.component.ts index 1e013fc..7698be5 100644 --- a/src/cheatsheet.component.ts +++ b/src/cheatsheet.component.ts @@ -134,9 +134,16 @@ export class CheatSheetComponent implements OnInit, OnDestroy { } public ngOnInit(): void { - this.subscription = this.hotkeysService.cheatSheetToggle.subscribe(() => { - this.hotkeys = this.hotkeysService.hotkeys.filter(hotkey => hotkey.description); - this.toggleCheatSheet(); + this.subscription = this.hotkeysService.cheatSheetToggle.subscribe((isOpen) => { + if(isOpen !== false) { + this.hotkeys = this.hotkeysService.hotkeys.filter(hotkey => hotkey.description); + } + + if(isOpen === false) { + this.helpVisible = false; + } else { + this.toggleCheatSheet(); + } }); } diff --git a/src/hotkey.options.ts b/src/hotkey.options.ts index a2d785d..3a16043 100644 --- a/src/hotkey.options.ts +++ b/src/hotkey.options.ts @@ -9,6 +9,11 @@ export interface IHotkeyOptions { * Key combination to trigger the cheat sheet. Default: '?' */ cheatSheetHotkey?: string; + + /** + * Use also ESC for closing the cheat sheet. Default: false + */ + cheatSheetCloseEsc?: boolean; /** * Description for the cheat sheet hot key in the cheat sheet. Default: 'Show / hide this help menu' */ diff --git a/src/hotkeys.service.ts b/src/hotkeys.service.ts index aad08be..a4d12d4 100644 --- a/src/hotkeys.service.ts +++ b/src/hotkeys.service.ts @@ -26,12 +26,24 @@ export class HotkeysService { this.add(new Hotkey( this.options.cheatSheetHotkey || '?', function (event: KeyboardEvent) { - this.cheatSheetToggle.next({}); + this.cheatSheetToggle.next(); }.bind(this), [], this.options.cheatSheetDescription || 'Show / hide this help menu', )); } + + if(this.options.cheatSheetCloseEsc) { + this.add(new Hotkey( + 'esc', + function (event: KeyboardEvent) { + this.cheatSheetToggle.next(false); + }.bind(this), + ['HOTKEYS-CHEATSHEET'], + 'Hide this help menu', + )); + } + } add(hotkey: Hotkey | Hotkey[], specificEvent?: string): Hotkey | Hotkey[] { diff --git a/tsconfig.json b/tsconfig.json index aaef34e..041ecde 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,11 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "sourceMap": true, - "declaration": true + "declaration": true, + "lib": [ + "es2016", + "dom" + ] }, "angularCompilerOptions": { "genDir": "compiled" From 00e9542e741fc25b557f2e722363eb0fd0a46821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Thu, 13 Jul 2017 16:26:09 +0200 Subject: [PATCH 2/5] #39: Add option to close cheat sheet on ESC, update angular dependencies to 4.2.5 and fix tsconfig --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44b4d3a..59bcf4f 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "repository": { "type": "git", - "url": "git@github.com:brtnshrdr/angular2-hotkeys.git" + "url": "git@github.com:AnBauer/angular2-hotkeys.git" }, "author": { "name": "Nick Richardson", @@ -25,7 +25,7 @@ ], "license": "MIT", "bugs": { - "url": "git@github.com:brtnshrdr/angular2-hotkeys.git/issues" + "url": "git@github.com:AnBauer/angular2-hotkeys.git/issues" }, "main": "./index.js", "dependencies": { From 56a084005f03de90de442f33406127e1842d0612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Thu, 13 Jul 2017 16:26:20 +0200 Subject: [PATCH 3/5] #39: Add option to close cheat sheet on ESC, update angular dependencies to 4.2.5 and fix tsconfig --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 59bcf4f..8d8bc20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular2-hotkeys", - "version": "2.0.1", + "version": "2.0.2", "scripts": { "lint": "tslint src/**/*.ts", "test": "tsc && karma start", From e57dd03b7b00a517993ea1dda722d27cf6001ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Wed, 19 Jul 2017 08:49:43 +0200 Subject: [PATCH 4/5] #39: Fix github urls and add option to readme --- README.MD | 4 ++++ package.json | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index fb70ad5..14575b7 100644 --- a/README.MD +++ b/README.MD @@ -79,6 +79,10 @@ export interface IHotkeyOptions { * Key combination to trigger the cheat sheet. Default: '?' */ cheatSheetHotkey?: string; + /** + * Use also ESC for closing the cheat sheet. Default: false + */ + cheatSheetCloseEsc?: boolean; /** * Description for the cheat sheet hot key in the cheat sheet. Default: 'Show / hide this help menu' */ diff --git a/package.json b/package.json index 8d8bc20..1eae3f3 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "repository": { "type": "git", - "url": "git@github.com:AnBauer/angular2-hotkeys.git" + "url": "git@github.com:brtnshrdr/angular2-hotkeys.git" }, "author": { "name": "Nick Richardson", @@ -25,7 +25,7 @@ ], "license": "MIT", "bugs": { - "url": "git@github.com:AnBauer/angular2-hotkeys.git/issues" + "url": "git@github.com:brtnshrdr/angular2-hotkeys.git/issues" }, "main": "./index.js", "dependencies": { From 9becfafc856416d512de8ad6270b059889b8b76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Wed, 19 Jul 2017 09:15:22 +0200 Subject: [PATCH 5/5] #39: Fix indention --- README.MD | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index 14575b7..5229aa2 100644 --- a/README.MD +++ b/README.MD @@ -80,9 +80,9 @@ export interface IHotkeyOptions { */ cheatSheetHotkey?: string; /** - * Use also ESC for closing the cheat sheet. Default: false - */ - cheatSheetCloseEsc?: boolean; + * Use also ESC for closing the cheat sheet. Default: false + */ + cheatSheetCloseEsc?: boolean; /** * Description for the cheat sheet hot key in the cheat sheet. Default: 'Show / hide this help menu' */