aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--background_scripts/commands.coffee4
-rw-r--r--content_scripts/mode.coffee2
-rw-r--r--content_scripts/mode_key_handler.coffee18
-rw-r--r--content_scripts/vimium_frontend.coffee4
-rw-r--r--pages/help_dialog.coffee2
5 files changed, 13 insertions, 17 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index 46869451..a36b0c7e 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -1,5 +1,5 @@
Commands =
- init: () ->
+ init: ->
for own command, description of commandDescriptions
@addCommand(command, description[0], description[1])
@loadKeyMappings Settings.get "keyMappings"
@@ -115,7 +115,7 @@ Commands =
if currentMapping[key]?.command
break # Do not overwrite existing command bindings, they take priority.
else if 0 < keys.length
- currentMapping = (currentMapping[key] ?= {})
+ currentMapping = currentMapping[key] ?= {}
else
currentMapping[key] = registryEntry
chrome.storage.local.set normalModeKeyStateMapping: keyStateMapping
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index 8a84457e..3327b58f 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -125,7 +125,7 @@ class Mode
@passKeys = ""
@push
_name: "mode-#{@id}/registerStateChange"
- registerStateChange: ({ enabled: @enabled, passKeys: @passKeys }) => @alwaysContinueBubbling =>
+ registerStateChange: ({ enabled: @enabled, passKeys: @passKeys }) => @continueBubbling
# If @options.passInitialKeyupEvents is set, then we pass initial non-printable keyup events to the page
# or to other extensions (because the corresponding keydown events were passed). This is used when
diff --git a/content_scripts/mode_key_handler.coffee b/content_scripts/mode_key_handler.coffee
index 97966644..567552c0 100644
--- a/content_scripts/mode_key_handler.coffee
+++ b/content_scripts/mode_key_handler.coffee
@@ -1,31 +1,27 @@
class KeyHandlerMode extends Mode
- countPrefix: 0
keydownEvents: {}
- keyState: []
+ setKeyMapping: (@keyMapping) -> @reset()
constructor: (options) ->
@commandHandler = options.commandHandler ? (->)
@setKeyMapping options.keyMapping ? {}
- delete options[option] for option in ["commandHandler", "keyMapping"]
super extend options,
keydown: @onKeydown.bind this
keypress: @onKeypress.bind this
keyup: @onKeyup.bind this
- # We cannot track matching keydown/keyup events if we lose the focus.
+ # We cannot track keyup events if we lose the focus.
blur: (event) => @alwaysContinueBubbling => @keydownEvents = {} if event.target == window
- setKeyMapping: (@keyMapping) -> @reset()
-
onKeydown: (event) ->
keyChar = KeyboardUtils.getKeyCharString event
if KeyboardUtils.isEscape event
if @countPrefix == 0 and @keyState.length == 1
@continueBubbling
else
+ @keydownEvents[event.keyCode] = true
@reset()
- DomUtils.suppressKeyupAfterEscape handlerStack
false # Suppress event.
else if keyChar and @mappingForKeyChar keyChar
@keydownEvents[event.keyCode] = true
@@ -33,10 +29,10 @@ class KeyHandlerMode extends Mode
else if keyChar
@continueBubbling
else if (keyChar = KeyboardUtils.getKeyChar event) and (@mappingForKeyChar(keyChar) or @isCountKey keyChar)
- # We did not handle the event, but we might handle a subsequent keypress. If we will be handling that
- # event, then we suppress propagation of this keydown to prevent triggering page events.
- DomUtils.suppressPropagation event
+ # We will probably be handling a subsequent keypress event, so suppress propagation of this event to
+ # prevent triggering page event listeners (e.g. Google instant Search).
@keydownEvents[event.keyCode] = true
+ DomUtils.suppressPropagation event
@stopBubblingAndTrue
else
@continueBubbling
@@ -69,7 +65,7 @@ class KeyHandlerMode extends Mode
countPrefix = if 0 < @countPrefix then @countPrefix else 1
@reset()
bgLog "Calling mode=#{@name}, command=#{commands[0].command}, count=#{countPrefix}."
- @commandHandler commands[0], countPrefix
+ @commandHandler command: commands[0], count: countPrefix, event: event
false # Suppress event.
# This returns the first key-state entry for which keyChar is mapped. The return value is truthy if a match
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index e821b136..ec666a23 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -107,13 +107,13 @@ class NormalMode extends KeyHandlerMode
if area == "local" and changes.normalModeKeyStateMapping?.newValue
@setKeyMapping changes.normalModeKeyStateMapping.newValue
- commandHandler: (registryEntry, count) ->
+ commandHandler: ({command: registryEntry, count, event}) ->
count *= registryEntry.options.count ? 1
count = 1 if registryEntry.noRepeat
if registryEntry.repeatLimit? and registryEntry.repeatLimit < count
return unless confirm """
- You have asked Vimium to perform #{count} repeats of the command: #{registryEntry.description}.\n
+ You have asked Vimium to perform #{count} repetitions of the command: #{registryEntry.description}.\n
Are you sure you want to continue?"""
if registryEntry.isBackgroundCommand
diff --git a/pages/help_dialog.coffee b/pages/help_dialog.coffee
index 4e6d1946..a5ac25af 100644
--- a/pages/help_dialog.coffee
+++ b/pages/help_dialog.coffee
@@ -53,7 +53,7 @@ HelpDialog =
HelpDialog.hide() if event?.type == "keydown"
hide: ->
- @exitOnEscape.exit()
+ @exitOnEscape?.exit()
UIComponentServer.postMessage "hide"
toggle: (html) ->