diff options
| -rw-r--r-- | background_scripts/marks.coffee | 22 | ||||
| -rw-r--r-- | content_scripts/marks.coffee | 21 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 7 |
3 files changed, 19 insertions, 31 deletions
diff --git a/background_scripts/marks.coffee b/background_scripts/marks.coffee index 7cdbbf74..8fe30b2f 100644 --- a/background_scripts/marks.coffee +++ b/background_scripts/marks.coffee @@ -23,9 +23,8 @@ Marks = @saveMark markInfo else # The front-end frame hasn't provided the scroll position (because it's not the top frame within its - # tab). We need to ask the top frame what its scroll position is. (With the frame Id set to 0, below, - # the request will only be handled by the top frame within the tab.) - chrome.tabs.sendMessage sender.tab.id, name: "getScrollPosition", frameId: 0, (response) => + # tab). We need to ask the top frame what its scroll position is. + chrome.tabs.sendMessage sender.tab.id, name: "getScrollPosition", (response) => @saveMark extend markInfo, scrollX: response.scrollX, scrollY: response.scrollY saveMark: (markInfo) -> @@ -42,13 +41,7 @@ Marks = key = @getLocationKey req.markName chrome.storage.sync.get key, (items) => markInfo = items[key] - if not markInfo - # The mark is not defined. - chrome.tabs.sendMessage sender.tab.id, - name: "showHUDforDuration", - text: "Global mark not set: '#{req.markName}'." - duration: 1000 - else if markInfo.vimiumSecret != vimiumSecret + if markInfo.vimiumSecret != vimiumSecret # This is a different Vimium instantiation, so markInfo.tabId is definitely out of date. @focusOrLaunch markInfo, req else @@ -64,13 +57,8 @@ Marks = # Focus an existing tab and scroll to the given position within it. gotoPositionInTab: ({ tabId, scrollX, scrollY, markName }) -> - chrome.tabs.update tabId, { selected: true }, -> - chrome.tabs.sendMessage tabId, - { name: "setScrollPosition", scrollX: scrollX, scrollY: scrollY }, -> - chrome.tabs.sendMessage tabId, - name: "showHUDforDuration", - text: "Jumped to global mark '#{markName}'." - duration: 1000 + chrome.tabs.update tabId, {selected: true}, -> + chrome.tabs.sendMessage tabId, {name: "setScrollPosition", scrollX, scrollY} # The tab we're trying to find no longer exists. We either find another tab with a matching URL and use it, # or we create a new tab. 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 -> |
