Chromium Code Reviews| 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; | 62 var CROS_PIN_POD_HEIGHT = 417; |
| 63 var CROS_PIN_POD_HEIGHT = 594; | |
| 64 var PIN_EXTRA_WIDTH = 90; | |
| 65 | 63 |
| 66 /** | 64 /** |
| 67 * Minimal padding between user pod and virtual keyboard. | 65 * Minimal padding between user pod and virtual keyboard. |
| 68 * @type {number} | 66 * @type {number} |
| 69 * @const | 67 * @const |
| 70 */ | 68 */ |
| 71 var USER_POD_KEYBOARD_MIN_PADDING = 20; | 69 var USER_POD_KEYBOARD_MIN_PADDING = 20; |
| 72 | 70 |
| 73 /** | 71 /** |
| 74 * Maximum time for which the pod row remains hidden until all user images | 72 * Maximum time for which the pod row remains hidden until all user images |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1086 this.querySelector('.mp-policy-primary-only-msg').hidden = false; | 1084 this.querySelector('.mp-policy-primary-only-msg').hidden = false; |
| 1087 else if (this.user.multiProfilesPolicy == 'owner-primary-only') | 1085 else if (this.user.multiProfilesPolicy == 'owner-primary-only') |
| 1088 this.querySelector('.mp-owner-primary-only-msg').hidden = false; | 1086 this.querySelector('.mp-owner-primary-only-msg').hidden = false; |
| 1089 else | 1087 else |
| 1090 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; | 1088 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; |
| 1091 } else if (this.user_.isApp) { | 1089 } else if (this.user_.isApp) { |
| 1092 this.setUserPodIconType('app'); | 1090 this.setUserPodIconType('app'); |
| 1093 } | 1091 } |
| 1094 }, | 1092 }, |
| 1095 | 1093 |
| 1094 isPinReady: function() { | |
| 1095 if (this.pinKeyboard) | |
|
jdufault
2016/08/08 21:12:42
return this.pinKeyboard && this.pinKeyboard.offset
sammiequon
2016/08/08 23:36:12
Done.
| |
| 1096 return this.pinKeyboard.offsetHeight > 0; | |
| 1097 return false; | |
| 1098 }, | |
| 1099 | |
| 1096 toggleTransitions: function(enable) { | 1100 toggleTransitions: function(enable) { |
| 1097 this.classList.toggle('flying-pin-pod', enable); | 1101 this.classList.toggle('flying-pin-pod', enable); |
| 1098 }, | 1102 }, |
| 1099 | 1103 |
| 1100 updatePinClass_: function(element, enable) { | 1104 updatePinClass_: function(element, enable) { |
| 1101 element.classList.toggle('pin-enabled', enable); | 1105 element.classList.toggle('pin-enabled', enable); |
| 1102 element.classList.toggle('pin-disabled', !enable); | 1106 element.classList.toggle('pin-disabled', !enable); |
| 1103 }, | 1107 }, |
| 1104 | 1108 |
| 1105 setPinVisibility: function(visible) { | 1109 setPinVisibility: function(visible) { |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2958 // One more iteration if it's not enough cells to place all pods. | 2962 // One more iteration if it's not enough cells to place all pods. |
| 2959 while (maxWidth >= this.columnsToWidth_(columns + 1) && | 2963 while (maxWidth >= this.columnsToWidth_(columns + 1) && |
| 2960 columns * rows < this.pods.length && | 2964 columns * rows < this.pods.length && |
| 2961 columns < MAX_NUMBER_OF_COLUMNS) { | 2965 columns < MAX_NUMBER_OF_COLUMNS) { |
| 2962 ++columns; | 2966 ++columns; |
| 2963 } | 2967 } |
| 2964 return {columns: columns, rows: rows}; | 2968 return {columns: columns, rows: rows}; |
| 2965 }, | 2969 }, |
| 2966 | 2970 |
| 2967 /** | 2971 /** |
| 2968 * Calculates the row and column of the given |pod|. | |
| 2969 * @param {UserPod} pod Pod we want the row and column of. | |
| 2970 * @param {number} columns Columns in the podrow. | |
| 2971 * @param {number} rows Rows in the podrow. | |
| 2972 * @return {{columns: number, rows: number}} | |
| 2973 * @private | |
| 2974 */ | |
| 2975 findPodLocation_: function(pod, columns, rows) { | |
| 2976 var column = -1; | |
| 2977 var row = -1; | |
| 2978 var index = this.pods.indexOf(pod); | |
| 2979 if (index >= 0) { | |
| 2980 row = Math.floor(index / columns); | |
| 2981 column = index % columns; | |
| 2982 } | |
| 2983 else { | |
| 2984 console.error('Pod not found in pod row.'); | |
| 2985 } | |
| 2986 return {column: column, row: row}; | |
| 2987 }, | |
| 2988 | |
| 2989 /** | |
| 2990 * Places pods onto their positions onto pod grid. | 2972 * Places pods onto their positions onto pod grid. |
| 2991 * @private | 2973 * @private |
| 2992 */ | 2974 */ |
| 2993 placePods_: function() { | 2975 placePods_: function() { |
| 2994 var isDesktopUserManager = Oobe.getInstance().displayType == | 2976 var isDesktopUserManager = Oobe.getInstance().displayType == |
| 2995 DISPLAY_TYPE.DESKTOP_USER_MANAGER; | 2977 DISPLAY_TYPE.DESKTOP_USER_MANAGER; |
| 2996 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible) | 2978 if (isDesktopUserManager && !Oobe.getInstance().userPodsPageVisible) |
| 2997 return; | 2979 return; |
| 2998 | 2980 |
| 2999 var layout = this.calculateLayout_(); | 2981 var layout = this.calculateLayout_(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 3014 if (index >= maxPodsNumber) { | 2996 if (index >= maxPodsNumber) { |
| 3015 pod.hidden = true; | 2997 pod.hidden = true; |
| 3016 return; | 2998 return; |
| 3017 } | 2999 } |
| 3018 pod.hidden = false; | 3000 pod.hidden = false; |
| 3019 if (pod.offsetHeight != height && | 3001 if (pod.offsetHeight != height && |
| 3020 pod.offsetHeight != CROS_PIN_POD_HEIGHT) { | 3002 pod.offsetHeight != CROS_PIN_POD_HEIGHT) { |
| 3021 console.error('Pod offsetHeight (' + pod.offsetHeight + | 3003 console.error('Pod offsetHeight (' + pod.offsetHeight + |
| 3022 ') and POD_HEIGHT (' + height + ') are not equal.'); | 3004 ') and POD_HEIGHT (' + height + ') are not equal.'); |
| 3023 } | 3005 } |
| 3024 if (pod.offsetWidth != width && | 3006 if (pod.offsetWidth != width) { |
| 3025 pod.offsetWidth != CROS_PIN_POD_WIDTH) { | |
| 3026 console.error('Pod offsetWidth (' + pod.offsetWidth + | 3007 console.error('Pod offsetWidth (' + pod.offsetWidth + |
| 3027 ') and POD_WIDTH (' + width + ') are not equal.'); | 3008 ') and POD_WIDTH (' + width + ') are not equal.'); |
| 3028 } | 3009 } |
| 3029 var column = index % columns; | 3010 var column = index % columns; |
| 3030 var row = Math.floor(index / columns); | 3011 var row = Math.floor(index / columns); |
| 3031 var offsetFromPin = 0; | |
| 3032 if (row == pinPodLocation.row) { | |
| 3033 offsetFromPin = PIN_EXTRA_WIDTH / 2; | |
| 3034 if (column <= pinPodLocation.column) | |
| 3035 offsetFromPin *= -1; | |
| 3036 } | |
| 3037 | 3012 |
| 3038 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : | 3013 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : |
| 3039 POD_ROW_PADDING; | 3014 POD_ROW_PADDING; |
| 3040 pod.left = rowPadding + column * (width + margin) + offsetFromPin; | 3015 pod.left = rowPadding + column * (width + margin); |
| 3041 | 3016 |
| 3042 // On desktop, we want the rows to always be equally spaced. | 3017 // On desktop, we want the rows to always be equally spaced. |
| 3043 pod.top = isDesktopUserManager ? row * (height + rowPadding) : | 3018 pod.top = isDesktopUserManager ? row * (height + rowPadding) : |
| 3044 row * height + rowPadding; | 3019 row * height + rowPadding; |
| 3045 }); | 3020 }); |
| 3046 Oobe.getInstance().updateScreenSize(this.parentNode); | 3021 Oobe.getInstance().updateScreenSize(this.parentNode); |
| 3047 }, | 3022 }, |
| 3048 | 3023 |
| 3049 /** | 3024 /** |
| 3050 * Number of columns. | 3025 * Number of columns. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3119 } | 3094 } |
| 3120 } | 3095 } |
| 3121 | 3096 |
| 3122 // Clear any error messages for previous pod. | 3097 // Clear any error messages for previous pod. |
| 3123 if (!this.isFocused(podToFocus)) | 3098 if (!this.isFocused(podToFocus)) |
| 3124 Oobe.clearErrors(); | 3099 Oobe.clearErrors(); |
| 3125 | 3100 |
| 3126 var hadFocus = !!this.focusedPod_; | 3101 var hadFocus = !!this.focusedPod_; |
| 3127 this.focusedPod_ = podToFocus; | 3102 this.focusedPod_ = podToFocus; |
| 3128 if (podToFocus) { | 3103 if (podToFocus) { |
| 3129 this.setFocusedPodPinVisibility(true); | 3104 // Only show the keyboard if it is fully loaded. |
| 3105 if (podToFocus.isPinReady()) | |
| 3106 podToFocus.setPinVisibility(true); | |
| 3130 podToFocus.classList.remove('faded'); | 3107 podToFocus.classList.remove('faded'); |
| 3131 podToFocus.classList.add('focused'); | 3108 podToFocus.classList.add('focused'); |
| 3132 if (!podToFocus.multiProfilesPolicyApplied) { | 3109 if (!podToFocus.multiProfilesPolicyApplied) { |
| 3133 podToFocus.classList.toggle('signing-in', false); | 3110 podToFocus.classList.toggle('signing-in', false); |
| 3134 if (!opt_skipInputFocus) | 3111 if (!opt_skipInputFocus) |
| 3135 podToFocus.focusInput(); | 3112 podToFocus.focusInput(); |
| 3136 } else { | 3113 } else { |
| 3137 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); | 3114 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); |
| 3138 // Note it is not necessary to skip this focus request when | 3115 // Note it is not necessary to skip this focus request when |
| 3139 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| | 3116 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| |
| 3140 // is false, it doesn't focus on the password input box by default. | 3117 // is false, it doesn't focus on the password input box by default. |
| 3141 podToFocus.focus(); | 3118 podToFocus.focus(); |
| 3142 } | 3119 } |
| 3143 | 3120 |
| 3144 // focusPod() automatically loads wallpaper | 3121 // focusPod() automatically loads wallpaper |
| 3145 if (!podToFocus.user.isApp) | 3122 if (!podToFocus.user.isApp) |
| 3146 chrome.send('focusPod', [podToFocus.user.username]); | 3123 chrome.send('focusPod', [podToFocus.user.username]); |
| 3147 this.firstShown_ = false; | 3124 this.firstShown_ = false; |
| 3148 this.lastFocusedPod_ = podToFocus; | 3125 this.lastFocusedPod_ = podToFocus; |
| 3149 this.scrollFocusedPodIntoView(); | 3126 this.scrollFocusedPodIntoView(); |
| 3150 } | 3127 } |
| 3151 this.insideFocusPod_ = false; | 3128 this.insideFocusPod_ = false; |
| 3152 this.placePods_(); | |
| 3153 }, | 3129 }, |
| 3154 | 3130 |
| 3155 /** | 3131 /** |
| 3156 * Resets wallpaper to the last active user's wallpaper, if any. | 3132 * Resets wallpaper to the last active user's wallpaper, if any. |
| 3157 */ | 3133 */ |
| 3158 loadLastWallpaper: function() { | 3134 loadLastWallpaper: function() { |
| 3159 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) | 3135 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) |
| 3160 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); | 3136 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); |
| 3161 }, | 3137 }, |
| 3162 | 3138 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3525 if (pod && pod.multiProfilesPolicyApplied) { | 3501 if (pod && pod.multiProfilesPolicyApplied) { |
| 3526 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3502 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3527 } | 3503 } |
| 3528 } | 3504 } |
| 3529 }; | 3505 }; |
| 3530 | 3506 |
| 3531 return { | 3507 return { |
| 3532 PodRow: PodRow | 3508 PodRow: PodRow |
| 3533 }; | 3509 }; |
| 3534 }); | 3510 }); |
| OLD | NEW |