From 98a3f4c96e8b189ca142f7cccbc1ef995c158b9d Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 9 Jun 2015 14:47:39 +0100 Subject: Make LinkHints a class (LinkHintsMode). Functionality wise, this is a no-op. However, since we now create a new LinkHintsMode object on every "f", we don't need to be so careful about resetting the state on exit. --- content_scripts/link_hints.coffee | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 31cdcfdf..81a5912e 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -19,6 +19,16 @@ OPEN_INCOGNITO = name: "incognito" DOWNLOAD_LINK_URL = name: "download" LinkHints = + activateMode: (mode = OPEN_IN_CURRENT_TAB) -> new LinkHintsMode 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 + +class LinkHintsMode hintMarkerContainingDiv: null # One of the enums listed at the top of this file. mode: undefined @@ -35,15 +45,7 @@ LinkHints = # A count of the number of Tab presses since the last non-Tab keyboard event. tabCount: 0 - # We need this as a top-level function because our command system doesn't yet support arguments. - 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) - - activateMode: (mode = OPEN_IN_CURRENT_TAB) -> + constructor: (mode = OPEN_IN_CURRENT_TAB) -> # we need documentElement to be ready in order to append links return unless document.documentElement -- cgit v1.2.3