From 1ae95161b021fc9a64e139485b0dac047a874c0e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 28 Feb 2016 09:44:55 +0000 Subject: Key bindings; simplify Commands initialization. --- background_scripts/commands.coffee | 17 +++++++++-------- background_scripts/main.coffee | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 9348e3c5..de03136e 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -1,7 +1,14 @@ Commands = - init: -> + init: (customKeyMappings) -> for own command, description of commandDescriptions @addCommand(command, description[0], description[1]) + @loadKeyMappings customKeyMappings + Settings.postUpdateHooks["keyMappings"] = @loadKeyMappings.bind this + + loadKeyMappings: (value) -> + @clearKeyMappingsAndSetDefaults() + @parseCustomKeyMappings value + @generateKeyStateStructure() availableCommands: {} keyToCommandRegistry: {} @@ -391,13 +398,7 @@ commandDescriptions = "Marks.activateCreateMode": ["Create a new mark", { noRepeat: true }] "Marks.activateGotoMode": ["Go to a mark", { noRepeat: true }] -Commands.init() - -# Register postUpdateHook for keyMappings setting. -Settings.postUpdateHooks["keyMappings"] = (value) -> - Commands.clearKeyMappingsAndSetDefaults() - Commands.parseCustomKeyMappings value - Commands.generateKeyStateStructure() +Commands.init Settings.get "keyMappings" root = exports ? window root.Commands = Commands diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 7975ec6d..f5bf90a6 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -481,7 +481,6 @@ window.runTests = -> open(chrome.runtime.getURL('tests/dom_tests/dom_tests.html' # # Begin initialization. # -Settings.postUpdateHooks["keyMappings"] Settings.get "keyMappings" # Show notification on upgrade. showUpgradeMessage = -> -- cgit v1.2.3