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

Side by Side Diff: ui/login/account_picker/user_pod_row.js

Issue 2254623003: Submit button added to user pod. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed patch set 4 errors. Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 User pod row implementation. 6 * @fileoverview User pod row implementation.
7 */ 7 */
8 8
9 cr.define('login', function() { 9 cr.define('login', function() {
10 /** 10 /**
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 /** 750 /**
751 * Initializes the pod after its properties set and added to a pod row. 751 * Initializes the pod after its properties set and added to a pod row.
752 */ 752 */
753 initialize: function() { 753 initialize: function() {
754 this.passwordElement.addEventListener('keydown', 754 this.passwordElement.addEventListener('keydown',
755 this.parentNode.handleKeyDown.bind(this.parentNode)); 755 this.parentNode.handleKeyDown.bind(this.parentNode));
756 this.passwordElement.addEventListener('keypress', 756 this.passwordElement.addEventListener('keypress',
757 this.handlePasswordKeyPress_.bind(this)); 757 this.handlePasswordKeyPress_.bind(this));
758 this.passwordElement.addEventListener('input', 758 this.passwordElement.addEventListener('input',
759 this.handleInputChanged_.bind(this)); 759 this.handleInputChanged_.bind(this));
760 this.submitButton.addEventListener('click',
761 this.handleSubmitButtonClick_.bind(this));
760 762
761 this.imageElement.addEventListener('load', 763 this.imageElement.addEventListener('load',
762 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); 764 this.parentNode.handlePodImageLoad.bind(this.parentNode, this));
763 765
764 var initialAuthType = this.user.initialAuthType || 766 var initialAuthType = this.user.initialAuthType ||
765 AUTH_TYPE.OFFLINE_PASSWORD; 767 AUTH_TYPE.OFFLINE_PASSWORD;
766 this.setAuthType(initialAuthType, null); 768 this.setAuthType(initialAuthType, null);
767 769
768 this.userClickAuthAllowed_ = false; 770 this.userClickAuthAllowed_ = false;
771
772 // Lazy load the assets needed for the polymer submit button.
773 if (!cr.ui.login.ResourceLoader.alreadyLoadedAssets(
774 'custom-elements-user-pod')) {
775 cr.ui.login.ResourceLoader.registerAssets({
776 id: 'custom-elements-user-pod',
777 html: [{ url: 'chrome://oobe/custom_elements_user_pod.html' }]
778 });
779 cr.ui.login.ResourceLoader.loadAssetsOnIdle('custom-elements-user-pod');
780 }
769 }, 781 },
770 782
771 /** 783 /**
772 * Resets tab order for pod elements to its initial state. 784 * Resets tab order for pod elements to its initial state.
773 */ 785 */
774 resetTabOrder: function() { 786 resetTabOrder: function() {
775 // Note: the |mainInput| can be the pod itself. 787 // Note: the |mainInput| can be the pod itself.
776 this.mainInput.tabIndex = -1; 788 this.mainInput.tabIndex = -1;
777 this.tabIndex = UserPodTabOrder.POD_INPUT; 789 this.tabIndex = UserPodTabOrder.POD_INPUT;
778 }, 790 },
779 791
780 /** 792 /**
781 * Handles keypress event (i.e. any textual input) on password input. 793 * Handles keypress event (i.e. any textual input) on password input.
782 * @param {Event} e Keypress Event object. 794 * @param {Event} e Keypress Event object.
783 * @private 795 * @private
784 */ 796 */
785 handlePasswordKeyPress_: function(e) { 797 handlePasswordKeyPress_: function(e) {
786 // When tabbing from the system tray a tab key press is received. Suppress 798 // When tabbing from the system tray a tab key press is received. Suppress
787 // this so as not to type a tab character into the password field. 799 // this so as not to type a tab character into the password field.
788 if (e.keyCode == 9) { 800 if (e.keyCode == 9) {
789 e.preventDefault(); 801 e.preventDefault();
790 return; 802 return;
791 } 803 }
792 this.customIconElement.cancelDelayedTooltipShow(); 804 this.customIconElement.cancelDelayedTooltipShow();
793 }, 805 },
794 806
795 /** 807 /**
808 * Handles a click event on submit button.
809 * @param {Event} e Click event.
810 */
811 handleSubmitButtonClick_: function(e) {
812 this.parentNode.setActivatedPod(this, e);
813 },
814
815 /**
796 * Top edge margin number of pixels. 816 * Top edge margin number of pixels.
797 * @type {?number} 817 * @type {?number}
798 */ 818 */
799 set top(top) { 819 set top(top) {
800 this.style.top = cr.ui.toCssPx(top); 820 this.style.top = cr.ui.toCssPx(top);
801 }, 821 },
802 822
803 /** 823 /**
804 * Top edge margin number of pixels. 824 * Top edge margin number of pixels.
805 */ 825 */
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 883
864 /** 884 /**
865 * Gets password field. 885 * Gets password field.
866 * @type {!HTMLInputElement} 886 * @type {!HTMLInputElement}
867 */ 887 */
868 get passwordElement() { 888 get passwordElement() {
869 return this.querySelector('.password'); 889 return this.querySelector('.password');
870 }, 890 },
871 891
872 /** 892 /**
893 * Gets submit button.
894 * @type {!HTMLInputElement}
895 */
896 get submitButton() {
897 return this.querySelector('.submit-button');
898 },
899
900 /**
873 * Gets the password label, which is used to show a message where the 901 * Gets the password label, which is used to show a message where the
874 * password field is normally. 902 * password field is normally.
875 * @type {!HTMLInputElement} 903 * @type {!HTMLInputElement}
876 */ 904 */
877 get passwordLabelElement() { 905 get passwordLabelElement() {
878 return this.querySelector('.password-label'); 906 return this.querySelector('.password-label');
879 }, 907 },
880 908
881 get pinContainer() { 909 get pinContainer() {
882 return this.querySelector('.pin-container'); 910 return this.querySelector('.pin-container');
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; 1124 this.querySelector('.mp-policy-not-allowed-msg').hidden = false;
1097 } else if (this.user_.isApp) { 1125 } else if (this.user_.isApp) {
1098 this.setUserPodIconType('app'); 1126 this.setUserPodIconType('app');
1099 } 1127 }
1100 }, 1128 },
1101 1129
1102 isPinReady: function() { 1130 isPinReady: function() {
1103 return this.pinKeyboard && this.pinKeyboard.offsetHeight > 0; 1131 return this.pinKeyboard && this.pinKeyboard.offsetHeight > 0;
1104 }, 1132 },
1105 1133
1134 setErrorDisplay: function(visible) {
jdufault 2016/08/30 21:02:27 toggleDisplayError? toggleErrorShown? setErrorShow
sammiequon 2016/08/30 22:28:27 Done.
1135 this.submitButton.classList.toggle('error-shown', visible);
1136 },
1137
1106 toggleTransitions: function(enable) { 1138 toggleTransitions: function(enable) {
1107 this.classList.toggle('flying-pin-pod', enable); 1139 this.classList.toggle('flying-pin-pod', enable);
1108 }, 1140 },
1109 1141
1110 updatePinClass_: function(element, enable) { 1142 updatePinClass_: function(element, enable) {
1111 element.classList.toggle('pin-enabled', enable); 1143 element.classList.toggle('pin-enabled', enable);
1112 element.classList.toggle('pin-disabled', !enable); 1144 element.classList.toggle('pin-disabled', !enable);
1113 }, 1145 },
1114 1146
1115 setPinVisibility: function(visible) { 1147 setPinVisibility: function(visible) {
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 this.parentNode.setActivatedPod(this); 1855 this.parentNode.setActivatedPod(this);
1824 }, 1856 },
1825 1857
1826 handlePinChanged_: function(e) { 1858 handlePinChanged_: function(e) {
1827 this.passwordElement.value = e.detail.pin; 1859 this.passwordElement.value = e.detail.pin;
1828 }, 1860 },
1829 1861
1830 handleInputChanged_: function(e) { 1862 handleInputChanged_: function(e) {
1831 if (this.pinKeyboard) 1863 if (this.pinKeyboard)
1832 this.pinKeyboard.value = this.passwordElement.value; 1864 this.pinKeyboard.value = this.passwordElement.value;
1865 this.submitButton.disabled = this.passwordElement.value.length <= 0;
1866 this.setErrorDisplay(false);
1833 }, 1867 },
1834 1868
1835 /** 1869 /**
1836 * Handles click event on a user pod. 1870 * Handles click event on a user pod.
1837 * @param {Event} e Click event. 1871 * @param {Event} e Click event.
1838 */ 1872 */
1839 handleClickOnPod_: function(e) { 1873 handleClickOnPod_: function(e) {
1840 if (this.parentNode.disabled) 1874 if (this.parentNode.disabled)
1841 return; 1875 return;
1842 1876
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 /** 2631 /**
2598 * Add an existing user pod to this pod row. 2632 * Add an existing user pod to this pod row.
2599 * @param {!Object} user User info dictionary. 2633 * @param {!Object} user User info dictionary.
2600 */ 2634 */
2601 addUserPod: function(user) { 2635 addUserPod: function(user) {
2602 var userPod = this.createUserPod(user); 2636 var userPod = this.createUserPod(user);
2603 this.appendChild(userPod); 2637 this.appendChild(userPod);
2604 userPod.initialize(); 2638 userPod.initialize();
2605 }, 2639 },
2606 2640
2641 /**
2642 * Enables or disables transitions on the user pod.
2643 * @param {boolean} enable
2644 */
2607 togglePinTransitions: function(enable) { 2645 togglePinTransitions: function(enable) {
2608 for (var i = 0; i < this.pods.length; ++i) 2646 for (var i = 0; i < this.pods.length; ++i)
2609 this.pods[i].toggleTransitions(enable); 2647 this.pods[i].toggleTransitions(enable);
2610 }, 2648 },
2611 2649
2650 /**
2651 * Performs visual changes on the user pod if there is an error.
2652 * @param {boolean} visible Whether to show or hide the display.
2653 */
2654 setFocusedPodErrorDisplay: function(visible) {
2655 if (this.focusedPod_)
2656 this.focusedPod_.setErrorDisplay(visible);
2657 },
2658
2659 /**
2660 * Shows or hides the pin keyboard for the current focused pod.
2661 * @param {boolean} visible
2662 */
2612 setFocusedPodPinVisibility: function(visible) { 2663 setFocusedPodPinVisibility: function(visible) {
2613 if (this.focusedPod_ && this.focusedPod_.user.showPin) 2664 if (this.focusedPod_ && this.focusedPod_.user.showPin)
2614 this.focusedPod_.setPinVisibility(visible); 2665 this.focusedPod_.setPinVisibility(visible);
2615 }, 2666 },
2616 2667
2617 /** 2668 /**
2618 * Runs app with a given id from the list of loaded apps. 2669 * Runs app with a given id from the list of loaded apps.
2619 * @param {!string} app_id of an app to run. 2670 * @param {!string} app_id of an app to run.
2620 * @param {boolean=} opt_diagnosticMode Whether to run the app in 2671 * @param {boolean=} opt_diagnosticMode Whether to run the app in
2621 * diagnostic mode. Default is false. 2672 * diagnostic mode. Default is false.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 /** 3019 /**
2969 * Called when window was resized. 3020 * Called when window was resized.
2970 */ 3021 */
2971 onWindowResize: function() { 3022 onWindowResize: function() {
2972 var layout = this.calculateLayout_(); 3023 var layout = this.calculateLayout_();
2973 if (layout.columns != this.columns || layout.rows != this.rows) 3024 if (layout.columns != this.columns || layout.rows != this.rows)
2974 this.placePods_(); 3025 this.placePods_();
2975 3026
2976 // Wrap this in a set timeout so the function is called after the pod is 3027 // Wrap this in a set timeout so the function is called after the pod is
2977 // finished transitioning so that we work with the final pod dimensions. 3028 // finished transitioning so that we work with the final pod dimensions.
2978 setTimeout(function(podrow) { 3029 setTimeout(function() {
2979 podrow.scrollFocusedPodIntoView(); 3030 this.scrollFocusedPodIntoView();
2980 }, 200, this); 3031 }.bind(this), 200);
jdufault 2016/08/30 21:02:26 Where does 200 come from?
sammiequon 2016/08/30 22:28:27 Done.
2981 }, 3032 },
2982 3033
2983 /** 3034 /**
2984 * Returns width of podrow having |columns| number of columns. 3035 * Returns width of podrow having |columns| number of columns.
2985 * @private 3036 * @private
2986 */ 3037 */
2987 columnsToWidth_: function(columns) { 3038 columnsToWidth_: function(columns) {
2988 var isDesktopUserManager = Oobe.getInstance().displayType == 3039 var isDesktopUserManager = Oobe.getInstance().displayType ==
2989 DISPLAY_TYPE.DESKTOP_USER_MANAGER; 3040 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
2990 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] : 3041 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] :
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
3573 if (pod && pod.multiProfilesPolicyApplied) { 3624 if (pod && pod.multiProfilesPolicyApplied) {
3574 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3625 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3575 } 3626 }
3576 } 3627 }
3577 }; 3628 };
3578 3629
3579 return { 3630 return {
3580 PodRow: PodRow 3631 PodRow: PodRow
3581 }; 3632 };
3582 }); 3633 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698