Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: chrome/browser/resources/uber/uber_frame.js

Issue 313363004: Separate Settings and Help from History and Extensions when settings-in- (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (no conflicts) Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/uber/uber_frame.html ('k') | chrome/browser/ui/chrome_pages.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
81 }
82
83 /**
84 * @return {Element} The currently selected nav item, if any.
85 */
86 function getSelectedNavItem() {
87 return document.querySelector('li.selected');
80 } 88 }
81 89
82 /** 90 /**
83 * Sets selection on the given nav item. 91 * Sets selection on the given nav item.
84 * @param {boolean} newSelection The item to be selected. 92 * @param {Element} newSelection The item to be selected.
85 */ 93 */
86 function setSelection(newSelection) { 94 function setSelection(newSelection) {
87 var lastSelectedNavItem = document.querySelector('li.selected'); 95 var lastSelectedNavItem = getSelectedNavItem();
88 if (lastSelectedNavItem !== newSelection) { 96 if (lastSelectedNavItem !== newSelection) {
89 newSelection.classList.add('selected'); 97 newSelection.classList.add('selected');
90 if (lastSelectedNavItem) 98 if (lastSelectedNavItem)
91 lastSelectedNavItem.classList.remove('selected'); 99 lastSelectedNavItem.classList.remove('selected');
92 } 100 }
93 } 101 }
94 102
95 /** 103 /**
104 * Shows nav items belonging to the same group as the selected item.
105 */
106 function showNavItems() {
107 var navItems = document.querySelectorAll('li');
108 var selectedNavItem = getSelectedNavItem();
109 assert(selectedNavItem);
110
111 var selectedGroup = selectedNavItem.getAttribute('group');
112 for (var i = 0; i < navItems.length; ++i) {
113 navItems[i].hidden = navItems[i].getAttribute('group') != selectedGroup;
114 }
115 }
116
117 /**
96 * Adjusts this frame's content to scrolls from the outer frame. This is done 118 * 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 119 * 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). 120 * currently RTL scrollbars still draw on the right).
99 * @param {number} scroll document.body.scrollLeft of the content frame. 121 * @param {number} scroll document.body.scrollLeft of the content frame.
100 */ 122 */
101 function adjustToScroll(scrollLeft) { 123 function adjustToScroll(scrollLeft) {
102 assert(isRTL()); 124 assert(isRTL());
103 document.body.style.webkitTransform = 'translateX(' + -scrollLeft + 'px)'; 125 document.body.style.webkitTransform = 'translateX(' + -scrollLeft + 'px)';
104 } 126 }
105 127
(...skipping 11 matching lines...) Expand all
117 /** 139 /**
118 * Handles mouse wheels on the top level element. Forwards them to uber.js. 140 * Handles mouse wheels on the top level element. Forwards them to uber.js.
119 * @param {Event} e The mouse wheel event. 141 * @param {Event} e The mouse wheel event.
120 */ 142 */
121 function onMouseWheel(e) { 143 function onMouseWheel(e) {
122 uber.invokeMethodOnParent('mouseWheel', 144 uber.invokeMethodOnParent('mouseWheel',
123 {deltaX: e.wheelDeltaX, deltaY: e.wheelDeltaY}); 145 {deltaX: e.wheelDeltaX, deltaY: e.wheelDeltaY});
124 } 146 }
125 147
126 /** 148 /**
127 * @return {Object} The currently selected iframe container. 149 * @return {Element} The currently selected iframe container.
128 * @private 150 * @private
129 */ 151 */
130 function getSelectedIframe() { 152 function getSelectedIframe() {
131 return document.querySelector('.iframe-container.selected'); 153 return document.querySelector('.iframe-container.selected');
132 } 154 }
133 155
134 /** 156 /**
135 * Finds the <li> element whose 'controls' attribute is |controls| and sets 157 * Finds the <li> element whose 'controls' attribute is |controls| and sets
136 * its 'override' attribute to |override|. 158 * its 'override' attribute to |override|.
137 * @param {string} controls The value of the 'controls' attribute of the 159 * @param {string} controls The value of the 'controls' attribute of the
138 * element to change. 160 * element to change.
139 * @param {string} override The value to set for the 'override' attribute of 161 * @param {string} override The value to set for the 'override' attribute of
140 * that element (either 'yes' or 'no'). 162 * that element (either 'yes' or 'no').
141 */ 163 */
142 function setNavigationOverride(controls, override) { 164 function setNavigationOverride(controls, override) {
143 var navItem = 165 var navItem =
144 document.querySelector('li[controls="' + controls + '"]'); 166 document.querySelector('li[controls="' + controls + '"]');
145 navItem.setAttribute('override', override); 167 navItem.setAttribute('override', override);
146 } 168 }
147 169
148 return { 170 return {
149 onLoad: onLoad, 171 onLoad: onLoad,
150 setNavigationOverride: setNavigationOverride, 172 setNavigationOverride: setNavigationOverride,
151 }; 173 };
152 174
153 }); 175 });
154 176
155 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); 177 document.addEventListener('DOMContentLoaded', uber_frame.onLoad);
OLDNEW
« no previous file with comments | « chrome/browser/resources/uber/uber_frame.html ('k') | chrome/browser/ui/chrome_pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698