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

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 8 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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 }, 821 },
819 822
820 /** 823 /**
821 * Height number of pixels. 824 * Height number of pixels.
822 */ 825 */
823 get height() { 826 get height() {
824 return this.offsetHeight; 827 return this.offsetHeight;
825 }, 828 },
826 829
827 /** 830 /**
828 * Gets the authorization element of the pod.
829 * @type {!HTMLDivElement}
830 */
831 get authElement() {
832 return this.querySelector('.auth-container');
833 },
834
835 /**
836 * Gets image pane element.
837 * @type {!HTMLDivElement}
838 */
839 get imagePaneElement() {
840 return this.querySelector('.user-image-pane');
841 },
842
843 /**
844 * Gets image element. 831 * Gets image element.
845 * @type {!HTMLImageElement} 832 * @type {!HTMLImageElement}
846 */ 833 */
847 get imageElement() { 834 get imageElement() {
848 return this.querySelector('.user-image'); 835 return this.querySelector('.user-image');
849 }, 836 },
850 837
851 /** 838 /**
852 * Gets name element. 839 * Gets name element.
853 * @type {!HTMLDivElement} 840 * @type {!HTMLDivElement}
(...skipping 29 matching lines...) Expand all
883 /** 870 /**
884 * Gets the password label, which is used to show a message where the 871 * Gets the password label, which is used to show a message where the
885 * password field is normally. 872 * password field is normally.
886 * @type {!HTMLInputElement} 873 * @type {!HTMLInputElement}
887 */ 874 */
888 get passwordLabelElement() { 875 get passwordLabelElement() {
889 return this.querySelector('.password-label'); 876 return this.querySelector('.password-label');
890 }, 877 },
891 878
892 /** 879 /**
893 * Gets the pin-container of the pod.
894 * @type {!HTMLDivElement}
895 */
896 get pinContainer() {
897 return this.querySelector('.pin-container');
898 },
899
900 /**
901 * Gets the pin-keyboard of the pod. 880 * Gets the pin-keyboard of the pod.
902 * @type {!HTMLElement} 881 * @type {!HTMLElement}
903 */ 882 */
904 get pinKeyboard() { 883 get pinKeyboard() {
905 return this.querySelector('pin-keyboard'); 884 return this.querySelector('pin-keyboard');
906 }, 885 },
907 886
908 /** 887 /**
909 * Gets user online sign in hint element. 888 * Gets user online sign in hint element.
910 * @type {!HTMLDivElement} 889 * @type {!HTMLDivElement}
911 */ 890 */
912 get reauthWarningElement() { 891 get reauthWarningElement() {
913 return this.querySelector('.reauth-hint-container'); 892 return this.querySelector('.reauth-hint-container');
914 }, 893 },
915 894
916 /** 895 /**
917 * Gets the signed in indicator of the pod.
918 * @type {!HTMLDivElement}
919 */
920 get signInElement() {
921 return this.querySelector('.signed-in-indicator');
922 },
923
924 /**
925 * Gets the container holding the launch app button. 896 * Gets the container holding the launch app button.
926 * @type {!HTMLButtonElement} 897 * @type {!HTMLButtonElement}
927 */ 898 */
928 get launchAppButtonContainerElement() { 899 get launchAppButtonContainerElement() {
929 return this.querySelector('.launch-app-button-container'); 900 return this.querySelector('.launch-app-button-container');
930 }, 901 },
931 902
932 /** 903 /**
933 * Gets launch app button. 904 * Gets launch app button.
934 * @type {!HTMLButtonElement} 905 * @type {!HTMLButtonElement}
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; 1090 this.querySelector('.mp-policy-not-allowed-msg').hidden = false;
1120 } else if (this.user_.isApp) { 1091 } else if (this.user_.isApp) {
1121 this.setUserPodIconType('app'); 1092 this.setUserPodIconType('app');
1122 } 1093 }
1123 }, 1094 },
1124 1095
1125 toggleTransitions: function(enable) { 1096 toggleTransitions: function(enable) {
1126 this.classList.toggle('flying-pin-pod', enable); 1097 this.classList.toggle('flying-pin-pod', enable);
1127 }, 1098 },
1128 1099
1100 updatePinClass_: function(element, enable) {
1101 element.classList.toggle('pin-enabled', enable);
1102 element.classList.toggle('pin-disabled', !enable);
1103 },
1104
1129 setPinVisibility: function(visible) { 1105 setPinVisibility: function(visible) {
1130 var elements = [this, this.authElement, this.imagePaneElement, 1106 var elements = this.getElementsByClassName('pin-tag');
1131 this.imageElement, this.pinContainer]; 1107 for (var i = 0; i < elements.length; ++i)
1132 1108 this.updatePinClass_(elements[i], visible);
1133 for (var idx = 0; idx < elements.length; idx++) { 1109 this.updatePinClass_(this, visible);
1134 var currentElement = elements[idx];
1135 currentElement.classList.toggle('pin-enabled', visible);
1136 currentElement.classList.toggle('pin-disabled', !visible);
1137 }
1138 1110
1139 // Set the focus to the input element after showing/hiding pin keyboard. 1111 // Set the focus to the input element after showing/hiding pin keyboard.
1140 if (visible) 1112 if (visible)
1141 this.pinKeyboard.focus(); 1113 this.pinKeyboard.focus();
1142 else 1114 else
1143 this.mainInput.focus(); 1115 this.mainInput.focus();
1144 }, 1116 },
1145 1117
1118 isPinShown: function() {
1119 return this.classList.contains('pin-enabled');
1120 },
1121
1146 setUserPodIconType: function(userTypeClass) { 1122 setUserPodIconType: function(userTypeClass) {
1147 this.userTypeIconAreaElement.classList.add(userTypeClass); 1123 this.userTypeIconAreaElement.classList.add(userTypeClass);
1148 this.userTypeIconAreaElement.hidden = false; 1124 this.userTypeIconAreaElement.hidden = false;
1149 }, 1125 },
1150 1126
1151 /** 1127 /**
1152 * The user that this pod represents. 1128 * The user that this pod represents.
1153 * @type {!Object} 1129 * @type {!Object}
1154 */ 1130 */
1155 user_: undefined, 1131 user_: undefined,
(...skipping 15 matching lines...) Expand all
1171 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); 1147 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING);
1172 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; 1148 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed;
1173 }, 1149 },
1174 1150
1175 /** 1151 /**
1176 * Gets main input element. 1152 * Gets main input element.
1177 * @type {(HTMLButtonElement|HTMLInputElement)} 1153 * @type {(HTMLButtonElement|HTMLInputElement)}
1178 */ 1154 */
1179 get mainInput() { 1155 get mainInput() {
1180 if (this.isAuthTypePassword) { 1156 if (this.isAuthTypePassword) {
1181 if (this.pinContainer.classList.contains('pin-enabled')) 1157 if (this.isPinShown() && this.pinKeyboard.inputElement)
1182 return this.pinKeyboard.inputElement; 1158 return this.pinKeyboard.inputElement;
1183 return this.passwordElement; 1159 return this.passwordElement;
1184 } else if (this.isAuthTypeOnlineSignIn) { 1160 } else if (this.isAuthTypeOnlineSignIn) {
1185 return this; 1161 return this;
1186 } else if (this.isAuthTypeUserClick) { 1162 } else if (this.isAuthTypeUserClick) {
1187 return this.passwordLabelElement; 1163 return this.passwordLabelElement;
1188 } 1164 }
1189 }, 1165 },
1190 1166
1191 /** 1167 /**
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
2985 // One more iteration if it's not enough cells to place all pods. 2961 // One more iteration if it's not enough cells to place all pods.
2986 while (maxWidth >= this.columnsToWidth_(columns + 1) && 2962 while (maxWidth >= this.columnsToWidth_(columns + 1) &&
2987 columns * rows < this.pods.length && 2963 columns * rows < this.pods.length &&
2988 columns < MAX_NUMBER_OF_COLUMNS) { 2964 columns < MAX_NUMBER_OF_COLUMNS) {
2989 ++columns; 2965 ++columns;
2990 } 2966 }
2991 return {columns: columns, rows: rows}; 2967 return {columns: columns, rows: rows};
2992 }, 2968 },
2993 2969
2994 /** 2970 /**
2971 * Calculates the row and column of the given |pod|.
2972 * @param {UserPod} pod Pod we want the row and column of.
2973 * @param {number} columns Columns in the podrow.
2974 * @param {number} rows Rows in the podrow.
2975 * @return {{columns: number, rows: number}}
2976 * @private
2977 */
2978 findPodLocation_: function(pod, columns, rows) {
2979 var column = -1;
2980 var row = -1;
2981 var index = this.pods.indexOf(pod);
2982 if (index != -1) {
2983 row = Math.floor(index / columns);
2984 column = index % columns;
2985 }
2986 if (column == -1 || row == -1) {
jdufault 2016/07/21 19:46:22 How about if (index >= 0) { /* ... */ } e
sammiequon 2016/07/21 19:57:48 Done.
2987 console.error('Pod not found in pod row.');
2988 }
2989 return {column: column, row: row};
2990 },
2991
2992 /**
2995 * Places pods onto their positions onto pod grid. 2993 * Places pods onto their positions onto pod grid.
2996 * @private 2994 * @private
2997 */ 2995 */
2998 placePods_: function() { 2996 placePods_: function() {
2999 var isDesktopUserManager = Oobe.getInstance().displayType == 2997 var isDesktopUserManager = Oobe.getInstance().displayType ==
3000 DISPLAY_TYPE.DESKTOP_USER_MANAGER; 2998 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
3001 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible) 2999 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible)
3002 return; 3000 return;
3003 3001
3004 var layout = this.calculateLayout_(); 3002 var layout = this.calculateLayout_();
3005 var columns = this.columns = layout.columns; 3003 var columns = this.columns = layout.columns;
3006 var rows = this.rows = layout.rows; 3004 var rows = this.rows = layout.rows;
3007 var maxPodsNumber = columns * rows; 3005 var maxPodsNumber = columns * rows;
3008 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] : 3006 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] :
3009 MARGIN_BY_COLUMNS[columns]; 3007 MARGIN_BY_COLUMNS[columns];
3010 this.parentNode.setPreferredSize( 3008 this.parentNode.setPreferredSize(
3011 this.columnsToWidth_(columns), this.rowsToHeight_(rows)); 3009 this.columnsToWidth_(columns), this.rowsToHeight_(rows));
3012 var height = this.userPodHeight_; 3010 var height = this.userPodHeight_;
3013 var width = this.userPodWidth_; 3011 var width = this.userPodWidth_;
3012 var pinPodLocation = { column: columns + 1, row: rows + 1 };
3013 if (this.focusedPod_ && this.focusedPod_.isPinShown())
3014 pinPodLocation = this.findPodLocation_(this.focusedPod_, columns, rows);
3015
3014 this.pods.forEach(function(pod, index) { 3016 this.pods.forEach(function(pod, index) {
3015 if (index >= maxPodsNumber) { 3017 if (index >= maxPodsNumber) {
3016 pod.hidden = true; 3018 pod.hidden = true;
3017 return; 3019 return;
3018 } 3020 }
3019 pod.hidden = false; 3021 pod.hidden = false;
3020 if (pod.offsetHeight != height) { 3022 if (pod.offsetHeight != height &&
3023 pod.offsetHeight != CROS_PIN_POD_HEIGHT) {
3021 console.error('Pod offsetHeight (' + pod.offsetHeight + 3024 console.error('Pod offsetHeight (' + pod.offsetHeight +
3022 ') and POD_HEIGHT (' + height + ') are not equal.'); 3025 ') and POD_HEIGHT (' + height + ') are not equal.');
3023 } 3026 }
3024 if (pod.offsetWidth != width) { 3027 if (pod.offsetWidth != width &&
3028 pod.offsetWidth != CROS_PIN_POD_WIDTH) {
3025 console.error('Pod offsetWidth (' + pod.offsetWidth + 3029 console.error('Pod offsetWidth (' + pod.offsetWidth +
3026 ') and POD_WIDTH (' + width + ') are not equal.'); 3030 ') and POD_WIDTH (' + width + ') are not equal.');
3027 } 3031 }
3028 var column = index % columns; 3032 var column = index % columns;
3029 var row = Math.floor(index / columns); 3033 var row = Math.floor(index / columns);
3034 var offsetFromPin = 0;
3035 if (row == pinPodLocation.row) {
3036 offsetFromPin = PIN_EXTRA_WIDTH / 2;
3037 if (column <= pinPodLocation.column)
3038 offsetFromPin *= -1;
3039 }
3040
3030 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : 3041 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING :
3031 POD_ROW_PADDING; 3042 POD_ROW_PADDING;
3032 pod.left = rowPadding + column * (width + margin); 3043 pod.left = rowPadding + column * (width + margin) + offsetFromPin;
3033 3044
3034 // On desktop, we want the rows to always be equally spaced. 3045 // On desktop, we want the rows to always be equally spaced.
3035 pod.top = isDesktopUserManager ? row * (height + rowPadding) : 3046 pod.top = isDesktopUserManager ? row * (height + rowPadding) :
3036 row * height + rowPadding; 3047 row * height + rowPadding;
3037 }); 3048 });
3038 Oobe.getInstance().updateScreenSize(this.parentNode); 3049 Oobe.getInstance().updateScreenSize(this.parentNode);
3039 }, 3050 },
3040 3051
3041 /** 3052 /**
3042 * Number of columns. 3053 * Number of columns.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3093 } 3104 }
3094 this.insideFocusPod_ = true; 3105 this.insideFocusPod_ = true;
3095 3106
3096 for (var i = 0, pod; pod = this.pods[i]; ++i) { 3107 for (var i = 0, pod; pod = this.pods[i]; ++i) {
3097 if (!this.alwaysFocusSinglePod) { 3108 if (!this.alwaysFocusSinglePod) {
3098 pod.isActionBoxMenuActive = false; 3109 pod.isActionBoxMenuActive = false;
3099 } 3110 }
3100 if (pod != podToFocus) { 3111 if (pod != podToFocus) {
3101 pod.isActionBoxMenuHovered = false; 3112 pod.isActionBoxMenuHovered = false;
3102 pod.classList.remove('focused'); 3113 pod.classList.remove('focused');
3114 pod.setPinVisibility(false);
3103 // On Desktop, the faded style is not set correctly, so we should 3115 // On Desktop, the faded style is not set correctly, so we should
3104 // manually fade out non-focused pods if there is a focused pod. 3116 // manually fade out non-focused pods if there is a focused pod.
3105 if (pod.user.isDesktopUser && podToFocus) 3117 if (pod.user.isDesktopUser && podToFocus)
3106 pod.classList.add('faded'); 3118 pod.classList.add('faded');
3107 else 3119 else
3108 pod.classList.remove('faded'); 3120 pod.classList.remove('faded');
3109 pod.reset(false); 3121 pod.reset(false);
3110 } 3122 }
3111 } 3123 }
3112 3124
3113 // Clear any error messages for previous pod. 3125 // Clear any error messages for previous pod.
3114 if (!this.isFocused(podToFocus)) 3126 if (!this.isFocused(podToFocus))
3115 Oobe.clearErrors(); 3127 Oobe.clearErrors();
3116 3128
3117 var hadFocus = !!this.focusedPod_; 3129 var hadFocus = !!this.focusedPod_;
3118 this.focusedPod_ = podToFocus; 3130 this.focusedPod_ = podToFocus;
3119 if (podToFocus) { 3131 if (podToFocus) {
3132 this.setFocusedPodPinVisibility(true);
3120 podToFocus.classList.remove('faded'); 3133 podToFocus.classList.remove('faded');
3121 podToFocus.classList.add('focused'); 3134 podToFocus.classList.add('focused');
3122 if (!podToFocus.multiProfilesPolicyApplied) { 3135 if (!podToFocus.multiProfilesPolicyApplied) {
3123 podToFocus.classList.toggle('signing-in', false); 3136 podToFocus.classList.toggle('signing-in', false);
3124 if (!opt_skipInputFocus) 3137 if (!opt_skipInputFocus)
3125 podToFocus.focusInput(); 3138 podToFocus.focusInput();
3126 } else { 3139 } else {
3127 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); 3140 podToFocus.userTypeBubbleElement.classList.add('bubble-shown');
3128 // Note it is not necessary to skip this focus request when 3141 // Note it is not necessary to skip this focus request when
3129 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| 3142 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied|
3130 // is false, it doesn't focus on the password input box by default. 3143 // is false, it doesn't focus on the password input box by default.
3131 podToFocus.focus(); 3144 podToFocus.focus();
3132 } 3145 }
3133 3146
3134 // focusPod() automatically loads wallpaper 3147 // focusPod() automatically loads wallpaper
3135 if (!podToFocus.user.isApp) 3148 if (!podToFocus.user.isApp)
3136 chrome.send('focusPod', [podToFocus.user.username]); 3149 chrome.send('focusPod', [podToFocus.user.username]);
3137 this.firstShown_ = false; 3150 this.firstShown_ = false;
3138 this.lastFocusedPod_ = podToFocus; 3151 this.lastFocusedPod_ = podToFocus;
3139 this.scrollFocusedPodIntoView(); 3152 this.scrollFocusedPodIntoView();
3140 } 3153 }
3141 this.insideFocusPod_ = false; 3154 this.insideFocusPod_ = false;
3155 this.placePods_();
3142 }, 3156 },
3143 3157
3144 /** 3158 /**
3145 * Resets wallpaper to the last active user's wallpaper, if any. 3159 * Resets wallpaper to the last active user's wallpaper, if any.
3146 */ 3160 */
3147 loadLastWallpaper: function() { 3161 loadLastWallpaper: function() {
3148 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) 3162 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp)
3149 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); 3163 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]);
3150 }, 3164 },
3151 3165
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 if (pod && pod.multiProfilesPolicyApplied) { 3528 if (pod && pod.multiProfilesPolicyApplied) {
3515 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3529 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3516 } 3530 }
3517 } 3531 }
3518 }; 3532 };
3519 3533
3520 return { 3534 return {
3521 PodRow: PodRow 3535 PodRow: PodRow
3522 }; 3536 };
3523 }); 3537 });
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