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 uber.invokeMethodOnParent('showPage', | 45 uber.invokeMethodOnParent( |
46 {pageId: e.currentTarget.getAttribute('controls')}); | 46 'showPage', {pageId: e.currentTarget.getAttribute('controls')}); |
47 | 47 |
48 setSelection(/** @type {Element} */(e.currentTarget)); | 48 setSelection(/** @type {Element} */ (e.currentTarget)); |
49 } | 49 } |
50 | 50 |
51 /** | 51 /** |
52 * Handles postMessage from chrome://chrome. | 52 * Handles postMessage from chrome://chrome. |
53 * @param {Event} e The post data. | 53 * @param {Event} e The post data. |
54 */ | 54 */ |
55 function handleWindowMessage(e) { | 55 function handleWindowMessage(e) { |
56 if (e.data.method === 'changeSelection') | 56 if (e.data.method === 'changeSelection') |
57 changeSelection(e.data.params); | 57 changeSelection(e.data.params); |
58 else if (e.data.method === 'adjustToScroll') | 58 else if (e.data.method === 'adjustToScroll') |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 function setContentChanging(enabled) { | 122 function setContentChanging(enabled) { |
123 assert(isRTL()); | 123 assert(isRTL()); |
124 document.documentElement.classList.toggle('changing-content', enabled); | 124 document.documentElement.classList.toggle('changing-content', enabled); |
125 } | 125 } |
126 | 126 |
127 /** | 127 /** |
128 * Handles mouse wheels on the top level element. Forwards them to uber.js. | 128 * Handles mouse wheels on the top level element. Forwards them to uber.js. |
129 * @param {Event} e The mouse wheel event. | 129 * @param {Event} e The mouse wheel event. |
130 */ | 130 */ |
131 function onMouseWheel(e) { | 131 function onMouseWheel(e) { |
132 uber.invokeMethodOnParent('mouseWheel', | 132 uber.invokeMethodOnParent( |
133 {deltaX: e.wheelDeltaX, deltaY: e.wheelDeltaY}); | 133 'mouseWheel', {deltaX: e.wheelDeltaX, deltaY: e.wheelDeltaY}); |
134 } | 134 } |
135 | 135 |
136 /** | 136 /** |
137 * Handles mouse presses on the top level element. Forwards them to uber.js. | 137 * Handles mouse presses on the top level element. Forwards them to uber.js. |
138 * @param {Event} e The mouse down event. | 138 * @param {Event} e The mouse down event. |
139 */ | 139 */ |
140 function onMouseDown(e) { | 140 function onMouseDown(e) { |
141 uber.invokeMethodOnParent('mouseDown'); | 141 uber.invokeMethodOnParent('mouseDown'); |
142 } | 142 } |
143 | 143 |
144 /** | 144 /** |
145 * @return {Element} The currently selected iframe container. | 145 * @return {Element} The currently selected iframe container. |
146 * @private | 146 * @private |
147 */ | 147 */ |
148 function getSelectedIframe() { | 148 function getSelectedIframe() { |
149 return document.querySelector('.iframe-container.selected'); | 149 return document.querySelector('.iframe-container.selected'); |
150 } | 150 } |
151 | 151 |
152 return {onLoad: onLoad}; | 152 return {onLoad: onLoad}; |
153 }); | 153 }); |
154 | 154 |
155 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); | 155 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); |
OLD | NEW |