diff options
| author | Stephen Blott | 2015-01-03 13:20:04 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-03 13:20:04 +0000 |
| commit | baccd7c5cef14480e21e41519e20ee19fa238655 (patch) | |
| tree | 26f1252bd952d0a2ab3b88259768cdcd30f0c26a /content_scripts/mode_passkeys.coffee | |
| parent | 00573389c63cebb42c225e10786aeb05e72fab39 (diff) | |
| download | vimium-baccd7c5cef14480e21e41519e20ee19fa238655.tar.bz2 | |
Modes; Fix various mode changes.
Diffstat (limited to 'content_scripts/mode_passkeys.coffee')
| -rw-r--r-- | content_scripts/mode_passkeys.coffee | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/content_scripts/mode_passkeys.coffee b/content_scripts/mode_passkeys.coffee index c754e967..4c4d7d41 100644 --- a/content_scripts/mode_passkeys.coffee +++ b/content_scripts/mode_passkeys.coffee @@ -3,19 +3,8 @@ class PassKeysMode extends Mode keyQueue: "" passKeys: "" - # Decide whether this keyChar should be passed to the underlying page. Keystrokes are *never* considered - # passKeys if the keyQueue is not empty. So, for example, if 't' is a passKey, then 'gt' and '99t' will - # neverthless be handled by vimium. - isPassKey: (keyChar) -> - not @keyQueue and 0 <= @passKeys.indexOf(keyChar) - - handlePassKeyEvent: (event) -> - for keyChar in [KeyboardUtils.getKeyChar(event), String.fromCharCode(event.charCode)] - return @stopBubblingAndTrue if keyChar and @isPassKey keyChar - @continueBubbling - - # This is called to set the pass-keys configuration and state with various types of request from various - # sources, so we handle several cases. + # This is called to set the passKeys configuration and state with various types of request from various + # sources, so we handle several cases here. # TODO(smblott) Rationalize this. configure: (request) -> if request.isEnabledForUrl? @@ -27,14 +16,21 @@ class PassKeysMode extends Mode if request.keyQueue? @keyQueue = request.keyQueue + # Decide whether this event should be passed to the underlying page. Keystrokes are *never* considered + # passKeys if the keyQueue is not empty. So, for example, if 't' is a passKey, then 'gt' and '99t' will + # neverthless be handled by vimium. + handlePassKeyEvent: (event) -> + for keyChar in [KeyboardUtils.getKeyChar(event), String.fromCharCode(event.charCode)] + return @stopBubblingAndTrue if keyChar and not @keyQueue and 0 <= @passKeys.indexOf(keyChar) + @continueBubbling + constructor: -> super name: "passkeys" keydown: (event) => @handlePassKeyEvent event keypress: (event) => @handlePassKeyEvent event - keyup: => @continueBubbling - updateBadgeForMode: (badge) -> + chooseBadge: (badge) -> @badge = if @passKeys and not @keyQueue then "P" else "" super badge |
