Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
root = window.Marks = {} | ||
|
||
marks = {} | ||
|
||
root.create = (req, sender) -> | ||
marks[req.markName] = | ||
tabId: sender.tab.id | ||
scrollX: req.scrollX | ||
scrollY: req.scrollY | ||
|
||
chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) -> | ||
if changeInfo.url? | ||
removeMarksForTab tabId | ||
|
||
chrome.tabs.onRemoved.addListener (tabId, removeInfo) -> | ||
# XXX(jez): what about restored tabs? | ||
removeMarksForTab tabId | ||
|
||
removeMarksForTab = (id) -> | ||
for markName, mark of marks | ||
if mark.tabId is id | ||
delete marks[markName] | ||
|
||
root.goto = (req, sender) -> | ||
mark = marks[req.markName] | ||
chrome.tabs.update mark.tabId, selected: true | ||
chrome.tabs.sendRequest mark.tabId, | ||
name: "setScrollPosition" | ||
scrollX: mark.scrollX | ||
scrollY: mark.scrollY | ||
chrome.tabs.sendRequest mark.tabId, | ||
name: "showHUDforDuration", | ||
text: "Jumped to global mark '#{req.markName}'" | ||
duration: 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
root = window.Marks = {} | ||
|
||
root.activateCreateMode = -> | ||
handlerStack.push keydown: (e) -> | ||
keyChar = KeyboardUtils.getKeyChar(event) | ||
return unless keyChar isnt "" | ||
|
||
if /[A-Z]/.test keyChar | ||
chrome.extension.sendRequest { | ||
handler: 'createMark', | ||
markName: keyChar | ||
scrollX: window.scrollX, | ||
scrollY: window.scrollY | ||
}, -> HUD.showForDuration "Created global mark '#{keyChar}'", 1000 | ||
else if /[a-z]/.test keyChar | ||
[baseLocation, sep, hash] = window.location.href.split '#' | ||
localStorage["vimiumMark|#{baseLocation}|#{keyChar}"] = JSON.stringify | ||
scrollX: window.scrollX, | ||
scrollY: window.scrollY | ||
HUD.showForDuration "Created local mark '#{keyChar}'", 1000 | ||
|
||
@remove() | ||
|
||
false | ||
|
||
root.activateGotoMode = -> | ||
handlerStack.push keydown: (e) -> | ||
keyChar = KeyboardUtils.getKeyChar(event) | ||
return unless keyChar isnt "" | ||
|
||
if /[A-Z]/.test keyChar | ||
chrome.extension.sendRequest | ||
handler: 'gotoMark' | ||
markName: keyChar | ||
else if /[a-z]/.test keyChar | ||
[baseLocation, sep, hash] = window.location.href.split '#' | ||
markString = localStorage["vimiumMark|#{baseLocation}|#{keyChar}"] | ||
if markString? | ||
mark = JSON.parse markString | ||
window.scrollTo mark.scrollX, mark.scrollY | ||
HUD.showForDuration "Jumped to local mark '#{keyChar}'", 1000 | ||
|
||
@remove() | ||
|
||
false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters