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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 { | 201 { |
202 isCloseable = typeof isCloseable === "boolean" ? isCloseable : this._clo
seableTabs; | 202 isCloseable = typeof isCloseable === "boolean" ? isCloseable : this._clo
seableTabs; |
203 var tab = new WebInspector.TabbedPaneTab(this, id, tabTitle, isCloseable
, view, tabTooltip); | 203 var tab = new WebInspector.TabbedPaneTab(this, id, tabTitle, isCloseable
, view, tabTooltip); |
204 tab.setDelegate(this._delegate); | 204 tab.setDelegate(this._delegate); |
205 this._tabsById[id] = tab; | 205 this._tabsById[id] = tab; |
206 if (index !== undefined) | 206 if (index !== undefined) |
207 this._tabs.splice(index, 0, tab); | 207 this._tabs.splice(index, 0, tab); |
208 else | 208 else |
209 this._tabs.push(tab); | 209 this._tabs.push(tab); |
210 this._tabsHistory.push(tab); | 210 this._tabsHistory.push(tab); |
211 view.attach(this.element); | |
212 if (this._tabsHistory[0] === tab && this.isShowing()) | 211 if (this._tabsHistory[0] === tab && this.isShowing()) |
213 this.selectTab(tab.id, userGesture); | 212 this.selectTab(tab.id, userGesture); |
214 this._updateTabElements(); | 213 this._updateTabElements(); |
215 }, | 214 }, |
216 | 215 |
217 /** | 216 /** |
218 * @param {string} id | 217 * @param {string} id |
219 * @param {boolean=} userGesture | 218 * @param {boolean=} userGesture |
220 */ | 219 */ |
221 closeTab: function(id, userGesture) | 220 closeTab: function(id, userGesture) |
(...skipping 30 matching lines...) Expand all Loading... |
252 if (this._currentTab && this._currentTab.id === id) | 251 if (this._currentTab && this._currentTab.id === id) |
253 this._hideCurrentTab(); | 252 this._hideCurrentTab(); |
254 | 253 |
255 var tab = this._tabsById[id]; | 254 var tab = this._tabsById[id]; |
256 delete this._tabsById[id]; | 255 delete this._tabsById[id]; |
257 | 256 |
258 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); | 257 this._tabsHistory.splice(this._tabsHistory.indexOf(tab), 1); |
259 this._tabs.splice(this._tabs.indexOf(tab), 1); | 258 this._tabs.splice(this._tabs.indexOf(tab), 1); |
260 if (tab._shown) | 259 if (tab._shown) |
261 this._hideTabElement(tab); | 260 this._hideTabElement(tab); |
262 tab.view.detach(); | |
263 | 261 |
264 var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture
}; | 262 var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture
}; |
265 this.dispatchEventToListeners(WebInspector.TabbedPane.EventTypes.TabClos
ed, eventData); | 263 this.dispatchEventToListeners(WebInspector.TabbedPane.EventTypes.TabClos
ed, eventData); |
266 return true; | 264 return true; |
267 }, | 265 }, |
268 | 266 |
269 /** | 267 /** |
270 * @param {string} tabId | 268 * @param {string} tabId |
271 * @return {boolean} | 269 * @return {boolean} |
272 */ | 270 */ |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 this._updateTabElements(); | 416 this._updateTabElements(); |
419 }, | 417 }, |
420 | 418 |
421 /** | 419 /** |
422 * @param {string} id | 420 * @param {string} id |
423 * @param {!WebInspector.Widget} view | 421 * @param {!WebInspector.Widget} view |
424 */ | 422 */ |
425 changeTabView: function(id, view) | 423 changeTabView: function(id, view) |
426 { | 424 { |
427 var tab = this._tabsById[id]; | 425 var tab = this._tabsById[id]; |
428 if (tab.view === view) | 426 if (this._currentTab && this._currentTab.id === tab.id) { |
429 return; | 427 if (tab.view !== view) |
430 | 428 this._hideTab(tab); |
431 var isSelected = this._currentTab && this._currentTab.id === id; | 429 tab.view = view; |
432 if (isSelected) | |
433 this._hideTab(tab); | |
434 tab.view.detach(); | |
435 tab.view = view; | |
436 tab.view.attach(this.element); | |
437 if (isSelected) | |
438 this._showTab(tab); | 430 this._showTab(tab); |
| 431 } else |
| 432 tab.view = view; |
439 }, | 433 }, |
440 | 434 |
441 onResize: function() | 435 onResize: function() |
442 { | 436 { |
443 this._updateTabElements(); | 437 this._updateTabElements(); |
444 }, | 438 }, |
445 | 439 |
446 headerResized: function() | 440 headerResized: function() |
447 { | 441 { |
448 this._updateTabElements(); | 442 this._updateTabElements(); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 this._hideTab(this._currentTab); | 752 this._hideTab(this._currentTab); |
759 delete this._currentTab; | 753 delete this._currentTab; |
760 }, | 754 }, |
761 | 755 |
762 /** | 756 /** |
763 * @param {!WebInspector.TabbedPaneTab} tab | 757 * @param {!WebInspector.TabbedPaneTab} tab |
764 */ | 758 */ |
765 _showTab: function(tab) | 759 _showTab: function(tab) |
766 { | 760 { |
767 tab.tabElement.classList.add("selected"); | 761 tab.tabElement.classList.add("selected"); |
768 tab.view.showWidget(); | 762 tab.view.show(this.element); |
769 this._updateTabSlider(); | 763 this._updateTabSlider(); |
770 }, | 764 }, |
771 | 765 |
772 _updateTabSlider: function() | 766 _updateTabSlider: function() |
773 { | 767 { |
774 if (!this._currentTab || !this._sliderEnabled) | 768 if (!this._currentTab || !this._sliderEnabled) |
775 return; | 769 return; |
776 var left = 0; | 770 var left = 0; |
777 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs
[i] && this._tabs[i]._shown; i++) | 771 for (var i = 0; i < this._tabs.length && this._currentTab !== this._tabs
[i] && this._tabs[i]._shown; i++) |
778 left += this._tabs[i]._measuredWidth; | 772 left += this._tabs[i]._measuredWidth; |
779 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi
dth : this._dropDownButton.offsetWidth; | 773 var sliderWidth = this._currentTab._shown ? this._currentTab._measuredWi
dth : this._dropDownButton.offsetWidth; |
780 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : ""; | 774 var scaleFactor = window.devicePixelRatio >= 1.5 ? " scaleY(0.75)" : ""; |
781 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa
ctor; | 775 this._tabSlider.style.transform = "translateX(" + left + "px)" + scaleFa
ctor; |
782 this._tabSlider.style.width = sliderWidth + "px"; | 776 this._tabSlider.style.width = sliderWidth + "px"; |
783 | 777 |
784 if (this._tabSlider.parentElement !== this._headerContentsElement) | 778 if (this._tabSlider.parentElement !== this._headerContentsElement) |
785 this._headerContentsElement.appendChild(this._tabSlider); | 779 this._headerContentsElement.appendChild(this._tabSlider); |
786 }, | 780 }, |
787 | 781 |
788 /** | 782 /** |
789 * @param {!WebInspector.TabbedPaneTab} tab | 783 * @param {!WebInspector.TabbedPaneTab} tab |
790 */ | 784 */ |
791 _hideTab: function(tab) | 785 _hideTab: function(tab) |
792 { | 786 { |
793 tab.tabElement.classList.remove("selected"); | 787 tab.tabElement.classList.remove("selected"); |
794 tab.view.hideWidget(); | 788 tab.view.detach(); |
795 }, | 789 }, |
796 | 790 |
797 /** | 791 /** |
798 * @override | 792 * @override |
799 * @return {!Array.<!Element>} | 793 * @return {!Array.<!Element>} |
800 */ | 794 */ |
801 elementsToRestoreScrollPositionsFor: function() | 795 elementsToRestoreScrollPositionsFor: function() |
802 { | 796 { |
803 return [ this._contentElement ]; | 797 return [ this._contentElement ]; |
804 }, | 798 }, |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 if (this._viewCallback && view) | 1423 if (this._viewCallback && view) |
1430 this._viewCallback(id, view); | 1424 this._viewCallback(id, view); |
1431 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces
tor(WebInspector.currentFocusElement()); | 1425 var shouldFocus = this._tabbedPane.visibleView.element.isSelfOrAnces
tor(WebInspector.currentFocusElement()); |
1432 this._tabbedPane.changeTabView(id, view); | 1426 this._tabbedPane.changeTabView(id, view); |
1433 if (shouldFocus) | 1427 if (shouldFocus) |
1434 view.focus(); | 1428 view.focus(); |
1435 return view; | 1429 return view; |
1436 } | 1430 } |
1437 } | 1431 } |
1438 } | 1432 } |
OLD | NEW |