diff options
| author | mrmr1993 | 2016-03-05 13:58:14 +0000 |
|---|---|---|
| committer | mrmr1993 | 2016-03-05 14:00:50 +0000 |
| commit | 1b03ab022c6280251289bcb259ccb7568464ea01 (patch) | |
| tree | c02c37cb0a84f93ba530cffa4f78061fd8001aae /content_scripts | |
| parent | e93b6b2cd689016022113006c53d0decfb98d5c5 (diff) | |
| download | vimium-1b03ab022c6280251289bcb259ccb7568464ea01.tar.bz2 | |
Move non-click link hint activators to the corresponding mode objects
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/link_hints.coffee | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 5c116bad..16932c26 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -20,8 +20,17 @@ OPEN_WITH_QUEUE = name: "queue" COPY_LINK_URL = name: "link" + linkActivator: (link) -> + if link.href? + chrome.runtime.sendMessage handler: "copyToClipboard", data: link.href + url = link.href + url = url[0..25] + "...." if 28 < url.length + @onExit = -> HUD.showForDuration "Yanked #{url}", 2000 + else + @onExit = -> HUD.showForDuration "No link to yank.", 2000 OPEN_INCOGNITO = name: "incognito" + linkActivator: (link) -> chrome.runtime.sendMessage handler: 'openUrlInIncognito', url: link.href DOWNLOAD_LINK_URL = name: "download" @@ -104,6 +113,7 @@ class LinkHintsMode setOpenLinkMode: (@mode) -> clickActivator = (modifiers) -> (link) -> DomUtils.simulateClick link, modifiers + @linkActivator = @mode.linkActivator if @mode.linkActivator? 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 @@ -122,18 +132,8 @@ class LinkHintsMode } else if @mode is COPY_LINK_URL @hintMode.setIndicator "Copy link URL to Clipboard." - @linkActivator = (link) => - if link.href? - chrome.runtime.sendMessage handler: "copyToClipboard", data: link.href - url = link.href - url = url[0..25] + "...." if 28 < url.length - @onExit = -> HUD.showForDuration "Yanked #{url}", 2000 - else - @onExit = -> HUD.showForDuration "No link to yank.", 2000 else if @mode is OPEN_INCOGNITO @hintMode.setIndicator "Open link in incognito window." - @linkActivator = (link) -> - chrome.runtime.sendMessage handler: 'openUrlInIncognito', url: link.href else if @mode is DOWNLOAD_LINK_URL @hintMode.setIndicator "Download link URL." @linkActivator = clickActivator altKey: true, ctrlKey: false, metaKey: false |
