diff options
| -rw-r--r-- | background_scripts/commands.coffee | 11 | ||||
| -rw-r--r-- | background_scripts/main.coffee | 22 | ||||
| -rw-r--r-- | test_harnesses/vomnibar.html | 16 |
3 files changed, 30 insertions, 19 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index b9586888..4b3130c8 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", "closeTabsToLeft","closeTabsToRight", + "restoreTab", "moveTabToNewWindow", "togglePinTab", "closeTabsOnLeft","closeTabsOnRight", "closeOtherTabs", "moveTabLeft", "moveTabRight"] misc: ["showHelp"] @@ -112,7 +112,8 @@ Commands = "scrollToLeft", "scrollToRight", "moveTabToNewWindow", "goUp", "goToRoot", "focusInput", "LinkHints.activateModeWithQueue", "LinkHints.activateModeToOpenIncognito", "goNext", "goPrevious", "Marks.activateCreateMode", - "Marks.activateGotoMode", "moveTabLeft", "moveTabRight"] + "Marks.activateGotoMode", "moveTabLeft", "moveTabRight", + "closeTabsOnLeft","closeTabsOnRight", "closeOtherTabs"] defaultKeyMappings = "?": "showHelp" @@ -254,9 +255,9 @@ commandDescriptions = moveTabToNewWindow: ["Move tab to new window", { background: true }] togglePinTab: ["Pin/unpin current tab", { background: true }] - closeTabsToLeft: ["Close tabs to the left", {background: true, noRepeat: true}] - closeTabsToRight: ["Close tabs to the right", {background: true, noRepeat: true}] - closeOtherTabs: ["Close other tabs", {background: true, noRepeat: true}] + closeTabsToLeft: ["Close tabs on the left", {background: true, noRepeat: true}] + closeTabsToRight: ["Close tabs on the right", {background: true, noRepeat: true}] + closeOtherTabs: ["Close all other tabs", {background: true, noRepeat: true}] moveTabLeft: ["Move tab to the left", { background: true, passCountToFunction: true }] moveTabRight: ["Move tab to the right", { background: true, passCountToFunction: true }] diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index a8f851c0..431d9a31 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -290,29 +290,29 @@ BackgroundCommands = chrome.tabs.sendMessage(tab.id, { name: "focusFrame", frameId: frames[newIndex].id, highlight: true })) - closeTabsToLeft: -> removeTabsRelative "before" - closeTabsToRight: -> removeTabsRelative "after" + closeTabsOnLeft: -> removeTabsRelative "before" + closeTabsOnRight: -> removeTabsRelative "after" closeOtherTabs: -> removeTabsRelative "both" # Remove tabs before, after, or either side of the currently active tab removeTabsRelative = (direction) -> chrome.tabs.query {currentWindow: true}, (tabs) -> - chrome.tabs.query {currentWindow: true, active: true}, (activeTabArr) -> - activeTabIndex = activeTabArr[0].index + chrome.tabs.query {currentWindow: true, active: true}, (activeTabs) -> + activeTabIndex = activeTabs[0].index - switch direction + shouldDelete = switch direction when "before" - shouldDelete = (index) -> index < activeTabIndex + (index) -> index < activeTabIndex when "after" - shouldDelete = (index) -> index > activeTabIndex + (index) -> index > activeTabIndex when "both" - shouldDelete = (index) -> index != activeTabIndex + (index) -> index != activeTabIndex - removeTabIds = [] + toRemove = [] for tab in tabs if not tab.pinned and shouldDelete tab.index - removeTabIds.push tab.id - chrome.tabs.remove removeTabIds + toRemove.push tab.id + chrome.tabs.remove toRemove # Selects a tab before or after the currently selected tab. # - direction: "next", "previous", "first" or "last". diff --git a/test_harnesses/vomnibar.html b/test_harnesses/vomnibar.html index f484279e..4d50e749 100644 --- a/test_harnesses/vomnibar.html +++ b/test_harnesses/vomnibar.html @@ -20,7 +20,7 @@ var itemHtml = '<span class="source">history</span> http://<span class="fuzzyMatch">n</span><span class="fuzzyMatch">i</span><span class="fuzzyMatch">n</span><span class="fuzzyMatch">j</span><span class="fuzzyMatch">a</span>words.com/info/about <span class="title">Ninjawords - a really fast dictionary</span>'; var results = [{ html: itemHtml }, { html: itemHtml }]; - // Stub out the chrome extension apis needed by the Vomnibar. + // Stub out the chrome extension APIs needed by the Vomnibar. window.chrome = { }; var port = { onMessage: { addListener: function(callback) { } }, @@ -53,8 +53,18 @@ </head> <body> - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br/><br/> + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex + ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat + nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit + anim id est laborum. - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <br/><br/> + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex + ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat + nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit + anim id est laborum. </body> </html> |
