diff options
| author | Stephen Blott | 2016-03-04 06:07:52 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2016-03-04 06:07:52 +0000 | 
| commit | 2beb94559937a9b97c5d11d24006d84931cdd4a1 (patch) | |
| tree | e28a01e7e2c91c767fdbd55a0ffc976a248141bc /pages | |
| parent | addceafab244b174aba89718d81f6bcb4cea22ff (diff) | |
| download | vimium-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.
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/help_dialog.coffee | 10 | 
1 files changed, 10 insertions, 0 deletions
| 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) -> | 
