From 2741021d2967866e5d5b2d8bc9673b44a99e4e61 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Wed, 6 Mar 2013 13:01:09 +0000 Subject: Added command to move tab to the left and right --- background_scripts/commands.coffee | 10 ++++++++-- background_scripts/main.coffee | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index e2211be1..628b7273 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" @@ -164,6 +164,9 @@ defaultKeyMappings = "g0": "firstTab" "g$": "lastTab" + "Ml": "moveTabLeft" + "Mr": "moveTabRight" + "W": "moveTabToNewWindow" "t": "createTab" "yt": "duplicateTab" @@ -250,6 +253,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 }] + moveTabRight: ["Move tab to the right", { background: 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 b2b4669c..a15d8d0a 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)) -- cgit v1.2.3 From 85406049e7048081f004ad8b01c8ec3818ed1974 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Thu, 7 Mar 2013 05:32:06 +0000 Subject: Fixed repetion and unmapped command --- background_scripts/commands.coffee | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 628b7273..282474ab 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -164,9 +164,6 @@ defaultKeyMappings = "g0": "firstTab" "g$": "lastTab" - "Ml": "moveTabLeft" - "Mr": "moveTabRight" - "W": "moveTabToNewWindow" "t": "createTab" "yt": "duplicateTab" @@ -253,8 +250,8 @@ commandDescriptions = moveTabToNewWindow: ["Move tab to new window", { background: true }] togglePinTab: ["Pin/unpin current tab", { background: true }] - moveTabLeft: ["Move tab to the left", { background: true }] - moveTabRight: ["Move tab to the right", { 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"] -- cgit v1.2.3