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"> | 10 // <include src="../../../../ui/webui/resources/js/util.js"> |
(...skipping 24 matching lines...) Expand all Loading... |
35 * Handles clicks on the navigation controls (switches the page and updates | 35 * Handles clicks on the navigation controls (switches the page and updates |
36 * the URL). | 36 * the URL). |
37 * @param {Event} e The click event. | 37 * @param {Event} e The click event. |
38 */ | 38 */ |
39 function onNavItemClicked(e) { | 39 function onNavItemClicked(e) { |
40 // Though pointer-event: none; is applied to the .selected nav item, users | 40 // Though pointer-event: none; is applied to the .selected nav item, users |
41 // can still tab to them and press enter/space which simulates a click. | 41 // can still tab to them and press enter/space which simulates a click. |
42 if (e.target.classList.contains('selected')) | 42 if (e.target.classList.contains('selected')) |
43 return; | 43 return; |
44 | 44 |
45 // Extensions can override Uber content (e.g., if the user has a history | |
46 // extension, it should display when the 'History' navigation is clicked). | |
47 if (e.currentTarget.getAttribute('override') == 'yes') { | |
48 window.open('chrome://' + e.currentTarget.getAttribute('controls'), | |
49 '_blank'); | |
50 return; | |
51 } | |
52 | |
53 uber.invokeMethodOnParent('showPage', | 45 uber.invokeMethodOnParent('showPage', |
54 {pageId: e.currentTarget.getAttribute('controls')}); | 46 {pageId: e.currentTarget.getAttribute('controls')}); |
55 | 47 |
56 setSelection(/** @type {Element} */(e.currentTarget)); | 48 setSelection(/** @type {Element} */(e.currentTarget)); |
57 } | 49 } |
58 | 50 |
59 /** | 51 /** |
60 * Handles postMessage from chrome://chrome. | 52 * Handles postMessage from chrome://chrome. |
61 * @param {Event} e The post data. | 53 * @param {Event} e The post data. |
62 */ | 54 */ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 94 } |
103 | 95 |
104 /** | 96 /** |
105 * Shows nav items belonging to the same group as the selected item. | 97 * Shows nav items belonging to the same group as the selected item. |
106 */ | 98 */ |
107 function showNavItems() { | 99 function showNavItems() { |
108 var hideSettingsAndHelp = loadTimeData.getBoolean('hideSettingsAndHelp'); | 100 var hideSettingsAndHelp = loadTimeData.getBoolean('hideSettingsAndHelp'); |
109 $('settings').hidden = hideSettingsAndHelp; | 101 $('settings').hidden = hideSettingsAndHelp; |
110 $('help').hidden = hideSettingsAndHelp; | 102 $('help').hidden = hideSettingsAndHelp; |
111 $('extensions').hidden = loadTimeData.getBoolean('hideExtensions'); | 103 $('extensions').hidden = loadTimeData.getBoolean('hideExtensions'); |
112 $('history').hidden = loadTimeData.getBoolean('hideHistory'); | |
113 } | 104 } |
114 | 105 |
115 /** | 106 /** |
116 * Adjusts this frame's content to scrolls from the outer frame. This is done | 107 * Adjusts this frame's content to scrolls from the outer frame. This is done |
117 * to obscure text in RTL as a user scrolls over the content of this frame (as | 108 * to obscure text in RTL as a user scrolls over the content of this frame (as |
118 * currently RTL scrollbars still draw on the right). | 109 * currently RTL scrollbars still draw on the right). |
119 * @param {number} scrollLeft document.body.scrollLeft of the content frame. | 110 * @param {number} scrollLeft document.body.scrollLeft of the content frame. |
120 */ | 111 */ |
121 function adjustToScroll(scrollLeft) { | 112 function adjustToScroll(scrollLeft) { |
122 assert(isRTL()); | 113 assert(isRTL()); |
(...skipping 28 matching lines...) Expand all Loading... |
151 } | 142 } |
152 | 143 |
153 /** | 144 /** |
154 * @return {Element} The currently selected iframe container. | 145 * @return {Element} The currently selected iframe container. |
155 * @private | 146 * @private |
156 */ | 147 */ |
157 function getSelectedIframe() { | 148 function getSelectedIframe() { |
158 return document.querySelector('.iframe-container.selected'); | 149 return document.querySelector('.iframe-container.selected'); |
159 } | 150 } |
160 | 151 |
161 /** | 152 return {onLoad: onLoad}; |
162 * Finds the <li> element whose 'controls' attribute is |controls| and sets | |
163 * its 'override' attribute to |override|. | |
164 * @param {string} controls The value of the 'controls' attribute of the | |
165 * element to change. | |
166 * @param {string} override The value to set for the 'override' attribute of | |
167 * that element (either 'yes' or 'no'). | |
168 */ | |
169 function setNavigationOverride(controls, override) { | |
170 var navItem = | |
171 document.querySelector('li[controls="' + controls + '"]'); | |
172 navItem.setAttribute('override', override); | |
173 } | |
174 | |
175 return { | |
176 onLoad: onLoad, | |
177 setNavigationOverride: setNavigationOverride, | |
178 }; | |
179 | |
180 }); | 153 }); |
181 | 154 |
182 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); | 155 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); |
OLD | NEW |