diff options
| author | Stephen Blott | 2015-01-02 15:01:32 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-02 15:01:32 +0000 |
| commit | b7d5e25e353010505db7754e97d4387c8aa6b8fc (patch) | |
| tree | 4208ecdda9f53ae22cb8e0d36aa8ffb2910dc9bb /content_scripts/vimium_frontend.coffee | |
| parent | d4c43d8f9095325b41544ad7811cc131c1b186f1 (diff) | |
| download | vimium-b7d5e25e353010505db7754e97d4387c8aa6b8fc.tar.bz2 | |
Modes; simplify badge handling.
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index fb6199bf..2df2e226 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -106,6 +106,21 @@ frameId = Math.floor(Math.random()*999999999) hasModifiersRegex = /^<([amc]-)+.>/ +class NormalMode extends Mode + constructor: -> + super + name: "normal" + badge: "N" + keydown: onKeydown + keypress: onKeypress + keyup: onKeyup + + updateBadgeForMode: (badge) -> + handlerStack.alwaysPropagate => + # Idea... Instead of an icon, we could show the keyQueue here (if it's non-empty). + super badge + badge.badge = "" unless isEnabledForUrl + # # Complete initialization work that sould be done prior to DOMReady. # @@ -115,20 +130,9 @@ initializePreDomReady = -> # Install normal mode. This is at the bottom of both the mode stack and the handler stack, and is never # deactivated. - new Mode - name: "normal" - badge: "N" - keydown: onKeydown - keypress: onKeypress - keyup: onKeyup - - # Overriding updateBadgeForMode() from Mode.updateBadgeForMode(). - updateBadgeForMode: (badge) -> - handlerStack.alwaysPropagate => - badge.badge ||= if keyQueue then keyQueue else @badge - badge.badge = "" unless isEnabledForUrl - - # Initialize the scroller. The scroller install a key handler, and this is next on the handler stack, + new NormalMode() + + # Initialize the scroller. The scroller installs a key handler, and this is next on the handler stack, # immediately above normal mode. Scroller.init settings |
