| 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"> |
| 11 <include src="uber_utils.js"> | 11 <include src="uber_utils.js"> |
| 12 | 12 |
| 13 cr.define('uber_frame', function() { | 13 cr.define('uber_frame', function() { |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Handles page initialization. | 16 * Handles page initialization. |
| 17 */ | 17 */ |
| 18 function onLoad() { | 18 function onLoad() { |
| 19 var navigationItems = document.querySelectorAll('li'); | 19 var navigationItems = document.querySelectorAll('li'); |
| 20 | 20 |
| 21 for (var i = 0; i < navigationItems.length; ++i) { | 21 for (var i = 0; i < navigationItems.length; ++i) { |
| 22 navigationItems[i].addEventListener('click', onNavItemClicked); | 22 navigationItems[i].addEventListener('click', onNavItemClicked); |
| 23 } | 23 } |
| 24 | 24 |
| 25 cr.ui.FocusOutlineManager.forDocument(this); |
| 26 |
| 25 window.addEventListener('message', handleWindowMessage); | 27 window.addEventListener('message', handleWindowMessage); |
| 26 uber.invokeMethodOnParent('navigationControlsLoaded'); | 28 uber.invokeMethodOnParent('navigationControlsLoaded'); |
| 27 | 29 |
| 28 document.documentElement.addEventListener('mousewheel', onMouseWheel); | 30 document.documentElement.addEventListener('mousewheel', onMouseWheel); |
| 29 document.documentElement.addEventListener('mousedown', onMouseDown); | 31 document.documentElement.addEventListener('mousedown', onMouseDown); |
| 30 } | 32 } |
| 31 | 33 |
| 32 /** | 34 /** |
| 33 * Handles clicks on the navigation controls (switches the page and updates | 35 * Handles clicks on the navigation controls (switches the page and updates |
| 34 * the URL). | 36 * the URL). |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 document.body.style.webkitTransform = 'translateX(' + -scrollLeft + 'px)'; | 126 document.body.style.webkitTransform = 'translateX(' + -scrollLeft + 'px)'; |
| 125 } | 127 } |
| 126 | 128 |
| 127 /** | 129 /** |
| 128 * Enable/disable an animation to ease the nav bar back into view when | 130 * Enable/disable an animation to ease the nav bar back into view when |
| 129 * changing content while horizontally scrolled. | 131 * changing content while horizontally scrolled. |
| 130 * @param {boolean} enabled Whether easing should be enabled. | 132 * @param {boolean} enabled Whether easing should be enabled. |
| 131 */ | 133 */ |
| 132 function setContentChanging(enabled) { | 134 function setContentChanging(enabled) { |
| 133 assert(isRTL()); | 135 assert(isRTL()); |
| 134 document.documentElement.classList[enabled ? 'add' : 'remove']( | 136 document.documentElement.classList.toggle('changing-content', enabled); |
| 135 'changing-content'); | |
| 136 } | 137 } |
| 137 | 138 |
| 138 /** | 139 /** |
| 139 * 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. |
| 140 * @param {Event} e The mouse wheel event. | 141 * @param {Event} e The mouse wheel event. |
| 141 */ | 142 */ |
| 142 function onMouseWheel(e) { | 143 function onMouseWheel(e) { |
| 143 uber.invokeMethodOnParent('mouseWheel', | 144 uber.invokeMethodOnParent('mouseWheel', |
| 144 {deltaX: e.wheelDeltaX, deltaY: e.wheelDeltaY}); | 145 {deltaX: e.wheelDeltaX, deltaY: e.wheelDeltaY}); |
| 145 } | 146 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 175 } | 176 } |
| 176 | 177 |
| 177 return { | 178 return { |
| 178 onLoad: onLoad, | 179 onLoad: onLoad, |
| 179 setNavigationOverride: setNavigationOverride, | 180 setNavigationOverride: setNavigationOverride, |
| 180 }; | 181 }; |
| 181 | 182 |
| 182 }); | 183 }); |
| 183 | 184 |
| 184 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); | 185 document.addEventListener('DOMContentLoaded', uber_frame.onLoad); |
| OLD | NEW |