diff options
| author | Stephen Blott | 2016-03-26 16:00:15 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2016-03-26 16:04:04 +0000 | 
| commit | b09a7524502e7df993bd1d5eb906553348130591 (patch) | |
| tree | af0a7414a2d19368c66e36021ef6404bfb17e427 /content_scripts | |
| parent | e2ea471eff20504b53da36a791769d246fff9593 (diff) | |
| download | vimium-b09a7524502e7df993bd1d5eb906553348130591.tar.bz2 | |
Rework global mark activation.
There were two problems, both stemming from the fact that the
notification was being displayed in the top frame, even if the mark was
triggered in another frame:
1. That looks odd, because we close the HUD in one frame then open it in
   another.
2. As a side effect, we were moving the focus to the top frame.
Here, we work out what's going to happen before sending the message to
the background page.  This allows us to display the message in the HUD
in the frame which generated it.
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/marks.coffee | 21 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 7 | 
2 files changed, 14 insertions, 14 deletions
diff --git a/content_scripts/marks.coffee b/content_scripts/marks.coffee index ba0467b0..808f0a1d 100644 --- a/content_scripts/marks.coffee +++ b/content_scripts/marks.coffee @@ -60,20 +60,25 @@ Marks =        suppressAllKeyboardEvents: true        keypress: (event) =>          @exit => -          keyChar = String.fromCharCode event.charCode -          if @isGlobalMark event, keyChar -            chrome.runtime.sendMessage -              handler: 'gotoMark' -              markName: keyChar +          markName = String.fromCharCode event.charCode +          if @isGlobalMark event, markName +            # This key must match @getLocationKey() in the back end. +            key = "vimiumGlobalMark|#{markName}" +            chrome.storage.sync.get key, (items) -> +              if key of items +                chrome.runtime.sendMessage handler: 'gotoMark', markName: markName +                HUD.showForDuration "Jumped to global mark '#{markName}'", 1000 +              else +                HUD.showForDuration "Global mark not set '#{markName}'", 1000            else -            markString = @localRegisters[keyChar] ? localStorage[@getLocationKey keyChar] +            markString = @localRegisters[markName] ? localStorage[@getLocationKey markName]              if markString?                @setPreviousPosition()                position = JSON.parse markString                window.scrollTo position.scrollX, position.scrollY -              @showMessage "Jumped to local mark", keyChar +              @showMessage "Jumped to local mark", markName              else -              @showMessage "Local mark not set", keyChar +              @showMessage "Local mark not set", markName  root = exports ? window  root.Marks =  Marks diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 79459b76..8acea3fc 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -144,10 +144,9 @@ initializePreDomReady = ->    checkIfEnabledForUrl()    requestHandlers = -    showHUDforDuration: handleShowHUDforDuration      toggleHelpDialog: (request) -> if frameId == request.frameId then HelpDialog.toggle request.dialogHtml      focusFrame: (request) -> if (frameId == request.frameId) then focusThisFrame request -    getScrollPosition: -> scrollX: window.scrollX, scrollY: window.scrollY +    getScrollPosition: -> if frameId == 0 then scrollX: window.scrollX, scrollY: window.scrollY      setScrollPosition: setScrollPosition      # A frame has received the focus.  We don't care here (the Vomnibar/UI-component handles this).      frameFocused: -> @@ -220,10 +219,6 @@ Frame =        isEnabledForUrl = false        window.removeEventListener "focus", onFocus -handleShowHUDforDuration = ({ text, duration }) -> -  if DomUtils.isTopFrame() -    DomUtils.documentReady -> HUD.showForDuration text, duration -  setScrollPosition = ({ scrollX, scrollY }) ->    if DomUtils.isTopFrame()      DomUtils.documentReady ->  | 
