aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/link_hints.coffee18
-rw-r--r--content_scripts/mode.coffee50
-rw-r--r--content_scripts/mode_find.coffee9
-rw-r--r--content_scripts/mode_insert.coffee7
-rw-r--r--content_scripts/mode_passkeys.coffee4
-rw-r--r--content_scripts/mode_visual_edit.coffee4
-rw-r--r--content_scripts/vimium_frontend.coffee3
7 files changed, 9 insertions, 86 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 72fde9e1..85c09257 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -8,16 +8,15 @@
# In 'filter' mode, our link hints are numbers, and the user can narrow down the range of possibilities by
# typing the text of the link itself.
#
-# The "name" property below is a short-form name to appear in the link-hints mode name. Debugging only. The
-# key appears in the mode's badge.
+# The "name" property below is a short-form name to appear in the link-hints mode's name. It's for debug only.
#
-OPEN_IN_CURRENT_TAB = { name: "curr-tab", key: "" }
-OPEN_IN_NEW_BG_TAB = { name: "bg-tab", key: "B" }
-OPEN_IN_NEW_FG_TAB = { name: "fg-tab", key: "F" }
-OPEN_WITH_QUEUE = { name: "queue", key: "Q" }
-COPY_LINK_URL = { name: "link", key: "C" }
-OPEN_INCOGNITO = { name: "incognito", key: "I" }
-DOWNLOAD_LINK_URL = { name: "download", key: "D" }
+OPEN_IN_CURRENT_TAB = name: "curr-tab"
+OPEN_IN_NEW_BG_TAB = name: "bg-tab"
+OPEN_IN_NEW_FG_TAB = name: "fg-tab"
+OPEN_WITH_QUEUE = name: "queue"
+COPY_LINK_URL = name: "link"
+OPEN_INCOGNITO = name: "incognito"
+DOWNLOAD_LINK_URL = name: "download"
LinkHints =
hintMarkerContainingDiv: null
@@ -67,7 +66,6 @@ LinkHints =
@hintMode = new Mode
name: "hint/#{mode.name}"
- badge: "#{mode.key}?"
passInitialKeyupEvents: true
keydown: @onKeyDownInMode.bind(this, hintMarkers),
# trap all key events
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
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee
index 67f2a7dc..ed08fbd5 100644
--- a/content_scripts/mode_find.coffee
+++ b/content_scripts/mode_find.coffee
@@ -33,8 +33,6 @@ class PostFindMode extends SuppressPrintable
super
name: "post-find"
- # We show a "?" badge, but only while an Escape activates insert mode.
- badge: "?"
# PostFindMode shares a singleton with the modes launched by focusInput; each displaces the other.
singleton: element
exitOnBlur: element
@@ -54,14 +52,7 @@ class PostFindMode extends SuppressPrintable
@suppressEvent
else
handlerStack.remove()
- @badge = ""
- Mode.updateBadge()
@continueBubbling
- updateBadge: (badge) ->
- badge.badge ||= @badge
- # Suppress the "I" badge from insert mode.
- InsertMode.suppressEvent badge # Always truthy.
-
root = exports ? window
root.PostFindMode = PostFindMode
diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee
index 90162d5a..c0f4c6e7 100644
--- a/content_scripts/mode_insert.coffee
+++ b/content_scripts/mode_insert.coffee
@@ -68,18 +68,13 @@ class InsertMode extends Mode
activateOnElement: (element) ->
@log "#{@id}: activating (permanent)" if @debug and @permanent
@insertModeLock = element
- Mode.updateBadge()
exit: (_, target) ->
if (target and target == @insertModeLock) or @global or target == undefined
@log "#{@id}: deactivating (permanent)" if @debug and @permanent and @insertModeLock
@insertModeLock = null
# Exit, but only if this isn't the permanently-installed instance.
- if @permanent then Mode.updateBadge() else super()
-
- updateBadge: (badge) ->
- badge.badge ||= @badge if @badge
- badge.badge ||= "I" if @isActive badge
+ super() unless @permanent
# Static stuff. This allows PostFindMode to suppress the permanently-installed InsertMode instance.
@suppressedEvent: null
diff --git a/content_scripts/mode_passkeys.coffee b/content_scripts/mode_passkeys.coffee
index 64db5447..cf74a844 100644
--- a/content_scripts/mode_passkeys.coffee
+++ b/content_scripts/mode_passkeys.coffee
@@ -16,9 +16,5 @@ class PassKeysMode extends Mode
else
@continueBubbling
- # Disabled, pending experimentation with how/whether to use badges (smblott, 2015/01/17).
- # updateBadge: (badge) ->
- # badge.badge ||= "P" if @passKeys and not @keyQueue
-
root = exports ? window
root.PassKeysMode = PassKeysMode
diff --git a/content_scripts/mode_visual_edit.coffee b/content_scripts/mode_visual_edit.coffee
index a5758a64..9b01094b 100644
--- a/content_scripts/mode_visual_edit.coffee
+++ b/content_scripts/mode_visual_edit.coffee
@@ -466,7 +466,6 @@ class VisualMode extends Movement
defaults =
name: "visual"
- badge: "V"
singleton: VisualMode
exitOnEscape: true
super extend defaults, options
@@ -587,7 +586,6 @@ class CaretMode extends Movement
defaults =
name: "caret"
- badge: "C"
singleton: VisualMode
exitOnEscape: true
super extend defaults, options
@@ -652,7 +650,6 @@ class EditMode extends Movement
defaults =
name: "edit"
- badge: "E"
exitOnEscape: true
exitOnBlur: @element
super extend defaults, options
@@ -748,7 +745,6 @@ class EditMode extends Movement
# and (possibly) deletes it.
enterVisualModeForMovement: (count, options = {}) ->
@launchSubMode VisualMode, extend options,
- badge: "M"
initialCountPrefix: count
oneMovementOnly: true
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index dec34774..cc8d820c 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -135,7 +135,6 @@ window.initializeModes = ->
# Install the permanent modes. The permanently-installed insert mode tracks focus/blur events, and
# activates/deactivates itself accordingly.
- new BadgeMode
new NormalMode
new PassKeysMode
new InsertMode permanent: true
@@ -391,7 +390,6 @@ extend window,
constructor: ->
super
name: "focus-selector"
- badge: "?"
exitOnClick: true
keydown: (event) =>
if event.keyCode == KeyboardUtils.keyCodes.tab
@@ -729,7 +727,6 @@ class FindMode extends Mode
@partialQuery = ""
super
name: "find"
- badge: "/"
exitOnEscape: true
exitOnClick: true