OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * TabSwitcher is an implementation of View that handles tab switching. | 6 * TabSwitcher is an implementation of View that handles tab switching. |
7 * | 7 * |
8 * +-----------------------------------+ | 8 * +-----------------------------------+ |
9 * | Tab1 / Tab2 / Tab3 / .. | <- tab handle view | 9 * | Tab1 / Tab2 / Tab3 / .. | <- tab handle view |
10 * +-----------------------------------+ | 10 * +-----------------------------------+ |
11 * | | | 11 * | | |
12 * | | | 12 * | | |
13 * | | | 13 * | | |
14 * | stacked tab content areas | | 14 * | stacked tab content areas | |
15 * | (only 1 is visible at a time) | | 15 * | (only 1 is visible at a time) | |
16 * | | | 16 * | | |
17 * | | | 17 * | | |
18 * | | | 18 * | | |
19 * +-----------------------------------+ | 19 * +-----------------------------------+ |
20 * | 20 * |
21 * @parameter {!View} tabHandleView the view that contains the tab handles. | 21 * @parameter {!View} tabHandleView the view that contains the tab handles. |
22 * | 22 * |
23 * @constructor | 23 * @constructor |
24 */ | 24 */ |
25 function TabSwitcherView(tabHandleView) { | 25 function TabSwitcherView(tabHandleDivId) { |
| 26 document.getElementById(tabHandleDivId).classList.add('tab-switcher-view'); |
| 27 var tabHandleView = new DivView(tabHandleDivId); |
| 28 |
26 View.call(this); | 29 View.call(this); |
27 this.tabHandleView_ = tabHandleView; | 30 this.tabHandleView_ = tabHandleView; |
28 this.tabs_ = []; | 31 this.tabs_ = []; |
29 } | 32 } |
30 | 33 |
31 inherits(TabSwitcherView, View); | 34 inherits(TabSwitcherView, View); |
32 | 35 |
33 TabSwitcherView.prototype.setGeometry = function(left, top, width, height) { | 36 TabSwitcherView.prototype.setGeometry = function(left, top, width, height) { |
34 TabSwitcherView.superClass_.setGeometry.call(this, left, top, width, height); | 37 TabSwitcherView.superClass_.setGeometry.call(this, left, top, width, height); |
35 | 38 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (oldTab) | 118 if (oldTab) |
116 oldTab.setSelected(false); | 119 oldTab.setSelected(false); |
117 | 120 |
118 var newTab = this.findTabById(id); | 121 var newTab = this.findTabById(id); |
119 newTab.setSelected(true); | 122 newTab.setSelected(true); |
120 if (params) | 123 if (params) |
121 newTab.contentView.setParameters(params); | 124 newTab.contentView.setParameters(params); |
122 | 125 |
123 // Update data needed by newly active tab, as it may be | 126 // Update data needed by newly active tab, as it may be |
124 // significantly out of date. | 127 // significantly out of date. |
125 g_browser.checkForUpdatedInfo(); | 128 if (typeof g_browser != 'undefined' && g_browser.checkForUpdatedInfo) |
| 129 g_browser.checkForUpdatedInfo(); |
126 }; | 130 }; |
127 | 131 |
128 TabSwitcherView.prototype.getAllTabIds = function() { | 132 TabSwitcherView.prototype.getAllTabIds = function() { |
129 var ids = []; | 133 var ids = []; |
130 for (var i = 0; i < this.tabs_.length; ++i) | 134 for (var i = 0; i < this.tabs_.length; ++i) |
131 ids.push(this.tabs_[i].id); | 135 ids.push(this.tabs_[i].id); |
132 return ids; | 136 return ids; |
133 }; | 137 }; |
134 | 138 |
135 //----------------------------------------------------------------------------- | 139 //----------------------------------------------------------------------------- |
(...skipping 12 matching lines...) Expand all Loading... |
148 this.contentView.show(isSelected); | 152 this.contentView.show(isSelected); |
149 }; | 153 }; |
150 | 154 |
151 /** | 155 /** |
152 * Returns the DOM node that is used to select the tab. | 156 * Returns the DOM node that is used to select the tab. |
153 */ | 157 */ |
154 TabEntry.prototype.getTabHandleNode = function() { | 158 TabEntry.prototype.getTabHandleNode = function() { |
155 return document.getElementById(this.id); | 159 return document.getElementById(this.id); |
156 }; | 160 }; |
157 | 161 |
OLD | NEW |