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 /** | 5 /** |
6 * @fileoverview Out of the box experience flow (OOBE). | 6 * @fileoverview Out of the box experience flow (OOBE). |
7 * This is the main code for the OOBE WebUI implementation. | 7 * This is the main code for the OOBE WebUI implementation. |
8 */ | 8 */ |
9 | 9 |
10 // <include src="login_shared.js"> | 10 // <include src="login_shared.js"> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 } | 49 } |
50 if (callback) { | 50 if (callback) { |
51 var runCallback = function() { | 51 var runCallback = function() { |
52 callback(select.options[select.selectedIndex].value); | 52 callback(select.options[select.selectedIndex].value); |
53 }; | 53 }; |
54 select.addEventListener('blur', runCallback); | 54 select.addEventListener('blur', runCallback); |
55 select.addEventListener('click', runCallback); | 55 select.addEventListener('click', runCallback); |
56 select.addEventListener('keyup', function(event) { | 56 select.addEventListener('keyup', function(event) { |
57 var keycodeInterested = [ | 57 var keycodeInterested = [ |
58 9, // Tab | 58 9, // Tab |
59 13, // Enter | 59 13, // Enter |
60 27, // Escape | 60 27, // Escape |
61 ]; | 61 ]; |
62 if (keycodeInterested.indexOf(event.keyCode) >= 0) | 62 if (keycodeInterested.indexOf(event.keyCode) >= 0) |
63 runCallback(); | 63 runCallback(); |
64 }); | 64 }); |
65 } | 65 } |
66 }, | 66 }, |
67 | 67 |
68 /** | 68 /** |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 Oobe.initializeA11yMenu(); | 142 Oobe.initializeA11yMenu(); |
143 | 143 |
144 chrome.send('screenStateInitialize'); | 144 chrome.send('screenStateInitialize'); |
145 }, | 145 }, |
146 | 146 |
147 /** | 147 /** |
148 * Initializes OOBE accessibility menu. | 148 * Initializes OOBE accessibility menu. |
149 */ | 149 */ |
150 initializeA11yMenu: function() { | 150 initializeA11yMenu: function() { |
151 cr.ui.Bubble.decorate($('accessibility-menu')); | 151 cr.ui.Bubble.decorate($('accessibility-menu')); |
152 $('connect-accessibility-link').addEventListener( | 152 $('connect-accessibility-link') |
153 'click', Oobe.handleAccessibilityLinkClick); | 153 .addEventListener('click', Oobe.handleAccessibilityLinkClick); |
154 $('eula-accessibility-link').addEventListener( | 154 $('eula-accessibility-link') |
155 'click', Oobe.handleAccessibilityLinkClick); | 155 .addEventListener('click', Oobe.handleAccessibilityLinkClick); |
156 $('update-accessibility-link').addEventListener( | 156 $('update-accessibility-link') |
157 'click', Oobe.handleAccessibilityLinkClick); | 157 .addEventListener('click', Oobe.handleAccessibilityLinkClick); |
158 // Same behaviour on hitting spacebar. See crbug.com/342991. | 158 // Same behaviour on hitting spacebar. See crbug.com/342991. |
159 function reactOnSpace(event) { | 159 function reactOnSpace(event) { |
160 if (event.keyCode == 32) | 160 if (event.keyCode == 32) |
161 Oobe.handleAccessibilityLinkClick(event); | 161 Oobe.handleAccessibilityLinkClick(event); |
162 } | 162 } |
163 $('connect-accessibility-link').addEventListener( | 163 $('connect-accessibility-link').addEventListener('keyup', reactOnSpace); |
164 'keyup', reactOnSpace); | 164 $('eula-accessibility-link').addEventListener('keyup', reactOnSpace); |
165 $('eula-accessibility-link').addEventListener( | 165 $('update-accessibility-link').addEventListener('keyup', reactOnSpace); |
166 'keyup', reactOnSpace); | |
167 $('update-accessibility-link').addEventListener( | |
168 'keyup', reactOnSpace); | |
169 | 166 |
170 $('high-contrast').addEventListener('click', | 167 $('high-contrast') |
171 Oobe.handleHighContrastClick); | 168 .addEventListener('click', Oobe.handleHighContrastClick); |
172 $('large-cursor').addEventListener('click', | 169 $('large-cursor').addEventListener('click', Oobe.handleLargeCursorClick); |
173 Oobe.handleLargeCursorClick); | 170 $('spoken-feedback') |
174 $('spoken-feedback').addEventListener('click', | 171 .addEventListener('click', Oobe.handleSpokenFeedbackClick); |
175 Oobe.handleSpokenFeedbackClick); | 172 $('screen-magnifier') |
176 $('screen-magnifier').addEventListener('click', | 173 .addEventListener('click', Oobe.handleScreenMagnifierClick); |
177 Oobe.handleScreenMagnifierClick); | 174 $('virtual-keyboard') |
178 $('virtual-keyboard').addEventListener('click', | 175 .addEventListener('click', Oobe.handleVirtualKeyboardClick); |
179 Oobe.handleVirtualKeyboardClick); | |
180 | 176 |
181 $('high-contrast').addEventListener('keypress', Oobe.handleA11yKeyPress); | 177 $('high-contrast').addEventListener('keypress', Oobe.handleA11yKeyPress); |
182 $('large-cursor').addEventListener('keypress', Oobe.handleA11yKeyPress); | 178 $('large-cursor').addEventListener('keypress', Oobe.handleA11yKeyPress); |
183 $('spoken-feedback') | 179 $('spoken-feedback') |
184 .addEventListener('keypress', Oobe.handleA11yKeyPress); | 180 .addEventListener('keypress', Oobe.handleA11yKeyPress); |
185 $('screen-magnifier') | 181 $('screen-magnifier') |
186 .addEventListener('keypress', Oobe.handleA11yKeyPress); | 182 .addEventListener('keypress', Oobe.handleA11yKeyPress); |
187 $('virtual-keyboard') | 183 $('virtual-keyboard') |
188 .addEventListener('keypress', Oobe.handleA11yKeyPress); | 184 .addEventListener('keypress', Oobe.handleA11yKeyPress); |
189 | 185 |
190 // A11y menu should be accessible i.e. disable autohide on any | 186 // A11y menu should be accessible i.e. disable autohide on any |
191 // keydown or click inside menu. | 187 // keydown or click inside menu. |
192 $('accessibility-menu').hideOnKeyPress = false; | 188 $('accessibility-menu').hideOnKeyPress = false; |
193 $('accessibility-menu').hideOnSelfClick = false; | 189 $('accessibility-menu').hideOnSelfClick = false; |
194 }, | 190 }, |
195 | 191 |
196 /** | 192 /** |
197 * Accessibility link handler. | 193 * Accessibility link handler. |
198 */ | 194 */ |
199 handleAccessibilityLinkClick: function(e) { | 195 handleAccessibilityLinkClick: function(e) { |
200 /** @const */ var BUBBLE_OFFSET = 5; | 196 /** @const */ var BUBBLE_OFFSET = 5; |
201 /** @const */ var BUBBLE_PADDING = 10; | 197 /** @const */ var BUBBLE_PADDING = 10; |
202 $('accessibility-menu').showForElement(e.target, | 198 $('accessibility-menu') |
203 cr.ui.Bubble.Attachment.BOTTOM, | 199 .showForElement( |
204 BUBBLE_OFFSET, BUBBLE_PADDING); | 200 e.target, cr.ui.Bubble.Attachment.BOTTOM, BUBBLE_OFFSET, |
| 201 BUBBLE_PADDING); |
205 | 202 |
206 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping( | 203 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping( |
207 $('accessibility-menu')); | 204 $('accessibility-menu')); |
208 if (maxHeight < $('accessibility-menu').offsetHeight) { | 205 if (maxHeight < $('accessibility-menu').offsetHeight) { |
209 $('accessibility-menu').showForElement(e.target, | 206 $('accessibility-menu') |
210 cr.ui.Bubble.Attachment.TOP, | 207 .showForElement( |
211 BUBBLE_OFFSET, BUBBLE_PADDING); | 208 e.target, cr.ui.Bubble.Attachment.TOP, BUBBLE_OFFSET, |
| 209 BUBBLE_PADDING); |
212 } | 210 } |
213 | 211 |
214 $('accessibility-menu').firstBubbleElement = $('spoken-feedback'); | 212 $('accessibility-menu').firstBubbleElement = $('spoken-feedback'); |
215 $('accessibility-menu').lastBubbleElement = $('close-accessibility-menu'); | 213 $('accessibility-menu').lastBubbleElement = $('close-accessibility-menu'); |
216 $('spoken-feedback').focus(); | 214 $('spoken-feedback').focus(); |
217 | 215 |
218 if (Oobe.getInstance().currentScreen && | 216 if (Oobe.getInstance().currentScreen && |
219 Oobe.getInstance().currentScreen.defaultControl) { | 217 Oobe.getInstance().currentScreen.defaultControl) { |
220 $('accessibility-menu').elementToFocusOnHide = | 218 $('accessibility-menu').elementToFocusOnHide = |
221 Oobe.getInstance().currentScreen.defaultControl; | 219 Oobe.getInstance().currentScreen.defaultControl; |
222 } else { | 220 } else { |
223 // Update screen falls into this category. Since it doesn't have any | 221 // Update screen falls into this category. Since it doesn't have any |
224 // controls other than a11y link we don't want that link to receive | 222 // controls other than a11y link we don't want that link to receive |
225 // focus when screen is shown i.e. defaultControl is not defined. | 223 // focus when screen is shown i.e. defaultControl is not defined. |
226 // Focus a11y link instead. | 224 // Focus a11y link instead. |
227 $('accessibility-menu').elementToFocusOnHide = e.target; | 225 $('accessibility-menu').elementToFocusOnHide = e.target; |
228 } | 226 } |
229 e.stopPropagation(); | 227 e.stopPropagation(); |
230 }, | 228 }, |
231 | 229 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 $('oobe-shield').setAttribute('md-mode', 'true'); | 382 $('oobe-shield').setAttribute('md-mode', 'true'); |
385 $('popup-overlay').setAttribute('md-mode', 'true'); | 383 $('popup-overlay').setAttribute('md-mode', 'true'); |
386 } else { | 384 } else { |
387 $('oobe').removeAttribute('md-mode'); | 385 $('oobe').removeAttribute('md-mode'); |
388 $('oobe-shield').removeAttribute('md-mode'); | 386 $('oobe-shield').removeAttribute('md-mode'); |
389 $('popup-overlay').removeAttribute('md-mode'); | 387 $('popup-overlay').removeAttribute('md-mode'); |
390 } | 388 } |
391 }, | 389 }, |
392 }; | 390 }; |
393 }); | 391 }); |
OLD | NEW |