diff options
| -rw-r--r-- | background_scripts/commands.coffee | 12 | ||||
| -rw-r--r-- | content_scripts/link_hints.coffee | 19 |
2 files changed, 17 insertions, 14 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index a307f23f..d42fd9fb 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -270,7 +270,7 @@ commandDescriptions = toggleViewSource: ["View page source", { noRepeat: true }] copyCurrentUrl: ["Copy the current URL to the clipboard", { noRepeat: true }] - "LinkHints.activateModeToCopyLinkUrl": ["Copy a link URL to the clipboard", { noRepeat: true }] + "LinkHints.activateModeToCopyLinkUrl": ["Copy a link URL to the clipboard", { passCountToFunction: true }] openCopiedUrlInCurrentTab: ["Open the clipboard's URL in the current tab", { background: true }] openCopiedUrlInNewTab: ["Open the clipboard's URL in a new tab", { background: true, repeatLimit: 20 }] @@ -281,12 +281,12 @@ commandDescriptions = focusInput: ["Focus the first text box on the page. Cycle between them using tab", { passCountToFunction: true }] - "LinkHints.activateMode": ["Open a link in the current tab", { noRepeat: true }] - "LinkHints.activateModeToOpenInNewTab": ["Open a link in a new tab", { noRepeat: true }] - "LinkHints.activateModeToOpenInNewForegroundTab": ["Open a link in a new tab & switch to it", { noRepeat: true }] + "LinkHints.activateMode": ["Open a link in the current tab", { passCountToFunction: true }] + "LinkHints.activateModeToOpenInNewTab": ["Open a link in a new tab", { passCountToFunction: true }] + "LinkHints.activateModeToOpenInNewForegroundTab": ["Open a link in a new tab & switch to it", { passCountToFunction: true }] "LinkHints.activateModeWithQueue": ["Open multiple links in a new tab", { noRepeat: true }] - "LinkHints.activateModeToOpenIncognito": ["Open a link in incognito window", { noRepeat: true }] - "LinkHints.activateModeToDownloadLink": ["Download link url", { noRepeat: true }] + "LinkHints.activateModeToOpenIncognito": ["Open a link in incognito window", { passCountToFunction: true }] + "LinkHints.activateModeToDownloadLink": ["Download link url", { passCountToFunction: true }] enterFindMode: ["Enter find mode", { noRepeat: true }] performFind: ["Cycle forward to the next find match"] diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 54476935..3fcbfd40 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -19,14 +19,16 @@ OPEN_INCOGNITO = name: "incognito" DOWNLOAD_LINK_URL = name: "download" LinkHints = - activateMode: (mode = OPEN_IN_CURRENT_TAB) -> new LinkHintsMode mode + activateMode: (count = 1, mode = OPEN_IN_CURRENT_TAB) -> + if 0 < count + new LinkHintsMode mode, -> LinkHints.activateMode count-1, mode - activateModeToOpenInNewTab: -> @activateMode OPEN_IN_NEW_BG_TAB - activateModeToOpenInNewForegroundTab: -> @activateMode OPEN_IN_NEW_FG_TAB - activateModeToCopyLinkUrl: -> @activateMode COPY_LINK_URL - activateModeWithQueue: -> @activateMode OPEN_WITH_QUEUE - activateModeToOpenIncognito: -> @activateMode OPEN_INCOGNITO - activateModeToDownloadLink: -> @activateMode DOWNLOAD_LINK_URL + activateModeToOpenInNewTab: (count) -> @activateMode count, OPEN_IN_NEW_BG_TAB + activateModeToOpenInNewForegroundTab: (count) -> @activateMode count, OPEN_IN_NEW_FG_TAB + activateModeToCopyLinkUrl: (count) -> @activateMode count, COPY_LINK_URL + activateModeWithQueue: -> @activateMode 1, OPEN_WITH_QUEUE + activateModeToOpenIncognito: (count) -> @activateMode count, OPEN_INCOGNITO + activateModeToDownloadLink: (count) -> @activateMode count, DOWNLOAD_LINK_URL class LinkHintsMode hintMarkerContainingDiv: null @@ -43,7 +45,7 @@ class LinkHintsMode # A count of the number of Tab presses since the last non-Tab keyboard event. tabCount: 0 - constructor: (mode = OPEN_IN_CURRENT_TAB) -> + constructor: (mode = OPEN_IN_CURRENT_TAB, onExit = (->)) -> # we need documentElement to be ready in order to append links return unless document.documentElement @isActive = true @@ -80,6 +82,7 @@ class LinkHintsMode @hintMode.onExit => @deactivateMode() if @isActive + @hintMode.onExit onExit @setOpenLinkMode mode |
