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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 { 285 {
286 return !!this._tabsById[tabId]; 286 return !!this._tabsById[tabId];
287 }, 287 },
288 288
289 /** 289 /**
290 * @return {!Array.<string>} 290 * @return {!Array.<string>}
291 */ 291 */
292 allTabs: function() 292 allTabs: function()
293 { 293 {
294 var result = []; 294 var result = [];
295 var tabs = this._tabs.slice(); 295 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.
296 for (var i = 0; i < tabs.length; ++i) 296 result.push(this._tabs[i].id);
297 result.push(tabs[i].id);
298 return result; 297 return result;
299 }, 298 },
300 299
301 /** 300 /**
302 * @param {string} id 301 * @param {string} id
303 * @return {!Array.<string>} 302 * @return {!Array.<string>}
304 */ 303 */
305 otherTabs: function(id) 304 otherTabs: function(id)
306 { 305 {
307 var result = []; 306 var result = [];
308 var tabs = this._tabs.slice(); 307 for (var i = 0; i < this._tabs.length; ++i) {
309 for (var i = 0; i < tabs.length; ++i) { 308 if (this._tabs[i].id !== id)
310 if (tabs[i].id !== id) 309 result.push(this._tabs[i].id);
311 result.push(tabs[i].id);
312 } 310 }
313 return result; 311 return result;
314 }, 312 },
315 313
316 /** 314 /**
317 * @param {string} id 315 * @param {string} id
316 * @return {!Array.<string>}
317 */
318 _tabsToTheRight: function(id)
319 {
320 var index = -1;
321 for (var i = 0; i < this._tabs.length; ++i) {
322 if (this._tabs[i].id === id) {
323 index = i;
324 break;
325 }
326 }
327 if (index === -1)
328 return [];
329 return this._tabs.slice(index + 1).map(function (tab) { return tab.id; } );
330 },
331
332 /**
333 * @param {string} id
318 * @param {boolean=} userGesture 334 * @param {boolean=} userGesture
319 * @return {boolean} 335 * @return {boolean}
320 */ 336 */
321 selectTab: function(id, userGesture) 337 selectTab: function(id, userGesture)
322 { 338 {
323 if (this._currentTabLocked) 339 if (this._currentTabLocked)
324 return false; 340 return false;
325 var focused = this.hasFocus(); 341 var focused = this.hasFocus();
326 var tab = this._tabsById[id]; 342 var tab = this._tabsById[id];
327 if (!tab) 343 if (!tab)
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 } 1080 }
1065 1081
1066 /** 1082 /**
1067 * @this {WebInspector.TabbedPaneTab} 1083 * @this {WebInspector.TabbedPaneTab}
1068 */ 1084 */
1069 function closeAll() 1085 function closeAll()
1070 { 1086 {
1071 this._closeTabs(this._tabbedPane.allTabs()); 1087 this._closeTabs(this._tabbedPane.allTabs());
1072 } 1088 }
1073 1089
1090 /**
1091 * @this {WebInspector.TabbedPaneTab}
1092 */
1093 function closeToTheRight()
1094 {
1095 this._closeTabs(this._tabbedPane._tabsToTheRight(this.id));
1096 }
1097
1074 var contextMenu = new WebInspector.ContextMenu(event); 1098 var contextMenu = new WebInspector.ContextMenu(event);
1075 contextMenu.appendItem(WebInspector.UIString.capitalize("Close"), close. bind(this)); 1099 contextMenu.appendItem(WebInspector.UIString.capitalize("Close"), close. bind(this));
1076 contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^others") , closeOthers.bind(this)); 1100 contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^others") , closeOthers.bind(this));
1101 contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^tabs to the ^right"), closeToTheRight.bind(this));
1077 contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^all"), c loseAll.bind(this)); 1102 contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^all"), c loseAll.bind(this));
1078 contextMenu.show(); 1103 contextMenu.show();
1079 }, 1104 },
1080 1105
1081 /** 1106 /**
1082 * @param {!Event} event 1107 * @param {!Event} event
1083 * @return {boolean} 1108 * @return {boolean}
1084 */ 1109 */
1085 _startTabDragging: function(event) 1110 _startTabDragging: function(event)
1086 { 1111 {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 /** 1311 /**
1287 * @param {string} id1 1312 * @param {string} id1
1288 * @param {string} id2 1313 * @param {string} id2
1289 * @return {number} 1314 * @return {number}
1290 */ 1315 */
1291 _tabOrderComparator: function(id1, id2) 1316 _tabOrderComparator: function(id1, id2)
1292 { 1317 {
1293 return this._tabOrders[id2] = this._tabOrders[id1]; 1318 return this._tabOrders[id2] = this._tabOrders[id1];
1294 } 1319 }
1295 } 1320 }
OLDNEW
« 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