OLD | NEW |
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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 hasTab: function(tabId) | 284 hasTab: function(tabId) |
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 return this._tabs.map(function (tab) { return tab.id; }); |
295 var tabs = this._tabs.slice(); | |
296 for (var i = 0; i < tabs.length; ++i) | |
297 result.push(tabs[i].id); | |
298 return result; | |
299 }, | 295 }, |
300 | 296 |
301 /** | 297 /** |
302 * @param {string} id | 298 * @param {string} id |
303 * @return {!Array.<string>} | 299 * @return {!Array.<string>} |
304 */ | 300 */ |
305 otherTabs: function(id) | 301 otherTabs: function(id) |
306 { | 302 { |
307 var result = []; | 303 var result = []; |
308 var tabs = this._tabs.slice(); | 304 for (var i = 0; i < this._tabs.length; ++i) { |
309 for (var i = 0; i < tabs.length; ++i) { | 305 if (this._tabs[i].id !== id) |
310 if (tabs[i].id !== id) | 306 result.push(this._tabs[i].id); |
311 result.push(tabs[i].id); | |
312 } | 307 } |
313 return result; | 308 return result; |
314 }, | 309 }, |
315 | 310 |
316 /** | 311 /** |
317 * @param {string} id | 312 * @param {string} id |
| 313 * @return {!Array.<string>} |
| 314 */ |
| 315 _tabsToTheRight: function(id) |
| 316 { |
| 317 var index = -1; |
| 318 for (var i = 0; i < this._tabs.length; ++i) { |
| 319 if (this._tabs[i].id === id) { |
| 320 index = i; |
| 321 break; |
| 322 } |
| 323 } |
| 324 if (index === -1) |
| 325 return []; |
| 326 return this._tabs.slice(index + 1).map(function (tab) { return tab.id; }
); |
| 327 }, |
| 328 |
| 329 /** |
| 330 * @param {string} id |
318 * @param {boolean=} userGesture | 331 * @param {boolean=} userGesture |
319 * @return {boolean} | 332 * @return {boolean} |
320 */ | 333 */ |
321 selectTab: function(id, userGesture) | 334 selectTab: function(id, userGesture) |
322 { | 335 { |
323 if (this._currentTabLocked) | 336 if (this._currentTabLocked) |
324 return false; | 337 return false; |
325 var focused = this.hasFocus(); | 338 var focused = this.hasFocus(); |
326 var tab = this._tabsById[id]; | 339 var tab = this._tabsById[id]; |
327 if (!tab) | 340 if (!tab) |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 } | 1077 } |
1065 | 1078 |
1066 /** | 1079 /** |
1067 * @this {WebInspector.TabbedPaneTab} | 1080 * @this {WebInspector.TabbedPaneTab} |
1068 */ | 1081 */ |
1069 function closeAll() | 1082 function closeAll() |
1070 { | 1083 { |
1071 this._closeTabs(this._tabbedPane.allTabs()); | 1084 this._closeTabs(this._tabbedPane.allTabs()); |
1072 } | 1085 } |
1073 | 1086 |
| 1087 /** |
| 1088 * @this {WebInspector.TabbedPaneTab} |
| 1089 */ |
| 1090 function closeToTheRight() |
| 1091 { |
| 1092 this._closeTabs(this._tabbedPane._tabsToTheRight(this.id)); |
| 1093 } |
| 1094 |
1074 var contextMenu = new WebInspector.ContextMenu(event); | 1095 var contextMenu = new WebInspector.ContextMenu(event); |
1075 contextMenu.appendItem(WebInspector.UIString.capitalize("Close"), close.
bind(this)); | 1096 contextMenu.appendItem(WebInspector.UIString.capitalize("Close"), close.
bind(this)); |
1076 contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^others")
, closeOthers.bind(this)); | 1097 contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^others")
, closeOthers.bind(this)); |
| 1098 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)); | 1099 contextMenu.appendItem(WebInspector.UIString.capitalize("Close ^all"), c
loseAll.bind(this)); |
1078 contextMenu.show(); | 1100 contextMenu.show(); |
1079 }, | 1101 }, |
1080 | 1102 |
1081 /** | 1103 /** |
1082 * @param {!Event} event | 1104 * @param {!Event} event |
1083 * @return {boolean} | 1105 * @return {boolean} |
1084 */ | 1106 */ |
1085 _startTabDragging: function(event) | 1107 _startTabDragging: function(event) |
1086 { | 1108 { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 /** | 1308 /** |
1287 * @param {string} id1 | 1309 * @param {string} id1 |
1288 * @param {string} id2 | 1310 * @param {string} id2 |
1289 * @return {number} | 1311 * @return {number} |
1290 */ | 1312 */ |
1291 _tabOrderComparator: function(id1, id2) | 1313 _tabOrderComparator: function(id1, id2) |
1292 { | 1314 { |
1293 return this._tabOrders[id2] = this._tabOrders[id1]; | 1315 return this._tabOrders[id2] = this._tabOrders[id1]; |
1294 } | 1316 } |
1295 } | 1317 } |
OLD | NEW |