diff options
| author | Stephen Blott | 2014-10-25 15:54:20 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2014-10-25 15:54:20 +0100 | 
| commit | f5fa44f552a7223e978880b79dba8a1076befab0 (patch) | |
| tree | 25ceac77577c85df5776426a6115b47678de55c8 | |
| parent | e98f3f678237c1841d9626f17e560b6cb8327dc8 (diff) | |
| parent | 238893e6cf02dbdfb85d274f77368dbd7d039a3d (diff) | |
| download | vimium-f5fa44f552a7223e978880b79dba8a1076befab0.tar.bz2 | |
Merge pull request #784 from deiga/patch-3
Add links-hint mode to download links
| -rw-r--r-- | background_scripts/commands.coffee | 5 | ||||
| -rw-r--r-- | content_scripts/link_hints.coffee | 12 | 
2 files changed, 15 insertions, 2 deletions
| diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index fe063066..825160d8 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -110,7 +110,7 @@ Commands =    # from Vimium will uncover these gems.    advancedCommands: [      "scrollToLeft", "scrollToRight", "moveTabToNewWindow", -    "goUp", "goToRoot", "focusInput", "LinkHints.activateModeWithQueue", +    "goUp", "goToRoot", "focusInput", "LinkHints.activateModeWithQueue", "LinkHints.activateModeToDownloadLink",      "LinkHints.activateModeToOpenIncognito", "goNext", "goPrevious", "Marks.activateCreateMode",      "Marks.activateGotoMode", "moveTabLeft", "moveTabRight",      "closeTabsOnLeft","closeTabsOnRight", "closeOtherTabs"] @@ -146,6 +146,8 @@ defaultKeyMappings =    "F":     "LinkHints.activateModeToOpenInNewTab"    "<a-f>": "LinkHints.activateModeWithQueue" +  "af": "LinkHints.activateModeToDownloadLink" +    "/": "enterFindMode"    "n": "performFind"    "N": "performBackwardsFind" @@ -228,6 +230,7 @@ commandDescriptions =    "LinkHints.activateModeToOpenIncognito": ["Open a link in incognito window"] +  "LinkHints.activateModeToDownloadLink": ["Download link url"]    enterFindMode: ["Enter find mode"]    performFind: ["Cycle forward to the next find match"]    performBackwardsFind: ["Cycle backward to the previous find match"] diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 24314b26..24bd7126 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -14,6 +14,7 @@ OPEN_IN_NEW_FG_TAB = {}  OPEN_WITH_QUEUE = {}  COPY_LINK_URL = {}  OPEN_INCOGNITO = {} +DOWNLOAD_LINK_URL = {}  LinkHints =    hintMarkerContainingDiv: null @@ -52,6 +53,7 @@ LinkHints =    activateModeToCopyLinkUrl: -> @activateMode(COPY_LINK_URL)    activateModeWithQueue: -> @activateMode(OPEN_WITH_QUEUE)    activateModeToOpenIncognito: -> @activateMode(OPEN_INCOGNITO) +  activateModeToDownloadLink: -> @activateMode(DOWNLOAD_LINK_URL)    activateMode: (mode = OPEN_IN_CURRENT_TAB) ->      # we need documentElement to be ready in order to append links @@ -93,7 +95,8 @@ LinkHints =          DomUtils.simulateClick(link, {            shiftKey: @mode is OPEN_IN_NEW_FG_TAB,            metaKey: KeyboardUtils.platform == "Mac", -          ctrlKey: KeyboardUtils.platform != "Mac" }) +          ctrlKey: KeyboardUtils.platform != "Mac", +          altKey: false})      else if @mode is COPY_LINK_URL        HUD.show("Copy link URL to Clipboard")        @linkActivator = (link) -> @@ -105,6 +108,13 @@ LinkHints =          chrome.runtime.sendMessage(            handler: 'openUrlInIncognito'            url: link.href) +    else if @mode is DOWNLOAD_LINK_URL +      HUD.show("Download link URL") +      @linkActivator = (link) -> +        DomUtils.simulateClick(link, { +          altKey: true, +          ctrlKey: false, +          metaKey: false })      else # OPEN_IN_CURRENT_TAB        HUD.show("Open link in current tab")        @linkActivator = (link) -> DomUtils.simulateClick.bind(DomUtils, link)() | 
