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="../shared/js/util.js"></include> | 10 <include src="../shared/js/util.js"></include> |
(...skipping 21 matching lines...) Expand all Loading... | |
32 * Handles clicks on the navigation controls (switches the page and updates | 32 * Handles clicks on the navigation controls (switches the page and updates |
33 * the URL). | 33 * the URL). |
34 * @param {Event} e The click event. | 34 * @param {Event} e The click event. |
35 */ | 35 */ |
36 function onNavItemClicked(e) { | 36 function onNavItemClicked(e) { |
37 // Though pointer-event: none; is applied to the .selected nav item, users | 37 // Though pointer-event: none; is applied to the .selected nav item, users |
38 // can still tab to them and press enter/space which simulates a click. | 38 // can still tab to them and press enter/space which simulates a click. |
39 if (e.target.classList.contains('selected')) | 39 if (e.target.classList.contains('selected')) |
40 return; | 40 return; |
41 | 41 |
42 // Extensions can override Uber content (e.g., if the user has a history | |
Mark Mentovai
2012/04/09 22:55:58
This too.
| |
43 // extension, it should display when the 'History' navigation is clicked). | |
44 if (e.currentTarget.getAttribute('override') == 'yes') { | |
45 window.open('chrome://' + e.currentTarget.getAttribute('controls'), | |
46 '_blank'); | |
47 return; | |
48 } | |
49 | |
42 uber.invokeMethodOnParent('showPage', | 50 uber.invokeMethodOnParent('showPage', |
43 {pageId: e.currentTarget.getAttribute('controls')}); | 51 {pageId: e.currentTarget.getAttribute('controls')}); |
44 | 52 |
45 setSelection(e.currentTarget); | 53 setSelection(e.currentTarget); |
46 } | 54 } |
47 | 55 |
48 /** | 56 /** |
49 * Handles postMessage from chrome://chrome. | 57 * Handles postMessage from chrome://chrome. |
50 * @param {Event} e The post data. | 58 * @param {Event} e The post data. |
51 */ | 59 */ |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 } | 123 } |
116 | 124 |
117 /** | 125 /** |
118 * @return {Object} The currently selected iframe container. | 126 * @return {Object} The currently selected iframe container. |
119 * @private | 127 * @private |
120 */ | 128 */ |
121 function getSelectedIframe() { | 129 function getSelectedIframe() { |
122 return document.querySelector('.iframe-container.selected'); | 130 return document.querySelector('.iframe-container.selected'); |
123 } | 131 } |
124 | 132 |
133 /** | |
134 * Finds the <li> element whose 'controls' attribute is |controls| and sets | |
135 * its 'override' attribute to |override|. | |
136 * @param {string} controls The value of the 'controls' attribute of the | |
137 * element to change. | |
138 * @param {string} override The value to set for the 'override' attribute of | |
139 * that element (either 'yes' or 'no'). | |
140 */ | |
141 function setNavigationOverride(controls, override) { | |
142 var navItem = | |
143 document.querySelector('li[controls="' + controls + '"]'); | |
144 navItem.setAttribute('override', override); | |
145 } | |
146 | |
125 return { | 147 return { |
126 onLoad: onLoad, | 148 onLoad: onLoad, |
149 setNavigationOverride: setNavigationOverride, | |
127 }; | 150 }; |
128 | 151 |
129 }); | 152 }); |
130 | 153 |
131 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); | 154 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); |
OLD | NEW |