From 2beb94559937a9b97c5d11d24006d84931cdd4a1 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 4 Mar 2016 06:07:52 +0000 Subject: 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. --- pages/help_dialog.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pages') 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) -> -- cgit v1.2.3