diff options
| -rw-r--r-- | background_scripts/commands.coffee | 7 | ||||
| -rw-r--r-- | background_scripts/main.coffee | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index e2211be1..282474ab 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -100,7 +100,7 @@ Commands = ["goBack", "goForward"] tabManipulation: ["nextTab", "previousTab", "firstTab", "lastTab", "createTab", "duplicateTab", "removeTab", - "restoreTab", "moveTabToNewWindow", "togglePinTab"] + "restoreTab", "moveTabToNewWindow", "togglePinTab", "moveTabLeft", "moveTabRight"] misc: ["showHelp"] @@ -111,7 +111,7 @@ Commands = "scrollToLeft", "scrollToRight", "moveTabToNewWindow", "goUp", "goToRoot", "focusInput", "LinkHints.activateModeWithQueue", "LinkHints.activateModeToOpenIncognito", "goNext", "goPrevious", "Marks.activateCreateMode", - "Marks.activateGotoMode"] + "Marks.activateGotoMode", "moveTabLeft", "moveTabRight"] defaultKeyMappings = "?": "showHelp" @@ -250,6 +250,9 @@ commandDescriptions = moveTabToNewWindow: ["Move tab to new window", { background: true }] togglePinTab: ["Pin/unpin current tab", { background: true }] + moveTabLeft: ["Move tab to the left", { background: true, passCountToFunction: true }] + moveTabRight: ["Move tab to the right", { background: true, passCountToFunction: true }] + "Vomnibar.activate": ["Open URL, bookmark, or history entry"] "Vomnibar.activateInNewTab": ["Open URL, bookmark, history entry, in a new tab"] "Vomnibar.activateTabSelection": ["Search through your open tabs"] diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index ab633d8e..666c37e0 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -217,6 +217,10 @@ repeatFunction = (func, totalCount, currentCount, frameId) -> -> repeatFunction(func, totalCount, currentCount + 1, frameId), frameId) +moveTab = (callback, direction) -> + chrome.tabs.getSelected(null, (tab) -> + chrome.tabs.move(tab.id, {index: tab.index + direction }, callback)) + # Start action functions # These are commands which are bound to keystroke which must be handled by the background page. They are @@ -234,6 +238,8 @@ BackgroundCommands = previousTab: (callback) -> selectTab(callback, "previous") firstTab: (callback) -> selectTab(callback, "first") lastTab: (callback) -> selectTab(callback, "last") + moveTabLeft: (callback) -> moveTab(callback, -1) + moveTabRight: (callback) -> moveTab(callback, 1) removeTab: -> chrome.tabs.getSelected(null, (tab) -> chrome.tabs.remove(tab.id)) |
