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

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

Issue 2129253002: Multi-pod support for lock screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed patch set 5 errors. Created 4 years, 5 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = 213;
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_WIDTH = 270;
63 var CROS_PIN_POD_HEIGHT = 594;
64 var PIN_EXTRA_WIDTH = 90;
62 65
63 /** 66 /**
64 * Minimal padding between user pod and virtual keyboard. 67 * Minimal padding between user pod and virtual keyboard.
65 * @type {number} 68 * @type {number}
66 * @const 69 * @const
67 */ 70 */
68 var USER_POD_KEYBOARD_MIN_PADDING = 20; 71 var USER_POD_KEYBOARD_MIN_PADDING = 20;
69 72
70 /** 73 /**
71 * Maximum time for which the pod row remains hidden until all user images 74 * Maximum time for which the pod row remains hidden until all user images
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 }, 816 },
814 817
815 /** 818 /**
816 * Height number of pixels. 819 * Height number of pixels.
817 */ 820 */
818 get height() { 821 get height() {
819 return this.offsetHeight; 822 return this.offsetHeight;
820 }, 823 },
821 824
822 /** 825 /**
823 * Gets the authorization element of the pod.
824 * @type {!HTMLDivElement}
825 */
826 get authElement() {
827 return this.querySelector('.auth-container');
828 },
829
830 /**
831 * Gets image pane element.
832 * @type {!HTMLDivElement}
833 */
834 get imagePaneElement() {
835 return this.querySelector('.user-image-pane');
836 },
837
838 /**
839 * Gets image element. 826 * Gets image element.
840 * @type {!HTMLImageElement} 827 * @type {!HTMLImageElement}
841 */ 828 */
842 get imageElement() { 829 get imageElement() {
843 return this.querySelector('.user-image'); 830 return this.querySelector('.user-image');
844 }, 831 },
845 832
846 /** 833 /**
847 * Gets name element. 834 * Gets name element.
848 * @type {!HTMLDivElement} 835 * @type {!HTMLDivElement}
(...skipping 29 matching lines...) Expand all
878 /** 865 /**
879 * Gets the password label, which is used to show a message where the 866 * Gets the password label, which is used to show a message where the
880 * password field is normally. 867 * password field is normally.
881 * @type {!HTMLInputElement} 868 * @type {!HTMLInputElement}
882 */ 869 */
883 get passwordLabelElement() { 870 get passwordLabelElement() {
884 return this.querySelector('.password-label'); 871 return this.querySelector('.password-label');
885 }, 872 },
886 873
887 /** 874 /**
888 * Gets the pin-container of the pod.
889 * @type {!HTMLDivElement}
890 */
891 get pinContainer() {
892 return this.querySelector('.pin-container');
893 },
894
895 /**
896 * Gets the pin-keyboard of the pod. 875 * Gets the pin-keyboard of the pod.
897 * @type {!HTMLElement} 876 * @type {!HTMLElement}
898 */ 877 */
899 get pinKeyboard() { 878 get pinKeyboard() {
900 return this.querySelector('pin-keyboard'); 879 return this.querySelector('pin-keyboard');
901 }, 880 },
902 881
903 /** 882 /**
904 * Gets user online sign in hint element. 883 * Gets user online sign in hint element.
905 * @type {!HTMLDivElement} 884 * @type {!HTMLDivElement}
906 */ 885 */
907 get reauthWarningElement() { 886 get reauthWarningElement() {
908 return this.querySelector('.reauth-hint-container'); 887 return this.querySelector('.reauth-hint-container');
909 }, 888 },
910 889
911 /** 890 /**
912 * Gets the signed in indicator of the pod.
913 * @type {!HTMLDivElement}
914 */
915 get signInElement() {
916 return this.querySelector('.signed-in-indicator');
917 },
918
919 /**
920 * Gets the container holding the launch app button. 891 * Gets the container holding the launch app button.
921 * @type {!HTMLButtonElement} 892 * @type {!HTMLButtonElement}
922 */ 893 */
923 get launchAppButtonContainerElement() { 894 get launchAppButtonContainerElement() {
924 return this.querySelector('.launch-app-button-container'); 895 return this.querySelector('.launch-app-button-container');
925 }, 896 },
926 897
927 /** 898 /**
928 * Gets launch app button. 899 * Gets launch app button.
929 * @type {!HTMLButtonElement} 900 * @type {!HTMLButtonElement}
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; 1085 this.querySelector('.mp-policy-not-allowed-msg').hidden = false;
1115 } else if (this.user_.isApp) { 1086 } else if (this.user_.isApp) {
1116 this.setUserPodIconType('app'); 1087 this.setUserPodIconType('app');
1117 } 1088 }
1118 }, 1089 },
1119 1090
1120 toggleTransitions: function(enable) { 1091 toggleTransitions: function(enable) {
1121 this.classList.toggle('flying-pin-pod', enable); 1092 this.classList.toggle('flying-pin-pod', enable);
1122 }, 1093 },
1123 1094
1095 setPinClass_: function(element, enable) {
1096 element.classList.toggle('pin-enabled', enable);
1097 element.classList.toggle('pin-disabled', !enable);
1098 },
1099
1124 setPinVisibility: function(visible) { 1100 setPinVisibility: function(visible) {
1125 var elements = [this, this.authElement, this.imagePaneElement, 1101 [].forEach.call(
jdufault 2016/07/19 18:22:19 I don't think the forEach improves readability her
sammiequon 2016/07/20 17:11:06 Done.
1126 this.imageElement, this.pinContainer]; 1102 this.getElementsByClassName('pin-tag'), function(el) {
1127 1103 this.setPinClass_(el, visible);
1128 for (var idx = 0; idx < elements.length; idx++) { 1104 }, this);
1129 var currentElement = elements[idx]; 1105 this.setPinClass_(this, visible);
1130 currentElement.classList.toggle('pin-enabled', visible);
1131 currentElement.classList.toggle('pin-disabled', !visible);
1132 }
1133 1106
1134 // Set the focus to the input element after showing/hiding pin keyboard. 1107 // Set the focus to the input element after showing/hiding pin keyboard.
1135 if (visible) 1108 if (visible)
1136 this.pinKeyboard.focus(); 1109 this.pinKeyboard.focus();
1137 else 1110 else
1138 this.mainInput.focus(); 1111 this.mainInput.focus();
1139 }, 1112 },
1140 1113
1114 isPinShown: function() {
1115 return this.classList.contains('pin-enabled');
1116 },
1117
1141 setUserPodIconType: function(userTypeClass) { 1118 setUserPodIconType: function(userTypeClass) {
1142 this.userTypeIconAreaElement.classList.add(userTypeClass); 1119 this.userTypeIconAreaElement.classList.add(userTypeClass);
1143 this.userTypeIconAreaElement.hidden = false; 1120 this.userTypeIconAreaElement.hidden = false;
1144 }, 1121 },
1145 1122
1146 /** 1123 /**
1147 * The user that this pod represents. 1124 * The user that this pod represents.
1148 * @type {!Object} 1125 * @type {!Object}
1149 */ 1126 */
1150 user_: undefined, 1127 user_: undefined,
(...skipping 15 matching lines...) Expand all
1166 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); 1143 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING);
1167 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; 1144 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed;
1168 }, 1145 },
1169 1146
1170 /** 1147 /**
1171 * Gets main input element. 1148 * Gets main input element.
1172 * @type {(HTMLButtonElement|HTMLInputElement)} 1149 * @type {(HTMLButtonElement|HTMLInputElement)}
1173 */ 1150 */
1174 get mainInput() { 1151 get mainInput() {
1175 if (this.isAuthTypePassword) { 1152 if (this.isAuthTypePassword) {
1176 if (this.pinContainer.classList.contains('pin-enabled')) 1153 if (this.isPinShown() && this.pinKeyboard.inputElement)
1177 return this.pinKeyboard.inputElement; 1154 return this.pinKeyboard.inputElement;
1178 return this.passwordElement; 1155 return this.passwordElement;
1179 } else if (this.isAuthTypeOnlineSignIn) { 1156 } else if (this.isAuthTypeOnlineSignIn) {
1180 return this; 1157 return this;
1181 } else if (this.isAuthTypeUserClick) { 1158 } else if (this.isAuthTypeUserClick) {
1182 return this.passwordLabelElement; 1159 return this.passwordLabelElement;
1183 } 1160 }
1184 }, 1161 },
1185 1162
1186 /** 1163 /**
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after
2976 // One more iteration if it's not enough cells to place all pods. 2953 // One more iteration if it's not enough cells to place all pods.
2977 while (maxWidth >= this.columnsToWidth_(columns + 1) && 2954 while (maxWidth >= this.columnsToWidth_(columns + 1) &&
2978 columns * rows < this.pods.length && 2955 columns * rows < this.pods.length &&
2979 columns < MAX_NUMBER_OF_COLUMNS) { 2956 columns < MAX_NUMBER_OF_COLUMNS) {
2980 ++columns; 2957 ++columns;
2981 } 2958 }
2982 return {columns: columns, rows: rows}; 2959 return {columns: columns, rows: rows};
2983 }, 2960 },
2984 2961
2985 /** 2962 /**
2963 * Calculates the row and column of the |pod| with the pin keyboard (if
2964 * any), otherwise returns a column and row greater than |maxPods|.
2965 * @return {{columns: number, rows: number}}
jdufault 2016/07/19 18:22:19 Add type annotations for parameters. Return type
sammiequon 2016/07/20 17:11:06 Added type annotations. Return type can be nullabl
jdufault 2016/07/20 17:41:26 console.error doesn't abort JS execution, so { col
jdufault 2016/07/20 18:20:04 Please address this comment :)
sammiequon 2016/07/20 19:00:37 As per offline conversation, {column: -1, row: -1}
2966 */
2967 findPinPodLocation_: function(pod, columns, rows, maxPods) {
jdufault 2016/07/19 18:22:19 Rename to findPodLocation_
sammiequon 2016/07/20 17:11:06 Done.
2968 var column = maxPods + 1;
2969 var row = maxPods + 1;
2970 if (pod && pod.isPinShown()) {
jdufault 2016/07/19 18:22:19 pod should always be valid. This function doesn't
sammiequon 2016/07/20 17:11:06 I moved this check outside as suggested, put focus
2971 this.pods.forEach(function(currentPod, index) {
2972 var currentColumn = index % columns;
2973 var currentRow = Math.floor(index / columns);
2974 if (currentPod == pod) {
2975 row = currentRow;
2976 column = currentColumn;
2977 } else if (currentPod.isPinShown()) {
2978 // Only the focused pod should ever show the PIN keyboard.
jdufault 2016/07/19 18:22:19 Remove error message, this function doesn't need t
sammiequon 2016/07/20 17:11:06 Done.
2979 console.error('Non-focused pod is showing a PIN keyboard.');
2980 }
2981 });
2982 }
2983 return {column: column, row: row};
jdufault 2016/07/19 18:22:19 Initialize column/row to undefined. If they're und
sammiequon 2016/07/20 17:11:06 Done.
2984 },
2985
2986 /**
2986 * Places pods onto their positions onto pod grid. 2987 * Places pods onto their positions onto pod grid.
2987 * @private 2988 * @private
2988 */ 2989 */
2989 placePods_: function() { 2990 placePods_: function() {
2990 var isDesktopUserManager = Oobe.getInstance().displayType == 2991 var isDesktopUserManager = Oobe.getInstance().displayType ==
2991 DISPLAY_TYPE.DESKTOP_USER_MANAGER; 2992 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
2992 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible) 2993 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible)
2993 return; 2994 return;
2994 2995
2995 var layout = this.calculateLayout_(); 2996 var layout = this.calculateLayout_();
2996 var columns = this.columns = layout.columns; 2997 var columns = this.columns = layout.columns;
2997 var rows = this.rows = layout.rows; 2998 var rows = this.rows = layout.rows;
2998 var maxPodsNumber = columns * rows; 2999 var maxPodsNumber = columns * rows;
2999 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] : 3000 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] :
3000 MARGIN_BY_COLUMNS[columns]; 3001 MARGIN_BY_COLUMNS[columns];
3001 this.parentNode.setPreferredSize( 3002 this.parentNode.setPreferredSize(
3002 this.columnsToWidth_(columns), this.rowsToHeight_(rows)); 3003 this.columnsToWidth_(columns), this.rowsToHeight_(rows));
3003 var height = this.userPodHeight_; 3004 var height = this.userPodHeight_;
3004 var width = this.userPodWidth_; 3005 var width = this.userPodWidth_;
3006 var pinPodLocation = this.findPinPodLocation_(
jdufault 2016/07/19 18:22:19 Initialize pinPodLocation by default to { column+1
sammiequon 2016/07/20 17:11:06 Done.
3007 this.focusedPod_, columns, rows, maxPodsNumber);
3008
3005 this.pods.forEach(function(pod, index) { 3009 this.pods.forEach(function(pod, index) {
3006 if (index >= maxPodsNumber) { 3010 if (index >= maxPodsNumber) {
3007 pod.hidden = true; 3011 pod.hidden = true;
3008 return; 3012 return;
3009 } 3013 }
3010 pod.hidden = false; 3014 pod.hidden = false;
3011 if (pod.offsetHeight != height) { 3015 if (pod.offsetHeight != height &&
3016 pod.offsetHeight != CROS_PIN_POD_HEIGHT) {
3012 console.error('Pod offsetHeight (' + pod.offsetHeight + 3017 console.error('Pod offsetHeight (' + pod.offsetHeight +
3013 ') and POD_HEIGHT (' + height + ') are not equal.'); 3018 ') and POD_HEIGHT (' + height + ') are not equal.');
3014 } 3019 }
3015 if (pod.offsetWidth != width) { 3020 if (pod.offsetWidth != width &&
3021 pod.offsetWidth != CROS_PIN_POD_WIDTH) {
3016 console.error('Pod offsetWidth (' + pod.offsetWidth + 3022 console.error('Pod offsetWidth (' + pod.offsetWidth +
3017 ') and POD_WIDTH (' + width + ') are not equal.'); 3023 ') and POD_WIDTH (' + width + ') are not equal.');
3018 } 3024 }
3019 var column = index % columns; 3025 var column = index % columns;
3020 var row = Math.floor(index / columns); 3026 var row = Math.floor(index / columns);
3027 var offsetFromPin = 0;
3028 if (row == pinPodLocation.row) {
3029 offsetFromPin = PIN_EXTRA_WIDTH / 2;
3030 if (column <= pinPodLocation.column)
3031 offsetFromPin *= -1;
3032 }
3033
3021 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : 3034 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING :
3022 POD_ROW_PADDING; 3035 POD_ROW_PADDING;
3023 pod.left = rowPadding + column * (width + margin); 3036 pod.left = rowPadding + column * (width + margin) + offsetFromPin;
3024 3037
3025 // On desktop, we want the rows to always be equally spaced. 3038 // On desktop, we want the rows to always be equally spaced.
3026 pod.top = isDesktopUserManager ? row * (height + rowPadding) : 3039 pod.top = isDesktopUserManager ? row * (height + rowPadding) :
3027 row * height + rowPadding; 3040 row * height + rowPadding;
3028 }); 3041 });
3029 Oobe.getInstance().updateScreenSize(this.parentNode); 3042 Oobe.getInstance().updateScreenSize(this.parentNode);
3030 }, 3043 },
3031 3044
3032 /** 3045 /**
3033 * Number of columns. 3046 * Number of columns.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3084 } 3097 }
3085 this.insideFocusPod_ = true; 3098 this.insideFocusPod_ = true;
3086 3099
3087 for (var i = 0, pod; pod = this.pods[i]; ++i) { 3100 for (var i = 0, pod; pod = this.pods[i]; ++i) {
3088 if (!this.alwaysFocusSinglePod) { 3101 if (!this.alwaysFocusSinglePod) {
3089 pod.isActionBoxMenuActive = false; 3102 pod.isActionBoxMenuActive = false;
3090 } 3103 }
3091 if (pod != podToFocus) { 3104 if (pod != podToFocus) {
3092 pod.isActionBoxMenuHovered = false; 3105 pod.isActionBoxMenuHovered = false;
3093 pod.classList.remove('focused'); 3106 pod.classList.remove('focused');
3107 pod.setPinVisibility(false);
3094 // On Desktop, the faded style is not set correctly, so we should 3108 // On Desktop, the faded style is not set correctly, so we should
3095 // manually fade out non-focused pods if there is a focused pod. 3109 // manually fade out non-focused pods if there is a focused pod.
3096 if (pod.user.isDesktopUser && podToFocus) 3110 if (pod.user.isDesktopUser && podToFocus)
3097 pod.classList.add('faded'); 3111 pod.classList.add('faded');
3098 else 3112 else
3099 pod.classList.remove('faded'); 3113 pod.classList.remove('faded');
3100 pod.reset(false); 3114 pod.reset(false);
3101 } 3115 }
3102 } 3116 }
3103 3117
3104 // Clear any error messages for previous pod. 3118 // Clear any error messages for previous pod.
3105 if (!this.isFocused(podToFocus)) 3119 if (!this.isFocused(podToFocus))
3106 Oobe.clearErrors(); 3120 Oobe.clearErrors();
3107 3121
3108 var hadFocus = !!this.focusedPod_; 3122 var hadFocus = !!this.focusedPod_;
3109 this.focusedPod_ = podToFocus; 3123 this.focusedPod_ = podToFocus;
3110 if (podToFocus) { 3124 if (podToFocus) {
3125 this.setFocusedPodPinVisibility(true);
3111 podToFocus.classList.remove('faded'); 3126 podToFocus.classList.remove('faded');
3112 podToFocus.classList.add('focused'); 3127 podToFocus.classList.add('focused');
3113 if (!podToFocus.multiProfilesPolicyApplied) { 3128 if (!podToFocus.multiProfilesPolicyApplied) {
3114 podToFocus.classList.toggle('signing-in', false); 3129 podToFocus.classList.toggle('signing-in', false);
3115 if (!opt_skipInputFocus) 3130 if (!opt_skipInputFocus)
3116 podToFocus.focusInput(); 3131 podToFocus.focusInput();
3117 } else { 3132 } else {
3118 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); 3133 podToFocus.userTypeBubbleElement.classList.add('bubble-shown');
3119 // Note it is not necessary to skip this focus request when 3134 // Note it is not necessary to skip this focus request when
3120 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| 3135 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied|
3121 // is false, it doesn't focus on the password input box by default. 3136 // is false, it doesn't focus on the password input box by default.
3122 podToFocus.focus(); 3137 podToFocus.focus();
3123 } 3138 }
3124 3139
3125 // focusPod() automatically loads wallpaper 3140 // focusPod() automatically loads wallpaper
3126 if (!podToFocus.user.isApp) 3141 if (!podToFocus.user.isApp)
3127 chrome.send('focusPod', [podToFocus.user.username]); 3142 chrome.send('focusPod', [podToFocus.user.username]);
3128 this.firstShown_ = false; 3143 this.firstShown_ = false;
3129 this.lastFocusedPod_ = podToFocus; 3144 this.lastFocusedPod_ = podToFocus;
3130 this.scrollFocusedPodIntoView(); 3145 this.scrollFocusedPodIntoView();
3131 } 3146 }
3132 this.insideFocusPod_ = false; 3147 this.insideFocusPod_ = false;
3148 this.placePods_();
3133 }, 3149 },
3134 3150
3135 /** 3151 /**
3136 * Resets wallpaper to the last active user's wallpaper, if any. 3152 * Resets wallpaper to the last active user's wallpaper, if any.
3137 */ 3153 */
3138 loadLastWallpaper: function() { 3154 loadLastWallpaper: function() {
3139 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) 3155 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp)
3140 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); 3156 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]);
3141 }, 3157 },
3142 3158
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3505 if (pod && pod.multiProfilesPolicyApplied) { 3521 if (pod && pod.multiProfilesPolicyApplied) {
3506 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3522 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3507 } 3523 }
3508 } 3524 }
3509 }; 3525 };
3510 3526
3511 return { 3527 return {
3512 PodRow: PodRow 3528 PodRow: PodRow
3513 }; 3529 };
3514 }); 3530 });
OLDNEW
« no previous file with comments | « ui/login/account_picker/user_pod_row.css ('k') | ui/login/account_picker/user_pod_template.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698