| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Controller and View for switching between tabs. | 6 * Controller and View for switching between tabs. |
| 7 * | 7 * |
| 8 * The View part of TabSwitcherView displays the contents of the currently | 8 * The View part of TabSwitcherView displays the contents of the currently |
| 9 * selected tab (only one tab can be active at a time). | 9 * selected tab (only one tab can be active at a time). |
| 10 * | 10 * |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 view.show(false); | 86 view.show(false); |
| 87 | 87 |
| 88 // Add it to the dropdown menu. | 88 // Add it to the dropdown menu. |
| 89 var menuItem = addNode(this.dropdownMenu_, 'option'); | 89 var menuItem = addNode(this.dropdownMenu_, 'option'); |
| 90 menuItem.value = tabId; | 90 menuItem.value = tabId; |
| 91 menuItem.textContent = name; | 91 menuItem.textContent = name; |
| 92 }, | 92 }, |
| 93 | 93 |
| 94 showMenuItem: function(tabId, isVisible) { | 94 showMenuItem: function(tabId, isVisible) { |
| 95 var wasActive = this.activeTabId_ == tabId; | 95 var wasActive = this.activeTabId_ == tabId; |
| 96 setNodeDisplay(this.getMenuItemNode_(tabId), isVisible); | 96 |
| 97 // Hide the menuitem from the list. Note it needs to be 'disabled' to |
| 98 // prevent it being selectable from keyboard. |
| 99 var menuitem = this.getMenuItemNode_(tabId); |
| 100 setNodeDisplay(menuitem, isVisible); |
| 101 menuitem.disabled = !isVisible; |
| 97 | 102 |
| 98 if (wasActive && !isVisible) { | 103 if (wasActive && !isVisible) { |
| 99 // If the active tab is being hidden in the dropdown menu, then | 104 // If the active tab is being hidden in the dropdown menu, then |
| 100 // switch to the first tab which is still visible. | 105 // switch to the first tab which is still visible. |
| 101 for (var i = 0; i < this.dropdownMenu_.options.length; ++i) { | 106 for (var i = 0; i < this.dropdownMenu_.options.length; ++i) { |
| 102 var option = this.dropdownMenu_.options[i]; | 107 var option = this.dropdownMenu_.options[i]; |
| 103 if (option.style.display != 'none') { | 108 if (option.style.display != 'none') { |
| 104 this.switchToTab(option.value); | 109 this.switchToTab(option.value); |
| 105 break; | 110 break; |
| 106 } | 111 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 }, | 168 }, |
| 164 | 169 |
| 165 onMenuSelectionChanged_: function(event) { | 170 onMenuSelectionChanged_: function(event) { |
| 166 var tabId = this.dropdownMenu_.value; | 171 var tabId = this.dropdownMenu_.value; |
| 167 this.switchToTab(tabId); | 172 this.switchToTab(tabId); |
| 168 }, | 173 }, |
| 169 }; | 174 }; |
| 170 | 175 |
| 171 return TabSwitcherView; | 176 return TabSwitcherView; |
| 172 })(); | 177 })(); |
| OLD | NEW |