From c0c420cd6c77897e6d21de7f2e8ee4e78a37f4f0 Mon Sep 17 00:00:00 2001 From: Jonathan Park Date: Tue, 3 Mar 2015 11:15:49 -0800 Subject: [PATCH 1/2] hotkeys interface supports both string and string[] for combos --- angular-hotkeys/angular-hotkeys-tests.ts | 5 +++++ angular-hotkeys/angular-hotkeys.d.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/angular-hotkeys/angular-hotkeys-tests.ts b/angular-hotkeys/angular-hotkeys-tests.ts index a065d4b21d..3584108113 100644 --- a/angular-hotkeys/angular-hotkeys-tests.ts +++ b/angular-hotkeys/angular-hotkeys-tests.ts @@ -22,4 +22,9 @@ hotkeyProvider.bindTo(scope) description: 'blah blah', callback: function() {} }); + .add({ + combo: ['w', 'mod+w'], + description: 'blah blah', + callback: function() {} + }); diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts index 63da273ceb..83d5021cc7 100644 --- a/angular-hotkeys/angular-hotkeys.d.ts +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -40,7 +40,7 @@ declare module ng.hotkeys { } interface Hotkey { - combo: string; + combo: string | string[]; description?: string; callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void; action?: string; From 07305d7e950b258d185e3484300d6353056d696b Mon Sep 17 00:00:00 2001 From: Jonathan Park Date: Tue, 3 Mar 2015 11:50:52 -0800 Subject: [PATCH 2/2] Extend to all interfaces --- angular-hotkeys/angular-hotkeys-tests.ts | 5 ++++- angular-hotkeys/angular-hotkeys.d.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/angular-hotkeys/angular-hotkeys-tests.ts b/angular-hotkeys/angular-hotkeys-tests.ts index 3584108113..c683540a3a 100644 --- a/angular-hotkeys/angular-hotkeys-tests.ts +++ b/angular-hotkeys/angular-hotkeys-tests.ts @@ -6,10 +6,13 @@ var hotkeyProvider: ng.hotkeys.HotkeysProvider; var hotkeyObj: ng.hotkeys.Hotkey; hotkeyProvider.add("mod+s", "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} ); +hotkeyProvider.add(["mod+s"], "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} ); hotkeyProvider.add(hotkeyObj); hotkeyProvider.bindTo(scope); hotkeyProvider.del("mod+s"); +hotkeyProvider.del(["mod+s"]); hotkeyProvider.get("mod+s"); +hotkeyProvider.get(["mod+s"]); hotkeyProvider.toggleCheatSheet(); hotkeyProvider.add(hotkeyObj.combo, hotkeyObj.description ,hotkeyObj.callback); @@ -21,7 +24,7 @@ hotkeyProvider.bindTo(scope) combo: 'w', description: 'blah blah', callback: function() {} - }); + }) .add({ combo: ['w', 'mod+w'], description: 'blah blah', diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts index 83d5021cc7..0c0b9109a0 100644 --- a/angular-hotkeys/angular-hotkeys.d.ts +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -14,19 +14,19 @@ declare module ng.hotkeys { cheatSheetHotkey: string; cheatSheetDescription: string; - add(combo: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; + add(combo: string|string[], callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; - add(combo: string, description: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; + add(combo: string|string[], description: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; add(hotkeyObj: ng.hotkeys.Hotkey): ng.hotkeys.Hotkey; bindTo(scope : ng.IScope): ng.hotkeys.HotkeysProviderChained; - del(combo: string): void; + del(combo: string|string[]): void; del(hotkeyObj: ng.hotkeys.Hotkey): void; - get(combo: string): ng.hotkeys.Hotkey; + get(combo: string|string[]): ng.hotkeys.Hotkey; toggleCheatSheet(): void; @@ -34,13 +34,13 @@ declare module ng.hotkeys { } interface HotkeysProviderChained { - add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained; + add(combo: string|string[], description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained; add(hotkeyObj: ng.hotkeys.Hotkey): HotkeysProviderChained; } interface Hotkey { - combo: string | string[]; + combo: string|string[]; description?: string; callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void; action?: string;