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 login.createScreen('LocallyManagedUserCreationScreen', | 9 login.createScreen('LocallyManagedUserCreationScreen', |
10 'managed-user-creation', function() { | 10 'managed-user-creation', function() { |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 /** @override */ | 28 /** @override */ |
29 decorate: function() { | 29 decorate: function() { |
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'); | 34 var screen = $('managed-user-creation'); |
35 var managerPod = this; | 35 var managerPod = this; |
36 var hideManagerPasswordError = function(element) { | 36 var hideManagerPasswordError = function(element) { |
37 managerPod.passwordErrorElement.hidden = true; | 37 managerPod.passwordElement.classList.remove('password-error'); |
| 38 $('bubble').hide(); |
38 }; | 39 }; |
39 | 40 |
40 screen.configureTextInput( | 41 screen.configureTextInput( |
41 this.passwordElement, | 42 this.passwordElement, |
42 screen.updateNextButtonForManager_.bind(screen), | 43 screen.updateNextButtonForManager_.bind(screen), |
43 screen.validIfNotEmpty_.bind(screen), | 44 screen.validIfNotEmpty_.bind(screen), |
44 function(element) { | 45 function(element) { |
45 screen.getScreenButton('next').focus(); | 46 screen.getScreenButton('next').focus(); |
46 }, | 47 }, |
47 hideManagerPasswordError); | 48 hideManagerPasswordError); |
48 }, | 49 }, |
49 | 50 |
50 /** | 51 /** |
51 * Updates UI elements from user data. | 52 * Updates UI elements from user data. |
52 */ | 53 */ |
53 update: function() { | 54 update: function() { |
54 this.imageElement.src = 'chrome://userimage/' + this.user.username + | 55 this.imageElement.src = 'chrome://userimage/' + this.user.username + |
55 '?id=' + ManagerPod.userImageSalt_[this.user.username]; | 56 '?id=' + ManagerPod.userImageSalt_[this.user.username]; |
56 | 57 |
57 this.nameElement.textContent = this.user.displayName; | 58 this.nameElement.textContent = this.user.displayName; |
58 this.emailElement.textContent = this.user.emailAddress; | 59 this.emailElement.textContent = this.user.emailAddress; |
59 }, | 60 }, |
60 | 61 |
61 showPasswordError: function() { | 62 showPasswordError: function() { |
62 this.passwordErrorElement.hidden = false; | 63 this.passwordElement.classList.add('password-error'); |
| 64 $('bubble').showTextForElement( |
| 65 this.passwordElement, |
| 66 loadTimeData.getString('createManagedUserWrongManagerPasswordText'), |
| 67 cr.ui.Bubble.Attachment.BOTTOM, |
| 68 24, 4); |
63 }, | 69 }, |
64 | 70 |
65 /** | 71 /** |
66 * Brings focus to password field. | 72 * Brings focus to password field. |
67 */ | 73 */ |
68 focusInput: function() { | 74 focusInput: function() { |
69 this.passwordElement.focus(); | 75 this.passwordElement.focus(); |
70 }, | 76 }, |
71 | 77 |
72 /** | 78 /** |
(...skipping 22 matching lines...) Expand all Loading... |
95 | 101 |
96 /** | 102 /** |
97 * Gets password element. | 103 * Gets password element. |
98 * @type {!HTMLDivElement} | 104 * @type {!HTMLDivElement} |
99 */ | 105 */ |
100 get passwordElement() { | 106 get passwordElement() { |
101 return this.querySelector('.managed-user-creation-manager-password'); | 107 return this.querySelector('.managed-user-creation-manager-password'); |
102 }, | 108 }, |
103 | 109 |
104 /** | 110 /** |
105 * Gets password error element. | |
106 * @type {!HTMLDivElement} | |
107 */ | |
108 get passwordErrorElement() { | |
109 return this. | |
110 querySelector('.managed-user-creation-manager-wrong-password'); | |
111 }, | |
112 | |
113 /** | |
114 * Gets password enclosing block. | 111 * Gets password enclosing block. |
115 * @type {!HTMLDivElement} | 112 * @type {!HTMLDivElement} |
116 */ | 113 */ |
117 get passwordBlock() { | 114 get passwordBlock() { |
118 return this.querySelector('.password-block'); | 115 return this.querySelector('.password-block'); |
119 }, | 116 }, |
120 | 117 |
121 /** @override */ | 118 /** @override */ |
122 handleMouseDown_: function(e) { | 119 handleMouseDown_: function(e) { |
123 this.parentNode.selectPod(this); | 120 this.parentNode.selectPod(this); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 $('managed-user-creation-managers-pane'). | 224 $('managed-user-creation-managers-pane'). |
228 appendChild(this.managerList_); | 225 appendChild(this.managerList_); |
229 | 226 |
230 var userNameField = $('managed-user-creation-name'); | 227 var userNameField = $('managed-user-creation-name'); |
231 var passwordField = $('managed-user-creation-password'); | 228 var passwordField = $('managed-user-creation-password'); |
232 var password2Field = $('managed-user-creation-password-confirm'); | 229 var password2Field = $('managed-user-creation-password-confirm'); |
233 | 230 |
234 var creationScreen = this; | 231 var creationScreen = this; |
235 | 232 |
236 var hideUserPasswordError = function(element) { | 233 var hideUserPasswordError = function(element) { |
237 creationScreen.passwordErrorVisible = false; | 234 $('bubble').hide(); |
| 235 $('managed-user-creation-password').classList.remove('password-error'); |
238 }; | 236 }; |
239 | 237 |
240 this.configureTextInput(userNameField, | 238 this.configureTextInput(userNameField, |
241 this.checkUserName_.bind(this), | 239 this.checkUserName_.bind(this), |
242 this.validIfNotEmpty_.bind(this), | 240 this.validIfNotEmpty_.bind(this), |
243 function(element) { | 241 function(element) { |
244 passwordField.focus(); | 242 passwordField.focus(); |
245 }, | 243 }, |
246 this.clearUserNameError_.bind(this)); | 244 this.clearUserNameError_.bind(this)); |
247 | 245 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 return; | 532 return; |
535 } | 533 } |
536 this.nameErrorVisible = false; | 534 this.nameErrorVisible = false; |
537 }, | 535 }, |
538 | 536 |
539 /** | 537 /** |
540 * Called by backend part in case of password validation failure. | 538 * Called by backend part in case of password validation failure. |
541 * @param {string} errorText - reason why this password is invalid. | 539 * @param {string} errorText - reason why this password is invalid. |
542 */ | 540 */ |
543 showPasswordError: function(errorText) { | 541 showPasswordError: function(errorText) { |
544 $('managed-user-creation-password-error').textContent = errorText; | 542 $('bubble').showTextForElement( |
545 this.passwordErrorVisible = true; | 543 $('managed-user-creation-password'), |
| 544 errorText, |
| 545 cr.ui.Bubble.Attachment.RIGHT, |
| 546 24, 4); |
| 547 $('managed-user-creation-password').classList.add('password-error'); |
546 $('managed-user-creation-password').focus(); | 548 $('managed-user-creation-password').focus(); |
547 | 549 |
548 this.setButtonDisabledStatus('next', true); | 550 this.setButtonDisabledStatus('next', true); |
549 }, | 551 }, |
550 | 552 |
551 /** | 553 /** |
552 * True if user name error should be displayed. | 554 * True if user name error should be displayed. |
553 * @type {boolean} | 555 * @type {boolean} |
554 */ | 556 */ |
555 set nameErrorVisible(value) { | 557 set nameErrorVisible(value) { |
556 $('managed-user-creation-name-error'). | 558 $('managed-user-creation-name-error'). |
557 classList.toggle('error', value); | 559 classList.toggle('error', value); |
558 $('managed-user-creation-name'). | 560 $('managed-user-creation-name'). |
559 classList.toggle('duplicate-name', value); | 561 classList.toggle('duplicate-name', value); |
560 if (!value) | 562 if (!value) |
561 $('managed-user-creation-name-error').textContent = ''; | 563 $('managed-user-creation-name-error').textContent = ''; |
562 }, | 564 }, |
563 | 565 |
564 /** | 566 /** |
565 * True if user name error should be displayed. | |
566 * @type {boolean} | |
567 */ | |
568 set passwordErrorVisible(value) { | |
569 $('managed-user-creation-password-error'). | |
570 classList.toggle('error', value); | |
571 if (!value) | |
572 $('managed-user-creation-password-error').textContent = ''; | |
573 }, | |
574 | |
575 /** | |
576 * Updates state of Continue button after minimal checks. | 567 * Updates state of Continue button after minimal checks. |
577 * @return {boolean} true, if form seems to be valid. | 568 * @return {boolean} true, if form seems to be valid. |
578 * @private | 569 * @private |
579 */ | 570 */ |
580 updateNextButtonForManager_: function() { | 571 updateNextButtonForManager_: function() { |
581 var selectedPod = this.managerList_.selectedPod_; | 572 var selectedPod = this.managerList_.selectedPod_; |
582 canProceed = null != selectedPod && | 573 canProceed = null != selectedPod && |
583 selectedPod.passwordElement.value.length > 0; | 574 selectedPod.passwordElement.value.length > 0; |
584 | 575 |
585 this.setButtonDisabledStatus('next', !canProceed); | 576 this.setButtonDisabledStatus('next', !canProceed); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 }, | 819 }, |
829 | 820 |
830 showIntroPage: function() { | 821 showIntroPage: function() { |
831 $('managed-user-creation-password').value = ''; | 822 $('managed-user-creation-password').value = ''; |
832 $('managed-user-creation-password-confirm').value = ''; | 823 $('managed-user-creation-password-confirm').value = ''; |
833 $('managed-user-creation-name').value = ''; | 824 $('managed-user-creation-name').value = ''; |
834 | 825 |
835 this.lastVerifiedName_ = null; | 826 this.lastVerifiedName_ = null; |
836 this.lastIncorrectUserName_ = null; | 827 this.lastIncorrectUserName_ = null; |
837 this.passwordErrorVisible = false; | 828 this.passwordErrorVisible = false; |
| 829 $('managed-user-creation-password').classList.remove('password-error'); |
838 this.nameErrorVisible = false; | 830 this.nameErrorVisible = false; |
839 | 831 |
840 this.setVisiblePage_('intro'); | 832 this.setVisiblePage_('intro'); |
841 }, | 833 }, |
842 | 834 |
843 showManagerPage: function() { | 835 showManagerPage: function() { |
844 this.setVisiblePage_('manager'); | 836 this.setVisiblePage_('manager'); |
845 }, | 837 }, |
846 | 838 |
847 showUsernamePage: function() { | 839 showUsernamePage: function() { |
(...skipping 12 matching lines...) Expand all Loading... |
860 this.setVisiblePage_('error'); | 852 this.setVisiblePage_('error'); |
861 }, | 853 }, |
862 | 854 |
863 showManagerPasswordError: function() { | 855 showManagerPasswordError: function() { |
864 this.disabled = false; | 856 this.disabled = false; |
865 this.showSelectedManagerPasswordError_(); | 857 this.showSelectedManagerPasswordError_(); |
866 } | 858 } |
867 }; | 859 }; |
868 }); | 860 }); |
869 | 861 |
OLD | NEW |