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