diff options
| author | Stephen Blott | 2015-04-18 07:45:30 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-04-18 07:45:30 +0100 |
| commit | 6224319dcfa5eed1d9d9fab3a5fc2d0c20b70c2e (patch) | |
| tree | 36927befe9dac34897df94aee76c6086676407ab /content_scripts/mode.coffee | |
| parent | e5a2dee7d1a09d593cc721d9a6c8d95638270a76 (diff) | |
| download | vimium-6224319dcfa5eed1d9d9fab3a5fc2d0c20b70c2e.tar.bz2 | |
Mode indicator: strip all references to badges.
Diffstat (limited to 'content_scripts/mode.coffee')
| -rw-r--r-- | content_scripts/mode.coffee | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index bded402c..292dc24e 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -6,13 +6,6 @@ # name: # A name for this mode. # -# badge: -# A badge (to appear on the browser popup). -# Optional. Define a badge if the badge is constant; for example, in find mode the badge is always "/". -# Otherwise, do not define a badge, but instead override the updateBadge method; for example, in passkeys -# mode, the badge may be "P" or "", depending on the configuration state. Or, if the mode *never* shows a -# badge, then do neither. -# # keydown: # keypress: # keyup: @@ -48,7 +41,6 @@ class Mode @handlers = [] @exitHandlers = [] @modeIsActive = true - @badge = @options.badge || "" @name = @options.name || "anonymous" @count = ++count @@ -59,7 +51,6 @@ class Mode keydown: @options.keydown || null keypress: @options.keypress || null keyup: @options.keyup || null - updateBadge: (badge) => @alwaysContinueBubbling => @updateBadge badge # If @options.exitOnEscape is truthy, then the mode will exit when the escape key is pressed. if @options.exitOnEscape @@ -131,7 +122,6 @@ class Mode if KeyboardUtils.isPrintable event then @stopBubblingAndFalse else @stopBubblingAndTrue Mode.modes.push @ - Mode.updateBadge() @logModes() # End of Mode constructor. @@ -152,17 +142,11 @@ class Mode handler() for handler in @exitHandlers handlerStack.remove handlerId for handlerId in @handlers Mode.modes = Mode.modes.filter (mode) => mode != @ - Mode.updateBadge() @modeIsActive = false deactivateSingleton: (singleton) -> Mode.singletons?[Utils.getIdentity singleton]?.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) -> - badge.badge ||= @badge - # Shorthand for an otherwise long name. This wraps a handler with an arbitrary return value, and always # yields @continueBubbling instead. This simplifies handlers if they always continue bubbling (a common # case), because they do not need to be concerned with the value they yield. @@ -174,14 +158,6 @@ class Mode delete @options[key] for key in [ "keydown", "keypress", "keyup" ] new @constructor @options - # Static method. Used externally and internally to initiate bubbling of an updateBadge event and to send - # the resulting badge to the background page. We only update the badge if this document (hence this frame) - # has the focus. - @updateBadge: -> - if document.hasFocus() - handlerStack.bubbleEvent "updateBadge", badge = badge: "" - chrome.runtime.sendMessage { handler: "setBadge", badge: badge.badge }, -> - # Debugging routines. logModes: -> if @debug @@ -200,31 +176,5 @@ class Mode mode.exit() for mode in @modes @modes = [] -# BadgeMode is a pseudo mode for triggering badge updates on focus changes and state updates. It sits at the -# bottom of the handler stack, and so it receives state changes *after* all other modes, and can override the -# badge choice of the other modes. -class BadgeMode extends Mode - constructor: () -> - super - name: "badge" - trackState: true - - # FIXME(smblott) BadgeMode is currently triggering an updateBadge event on every focus event. That's a - # lot, considerably more than necessary. Really, it only needs to trigger when we change frame, or when - # we change tab. - @push - _name: "mode-#{@id}/focus" - "focus": => @alwaysContinueBubbling -> Mode.updateBadge() - - updateBadge: (badge) -> - # If we're not enabled, then post an empty badge. - badge.badge = "" unless @enabled - - # When the registerStateChange event bubbles to the bottom of the stack, all modes have been notified. So - # it's now time to update the badge. - registerStateChange: -> - Mode.updateBadge() - root = exports ? window root.Mode = Mode -root.BadgeMode = BadgeMode |
