aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorPhil Crosby2014-05-11 16:26:48 -0700
committerPhil Crosby2014-05-11 16:26:48 -0700
commit9fdd122abde7c55926b6d58e135f1bcb3024c0a2 (patch)
treed13d6b1e850553c629124b6b775e0e82ddb46e20 /background_scripts
parent70feaf233034f2cec8d20adf3a99ddc50b399156 (diff)
parent85406049e7048081f004ad8b01c8ec3818ed1974 (diff)
downloadvimium-9fdd122abde7c55926b6d58e135f1bcb3024c0a2.tar.bz2
Merge pull request #796 from deiga/tab-movement-commands
Added command to move tab to the left and right
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/commands.coffee7
-rw-r--r--background_scripts/main.coffee6
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))