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 // This file contains the navigation controls that are visible on the left side | 5 // This file contains the navigation controls that are visible on the left side |
6 // of the uber page. It exists separately from uber.js so that it may be loaded | 6 // of the uber page. It exists separately from uber.js so that it may be loaded |
7 // in an iframe. Iframes can be layered on top of each other, but not mixed in | 7 // in an iframe. Iframes can be layered on top of each other, but not mixed in |
8 // with page content, so all overlapping content on uber must be framed. | 8 // with page content, so all overlapping content on uber must be framed. |
9 | 9 |
10 <include src="../../../../ui/webui/resources/js/util.js"></include> | 10 <include src="../../../../ui/webui/resources/js/util.js"></include> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 } | 70 } |
71 | 71 |
72 /** | 72 /** |
73 * Changes the selected nav control. | 73 * Changes the selected nav control. |
74 * @param {Object} params Must contain pageId. | 74 * @param {Object} params Must contain pageId. |
75 */ | 75 */ |
76 function changeSelection(params) { | 76 function changeSelection(params) { |
77 var navItem = | 77 var navItem = |
78 document.querySelector('li[controls="' + params.pageId + '"]'); | 78 document.querySelector('li[controls="' + params.pageId + '"]'); |
79 setSelection(navItem); | 79 setSelection(navItem); |
80 showNavItems(); | |
Dan Beam
2014/06/06 21:21:23
shouldn't this only be invoked if IsSettingsWindow
michaelpg
2014/06/07 02:12:15
I've made the nav items hidden to prevent the flic
| |
80 } | 81 } |
81 | 82 |
82 /** | 83 /** |
83 * Sets selection on the given nav item. | 84 * Sets selection on the given nav item. |
84 * @param {boolean} newSelection The item to be selected. | 85 * @param {boolean} newSelection The item to be selected. |
85 */ | 86 */ |
86 function setSelection(newSelection) { | 87 function setSelection(newSelection) { |
87 var lastSelectedNavItem = document.querySelector('li.selected'); | 88 var lastSelectedNavItem = document.querySelector('li.selected'); |
88 if (lastSelectedNavItem !== newSelection) { | 89 if (lastSelectedNavItem !== newSelection) { |
89 newSelection.classList.add('selected'); | 90 newSelection.classList.add('selected'); |
90 if (lastSelectedNavItem) | 91 if (lastSelectedNavItem) |
Dan Beam
2014/06/06 21:21:23
^ it would seem that there might not be a selected
michaelpg
2014/06/07 02:12:15
The page starts out without a selected nav item.
| |
91 lastSelectedNavItem.classList.remove('selected'); | 92 lastSelectedNavItem.classList.remove('selected'); |
92 } | 93 } |
93 } | 94 } |
94 | 95 |
95 /** | 96 /** |
97 * Shows nav items belonging to the same group as the selected item. | |
98 */ | |
99 function showNavItems() { | |
100 var navItems = document.querySelectorAll('li'); | |
101 var selectedNavItem = document.querySelector('li.selected'); | |
Dan Beam
2014/06/06 21:21:23
what happens if this returns null?
Dan Beam
2014/06/06 21:21:23
nit: make a
function getSelectedNavItem() {
michaelpg
2014/06/07 02:12:15
Done.
michaelpg
2014/06/07 02:12:15
bad things.. but.. it can't because of the orderin
| |
102 | |
103 for (var i = 0; i < navItems.length; ++i) { | |
104 navItems[i].hidden = (navItems[i].getAttribute('group') != | |
105 selectedNavItem.getAttribute('group')); | |
Dan Beam
2014/06/06 21:21:23
nit: needless ()
Dan Beam
2014/06/06 21:21:23
you don't ever actually use selectedNavItem itself
michaelpg
2014/06/07 02:12:15
Done.
| |
106 } | |
107 } | |
108 | |
109 /** | |
96 * Adjusts this frame's content to scrolls from the outer frame. This is done | 110 * Adjusts this frame's content to scrolls from the outer frame. This is done |
97 * to obscure text in RTL as a user scrolls over the content of this frame (as | 111 * to obscure text in RTL as a user scrolls over the content of this frame (as |
98 * currently RTL scrollbars still draw on the right). | 112 * currently RTL scrollbars still draw on the right). |
99 * @param {number} scroll document.body.scrollLeft of the content frame. | 113 * @param {number} scroll document.body.scrollLeft of the content frame. |
100 */ | 114 */ |
101 function adjustToScroll(scrollLeft) { | 115 function adjustToScroll(scrollLeft) { |
102 assert(isRTL()); | 116 assert(isRTL()); |
103 document.body.style.webkitTransform = 'translateX(' + -scrollLeft + 'px)'; | 117 document.body.style.webkitTransform = 'translateX(' + -scrollLeft + 'px)'; |
104 } | 118 } |
105 | 119 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 } | 160 } |
147 | 161 |
148 return { | 162 return { |
149 onLoad: onLoad, | 163 onLoad: onLoad, |
150 setNavigationOverride: setNavigationOverride, | 164 setNavigationOverride: setNavigationOverride, |
151 }; | 165 }; |
152 | 166 |
153 }); | 167 }); |
154 | 168 |
155 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); | 169 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); |
OLD | NEW |