| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 OptionsPage.showTab = function(tab) { | 331 OptionsPage.showTab = function(tab) { |
| 332 // Search parents until we find a tab, or the nav bar itself. This allows | 332 // Search parents until we find a tab, or the nav bar itself. This allows |
| 333 // tabs to have child nodes, e.g. labels in separately-styled spans. | 333 // tabs to have child nodes, e.g. labels in separately-styled spans. |
| 334 while (tab && !tab.classList.contains('subpages-nav-tabs') && | 334 while (tab && !tab.classList.contains('subpages-nav-tabs') && |
| 335 !tab.classList.contains('tab')) { | 335 !tab.classList.contains('tab')) { |
| 336 tab = tab.parentNode; | 336 tab = tab.parentNode; |
| 337 } | 337 } |
| 338 if (!tab || !tab.classList.contains('tab')) | 338 if (!tab || !tab.classList.contains('tab')) |
| 339 return; | 339 return; |
| 340 | 340 |
| 341 if (this.activeNavTab != null) { | 341 // Find tab bar of the tab. |
| 342 this.activeNavTab.classList.remove('active-tab'); | 342 var tabBar = tab; |
| 343 $(this.activeNavTab.getAttribute('tab-contents')).classList. | 343 while (tabBar && !tabBar.classList.contains('subpages-nav-tabs')) { |
| 344 tabBar = tabBar.parentNode; |
| 345 } |
| 346 if (!tabBar) |
| 347 return; |
| 348 |
| 349 if (tabBar.activeNavTab != null) { |
| 350 tabBar.activeNavTab.classList.remove('active-tab'); |
| 351 $(tabBar.activeNavTab.getAttribute('tab-contents')).classList. |
| 344 remove('active-tab-contents'); | 352 remove('active-tab-contents'); |
| 345 } | 353 } |
| 346 | 354 |
| 347 tab.classList.add('active-tab'); | 355 tab.classList.add('active-tab'); |
| 348 $(tab.getAttribute('tab-contents')).classList.add('active-tab-contents'); | 356 $(tab.getAttribute('tab-contents')).classList.add('active-tab-contents'); |
| 349 this.activeNavTab = tab; | 357 tabBar.activeNavTab = tab; |
| 350 }; | 358 }; |
| 351 | 359 |
| 352 /** | 360 /** |
| 353 * Registers new options page. | 361 * Registers new options page. |
| 354 * @param {OptionsPage} page Page to register. | 362 * @param {OptionsPage} page Page to register. |
| 355 */ | 363 */ |
| 356 OptionsPage.register = function(page) { | 364 OptionsPage.register = function(page) { |
| 357 this.registeredPages[page.name.toLowerCase()] = page; | 365 this.registeredPages[page.name.toLowerCase()] = page; |
| 358 // Create and add new page <li> element to navbar. | 366 // Create and add new page <li> element to navbar. |
| 359 var pageNav = document.createElement('li'); | 367 var pageNav = document.createElement('li'); |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 canShowPage: function() { | 1026 canShowPage: function() { |
| 1019 return true; | 1027 return true; |
| 1020 }, | 1028 }, |
| 1021 }; | 1029 }; |
| 1022 | 1030 |
| 1023 // Export | 1031 // Export |
| 1024 return { | 1032 return { |
| 1025 OptionsPage: OptionsPage | 1033 OptionsPage: OptionsPage |
| 1026 }; | 1034 }; |
| 1027 }); | 1035 }); |
| OLD | NEW |