Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/resources/chromeos/login/screen_locally_managed_user_creation.js

Issue 22896002: Fix next button status, error bubble positions, initial focus on user name screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 chrome.send('specifyLocallyManagedUserCreationFlowUserData', 522 chrome.send('specifyLocallyManagedUserCreationFlowUserData',
523 [userName, firstPassword]); 523 [userName, firstPassword]);
524 }, 524 },
525 525
526 /** 526 /**
527 * Calls backend part to check if current user name is valid/not taken. 527 * Calls backend part to check if current user name is valid/not taken.
528 * Results in call to either managedUserNameOk or managedUserNameError. 528 * Results in call to either managedUserNameOk or managedUserNameError.
529 * @private 529 * @private
530 */ 530 */
531 checkUserName_: function() { 531 checkUserName_: function() {
532 var userName = $('managed-user-creation-name').value; 532 var userName = this.getScreenElement('name').value;
533 533
534 // Avoid flickering 534 // Avoid flickering
535 if (userName == this.lastIncorrectUserName_ || 535 if (userName == this.lastIncorrectUserName_ ||
536 userName == this.lastVerifiedName_) { 536 userName == this.lastVerifiedName_) {
537 return; 537 return;
538 } 538 }
539 if (userName.length > 0) { 539 if (userName.length > 0) {
540 chrome.send('checkLocallyManagedUserName', [userName]); 540 chrome.send('checkLocallyManagedUserName', [userName]);
541 } else { 541 } else {
542 this.nameErrorVisible = false; 542 this.nameErrorVisible = false;
543 this.lastVerifiedName_ = null; 543 this.lastVerifiedName_ = null;
544 this.lastIncorrectUserName_ = null; 544 this.lastIncorrectUserName_ = null;
545 this.updateNextButtonForUser_();
545 } 546 }
546 }, 547 },
547 548
548 /** 549 /**
549 * Called by backend part in case of successful name validation. 550 * Called by backend part in case of successful name validation.
550 * @param {string} name - name that was validated. 551 * @param {string} name - name that was validated.
551 */ 552 */
552 managedUserNameOk: function(name) { 553 managedUserNameOk: function(name) {
553 this.lastVerifiedName_ = name; 554 this.lastVerifiedName_ = name;
554 this.lastIncorrectUserName_ = null; 555 this.lastIncorrectUserName_ = null;
555 if ($('managed-user-creation-name').value == name) 556 if ($('managed-user-creation-name').value == name)
556 this.clearUserNameError_(); 557 this.clearUserNameError_();
557 this.updateNextButtonForManager_(); 558 this.updateNextButtonForUser_();
558 }, 559 },
559 560
560 /** 561 /**
561 * Called by backend part in case of name validation failure. 562 * Called by backend part in case of name validation failure.
562 * @param {string} name - name that was validated. 563 * @param {string} name - name that was validated.
563 * @param {string} errorText - reason why this name is invalid. 564 * @param {string} errorText - reason why this name is invalid.
564 */ 565 */
565 managedUserNameError: function(name, errorText) { 566 managedUserNameError: function(name, errorText) {
566 this.lastIncorrectUserName_ = name; 567 this.lastIncorrectUserName_ = name;
567 this.lastVerifiedName_ = null; 568 this.lastVerifiedName_ = null;
568 569
569 var userNameField = $('managed-user-creation-name'); 570 var userNameField = $('managed-user-creation-name');
570 if (userNameField.value == this.lastIncorrectUserName_) { 571 if (userNameField.value == this.lastIncorrectUserName_) {
571 this.nameErrorVisible = true; 572 this.nameErrorVisible = true;
572 $('bubble').showTextForElement( 573 $('bubble').showTextForElement(
573 $('managed-user-creation-name'), 574 $('managed-user-creation-name'),
574 errorText, 575 errorText,
575 cr.ui.Bubble.Attachment.RIGHT, 576 cr.ui.Bubble.Attachment.RIGHT,
576 24, 4); 577 12, 4);
577 this.setButtonDisabledStatus('next', true); 578 this.setButtonDisabledStatus('next', true);
578 } 579 }
579 }, 580 },
580 581
581 /** 582 /**
582 * Clears user name error, if name is no more guaranteed to be invalid. 583 * Clears user name error, if name is no more guaranteed to be invalid.
583 * @private 584 * @private
584 */ 585 */
585 clearUserNameError_: function() { 586 clearUserNameError_: function() {
586 // Avoid flickering 587 // Avoid flickering
587 if ($('managed-user-creation-name').value == 588 if ($('managed-user-creation-name').value ==
588 this.lastIncorrectUserName_) { 589 this.lastIncorrectUserName_) {
589 return; 590 return;
590 } 591 }
591 this.nameErrorVisible = false; 592 this.nameErrorVisible = false;
592 }, 593 },
593 594
594 /** 595 /**
595 * Called by backend part in case of password validation failure. 596 * Called by backend part in case of password validation failure.
596 * @param {string} errorText - reason why this password is invalid. 597 * @param {string} errorText - reason why this password is invalid.
597 */ 598 */
598 showPasswordError: function(errorText) { 599 showPasswordError: function(errorText) {
599 $('bubble').showTextForElement( 600 $('bubble').showTextForElement(
600 $('managed-user-creation-password'), 601 $('managed-user-creation-password'),
601 errorText, 602 errorText,
602 cr.ui.Bubble.Attachment.RIGHT, 603 cr.ui.Bubble.Attachment.RIGHT,
603 24, 4); 604 12, 4);
604 $('managed-user-creation-password').classList.add('password-error'); 605 $('managed-user-creation-password').classList.add('password-error');
605 $('managed-user-creation-password').focus(); 606 $('managed-user-creation-password').focus();
606 this.disabled = false; 607 this.disabled = false;
607 this.setButtonDisabledStatus('next', true); 608 this.setButtonDisabledStatus('next', true);
608 }, 609 },
609 610
610 /** 611 /**
611 * True if user name error should be displayed. 612 * True if user name error should be displayed.
612 * @type {boolean} 613 * @type {boolean}
613 */ 614 */
(...skipping 17 matching lines...) Expand all
631 this.setButtonDisabledStatus('next', !canProceed); 632 this.setButtonDisabledStatus('next', !canProceed);
632 return canProceed; 633 return canProceed;
633 }, 634 },
634 635
635 /** 636 /**
636 * Updates state of Continue button after minimal checks. 637 * Updates state of Continue button after minimal checks.
637 * @return {boolean} true, if form seems to be valid. 638 * @return {boolean} true, if form seems to be valid.
638 * @private 639 * @private
639 */ 640 */
640 updateNextButtonForUser_: function() { 641 updateNextButtonForUser_: function() {
641 var firstPassword = $('managed-user-creation-password').value; 642 var firstPassword = this.getScreenElement('password').value;
642 var secondPassword = 643 var secondPassword = this.getScreenElement('password-confirm').value;
643 $('managed-user-creation-password-confirm').value; 644 var userName = this.getScreenElement('name').value;
644 var userName = $('managed-user-creation-name').value;
645 645
646 var canProceed = 646 var canProceed =
647 (userName.length > 0) &&
647 (firstPassword.length > 0) && 648 (firstPassword.length > 0) &&
648 (firstPassword.length == secondPassword.length) && 649 (firstPassword.length == secondPassword.length) &&
649 this.lastVerifiedName_ && 650 this.lastVerifiedName_ &&
650 (userName == this.lastVerifiedName_); 651 (userName == this.lastVerifiedName_);
651 652
652 this.setButtonDisabledStatus('next', !canProceed); 653 this.setButtonDisabledStatus('next', !canProceed);
653 return canProceed; 654 return canProceed;
654 }, 655 },
655 656
656 showSelectedManagerPasswordError_: function() { 657 showSelectedManagerPasswordError_: function() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 710
710 if (visiblePage == 'username') { 711 if (visiblePage == 'username') {
711 var imageGrid = this.getScreenElement('image-grid'); 712 var imageGrid = this.getScreenElement('image-grid');
712 // select some image. 713 // select some image.
713 var selected = this.imagesData_[ 714 var selected = this.imagesData_[
714 Math.floor(Math.random() * this.imagesData_.length)]; 715 Math.floor(Math.random() * this.imagesData_.length)];
715 imageGrid.selectedItemUrl = selected.url; 716 imageGrid.selectedItemUrl = selected.url;
716 chrome.send('supervisedUserSelectImage', 717 chrome.send('supervisedUserSelectImage',
717 [selected.url, 'default']); 718 [selected.url, 'default']);
718 this.getScreenElement('image-grid').redraw(); 719 this.getScreenElement('image-grid').redraw();
720 this.updateNextButtonForUser_();
721 this.getScreenElement('name').focus();
719 } 722 }
720 }, 723 },
721 724
722 setButtonDisabledStatus: function(buttonName, status) { 725 setButtonDisabledStatus: function(buttonName, status) {
723 var button = $('managed-user-creation-' + buttonName + '-button'); 726 var button = $('managed-user-creation-' + buttonName + '-button');
724 button.disabled = status; 727 button.disabled = status;
725 }, 728 },
726 729
727 gotItButtonPressed_: function() { 730 gotItButtonPressed_: function() {
728 chrome.send('finishLocalManagedUserCreation'); 731 chrome.send('finishLocalManagedUserCreation');
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 var imageGrid = this.getScreenElement('image-grid'); 1001 var imageGrid = this.getScreenElement('image-grid');
999 imageGrid.discardPhoto(); 1002 imageGrid.discardPhoto();
1000 }, 1003 },
1001 1004
1002 setCameraPresent: function(present) { 1005 setCameraPresent: function(present) {
1003 this.getScreenElement('image-grid').cameraPresent = present; 1006 this.getScreenElement('image-grid').cameraPresent = present;
1004 }, 1007 },
1005 }; 1008 };
1006 }); 1009 });
1007 1010
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698