aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-03-04 06:07:52 +0000
committerStephen Blott2016-03-04 06:07:52 +0000
commit2beb94559937a9b97c5d11d24006d84931cdd4a1 (patch)
treee28a01e7e2c91c767fdbd55a0ffc976a248141bc
parentaddceafab244b174aba89718d81f6bcb4cea22ff (diff)
downloadvimium-2beb94559937a9b97c5d11d24006d84931cdd4a1.tar.bz2
Make command names in the help diablog clickable.
Clicking on command names in the help dialog copies the command name to the clipboard. Moreover, command names can be clicked (hence copied) with link hints. As a a side effect, any element on any page with the `vimiumClickable` class becomes clickable. That's zero elements on zero pages, currently. But there was a PR some time ago where a web developer was looking for a way to make their elements vimium clickable. On the negative side, this is pretty undiscoverable. Also, the `indexOf()` class-name test within a string isn't exactly precise.
-rw-r--r--content_scripts/link_hints.coffee1
-rw-r--r--pages/help_dialog.coffee10
2 files changed, 11 insertions, 0 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index c8f9b6f9..e74653f2 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -205,6 +205,7 @@ class LinkHintsMode
if (element.hasAttribute("onclick") or
element.getAttribute("role")?.toLowerCase() in ["button", "link"] or
element.getAttribute("class")?.toLowerCase().indexOf("button") >= 0 or
+ element.getAttribute("class")?.indexOf("vimiumClickable") >= 0 or
element.getAttribute("contentEditable")?.toLowerCase() in ["", "contentEditable", "true"])
isClickable = true
diff --git a/pages/help_dialog.coffee b/pages/help_dialog.coffee
index 1b9420c3..0589e379 100644
--- a/pages/help_dialog.coffee
+++ b/pages/help_dialog.coffee
@@ -38,6 +38,16 @@ HelpDialog =
@showAdvancedCommands(@getShowAdvancedCommands())
+ # When command names are shown, clicking on them copies their text to the clipboard (and they can be
+ # clicked with link hints).
+ for element in @dialogElement.getElementsByClassName "commandName"
+ do (element) ->
+ element.classList.add "vimiumClickable"
+ element.addEventListener "click", ->
+ commandName = element.textContent.replace("(","").replace ")", ""
+ chrome.runtime.sendMessage handler: "copyToClipboard", data: commandName
+ HUD.showForDuration("Yanked #{commandName}.", 2000)
+
hide: -> UIComponentServer.postMessage "hide"
toggle: (html) ->