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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 /** @const */ var FocusOutlineManager = cr.ui.FocusOutlineManager; | 6 /** @const */ var FocusOutlineManager = cr.ui.FocusOutlineManager; |
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | |
8 | 7 |
9 var OptionsPage = { | 8 var OptionsPage = { |
10 /** | 9 /** |
11 * This is the absolute difference maintained between standard and | 10 * This is the absolute difference maintained between standard and |
12 * fixed-width font sizes. Refer http://crbug.com/91922. | 11 * fixed-width font sizes. Refer http://crbug.com/91922. |
13 * @const | 12 * @const |
14 */ | 13 */ |
15 SIZE_DIFFERENCE_FIXED_STANDARD: 3, | 14 SIZE_DIFFERENCE_FIXED_STANDARD: 3, |
16 | 15 |
17 /** | 16 /** |
18 * Initializes the complete options page. This will cause all C++ handlers | 17 * Initializes the complete options page. This will cause all C++ handlers |
19 * to be invoked to do final setup. | 18 * to be invoked to do final setup. |
20 */ | 19 */ |
21 initialize: function() { | 20 initialize: function() { |
22 chrome.send('coreOptionsInitialize'); | 21 chrome.send('coreOptionsInitialize'); |
23 }, | 22 }, |
24 | 23 |
25 /** | 24 /** |
26 * Shows the tab contents for the given navigation tab. | 25 * Shows the tab contents for the given navigation tab. |
27 * @param {!Element} tab The tab that the user clicked. | 26 * @param {Node} tab The tab that the user clicked. |
28 */ | 27 */ |
29 showTab: function(tab) { | 28 showTab: function(tab) { |
30 // Search parents until we find a tab, or the nav bar itself. This allows | 29 // Search parents until we find a tab, or the nav bar itself. This allows |
31 // tabs to have child nodes, e.g. labels in separately-styled spans. | 30 // tabs to have child nodes, e.g. labels in separately-styled spans. |
32 while (tab && !tab.classList.contains('subpages-nav-tabs') && | 31 while (tab && tab.classList && |
| 32 !tab.classList.contains('subpages-nav-tabs') && |
33 !tab.classList.contains('tab')) { | 33 !tab.classList.contains('tab')) { |
34 tab = tab.parentNode; | 34 tab = tab.parentNode; |
35 } | 35 } |
36 if (!tab || !tab.classList.contains('tab')) | 36 if (!tab || !tab.classList || !tab.classList.contains('tab')) |
37 return; | 37 return; |
38 | 38 |
39 // Find tab bar of the tab. | 39 // Find tab bar of the tab. |
40 var tabBar = tab; | 40 var tabBar = tab; |
41 while (tabBar && !tabBar.classList.contains('subpages-nav-tabs')) { | 41 while (tabBar && tabBar.classList && |
| 42 !tabBar.classList.contains('subpages-nav-tabs')) { |
42 tabBar = tabBar.parentNode; | 43 tabBar = tabBar.parentNode; |
43 } | 44 } |
44 if (!tabBar) | 45 if (!tabBar || !tabBar.classList) |
45 return; | 46 return; |
46 | 47 |
47 if (tabBar.activeNavTab != null) { | 48 if (tabBar.activeNavTab != null) { |
48 tabBar.activeNavTab.classList.remove('active-tab'); | 49 tabBar.activeNavTab.classList.remove('active-tab'); |
49 $(tabBar.activeNavTab.getAttribute('tab-contents')).classList. | 50 $(tabBar.activeNavTab.getAttribute('tab-contents')).classList. |
50 remove('active-tab-contents'); | 51 remove('active-tab-contents'); |
51 } | 52 } |
52 | 53 |
53 tab.classList.add('active-tab'); | 54 tab.classList.add('active-tab'); |
54 $(tab.getAttribute('tab-contents')).classList.add('active-tab-contents'); | 55 $(tab.getAttribute('tab-contents')).classList.add('active-tab-contents'); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 isSettingsApp: function() { | 103 isSettingsApp: function() { |
103 return document.documentElement.classList.contains('settings-app'); | 104 return document.documentElement.classList.contains('settings-app'); |
104 }, | 105 }, |
105 }; | 106 }; |
106 | 107 |
107 // Export | 108 // Export |
108 return { | 109 return { |
109 OptionsPage: OptionsPage | 110 OptionsPage: OptionsPage |
110 }; | 111 }; |
111 }); | 112 }); |
OLD | NEW |