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