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 6 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;
2980 var row;
2981 this.pods.forEach(function(currentPod, index) {
2982 var currentColumn = index % columns;
2983 var currentRow = Math.floor(index / columns);
2984 if (currentPod == pod) {
2985 row = currentRow;
jdufault 2016/07/20 17:41:26 Eliminate the currentColumn and currentRow tempora
sammiequon 2016/07/20 17:59:43 Done.
2986 column = currentColumn;
2987 }
2988 });
2989 if (!column || !row) {
2990 console.error('Pod not found in pod row.');
2991 }
2992 return {column: column, row: row};
2993 },
2994
2995 /**
2995 * Places pods onto their positions onto pod grid. 2996 * Places pods onto their positions onto pod grid.
2996 * @private 2997 * @private
2997 */ 2998 */
2998 placePods_: function() { 2999 placePods_: function() {
2999 var isDesktopUserManager = Oobe.getInstance().displayType == 3000 var isDesktopUserManager = Oobe.getInstance().displayType ==
3000 DISPLAY_TYPE.DESKTOP_USER_MANAGER; 3001 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
3001 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible) 3002 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible)
3002 return; 3003 return;
3003 3004
3004 var layout = this.calculateLayout_(); 3005 var layout = this.calculateLayout_();
3005 var columns = this.columns = layout.columns; 3006 var columns = this.columns = layout.columns;
3006 var rows = this.rows = layout.rows; 3007 var rows = this.rows = layout.rows;
3007 var maxPodsNumber = columns * rows; 3008 var maxPodsNumber = columns * rows;
3008 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] : 3009 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] :
3009 MARGIN_BY_COLUMNS[columns]; 3010 MARGIN_BY_COLUMNS[columns];
3010 this.parentNode.setPreferredSize( 3011 this.parentNode.setPreferredSize(
3011 this.columnsToWidth_(columns), this.rowsToHeight_(rows)); 3012 this.columnsToWidth_(columns), this.rowsToHeight_(rows));
3012 var height = this.userPodHeight_; 3013 var height = this.userPodHeight_;
3013 var width = this.userPodWidth_; 3014 var width = this.userPodWidth_;
3015 var pinPodLocation = { column: columns + 1, row: rows + 1 };
3016 if (this.focusedPod_ && this.focusedPod_.isPinShown())
3017 pinPodLocation = this.findPodLocation_(this.focusedPod_, columns, rows);
3018
3014 this.pods.forEach(function(pod, index) { 3019 this.pods.forEach(function(pod, index) {
3015 if (index >= maxPodsNumber) { 3020 if (index >= maxPodsNumber) {
3016 pod.hidden = true; 3021 pod.hidden = true;
3017 return; 3022 return;
3018 } 3023 }
3019 pod.hidden = false; 3024 pod.hidden = false;
3020 if (pod.offsetHeight != height) { 3025 if (pod.offsetHeight != height &&
3026 pod.offsetHeight != CROS_PIN_POD_HEIGHT) {
3021 console.error('Pod offsetHeight (' + pod.offsetHeight + 3027 console.error('Pod offsetHeight (' + pod.offsetHeight +
3022 ') and POD_HEIGHT (' + height + ') are not equal.'); 3028 ') and POD_HEIGHT (' + height + ') are not equal.');
3023 } 3029 }
3024 if (pod.offsetWidth != width) { 3030 if (pod.offsetWidth != width &&
3031 pod.offsetWidth != CROS_PIN_POD_WIDTH) {
3025 console.error('Pod offsetWidth (' + pod.offsetWidth + 3032 console.error('Pod offsetWidth (' + pod.offsetWidth +
3026 ') and POD_WIDTH (' + width + ') are not equal.'); 3033 ') and POD_WIDTH (' + width + ') are not equal.');
3027 } 3034 }
3028 var column = index % columns; 3035 var column = index % columns;
3029 var row = Math.floor(index / columns); 3036 var row = Math.floor(index / columns);
3037 var offsetFromPin = 0;
3038 if (row == pinPodLocation.row) {
3039 offsetFromPin = PIN_EXTRA_WIDTH / 2;
3040 if (column <= pinPodLocation.column)
3041 offsetFromPin *= -1;
3042 }
3043
3030 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : 3044 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING :
3031 POD_ROW_PADDING; 3045 POD_ROW_PADDING;
3032 pod.left = rowPadding + column * (width + margin); 3046 pod.left = rowPadding + column * (width + margin) + offsetFromPin;
3033 3047
3034 // On desktop, we want the rows to always be equally spaced. 3048 // On desktop, we want the rows to always be equally spaced.
3035 pod.top = isDesktopUserManager ? row * (height + rowPadding) : 3049 pod.top = isDesktopUserManager ? row * (height + rowPadding) :
3036 row * height + rowPadding; 3050 row * height + rowPadding;
3037 }); 3051 });
3038 Oobe.getInstance().updateScreenSize(this.parentNode); 3052 Oobe.getInstance().updateScreenSize(this.parentNode);
3039 }, 3053 },
3040 3054
3041 /** 3055 /**
3042 * Number of columns. 3056 * Number of columns.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3093 } 3107 }
3094 this.insideFocusPod_ = true; 3108 this.insideFocusPod_ = true;
3095 3109
3096 for (var i = 0, pod; pod = this.pods[i]; ++i) { 3110 for (var i = 0, pod; pod = this.pods[i]; ++i) {
3097 if (!this.alwaysFocusSinglePod) { 3111 if (!this.alwaysFocusSinglePod) {
3098 pod.isActionBoxMenuActive = false; 3112 pod.isActionBoxMenuActive = false;
3099 } 3113 }
3100 if (pod != podToFocus) { 3114 if (pod != podToFocus) {
3101 pod.isActionBoxMenuHovered = false; 3115 pod.isActionBoxMenuHovered = false;
3102 pod.classList.remove('focused'); 3116 pod.classList.remove('focused');
3117 pod.setPinVisibility(false);
3103 // On Desktop, the faded style is not set correctly, so we should 3118 // 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. 3119 // manually fade out non-focused pods if there is a focused pod.
3105 if (pod.user.isDesktopUser && podToFocus) 3120 if (pod.user.isDesktopUser && podToFocus)
3106 pod.classList.add('faded'); 3121 pod.classList.add('faded');
3107 else 3122 else
3108 pod.classList.remove('faded'); 3123 pod.classList.remove('faded');
3109 pod.reset(false); 3124 pod.reset(false);
3110 } 3125 }
3111 } 3126 }
3112 3127
3113 // Clear any error messages for previous pod. 3128 // Clear any error messages for previous pod.
3114 if (!this.isFocused(podToFocus)) 3129 if (!this.isFocused(podToFocus))
3115 Oobe.clearErrors(); 3130 Oobe.clearErrors();
3116 3131
3117 var hadFocus = !!this.focusedPod_; 3132 var hadFocus = !!this.focusedPod_;
3118 this.focusedPod_ = podToFocus; 3133 this.focusedPod_ = podToFocus;
3119 if (podToFocus) { 3134 if (podToFocus) {
3135 this.setFocusedPodPinVisibility(true);
3120 podToFocus.classList.remove('faded'); 3136 podToFocus.classList.remove('faded');
3121 podToFocus.classList.add('focused'); 3137 podToFocus.classList.add('focused');
3122 if (!podToFocus.multiProfilesPolicyApplied) { 3138 if (!podToFocus.multiProfilesPolicyApplied) {
3123 podToFocus.classList.toggle('signing-in', false); 3139 podToFocus.classList.toggle('signing-in', false);
3124 if (!opt_skipInputFocus) 3140 if (!opt_skipInputFocus)
3125 podToFocus.focusInput(); 3141 podToFocus.focusInput();
3126 } else { 3142 } else {
3127 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); 3143 podToFocus.userTypeBubbleElement.classList.add('bubble-shown');
3128 // Note it is not necessary to skip this focus request when 3144 // Note it is not necessary to skip this focus request when
3129 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| 3145 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied|
3130 // is false, it doesn't focus on the password input box by default. 3146 // is false, it doesn't focus on the password input box by default.
3131 podToFocus.focus(); 3147 podToFocus.focus();
3132 } 3148 }
3133 3149
3134 // focusPod() automatically loads wallpaper 3150 // focusPod() automatically loads wallpaper
3135 if (!podToFocus.user.isApp) 3151 if (!podToFocus.user.isApp)
3136 chrome.send('focusPod', [podToFocus.user.username]); 3152 chrome.send('focusPod', [podToFocus.user.username]);
3137 this.firstShown_ = false; 3153 this.firstShown_ = false;
3138 this.lastFocusedPod_ = podToFocus; 3154 this.lastFocusedPod_ = podToFocus;
3139 this.scrollFocusedPodIntoView(); 3155 this.scrollFocusedPodIntoView();
3140 } 3156 }
3141 this.insideFocusPod_ = false; 3157 this.insideFocusPod_ = false;
3158 this.placePods_();
3142 }, 3159 },
3143 3160
3144 /** 3161 /**
3145 * Resets wallpaper to the last active user's wallpaper, if any. 3162 * Resets wallpaper to the last active user's wallpaper, if any.
3146 */ 3163 */
3147 loadLastWallpaper: function() { 3164 loadLastWallpaper: function() {
3148 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) 3165 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp)
3149 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); 3166 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]);
3150 }, 3167 },
3151 3168
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 if (pod && pod.multiProfilesPolicyApplied) { 3531 if (pod && pod.multiProfilesPolicyApplied) {
3515 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3532 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3516 } 3533 }
3517 } 3534 }
3518 }; 3535 };
3519 3536
3520 return { 3537 return {
3521 PodRow: PodRow 3538 PodRow: PodRow
3522 }; 3539 };
3523 }); 3540 });
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