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

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

Issue 2875513002: Single user pod implementation for new login screen (Closed)
Patch Set: Address comments Created 3 years, 7 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 30 matching lines...) Expand all
41 * Maximal number of rows if sign-in banner is displayed alonside. 41 * Maximal number of rows if sign-in banner is displayed alonside.
42 * @type {number} 42 * @type {number}
43 * @const 43 * @const
44 */ 44 */
45 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2; 45 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2;
46 46
47 /** 47 /**
48 * Variables used for pod placement processing. Width and height should be 48 * Variables used for pod placement processing. Width and height should be
49 * synced with computed CSS sizes of pods. 49 * synced with computed CSS sizes of pods.
50 */ 50 */
51 var CROS_POD_WIDTH = 180; 51 var CROS_POD_WIDTH = 306;
52 var DESKTOP_POD_WIDTH = 180; 52 var DESKTOP_POD_WIDTH = 180;
53 var MD_DESKTOP_POD_WIDTH = 160; 53 var MD_DESKTOP_POD_WIDTH = 160;
54 var PUBLIC_EXPANDED_BASIC_WIDTH = 500; 54 var PUBLIC_EXPANDED_BASIC_WIDTH = 500;
55 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610; 55 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610;
56 var CROS_POD_HEIGHT = 213; 56 var CROS_POD_HEIGHT = 346;
57 var DESKTOP_POD_HEIGHT = 226; 57 var DESKTOP_POD_HEIGHT = 226;
58 var MD_DESKTOP_POD_HEIGHT = 200; 58 var MD_DESKTOP_POD_HEIGHT = 200;
59 var POD_ROW_PADDING = 10; 59 var POD_ROW_PADDING = 10;
60 var DESKTOP_ROW_PADDING = 32; 60 var DESKTOP_ROW_PADDING = 32;
61 var CUSTOM_ICON_CONTAINER_SIZE = 40; 61 var CUSTOM_ICON_CONTAINER_SIZE = 40;
62 var CROS_PIN_POD_HEIGHT = 417; 62 var CROS_PIN_POD_HEIGHT = 417;
63 63
64 /** 64 /**
65 * Minimal padding between user pod and virtual keyboard. 65 * Minimal padding between user pod and virtual keyboard.
66 * @type {number} 66 * @type {number}
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1078
1079 /** 1079 /**
1080 * Gets action box menu title, user email item. 1080 * Gets action box menu title, user email item.
1081 * @type {!HTMLSpanElement} 1081 * @type {!HTMLSpanElement}
1082 */ 1082 */
1083 get actionBoxMenuTitleEmailElement() { 1083 get actionBoxMenuTitleEmailElement() {
1084 return this.querySelector('.action-box-menu-title-email'); 1084 return this.querySelector('.action-box-menu-title-email');
1085 }, 1085 },
1086 1086
1087 /** 1087 /**
1088 * Gets action box menu, remove user command item.
1089 * @type {!HTMLInputElement}
1090 */
1091 get actionBoxMenuCommandElement() {
1092 return this.querySelector('.action-box-menu-remove-command');
1093 },
1094
1095 /**
1096 * Gets action box menu, remove user command item div. 1088 * Gets action box menu, remove user command item div.
1097 * @type {!HTMLInputElement} 1089 * @type {!HTMLInputElement}
1098 */ 1090 */
1099 get actionBoxMenuRemoveElement() { 1091 get actionBoxMenuRemoveElement() {
1100 return this.querySelector('.action-box-menu-remove'); 1092 return this.querySelector('.action-box-menu-remove');
1101 }, 1093 },
1102 1094
1103 /** 1095 /**
1104 * Gets action box menu, remove user command item div. 1096 * Gets action box menu, remove user command item div.
1105 * @type {!HTMLInputElement} 1097 * @type {!HTMLInputElement}
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 this.actionBoxMenuRemoveElement.setAttribute( 1178 this.actionBoxMenuRemoveElement.setAttribute(
1187 'aria-label', loadTimeData.getString( 1179 'aria-label', loadTimeData.getString(
1188 'podMenuRemoveItemAccessibleName')); 1180 'podMenuRemoveItemAccessibleName'));
1189 this.actionBoxMenuTitleNameElement.textContent = this.user_.isOwner ? 1181 this.actionBoxMenuTitleNameElement.textContent = this.user_.isOwner ?
1190 loadTimeData.getStringF('ownerUserPattern', this.user_.displayName) : 1182 loadTimeData.getStringF('ownerUserPattern', this.user_.displayName) :
1191 this.user_.displayName; 1183 this.user_.displayName;
1192 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress; 1184 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress;
1193 1185
1194 this.actionBoxMenuTitleEmailElement.hidden = 1186 this.actionBoxMenuTitleEmailElement.hidden =
1195 this.user_.legacySupervisedUser; 1187 this.user_.legacySupervisedUser;
1196
1197 this.actionBoxMenuCommandElement.textContent =
1198 loadTimeData.getString('removeUser');
1199 }, 1188 },
1200 1189
1201 customizeUserPodPerUserType: function() { 1190 customizeUserPodPerUserType: function() {
1202 if (this.user_.childUser && !this.user_.isDesktopUser) { 1191 if (this.user_.childUser && !this.user_.isDesktopUser) {
1203 this.setUserPodIconType('child'); 1192 this.setUserPodIconType('child');
1204 } else if (this.user_.legacySupervisedUser && !this.user_.isDesktopUser) { 1193 } else if (this.user_.legacySupervisedUser && !this.user_.isDesktopUser) {
1205 this.setUserPodIconType('legacySupervised'); 1194 this.setUserPodIconType('legacySupervised');
1206 this.classList.add('legacy-supervised'); 1195 this.classList.add('legacy-supervised');
1207 } else if (this.multiProfilesPolicyApplied) { 1196 } else if (this.multiProfilesPolicyApplied) {
1208 // Mark user pod as not focusable which in addition to the grayed out 1197 // Mark user pod as not focusable which in addition to the grayed out
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 */ 1988 */
2000 handlePodMouseDown_: function(e) { 1989 handlePodMouseDown_: function(e) {
2001 this.userClickAuthAllowed_ = this.parentNode.isFocused(this); 1990 this.userClickAuthAllowed_ = this.parentNode.isFocused(this);
2002 }, 1991 },
2003 1992
2004 /** 1993 /**
2005 * Called when the input of the password element changes. Updates the submit 1994 * Called when the input of the password element changes. Updates the submit
2006 * button color and state and hides the error popup bubble. 1995 * button color and state and hides the error popup bubble.
2007 */ 1996 */
2008 updateInput_: function() { 1997 updateInput_: function() {
1998 var isEmpty = this.passwordElement.value.length == 0;
2009 if (this.submitButton) { 1999 if (this.submitButton) {
2010 this.submitButton.disabled = this.passwordElement.value.length == 0; 2000 this.submitButton.disabled = isEmpty;
2011 if (this.isFingerprintIconShown()) { 2001 if (this.isFingerprintIconShown()) {
2012 this.submitButton.hidden = this.passwordElement.value.length == 0; 2002 this.submitButton.hidden = isEmpty;
2013 } else { 2003 } else {
2014 this.submitButton.hidden = false; 2004 this.submitButton.hidden = false;
2015 } 2005 }
2016 } 2006 }
2017 this.showError = false; 2007 this.showError = false;
2018 $('bubble').hide(); 2008 $('bubble').hide();
2009 var inputLine = this.querySelector('#input-line');
2010 if (inputLine) {
2011 if (!isEmpty)
2012 inputLine.setAttribute('active', 'true');
2013 else
2014 inputLine.removeAttribute('active');
2015 }
2019 }, 2016 },
2020 2017
2021 /** 2018 /**
2022 * Handles input event on the password element. 2019 * Handles input event on the password element.
2023 * @param {Event} e Input event. 2020 * @param {Event} e Input event.
2024 */ 2021 */
2025 handleInputChanged_: function(e) { 2022 handleInputChanged_: function(e) {
2026 this.updateInput_(); 2023 this.updateInput_();
2027 }, 2024 },
2028 2025
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after
3928 this.ownerDocument.addEventListener( 3925 this.ownerDocument.addEventListener(
3929 event, this.listeners_[event][0], this.listeners_[event][1]); 3926 event, this.listeners_[event][0], this.listeners_[event][1]);
3930 } 3927 }
3931 $('login-header-bar').buttonsTabIndex = UserPodTabOrder.HEADER_BAR; 3928 $('login-header-bar').buttonsTabIndex = UserPodTabOrder.HEADER_BAR;
3932 3929
3933 if (this.podPlacementPostponed_) { 3930 if (this.podPlacementPostponed_) {
3934 this.podPlacementPostponed_ = false; 3931 this.podPlacementPostponed_ = false;
3935 this.placePods_(); 3932 this.placePods_();
3936 this.maybePreselectPod(); 3933 this.maybePreselectPod();
3937 } 3934 }
3935
3936 this.updatePodNameArea();
3938 }, 3937 },
3939 3938
3940 /** 3939 /**
3941 * Called when the element is hidden. 3940 * Called when the element is hidden.
3942 */ 3941 */
3943 handleHide: function() { 3942 handleHide: function() {
3944 for (var event in this.listeners_) { 3943 for (var event in this.listeners_) {
3945 this.ownerDocument.removeEventListener( 3944 this.ownerDocument.removeEventListener(
3946 event, this.listeners_[event][0], this.listeners_[event][1]); 3945 event, this.listeners_[event][0], this.listeners_[event][1]);
3947 } 3946 }
3948 $('login-header-bar').buttonsTabIndex = 0; 3947 $('login-header-bar').buttonsTabIndex = 0;
3949 }, 3948 },
3950 3949
3951 /** 3950 /**
3952 * Called when a pod's user image finishes loading. 3951 * Called when a pod's user image finishes loading.
3953 */ 3952 */
3954 handlePodImageLoad: function(pod) { 3953 handlePodImageLoad: function(pod) {
3955 var index = this.podsWithPendingImages_.indexOf(pod); 3954 var index = this.podsWithPendingImages_.indexOf(pod);
3956 if (index == -1) { 3955 if (index == -1) {
3957 return; 3956 return;
3958 } 3957 }
3959 3958
3960 this.podsWithPendingImages_.splice(index, 1); 3959 this.podsWithPendingImages_.splice(index, 1);
3961 if (this.podsWithPendingImages_.length == 0) { 3960 if (this.podsWithPendingImages_.length == 0) {
3962 this.classList.remove('images-loading'); 3961 this.classList.remove('images-loading');
3963 } 3962 }
3964 }, 3963 },
3965 3964
3966 /** 3965 /**
3966 * Makes sure user name is centered in each pod and extra long name
3967 * does not exceed max width.
3968 */
3969 updatePodNameArea: function() {
3970 this.querySelectorAll('.name-container').forEach(function(nameArea) {
3971 var nameElement = nameArea.querySelector('.name');
3972 var leftMargin = (CROS_POD_WIDTH - nameElement.offsetWidth) / 2;
3973 if (leftMargin > 0)
3974 nameArea.style.left = leftMargin + 'px';
3975 else
3976 nameElement.style.width = CROS_POD_WIDTH + 'px';
3977 });
3978 },
3979
3980 /**
3967 * Preselects pod, if needed. 3981 * Preselects pod, if needed.
3968 */ 3982 */
3969 maybePreselectPod: function() { 3983 maybePreselectPod: function() {
3970 var pod = this.preselectedPod; 3984 var pod = this.preselectedPod;
3971 this.focusPod(pod); 3985 this.focusPod(pod);
3972 3986
3973 // Hide user-type-bubble in case all user pods are disabled and we focus 3987 // Hide user-type-bubble in case all user pods are disabled and we focus
3974 // first pod. 3988 // first pod.
3975 if (pod && pod.multiProfilesPolicyApplied) { 3989 if (pod && pod.multiProfilesPolicyApplied) {
3976 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3990 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3977 } 3991 }
3978 } 3992 }
3979 }; 3993 };
3980 3994
3981 return { 3995 return {
3982 PodRow: PodRow 3996 PodRow: PodRow
3983 }; 3997 };
3984 }); 3998 });
OLDNEW
« no previous file with comments | « ui/login/account_picker/md_user_pod_row.css ('k') | ui/login/account_picker/md_user_pod_template.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698