From 6224319dcfa5eed1d9d9fab3a5fc2d0c20b70c2e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 18 Apr 2015 07:45:30 +0100 Subject: Mode indicator: strip all references to badges. --- content_scripts/link_hints.coffee | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'content_scripts/link_hints.coffee') 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 -- cgit v1.2.3 From 870bd7831bdddf26d95017e390329b8f2bd3777e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 18 Apr 2015 12:22:27 +0100 Subject: Mode indicator: fix for link hints. --- content_scripts/link_hints.coffee | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'content_scripts/link_hints.coffee') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 85c09257..f1c7c43c 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -54,6 +54,15 @@ LinkHints = return @isActive = true + @hintMode = new Mode + name: "hint/#{mode.name}" + indicator: false + passInitialKeyupEvents: true + keydown: @onKeyDownInMode.bind(this, hintMarkers), + # trap all key events + keypress: -> false + keyup: -> false + @setOpenLinkMode(mode) hintMarkers = (@createMarkerFor(el) for el in @getVisibleClickableElements()) @getMarkerMatcher().fillInMarkers(hintMarkers) @@ -64,14 +73,6 @@ LinkHints = @hintMarkerContainingDiv = DomUtils.addElementList(hintMarkers, { id: "vimiumHintMarkerContainer", className: "vimiumReset" }) - @hintMode = new Mode - name: "hint/#{mode.name}" - passInitialKeyupEvents: true - keydown: @onKeyDownInMode.bind(this, hintMarkers), - # trap all key events - keypress: -> false - keyup: -> false - setOpenLinkMode: (@mode) -> if @mode is OPEN_IN_NEW_BG_TAB or @mode is OPEN_IN_NEW_FG_TAB or @mode is OPEN_WITH_QUEUE if @mode is OPEN_IN_NEW_BG_TAB -- cgit v1.2.3 From a0959294e5724137ee08ad8c6b935e1c3284e06e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 18 Apr 2015 12:49:32 +0100 Subject: Mode indicator: more fix for link hints. --- content_scripts/link_hints.coffee | 50 +++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'content_scripts/link_hints.coffee') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index f1c7c43c..73af6a06 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -54,18 +54,19 @@ LinkHints = return @isActive = true + hintMarkers = (@createMarkerFor(el) for el in @getVisibleClickableElements()) + @getMarkerMatcher().fillInMarkers(hintMarkers) + @hintMode = new Mode name: "hint/#{mode.name}" indicator: false passInitialKeyupEvents: true - keydown: @onKeyDownInMode.bind(this, hintMarkers), - # trap all key events + keydown: @onKeyDownInMode.bind this, hintMarkers + # Trap all other key events. keypress: -> false keyup: -> false - @setOpenLinkMode(mode) - hintMarkers = (@createMarkerFor(el) for el in @getVisibleClickableElements()) - @getMarkerMatcher().fillInMarkers(hintMarkers) + @setOpenLinkMode mode # Note(philc): Append these markers as top level children instead of as child nodes to the link itself, # because some clickable elements cannot contain children, e.g. submit buttons. This has the caveat @@ -76,39 +77,33 @@ LinkHints = setOpenLinkMode: (@mode) -> if @mode is OPEN_IN_NEW_BG_TAB or @mode is OPEN_IN_NEW_FG_TAB or @mode is OPEN_WITH_QUEUE if @mode is OPEN_IN_NEW_BG_TAB - HUD.show("Open link in new tab") + @hintMode.setIndicator "Open link in new tab" else if @mode is OPEN_IN_NEW_FG_TAB - HUD.show("Open link in new tab and switch to it") + @hintMode.setIndicator "Open link in new tab and switch to it" else - HUD.show("Open multiple links in a new tab") + @hintMode.setIndicator "Open multiple links in a new tab" @linkActivator = (link) -> # When "clicking" on a link, dispatch the event with the appropriate meta key (CMD on Mac, CTRL on # windows) to open it in a new tab if necessary. - DomUtils.simulateClick(link, { - shiftKey: @mode is OPEN_IN_NEW_FG_TAB, - metaKey: KeyboardUtils.platform == "Mac", - ctrlKey: KeyboardUtils.platform != "Mac", - altKey: false}) + DomUtils.simulateClick link, + shiftKey: @mode is OPEN_IN_NEW_FG_TAB + metaKey: KeyboardUtils.platform == "Mac" + ctrlKey: KeyboardUtils.platform != "Mac" + altKey: false else if @mode is COPY_LINK_URL - HUD.show("Copy link URL to Clipboard") + @hintMode.setIndicator "Copy link URL to Clipboard" @linkActivator = (link) -> - chrome.runtime.sendMessage({handler: "copyToClipboard", data: link.href}) + chrome.runtime.sendMessage handler: "copyToClipboard", data: link.href else if @mode is OPEN_INCOGNITO - HUD.show("Open link in incognito window") - + @hintMode.setIndicator "Open link in incognito window" @linkActivator = (link) -> - chrome.runtime.sendMessage( - handler: 'openUrlInIncognito' - url: link.href) + chrome.runtime.sendMessage handler: 'openUrlInIncognito', url: link.href else if @mode is DOWNLOAD_LINK_URL - HUD.show("Download link URL") + @hintMode.setIndicator "Download link URL" @linkActivator = (link) -> - DomUtils.simulateClick(link, { - altKey: true, - ctrlKey: false, - metaKey: false }) + DomUtils.simulateClick link, altKey: true, ctrlKey: false, metaKey: false else # OPEN_IN_CURRENT_TAB - HUD.show("Open link in current tab") + @hintMode.setIndicator "Open link in current tab" @linkActivator = (link) -> DomUtils.simulateClick.bind(DomUtils, link)() # @@ -275,8 +270,8 @@ LinkHints = handlerStack.push keyup: (event) => if event.keyCode == keyCode - @setOpenLinkMode previousMode if @isActive handlerStack.remove() + @setOpenLinkMode previousMode if @isActive true # TODO(philc): Ignore keys that have modifiers. @@ -346,7 +341,6 @@ LinkHints = DomUtils.removeElement LinkHints.hintMarkerContainingDiv LinkHints.hintMarkerContainingDiv = null @hintMode.exit() - HUD.hide() @isActive = false # we invoke the deactivate() function directly instead of using setTimeout(callback, 0) so that -- cgit v1.2.3