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