OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 Locally managed user creation flow screen. | 6 * @fileoverview Locally managed user creation flow screen. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('login', function() { | 9 cr.define('login', function() { |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 // Mousedown has to be used instead of click to be able to prevent 'focus' | 30 // Mousedown has to be used instead of click to be able to prevent 'focus' |
31 // event later. | 31 // event later. |
32 this.addEventListener('mousedown', | 32 this.addEventListener('mousedown', |
33 this.handleMouseDown_.bind(this)); | 33 this.handleMouseDown_.bind(this)); |
34 var screen = $('managed-user-creation-flow'); | 34 var screen = $('managed-user-creation-flow'); |
35 var managerPod = this; | 35 var managerPod = this; |
36 this.passwordElement.addEventListener('keydown', function(e) { | 36 this.passwordElement.addEventListener('keydown', function(e) { |
37 managerPod.passwordErrorElement.hidden = true; | 37 managerPod.passwordErrorElement.hidden = true; |
38 }); | 38 }); |
39 this.passwordElement.addEventListener('keyup', function(e) { | 39 this.passwordElement.addEventListener('keyup', function(e) { |
40 screen.updateContinueButton_(); | 40 screen.updateNextButtonForManager_(); |
41 }); | 41 }); |
42 }, | 42 }, |
43 | 43 |
44 /** | 44 /** |
45 * Updates UI elements from user data. | 45 * Updates UI elements from user data. |
46 */ | 46 */ |
47 update: function() { | 47 update: function() { |
48 this.imageElement.src = 'chrome://userimage/' + this.user.username + | 48 this.imageElement.src = 'chrome://userimage/' + this.user.username + |
49 '?id=' + ManagerPod.userImageSalt_[this.user.username]; | 49 '?id=' + ManagerPod.userImageSalt_[this.user.username]; |
50 | 50 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 if (pod != podToSelect) { | 178 if (pod != podToSelect) { |
179 pod.classList.remove('focused'); | 179 pod.classList.remove('focused'); |
180 pod.passwordElement.value = ''; | 180 pod.passwordElement.value = ''; |
181 pod.passwordBlock.hidden = true; | 181 pod.passwordBlock.hidden = true; |
182 } | 182 } |
183 } | 183 } |
184 podToSelect.classList.add('focused'); | 184 podToSelect.classList.add('focused'); |
185 podToSelect.passwordBlock.hidden = false; | 185 podToSelect.passwordBlock.hidden = false; |
186 podToSelect.passwordElement.value = ''; | 186 podToSelect.passwordElement.value = ''; |
187 podToSelect.focusInput(); | 187 podToSelect.focusInput(); |
188 chrome.send('managerSelectedOnLocallyManagedUserCreationFlow', | |
189 [podToSelect.user.emailAddress]); | |
190 | |
188 }, | 191 }, |
189 }; | 192 }; |
190 | 193 |
191 /** | 194 /** |
192 * Creates a new screen div. | 195 * Creates a new screen div. |
193 * @constructor | 196 * @constructor |
194 * @extends {HTMLDivElement} | 197 * @extends {HTMLDivElement} |
195 */ | 198 */ |
196 var LocallyManagedUserCreationScreen = cr.ui.define('div'); | 199 var LocallyManagedUserCreationScreen = cr.ui.define('div'); |
197 | 200 |
198 /** | 201 /** |
199 * Registers with Oobe. | 202 * Registers with Oobe. |
200 */ | 203 */ |
201 LocallyManagedUserCreationScreen.register = function() { | 204 LocallyManagedUserCreationScreen.register = function() { |
202 var screen = $('managed-user-creation-flow'); | 205 var screen = $('managed-user-creation-flow'); |
203 LocallyManagedUserCreationScreen.decorate(screen); | 206 LocallyManagedUserCreationScreen.decorate(screen); |
204 Oobe.getInstance().registerScreen(screen); | 207 Oobe.getInstance().registerScreen(screen); |
205 }; | 208 }; |
206 | 209 |
207 LocallyManagedUserCreationScreen.prototype = { | 210 LocallyManagedUserCreationScreen.prototype = { |
208 __proto__: HTMLDivElement.prototype, | 211 __proto__: HTMLDivElement.prototype, |
209 | 212 |
210 lastVerifiedName_: null, | 213 lastVerifiedName_: null, |
211 lastIncorrectUserName_: null, | 214 lastIncorrectUserName_: null, |
212 managerList_: null, | 215 managerList_: null, |
213 | 216 |
214 currentPage_: null, | 217 currentPage_: null, |
215 | 218 |
219 // Contains data that can be auto-shared with handler. | |
220 context_: {}, | |
221 | |
216 /** @override */ | 222 /** @override */ |
217 decorate: function() { | 223 decorate: function() { |
218 this.managerList_ = new ManagerPodList(); | 224 this.managerList_ = new ManagerPodList(); |
219 $('managed-user-creation-flow-managers-pane'). | 225 $('managed-user-creation-flow-managers-pane'). |
220 appendChild(this.managerList_); | 226 appendChild(this.managerList_); |
221 | 227 |
222 var userNameField = $('managed-user-creation-flow-name'); | 228 var userNameField = $('managed-user-creation-flow-name'); |
223 var passwordField = $('managed-user-creation-flow-password'); | 229 var passwordField = $('managed-user-creation-flow-password'); |
224 var password2Field = $('managed-user-creation-flow-password-confirm'); | 230 var password2Field = $('managed-user-creation-flow-password-confirm'); |
225 | 231 |
(...skipping 11 matching lines...) Expand all Loading... | |
237 | 243 |
238 userNameField.addEventListener('keyup', function(e) { | 244 userNameField.addEventListener('keyup', function(e) { |
239 creationScreen.checkUserName_(); | 245 creationScreen.checkUserName_(); |
240 }); | 246 }); |
241 | 247 |
242 passwordField.addEventListener('keydown', function(e) { | 248 passwordField.addEventListener('keydown', function(e) { |
243 creationScreen.passwordErrorVisible = false; | 249 creationScreen.passwordErrorVisible = false; |
244 if (e.keyIdentifier == 'Enter') { | 250 if (e.keyIdentifier == 'Enter') { |
245 if (passwordField.value.length > 0) { | 251 if (passwordField.value.length > 0) { |
246 password2Field.focus(); | 252 password2Field.focus(); |
247 creationScreen.updateContinueButton_(); | 253 creationScreen.updateNextButtonForUser_(); |
248 } | 254 } |
249 e.stopPropagation(); | 255 e.stopPropagation(); |
250 } | 256 } |
251 }); | 257 }); |
252 | 258 |
253 password2Field.addEventListener('keydown', function(e) { | 259 password2Field.addEventListener('keydown', function(e) { |
254 creationScreen.passwordErrorVisible = false; | 260 creationScreen.passwordErrorVisible = false; |
255 if (e.keyIdentifier == 'Enter') { | 261 if (e.keyIdentifier == 'Enter') { |
256 if (passwordField.value.length > 0) { | 262 if (passwordField.value.length > 0) { |
257 if (creationScreen.managerList_.selectedPod_) | 263 if (creationScreen.managerList_.selectedPod_) |
258 creationScreen.managerList_.selectedPod_.focusInput(); | 264 creationScreen.managerList_.selectedPod_.focusInput(); |
259 creationScreen.updateContinueButton_(); | 265 creationScreen.updateNextButtonForUser_(); |
260 } | 266 } |
261 e.stopPropagation(); | 267 e.stopPropagation(); |
262 } | 268 } |
263 }); | 269 }); |
264 | 270 |
265 password2Field.addEventListener('keyup', function(e) { | 271 password2Field.addEventListener('keyup', function(e) { |
266 creationScreen.updateContinueButton_(); | 272 creationScreen.updateNextButtonForUser_(); |
267 }); | 273 }); |
268 | 274 |
269 passwordField.addEventListener('keyup', function(e) { | 275 passwordField.addEventListener('keyup', function(e) { |
270 creationScreen.updateContinueButton_(); | 276 creationScreen.updateNextButtonForUser_(); |
271 }); | 277 }); |
272 }, | 278 }, |
273 | 279 |
274 /** | 280 /** |
275 * Screen controls. | 281 * Screen controls. |
276 * @type {!Array} Array of Buttons. | 282 * @type {!Array} Array of Buttons. |
277 */ | 283 */ |
278 get buttons() { | 284 get buttons() { |
279 var buttons = []; | 285 var buttons = []; |
280 | 286 |
281 var proceedButton = this.ownerDocument.createElement('button'); | 287 var startButton = this.ownerDocument.createElement('button'); |
282 proceedButton.id = 'managed-user-creation-flow-proceed-button'; | 288 startButton.id = 'managed-user-creation-flow-start-button'; |
283 | 289 |
284 proceedButton.textContent = loadTimeData. | 290 startButton.textContent = loadTimeData. |
285 getString('managedUserCreationFlowProceedButtonTitle'); | 291 getString('managedUserCreationFlowStartButtonTitle'); |
286 proceedButton.hidden = true; | 292 startButton.hidden = true; |
287 buttons.push(proceedButton); | 293 buttons.push(startButton); |
294 | |
295 var previousButton = this.ownerDocument.createElement('button'); | |
296 previousButton.id = 'managed-user-creation-flow-prev-button'; | |
297 | |
298 previousButton.textContent = loadTimeData. | |
299 getString('managedUserCreationFlowPreviousButtonTitle'); | |
300 previousButton.hidden = true; | |
301 buttons.push(previousButton); | |
302 | |
303 var nextButton = this.ownerDocument.createElement('button'); | |
304 nextButton.id = 'managed-user-creation-flow-next-button'; | |
305 | |
306 nextButton.textContent = loadTimeData. | |
307 getString('managedUserCreationFlowNextButtonTitle'); | |
308 nextButton.hidden = true; | |
309 buttons.push(nextButton); | |
288 | 310 |
289 var finishButton = this.ownerDocument.createElement('button'); | 311 var finishButton = this.ownerDocument.createElement('button'); |
290 finishButton.id = 'managed-user-creation-flow-finish-button'; | 312 finishButton.id = 'managed-user-creation-flow-finish-button'; |
291 | 313 |
292 finishButton.textContent = loadTimeData. | 314 finishButton.textContent = loadTimeData. |
293 getString('managedUserCreationFlowFinishButtonTitle'); | 315 getString('managedUserCreationFlowFinishButtonTitle'); |
294 finishButton.hidden = true; | 316 finishButton.hidden = true; |
295 buttons.push(finishButton); | 317 buttons.push(finishButton); |
296 | 318 |
297 var retryButton = this.ownerDocument.createElement('button'); | |
298 retryButton.id = 'managed-user-creation-flow-retry-button'; | |
299 | |
300 retryButton.textContent = loadTimeData. | |
301 getString('managedUserCreationFlowRetryButtonTitle'); | |
302 retryButton.hidden = true; | |
303 buttons.push(retryButton); | |
304 | |
305 var cancelButton = this.ownerDocument.createElement('button'); | 319 var cancelButton = this.ownerDocument.createElement('button'); |
306 cancelButton.id = 'managed-user-creation-flow-cancel-button'; | 320 cancelButton.id = 'managed-user-creation-flow-cancel-button'; |
307 | 321 |
308 cancelButton.textContent = loadTimeData. | |
309 getString('managedUserCreationFlowCancelButtonTitle'); | |
310 cancelButton.hidden = true; | |
311 buttons.push(cancelButton); | |
312 | |
313 var creationFlowScreen = this; | 322 var creationFlowScreen = this; |
314 finishButton.addEventListener('click', function(e) { | 323 finishButton.addEventListener('click', function(e) { |
315 creationFlowScreen.finishFlow_(); | 324 creationFlowScreen.finishButtonPressed_(); |
316 e.stopPropagation(); | 325 e.stopPropagation(); |
317 }); | 326 }); |
318 proceedButton.addEventListener('click', function(e) { | 327 startButton.addEventListener('click', function(e) { |
319 creationFlowScreen.proceedFlow_(); | 328 creationFlowScreen.startButtonPressed_(); |
320 e.stopPropagation(); | 329 e.stopPropagation(); |
321 }); | 330 }); |
322 retryButton.addEventListener('click', function(e) { | 331 nextButton.addEventListener('click', function(e) { |
323 creationFlowScreen.retryFlow_(); | 332 creationFlowScreen.nextButtonPressed_(); |
324 e.stopPropagation(); | 333 e.stopPropagation(); |
325 }); | 334 }); |
326 cancelButton.addEventListener('click', function(e) { | 335 previousButton.addEventListener('click', function(e) { |
327 creationFlowScreen.cancel(); | 336 creationFlowScreen.prevButtonPressed_(); |
328 e.stopPropagation(); | 337 e.stopPropagation(); |
329 }); | 338 }); |
330 | 339 |
331 return buttons; | 340 return buttons; |
332 }, | 341 }, |
333 | 342 |
343 | |
Nikita (slow)
2013/04/12 13:12:15
nit: Drop empty line.
| |
334 /** | 344 /** |
335 * Does sanity check and calls backend with current user name/password pair | 345 * Does sanity check and calls backend with current user name/password pair |
336 * to create a user. May result in showPasswordError. | 346 * to authenticate manager. May result in showManagerPasswordError. |
337 * @private | 347 * @private |
338 */ | 348 */ |
339 validateInputAndStartFlow_: function() { | 349 validateAndLogInAsManager_: function() { |
350 var selectedPod = this.managerList_.selectedPod_; | |
351 if (null == selectedPod) | |
352 return; | |
353 | |
354 var managerId = selectedPod.user.emailAddress; | |
355 var managerPassword = selectedPod.passwordElement.value; | |
356 if (managerPassword.empty) | |
357 return; | |
358 | |
359 this.disabled = true; | |
360 this.context_.managerId = managerId; | |
361 chrome.send('authenticateManagerInLocallyManagedUserCreationFlow', | |
362 [managerId, managerPassword]); | |
363 }, | |
364 | |
365 | |
366 /** | |
367 * Does sanity check and calls backend with user display name/password pair | |
368 * to create a user. | |
369 * @private | |
370 */ | |
371 validateAndCreateLocallyManagedUser_: function() { | |
340 var firstPassword = $('managed-user-creation-flow-password').value; | 372 var firstPassword = $('managed-user-creation-flow-password').value; |
341 var secondPassword = | 373 var secondPassword = |
342 $('managed-user-creation-flow-password-confirm').value; | 374 $('managed-user-creation-flow-password-confirm').value; |
343 var userName = $('managed-user-creation-flow-name').value; | 375 var userName = $('managed-user-creation-flow-name').value; |
344 if (firstPassword != secondPassword) { | 376 if (firstPassword != secondPassword) { |
345 this.showPasswordError( | 377 this.showPasswordError( |
346 loadTimeData.getString('createManagedUserPasswordMismatchError')); | 378 loadTimeData.getString('createManagedUserPasswordMismatchError')); |
347 return; | 379 return; |
348 } | 380 } |
349 var selectedPod = this.managerList_.selectedPod_; | |
350 if (null == selectedPod) | |
351 return; | |
352 | |
353 var managerId = selectedPod.user.emailAddress; | |
354 var managerPassword = selectedPod.passwordElement.value; | |
355 this.disabled = true; | 381 this.disabled = true; |
356 // TODO(antrim) : we might use some minimal password validation | 382 this.context_.managedName = userName; |
357 // (e.g. non-empty etc.) here. | 383 chrome.send('specifyLocallyManagedUserCreationFlowUserData', |
358 chrome.send('runLocallyManagedUserCreationFlow', | 384 [userName, firstPassword]); |
359 [userName, firstPassword, managerId, managerPassword]); | |
360 }, | 385 }, |
361 | 386 |
362 /** | 387 /** |
363 * Calls backend part to check if current user name is valid/not taken. | 388 * Calls backend part to check if current user name is valid/not taken. |
364 * Results in call to either managedUserNameOk or managedUserNameError. | 389 * Results in call to either managedUserNameOk or managedUserNameError. |
365 * @private | 390 * @private |
366 */ | 391 */ |
367 checkUserName_: function() { | 392 checkUserName_: function() { |
368 var userName = $('managed-user-creation-flow-name').value; | 393 var userName = $('managed-user-creation-flow-name').value; |
369 | 394 |
(...skipping 13 matching lines...) Expand all Loading... | |
383 | 408 |
384 /** | 409 /** |
385 * Called by backend part in case of successful name validation. | 410 * Called by backend part in case of successful name validation. |
386 * @param {string} name - name that was validated. | 411 * @param {string} name - name that was validated. |
387 */ | 412 */ |
388 managedUserNameOk: function(name) { | 413 managedUserNameOk: function(name) { |
389 this.lastVerifiedName_ = name; | 414 this.lastVerifiedName_ = name; |
390 this.lastIncorrectUserName_ = null; | 415 this.lastIncorrectUserName_ = null; |
391 if ($('managed-user-creation-flow-name').value == name) | 416 if ($('managed-user-creation-flow-name').value == name) |
392 this.clearUserNameError_(); | 417 this.clearUserNameError_(); |
393 this.updateContinueButton_(); | 418 this.updateNextButtonForManager_(); |
394 }, | 419 }, |
395 | 420 |
396 /** | 421 /** |
397 * Called by backend part in case of name validation failure. | 422 * Called by backend part in case of name validation failure. |
398 * @param {string} name - name that was validated. | 423 * @param {string} name - name that was validated. |
399 * @param {string} errorText - reason why this name is invalid. | 424 * @param {string} errorText - reason why this name is invalid. |
400 */ | 425 */ |
401 managedUserNameError: function(name, errorText) { | 426 managedUserNameError: function(name, errorText) { |
402 this.lastIncorrectUserName_ = name; | 427 this.lastIncorrectUserName_ = name; |
403 this.lastVerifiedName_ = null; | 428 this.lastVerifiedName_ = null; |
404 | 429 |
405 var userNameField = $('managed-user-creation-flow-name'); | 430 var userNameField = $('managed-user-creation-flow-name'); |
406 if (userNameField.value == this.lastIncorrectUserName_) { | 431 if (userNameField.value == this.lastIncorrectUserName_) { |
407 this.nameErrorVisible = true; | 432 this.nameErrorVisible = true; |
408 $('managed-user-creation-flow-name-error').textContent = errorText; | 433 $('managed-user-creation-flow-name-error').textContent = errorText; |
409 | 434 |
410 this.setButtonDisabledStatus('proceed', true); | 435 this.setButtonDisabledStatus('next', true); |
411 } | 436 } |
412 }, | 437 }, |
413 | 438 |
414 /** | 439 /** |
415 * Clears user name error, if name is no more guaranteed to be invalid. | 440 * Clears user name error, if name is no more guaranteed to be invalid. |
416 * @private | 441 * @private |
417 */ | 442 */ |
418 clearUserNameError_: function() { | 443 clearUserNameError_: function() { |
419 // Avoid flickering | 444 // Avoid flickering |
420 if ($('managed-user-creation-flow-name').value == | 445 if ($('managed-user-creation-flow-name').value == |
421 this.lastIncorrectUserName_) { | 446 this.lastIncorrectUserName_) { |
422 return; | 447 return; |
423 } | 448 } |
424 this.nameErrorVisible = false; | 449 this.nameErrorVisible = false; |
425 }, | 450 }, |
426 | 451 |
427 /** | 452 /** |
428 * Called by backend part in case of password validation failure. | 453 * Called by backend part in case of password validation failure. |
429 * @param {string} errorText - reason why this password is invalid. | 454 * @param {string} errorText - reason why this password is invalid. |
430 */ | 455 */ |
431 showPasswordError: function(errorText) { | 456 showPasswordError: function(errorText) { |
432 $('managed-user-creation-flow-password-error').textContent = errorText; | 457 $('managed-user-creation-flow-password-error').textContent = errorText; |
433 this.passwordErrorVisible = true; | 458 this.passwordErrorVisible = true; |
434 $('managed-user-creation-flow-password').focus(); | 459 $('managed-user-creation-flow-password').focus(); |
435 | 460 |
436 this.setButtonDisabledStatus('proceed', true); | 461 this.setButtonDisabledStatus('next', true); |
437 }, | 462 }, |
438 | 463 |
439 /** | 464 /** |
440 * True if user name error should be displayed. | 465 * True if user name error should be displayed. |
441 * @type {boolean} | 466 * @type {boolean} |
442 */ | 467 */ |
443 set nameErrorVisible(value) { | 468 set nameErrorVisible(value) { |
444 $('managed-user-creation-flow-name-error'). | 469 $('managed-user-creation-flow-name-error'). |
445 classList[value ? 'add' : 'remove']('error'); | 470 classList[value ? 'add' : 'remove']('error'); |
446 $('managed-user-creation-flow-name'). | 471 $('managed-user-creation-flow-name'). |
(...skipping 11 matching lines...) Expand all Loading... | |
458 classList[value ? 'add' : 'remove']('error'); | 483 classList[value ? 'add' : 'remove']('error'); |
459 if (!value) | 484 if (!value) |
460 $('managed-user-creation-flow-password-error').textContent = ''; | 485 $('managed-user-creation-flow-password-error').textContent = ''; |
461 }, | 486 }, |
462 | 487 |
463 /** | 488 /** |
464 * Updates state of Continue button after minimal checks. | 489 * Updates state of Continue button after minimal checks. |
465 * @return {boolean} true, if form seems to be valid. | 490 * @return {boolean} true, if form seems to be valid. |
466 * @private | 491 * @private |
467 */ | 492 */ |
468 updateContinueButton_: function() { | 493 updateNextButtonForManager_: function() { |
494 var selectedPod = this.managerList_.selectedPod_; | |
495 canProceed = null != selectedPod && | |
496 selectedPod.passwordElement.value.length > 0; | |
497 | |
498 this.setButtonDisabledStatus('next', !canProceed); | |
499 return canProceed; | |
500 }, | |
501 | |
502 /** | |
503 * Updates state of Continue button after minimal checks. | |
504 * @return {boolean} true, if form seems to be valid. | |
505 * @private | |
506 */ | |
507 updateNextButtonForUser_: function() { | |
469 var firstPassword = $('managed-user-creation-flow-password').value; | 508 var firstPassword = $('managed-user-creation-flow-password').value; |
470 var secondPassword = | 509 var secondPassword = |
471 $('managed-user-creation-flow-password-confirm').value; | 510 $('managed-user-creation-flow-password-confirm').value; |
472 var userName = $('managed-user-creation-flow-name').value; | 511 var userName = $('managed-user-creation-flow-name').value; |
473 | 512 |
474 var canProceed = | 513 var canProceed = |
475 (firstPassword.length > 0) && | 514 (firstPassword.length > 0) && |
476 (firstPassword.length == secondPassword.length) && | 515 (firstPassword.length == secondPassword.length) && |
477 this.lastVerifiedName_ && | 516 this.lastVerifiedName_ && |
478 (userName == this.lastVerifiedName_); | 517 (userName == this.lastVerifiedName_); |
479 | 518 |
480 var selectedPod = this.managerList_.selectedPod_; | 519 this.setButtonDisabledStatus('next', !canProceed); |
481 canProceed = canProceed && | |
482 null != selectedPod && | |
483 selectedPod.passwordElement.value.length > 0; | |
484 | |
485 this.setButtonDisabledStatus('proceed', !canProceed); | |
486 return canProceed; | 520 return canProceed; |
487 }, | 521 }, |
488 | 522 |
489 showSelectedManagerPasswordError_: function() { | 523 showSelectedManagerPasswordError_: function() { |
490 var selectedPod = this.managerList_.selectedPod_; | 524 var selectedPod = this.managerList_.selectedPod_; |
491 selectedPod.showPasswordError(); | 525 selectedPod.showPasswordError(); |
492 selectedPod.passwordElement.value = ''; | 526 selectedPod.passwordElement.value = ''; |
493 selectedPod.focusInput(); | 527 selectedPod.focusInput(); |
494 }, | 528 }, |
495 | 529 |
496 /** | 530 /** |
497 * Show final splash screen with success message. | 531 * Show final splash screen with success message. |
498 */ | 532 */ |
499 showFinishedMessage: function() { | |
500 this.setVisiblePage_('success'); | |
501 this.setVisibleButtons_(['finish']); | |
502 }, | |
503 | 533 |
504 /** | 534 /** |
505 * Show error message. | 535 * Show error message. |
506 * @param {string} errorText Text to be displayed. | 536 * @param {string} errorText Text to be displayed. |
507 * @param {boolean} recoverable Indicates if error was transiend and process | 537 * @param {boolean} recoverable Indicates if error was transiend and process |
508 * can be retried. | 538 * can be retried. |
509 */ | 539 */ |
510 showErrorMessage: function(errorText, recoverable) { | 540 showErrorMessage: function(errorText, recoverable) { |
511 $('managed-user-creation-flow-error-value').innerHTML = errorText; | 541 $('managed-user-creation-flow-error-value').innerHTML = errorText; |
512 this.setVisiblePage_('error'); | 542 this.setVisiblePage_('error'); |
513 this.setVisibleButtons_(recoverable ? ['retry', 'cancel'] : ['cancel']); | 543 this.setVisibleButtons_(['cancel']); |
514 }, | 544 }, |
515 | 545 |
516 /** | 546 /** |
517 * Enables one particular subpage and hides the rest. | 547 * Enables one particular subpage and hides the rest. |
518 * @param {string} visiblePage - name of subpage (one of 'progress', | 548 * @param {string} visiblePage - name of subpage. |
519 * 'error', 'success') | |
520 * @private | 549 * @private |
521 */ | 550 */ |
522 setVisiblePage_: function(visiblePage) { | 551 setVisiblePage_: function(visiblePage) { |
523 var screenNames = ['initial', 'progress', 'error', 'success']; | 552 this.disabled = false; |
553 this.updateText_(); | |
554 var screenNames = ['intro', | |
Nikita (slow)
2013/04/12 13:12:15
nit: These should be really renamed in the upcomin
| |
555 'manager', | |
556 'username', | |
557 'progress', | |
558 'error', | |
559 'tutorial']; | |
524 for (i in screenNames) { | 560 for (i in screenNames) { |
525 var screenName = screenNames[i]; | 561 var screenName = screenNames[i]; |
526 var screen = $('managed-user-creation-flow-' + screenName); | 562 var screen = $('managed-user-creation-flow-' + screenName); |
527 screen.hidden = (screenName != visiblePage); | 563 screen.hidden = (screenName != visiblePage); |
564 if (screenName == visiblePage) { | |
565 $('step-logo').hidden = screen.classList.contains('step-no-logo'); | |
566 } | |
528 } | 567 } |
529 this.currentPage_ = visiblePage; | 568 this.currentPage_ = visiblePage; |
530 }, | 569 }, |
531 | 570 |
532 /** | 571 /** |
533 * Enables specific control buttons. | 572 * Enables specific control buttons. |
534 * @param {List of strings} buttonsList - list of buttons to display (values | 573 * @param {List of strings} buttonsList - list of buttons to display. |
535 * can be 'retry', 'finish', 'cancel') | |
536 * @private | 574 * @private |
537 */ | 575 */ |
538 setVisibleButtons_: function(buttonsList) { | 576 setVisibleButtons_: function(buttonsList) { |
539 var buttonNames = ['proceed', 'retry', 'finish', 'cancel']; | 577 var buttonNames = ['start', |
578 'prev', | |
579 'next', | |
580 'cancel', | |
581 'finish']; | |
540 for (i in buttonNames) { | 582 for (i in buttonNames) { |
541 var buttonName = buttonNames[i]; | 583 var buttonName = buttonNames[i]; |
542 var button = $('managed-user-creation-flow-' + buttonName + '-button'); | 584 var button; |
543 if (button) | 585 if ('cancel' == buttonName) |
586 button = $('cancel-add-user-button'); | |
587 else | |
588 button = $('managed-user-creation-flow-' + buttonName + '-button'); | |
589 if (button) { | |
544 button.hidden = buttonsList.indexOf(buttonName) < 0; | 590 button.hidden = buttonsList.indexOf(buttonName) < 0; |
591 button.disabled = false; | |
592 } | |
545 } | 593 } |
546 }, | 594 }, |
547 | 595 |
548 setButtonDisabledStatus: function(buttonName, status) { | 596 setButtonDisabledStatus: function(buttonName, status) { |
549 var button = $('managed-user-creation-flow-' + buttonName + '-button'); | 597 var button = $('managed-user-creation-flow-' + buttonName + '-button'); |
550 button.disabled = status; | 598 button.disabled = status; |
551 }, | 599 }, |
552 | 600 |
553 finishFlow_: function() { | 601 finishButtonPressed_: function() { |
554 chrome.send('finishLocalManagedUserCreation'); | 602 chrome.send('finishLocalManagedUserCreation'); |
555 }, | 603 }, |
556 | 604 |
557 proceedFlow_: function() { | 605 startButtonPressed_: function() { |
558 this.validateInputAndStartFlow_(); | 606 this.setVisiblePage_('manager'); |
607 this.setVisibleButtons_(['next', 'prev', 'cancel']); | |
608 this.setButtonDisabledStatus('next', true); | |
559 }, | 609 }, |
560 | 610 |
561 retryFlow_: function() { | 611 nextButtonPressed_: function() { |
562 this.setVisiblePage_('progress'); | 612 if (this.currentPage_ == 'manager') { |
563 chrome.send('retryLocalManagedUserCreation'); | 613 this.validateAndLogInAsManager_(); |
614 return; | |
615 } | |
616 if (this.currentPage_ == 'username') { | |
617 this.validateAndCreateLocallyManagedUser_(); | |
618 return; | |
619 } | |
620 }, | |
621 | |
622 prevButtonPressed_: function() { | |
623 this.setVisiblePage_('intro'); | |
624 this.setVisibleButtons_(['start', 'cancel']); | |
625 return; | |
564 }, | 626 }, |
565 | 627 |
566 /** | 628 /** |
567 * Updates state of login header so that necessary buttons are displayed. | 629 * Updates state of login header so that necessary buttons are displayed. |
568 **/ | 630 **/ |
569 onBeforeShow: function(data) { | 631 onBeforeShow: function(data) { |
570 $('login-header-bar').signinUIState = | 632 $('login-header-bar').signinUIState = |
571 SIGNIN_UI_STATE.MANAGED_USER_CREATION_FLOW; | 633 SIGNIN_UI_STATE.MANAGED_USER_CREATION_FLOW; |
572 if (data['managers']) { | 634 if (data['managers']) { |
573 this.loadManagers(data['managers']); | 635 this.loadManagers(data['managers']); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 | 671 |
610 /** | 672 /** |
611 * Called by backend part to propagate list of possible managers. | 673 * Called by backend part to propagate list of possible managers. |
612 * @param {Array} userList - list of users that can be managers. | 674 * @param {Array} userList - list of users that can be managers. |
613 */ | 675 */ |
614 loadManagers: function(userList) { | 676 loadManagers: function(userList) { |
615 $('managed-user-creation-flow-managers-block').hidden = false; | 677 $('managed-user-creation-flow-managers-block').hidden = false; |
616 this.managerList_.clearPods(); | 678 this.managerList_.clearPods(); |
617 for (var i = 0; i < userList.length; ++i) | 679 for (var i = 0; i < userList.length; ++i) |
618 this.managerList_.addPod(userList[i]); | 680 this.managerList_.addPod(userList[i]); |
619 if (userList.length > 0) | 681 |
682 var usersInPane = Math.min(userList.length, 5); | |
683 $('managed-user-creation-flow-managers-pane').style.height = | |
684 (usersInPane * 60 + 28) + 'px'; | |
685 | |
686 if (userList.length == 1) | |
620 this.managerList_.selectPod(this.managerList_.pods[0]); | 687 this.managerList_.selectPod(this.managerList_.pods[0]); |
621 }, | 688 }, |
622 | 689 |
623 /** | 690 /** |
624 * Cancels user creation and drops to user screen (either sign). | 691 * Cancels user creation and drops to user screen (either sign). |
625 */ | 692 */ |
626 cancel: function() { | 693 cancel: function() { |
627 var notSignedInScreens = ['initial']; | 694 var notSignedInScreens = ['intro', 'manager']; |
628 if (notSignedInScreens.indexOf(this.currentPage_) >= 0) { | 695 if (notSignedInScreens.indexOf(this.currentPage_) >= 0) { |
629 // Make sure no manager password is kept: | 696 // Make sure no manager password is kept: |
630 this.managerList_.clearPods(); | 697 this.managerList_.clearPods(); |
631 | 698 |
632 $('pod-row').loadLastWallpaper(); | 699 $('pod-row').loadLastWallpaper(); |
633 | 700 |
634 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); | 701 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); |
635 Oobe.resetSigninUI(true); | 702 Oobe.resetSigninUI(true); |
636 return; | 703 return; |
637 } | 704 } |
638 chrome.send('abortLocalManagedUserCreation'); | 705 chrome.send('abortLocalManagedUserCreation'); |
639 }, | 706 }, |
707 | |
708 updateText_: function() { | |
709 $('managed-user-creation-flow-tutorial-created-text').textContent = | |
710 loadTimeData.getStringF('managedUserProfileCreatedMessageTemplate', | |
711 this.context_.managedName); | |
712 | |
713 var boldEmail = '<b>' + this.context_.managerId + '</b>'; | |
714 $('managed-user-creation-flow-tutorial-instructions-text').innerHTML = | |
715 loadTimeData.getStringF('managedUserInstructionTemplate', | |
716 boldEmail); | |
717 } | |
718 | |
640 }; | 719 }; |
641 | 720 |
642 LocallyManagedUserCreationScreen.showProgressScreen = function() { | 721 LocallyManagedUserCreationScreen.showIntroPage = function() { |
643 var screen = $('managed-user-creation-flow'); | |
644 screen.disabled = false; | |
645 screen.setVisiblePage_('progress'); | |
646 screen.setVisibleButtons_(['cancel']); | |
647 }; | |
648 | |
649 LocallyManagedUserCreationScreen.showIntialScreen = function() { | |
650 var screen = $('managed-user-creation-flow'); | 722 var screen = $('managed-user-creation-flow'); |
651 | 723 |
652 $('managed-user-creation-flow-password').value = ''; | 724 $('managed-user-creation-flow-password').value = ''; |
653 $('managed-user-creation-flow-password-confirm').value = ''; | 725 $('managed-user-creation-flow-password-confirm').value = ''; |
654 $('managed-user-creation-flow-name').value = ''; | 726 $('managed-user-creation-flow-name').value = ''; |
655 | 727 |
656 screen.lastVerifiedName_ = null; | 728 screen.lastVerifiedName_ = null; |
657 screen.lastIncorrectUserName_ = null; | 729 screen.lastIncorrectUserName_ = null; |
658 screen.passwordErrorVisible = false; | 730 screen.passwordErrorVisible = false; |
659 screen.nameErrorVisible = false; | 731 screen.nameErrorVisible = false; |
660 | 732 |
661 screen.setButtonDisabledStatus('proceed', true); | 733 screen.setVisiblePage_('intro'); |
662 | 734 screen.setVisibleButtons_(['start', 'cancel']); |
663 screen.setVisiblePage_('initial'); | |
664 screen.setVisibleButtons_(['proceed', 'cancel']); | |
665 }; | 735 }; |
666 | 736 |
667 LocallyManagedUserCreationScreen.showFinishedMessage = function() { | 737 LocallyManagedUserCreationScreen.showProgressPage = function() { |
668 var screen = $('managed-user-creation-flow'); | 738 var screen = $('managed-user-creation-flow'); |
669 screen.disabled = false; | 739 screen.setVisiblePage_('progress'); |
670 screen.showFinishedMessage(); | 740 screen.setVisibleButtons_(['cancel']); |
741 }; | |
742 | |
743 LocallyManagedUserCreationScreen.showManagerPage = function() { | |
744 var screen = $('managed-user-creation-flow'); | |
745 screen.setVisiblePage_('manager'); | |
746 screen.setVisibleButtons_(['cancel']); | |
747 }; | |
748 | |
749 LocallyManagedUserCreationScreen.showUsernamePage = function() { | |
750 var screen = $('managed-user-creation-flow'); | |
751 screen.setVisiblePage_('username'); | |
752 screen.setVisibleButtons_(['next', 'cancel']); | |
753 }; | |
754 | |
755 LocallyManagedUserCreationScreen.showTutorialPage = function() { | |
756 var screen = $('managed-user-creation-flow'); | |
757 screen.setVisiblePage_('tutorial'); | |
758 screen.setVisibleButtons_(['finish']); | |
671 }; | 759 }; |
672 | 760 |
673 LocallyManagedUserCreationScreen.showManagerPasswordError = function() { | 761 LocallyManagedUserCreationScreen.showManagerPasswordError = function() { |
674 var screen = $('managed-user-creation-flow'); | 762 var screen = $('managed-user-creation-flow'); |
675 screen.disabled = false; | 763 screen.disabled = false; |
676 screen.showSelectedManagerPasswordError_(); | 764 screen.showSelectedManagerPasswordError_(); |
677 }; | 765 }; |
678 | 766 |
679 LocallyManagedUserCreationScreen.showErrorMessage = function(errorText, | 767 LocallyManagedUserCreationScreen.showErrorPage = function(errorText, |
680 recoverable) { | 768 recoverable) { |
681 var screen = $('managed-user-creation-flow'); | 769 var screen = $('managed-user-creation-flow'); |
682 screen.disabled = false; | 770 screen.disabled = false; |
683 screen.showErrorMessage(errorText, recoverable); | 771 screen.showErrorPage(errorText, recoverable); |
684 }; | 772 }; |
685 | 773 |
686 LocallyManagedUserCreationScreen.managedUserNameOk = function(name) { | 774 LocallyManagedUserCreationScreen.managedUserNameOk = function(name) { |
687 var screen = $('managed-user-creation-flow'); | 775 var screen = $('managed-user-creation-flow'); |
688 screen.managedUserNameOk(name); | 776 screen.managedUserNameOk(name); |
689 }; | 777 }; |
690 | 778 |
691 LocallyManagedUserCreationScreen.managedUserNameError = | 779 LocallyManagedUserCreationScreen.managedUserNameError = |
692 function(name, error) { | 780 function(name, error) { |
693 var screen = $('managed-user-creation-flow'); | 781 var screen = $('managed-user-creation-flow'); |
694 screen.managedUserNameError(name, error); | 782 screen.managedUserNameError(name, error); |
695 }; | 783 }; |
696 | 784 |
697 LocallyManagedUserCreationScreen.showPasswordError = function(error) { | 785 LocallyManagedUserCreationScreen.showPasswordError = function(error) { |
698 var screen = $('managed-user-creation-flow'); | 786 var screen = $('managed-user-creation-flow'); |
699 screen.showPasswordError(error); | 787 screen.showPasswordError(error); |
700 }; | 788 }; |
701 | 789 |
702 LocallyManagedUserCreationScreen.loadManagers = function(userList) { | 790 LocallyManagedUserCreationScreen.loadManagers = function(userList) { |
703 var screen = $('managed-user-creation-flow'); | 791 var screen = $('managed-user-creation-flow'); |
704 screen.loadManagers(userList); | 792 screen.loadManagers(userList); |
705 }; | 793 }; |
706 | 794 |
707 LocallyManagedUserCreationScreen.showPostImageSelectionScreen = | |
708 function(userList) { | |
709 var screen = $('managed-user-creation-flow'); | |
710 screen.setVisiblePage_('success'); | |
711 }; | |
712 | |
713 return { | 795 return { |
714 LocallyManagedUserCreationScreen: LocallyManagedUserCreationScreen | 796 LocallyManagedUserCreationScreen: LocallyManagedUserCreationScreen |
715 }; | 797 }; |
716 }); | 798 }); |
OLD | NEW |