diff options
| author | Stephen Blott | 2015-01-27 16:36:49 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-27 16:36:54 +0000 |
| commit | a982ce074d517eb9e56c517d86a4bfb3869cf171 (patch) | |
| tree | 372a3cf5f96238e223cb91eccdfa56923e8fe854 /content_scripts/mode.coffee | |
| parent | 9d97ce8dab7672d7d1846f7cbe4d22af80c91b01 (diff) | |
| download | vimium-a982ce074d517eb9e56c517d86a4bfb3869cf171.tar.bz2 | |
Visual/edit modes: minor changes.
- Minor changes.
- Deactivate modes on inputs from focusInput().
Diffstat (limited to 'content_scripts/mode.coffee')
| -rw-r--r-- | content_scripts/mode.coffee | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index 5a26b836..c2e70e91 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -91,14 +91,10 @@ class Mode # be unique. New instances deactivate existing instances with the same key. if @options.singleton do => - key = @options.singleton - Mode.singletons ||= [] - @onExit => Mode.singletons = Mode.singletons.filter (active) => active.key != key - for active in Mode.singletons - if active.key == key - console.log "singleton, deactivating:", active.mode.id if @debug - active.mode.exit() - Mode.singletons.push key: key, mode: @ + console.log @options.singleton + @deactivateSingleton @options.singleton + @onExit => Mode.singletons = Mode.singletons.filter (active) => active.key != @options.singleton + Mode.singletons.push key: @options.singleton, mode: @ console.log "singletons:", (Mode.singletons.map (active) -> active.mode.id)... if @debug # If @options.trackState is truthy, then the mode mainatins the current state in @enabled and @passKeys, @@ -142,6 +138,13 @@ class Mode Mode.updateBadge() @modeIsActive = false + deactivateSingleton: (key) -> + Mode.singletons ||= [] + for active in Mode.singletons + if active.key == key and active.mode.modeIsActive + console.log "singleton, deactivating:", active.mode.id if @debug + active.mode.exit() + # The badge is chosen by bubbling an "updateBadge" event down the handler stack allowing each mode the # opportunity to choose a badge. This is overridden in sub-classes. updateBadge: (badge) -> |
