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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 ///////////////////////////////////////////////////////////////////////////// | 6 ///////////////////////////////////////////////////////////////////////////// |
7 // OptionsPage class: | 7 // OptionsPage class: |
8 | 8 |
9 /** | 9 /** |
10 * Base class for options page. | 10 * Base class for options page. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 }; | 58 }; |
59 | 59 |
60 OptionsPage.clearOverlays = function() { | 60 OptionsPage.clearOverlays = function() { |
61 for (var name in OptionsPage.registeredOverlayPages_) { | 61 for (var name in OptionsPage.registeredOverlayPages_) { |
62 var page = OptionsPage.registeredOverlayPages_[name]; | 62 var page = OptionsPage.registeredOverlayPages_[name]; |
63 page.visible = false; | 63 page.visible = false; |
64 } | 64 } |
65 }; | 65 }; |
66 | 66 |
67 /** | 67 /** |
| 68 * Shows the tab contents for the given navigation tab. |
| 69 * @param {!Element} tab The tab that the user clicked. |
| 70 */ |
| 71 OptionsPage.showTab = function(tab) { |
| 72 if (!tab.classList.contains('inactive-tab')) |
| 73 return; |
| 74 |
| 75 if (this.activeNavTab != null) { |
| 76 this.activeNavTab.classList.remove('active-tab'); |
| 77 $(this.activeNavTab.getAttribute('tab-contents')).classList. |
| 78 remove('active-tab-contents'); |
| 79 } |
| 80 |
| 81 tab.classList.add('active-tab'); |
| 82 $(tab.getAttribute('tab-contents')).classList.add('active-tab-contents'); |
| 83 this.activeNavTab = tab; |
| 84 } |
| 85 |
| 86 /** |
68 * Registers new options page. | 87 * Registers new options page. |
69 * @param {OptionsPage} page Page to register. | 88 * @param {OptionsPage} page Page to register. |
70 */ | 89 */ |
71 OptionsPage.register = function(page) { | 90 OptionsPage.register = function(page) { |
72 OptionsPage.registeredPages_[page.name] = page; | 91 OptionsPage.registeredPages_[page.name] = page; |
73 // Create and add new page <li> element to navbar. | 92 // Create and add new page <li> element to navbar. |
74 var pageNav = document.createElement('li'); | 93 var pageNav = document.createElement('li'); |
75 pageNav.id = page.name + 'PageNav'; | 94 pageNav.id = page.name + 'PageNav'; |
76 pageNav.className = 'navbar-item'; | 95 pageNav.className = 'navbar-item'; |
77 pageNav.setAttribute('pageName', page.name); | 96 pageNav.setAttribute('pageName', page.name); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 214 } |
196 }; | 215 }; |
197 | 216 |
198 // Export | 217 // Export |
199 return { | 218 return { |
200 OptionsPage: OptionsPage | 219 OptionsPage: OptionsPage |
201 }; | 220 }; |
202 | 221 |
203 }); | 222 }); |
204 | 223 |
OLD | NEW |