diff options
| author | Stephen Blott | 2016-04-19 13:32:39 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2016-04-22 14:52:45 +0100 | 
| commit | 740df9a23fa9a1e5b812584ce0702b813b226623 (patch) | |
| tree | 18350599c33c8cef17fa4cf8e55b3a9ca0fe0630 | |
| parent | 4a670aaa3d121834685a672acc904f9824721824 (diff) | |
| download | vimium-740df9a23fa9a1e5b812584ce0702b813b226623.tar.bz2 | |
Help dialog; do not offer hints outside of the help dialog.
| -rw-r--r-- | background_scripts/main.coffee | 4 | ||||
| -rw-r--r-- | content_scripts/link_hints.coffee | 14 | ||||
| -rw-r--r-- | pages/help_dialog.coffee | 3 | 
3 files changed, 15 insertions, 6 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 23b7ab48..cb978db3 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -366,10 +366,10 @@ HintCoordinator =      for own frameId, port of @tabState[tabId].ports        @postMessage tabId, parseInt(frameId), messageType, port, request -  prepareToActivateMode: (tabId, originatingFrameId, {modeIndex}) -> +  prepareToActivateMode: (tabId, originatingFrameId, {modeIndex, isVimiumHelpDialog}) ->      @tabState[tabId] = {frameIds: frameIdsForTab[tabId][..], hintDescriptors: {}, originatingFrameId, modeIndex}      @tabState[tabId].ports = extend {}, portsForTab[tabId] -    @sendMessage "getHintDescriptors", tabId, {modeIndex} +    @sendMessage "getHintDescriptors", tabId, {modeIndex, isVimiumHelpDialog}    # Receive hint descriptors from all frames and activate link-hints mode when we have them all.    postHintDescriptors: (tabId, frameId, {hintDescriptors}) -> diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 702ff69d..6e1ebe80 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -70,18 +70,26 @@ HintCoordinator =      # place, then Vimium blocks.  As a temporary measure, we install a timer to remove it.      Utils.setTimeout 1000, -> suppressKeyboardEvents.exit() if suppressKeyboardEvents?.modeIsActive      @onExit = [onExit] -    @sendMessage "prepareToActivateMode", modeIndex: availableModes.indexOf mode +    @sendMessage "prepareToActivateMode", +      modeIndex: availableModes.indexOf(mode), isVimiumHelpDialog: window.isVimiumHelpDialog    # Hint descriptors are global.  They include all of the information necessary for each frame to determine    # whether and when a hint from *any* frame is selected.  They include the following properties:    #   frameId: the frame id of this hint's local frame    #   localIndex: the index in @localHints for the full hint descriptor for this hint    #   linkText: the link's text for filtered hints (this is null for alphabet hints) -  getHintDescriptors: ({modeIndex}) -> +  getHintDescriptors: ({modeIndex, isVimiumHelpDialog}) ->      # Ensure that the document is ready and that the settings are loaded.      DomUtils.documentReady => Settings.onLoaded =>        requireHref = availableModes[modeIndex] in [COPY_LINK_URL, OPEN_INCOGNITO] -      @localHints = LocalHints.getLocalHints requireHref +      # If link hints is launched within the help dialog, then we only offer hints from that frame.  This +      # improves the usability of the help dialog on the options page (particularly for selecting command +      # names). +      @localHints = +        if isVimiumHelpDialog and not window.isVimiumHelpDialog +          [] +        else +          LocalHints.getLocalHints requireHref        @localHintDescriptors = @localHints.map ({linkText}, localIndex) -> {frameId, localIndex, linkText}        @sendMessage "postHintDescriptors", hintDescriptors: @localHintDescriptors diff --git a/pages/help_dialog.coffee b/pages/help_dialog.coffee index 401c3222..ebcf8486 100644 --- a/pages/help_dialog.coffee +++ b/pages/help_dialog.coffee @@ -38,7 +38,7 @@ HelpDialog =        do (element) ->          element.setAttribute "role", "link"          element.addEventListener "click", -> -          commandName = element.textContent.replace("(","").replace ")", "" +          commandName = element.textContent            chrome.runtime.sendMessage handler: "copyToClipboard", data: commandName            HUD.showForDuration("Yanked #{commandName}.", 2000) @@ -82,3 +82,4 @@ UIComponentServer.registerHandler (event) ->  root = exports ? window  root.HelpDialog = HelpDialog +root.isVimiumHelpDialog = true | 
