Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1408)

Unified Diff: Source/devtools/front_end/ui/TabbedPane.js

Issue 849073006: DevTools: Implement "close tabs to the right" for Sources panel tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ui/TabbedPane.js
diff --git a/Source/devtools/front_end/ui/TabbedPane.js b/Source/devtools/front_end/ui/TabbedPane.js
index 7d9130721c8d7d91021e48967c7303a86a4d3511..6c67585d74bffaf5de2014082cf41dd5641323bc 100644
--- a/Source/devtools/front_end/ui/TabbedPane.js
+++ b/Source/devtools/front_end/ui/TabbedPane.js
@@ -292,9 +292,8 @@ WebInspector.TabbedPane.prototype = {
allTabs: function()
{
var result = [];
- var tabs = this._tabs.slice();
- for (var i = 0; i < tabs.length; ++i)
- result.push(tabs[i].id);
+ for (var i = 0; i < this._tabs.length; ++i)
alph 2015/01/19 07:23:38 nit: return this._tabs.map(function(tab) { return
lushnikov 2015/01/19 10:54:18 Done.
+ result.push(this._tabs[i].id);
return result;
},
@@ -305,16 +304,33 @@ WebInspector.TabbedPane.prototype = {
otherTabs: function(id)
{
var result = [];
- var tabs = this._tabs.slice();
- for (var i = 0; i < tabs.length; ++i) {
- if (tabs[i].id !== id)
- result.push(tabs[i].id);
+ for (var i = 0; i < this._tabs.length; ++i) {
+ if (this._tabs[i].id !== id)
+ result.push(this._tabs[i].id);
}
return result;
},
/**
* @param {string} id
+ * @return {!Array.<string>}
+ */
+ _tabsToTheRight: function(id)
+ {
+ var index = -1;
+ for (var i = 0; i < this._tabs.length; ++i) {
+ if (this._tabs[i].id === id) {
+ index = i;
+ break;
+ }
+ }
+ if (index === -1)
+ return [];
+ return this._tabs.slice(index + 1).map(function (tab) { return tab.id; });
+ },
+
+ /**
+ * @param {string} id
* @param {boolean=} userGesture
* @return {boolean}
*/
@@ -1071,9 +1087,18 @@ WebInspector.TabbedPaneTab.prototype = {
this._closeTabs(this._tabbedPane.allTabs());
}
+ /**
+ * @this {WebInspector.TabbedPaneTab}
+ */
+ function closeToTheRight()
+ {
+ this._closeTabs(this._tabbedPane._tabsToTheRight(this.id));
+ }
+
var contextMenu = new WebInspector.ContextMenu(event);
contextMenu.appendItem(WebInspector.UIString.capitalize("Close"), close.bind(this));
contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^others"), closeOthers.bind(this));
+ contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^tabs to the ^right"), closeToTheRight.bind(this));
contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^all"), closeAll.bind(this));
contextMenu.show();
},
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698