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 30 matching lines...) Expand all Loading... | |
| 41 * Maximal number of rows if sign-in banner is displayed alonside. | 41 * Maximal number of rows if sign-in banner is displayed alonside. |
| 42 * @type {number} | 42 * @type {number} |
| 43 * @const | 43 * @const |
| 44 */ | 44 */ |
| 45 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2; | 45 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Variables used for pod placement processing. Width and height should be | 48 * Variables used for pod placement processing. Width and height should be |
| 49 * synced with computed CSS sizes of pods. | 49 * synced with computed CSS sizes of pods. |
| 50 */ | 50 */ |
| 51 var CROS_POD_WIDTH = 180; | 51 var CROS_POD_WIDTH = 306; |
| 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 = 346; |
| 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_HEIGHT = 417; | 62 var CROS_PIN_POD_HEIGHT = 417; |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Minimal padding between user pod and virtual keyboard. | 65 * Minimal padding between user pod and virtual keyboard. |
| 66 * @type {number} | 66 * @type {number} |
| (...skipping 3861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3928 this.ownerDocument.addEventListener( | 3928 this.ownerDocument.addEventListener( |
| 3929 event, this.listeners_[event][0], this.listeners_[event][1]); | 3929 event, this.listeners_[event][0], this.listeners_[event][1]); |
| 3930 } | 3930 } |
| 3931 $('login-header-bar').buttonsTabIndex = UserPodTabOrder.HEADER_BAR; | 3931 $('login-header-bar').buttonsTabIndex = UserPodTabOrder.HEADER_BAR; |
| 3932 | 3932 |
| 3933 if (this.podPlacementPostponed_) { | 3933 if (this.podPlacementPostponed_) { |
| 3934 this.podPlacementPostponed_ = false; | 3934 this.podPlacementPostponed_ = false; |
| 3935 this.placePods_(); | 3935 this.placePods_(); |
| 3936 this.maybePreselectPod(); | 3936 this.maybePreselectPod(); |
| 3937 } | 3937 } |
| 3938 | |
| 3939 this.updatePodNameArea(); | |
| 3938 }, | 3940 }, |
| 3939 | 3941 |
| 3940 /** | 3942 /** |
| 3941 * Called when the element is hidden. | 3943 * Called when the element is hidden. |
| 3942 */ | 3944 */ |
| 3943 handleHide: function() { | 3945 handleHide: function() { |
| 3944 for (var event in this.listeners_) { | 3946 for (var event in this.listeners_) { |
| 3945 this.ownerDocument.removeEventListener( | 3947 this.ownerDocument.removeEventListener( |
| 3946 event, this.listeners_[event][0], this.listeners_[event][1]); | 3948 event, this.listeners_[event][0], this.listeners_[event][1]); |
| 3947 } | 3949 } |
| 3948 $('login-header-bar').buttonsTabIndex = 0; | 3950 $('login-header-bar').buttonsTabIndex = 0; |
| 3949 }, | 3951 }, |
| 3950 | 3952 |
| 3951 /** | 3953 /** |
| 3952 * Called when a pod's user image finishes loading. | 3954 * Called when a pod's user image finishes loading. |
| 3953 */ | 3955 */ |
| 3954 handlePodImageLoad: function(pod) { | 3956 handlePodImageLoad: function(pod) { |
| 3955 var index = this.podsWithPendingImages_.indexOf(pod); | 3957 var index = this.podsWithPendingImages_.indexOf(pod); |
| 3956 if (index == -1) { | 3958 if (index == -1) { |
| 3957 return; | 3959 return; |
| 3958 } | 3960 } |
| 3959 | 3961 |
| 3960 this.podsWithPendingImages_.splice(index, 1); | 3962 this.podsWithPendingImages_.splice(index, 1); |
| 3961 if (this.podsWithPendingImages_.length == 0) { | 3963 if (this.podsWithPendingImages_.length == 0) { |
| 3962 this.classList.remove('images-loading'); | 3964 this.classList.remove('images-loading'); |
| 3963 } | 3965 } |
| 3964 }, | 3966 }, |
| 3965 | 3967 |
| 3966 /** | 3968 /** |
| 3969 * Makes sure user name is centered in each pod and extra long name | |
| 3970 * does not exceed max width. | |
| 3971 */ | |
| 3972 updatePodNameArea: function() { | |
| 3973 this.querySelectorAll('.name-container').forEach(function(nameArea) { | |
| 3974 var nameElement = nameArea.children[1]; | |
|
jdufault
2017/05/10 00:40:07
Use a more specific selector?
Wenzhao (Colin) Zang
2017/05/11 18:13:36
Done.
| |
| 3975 var leftMargin = (CROS_POD_WIDTH - nameElement.offsetWidth) / 2; | |
| 3976 if (leftMargin > 0) | |
| 3977 nameArea.style.left = leftMargin + 'px'; | |
| 3978 else | |
| 3979 nameElement.style.width = CROS_POD_WIDTH + 'px'; | |
| 3980 }); | |
| 3981 }, | |
| 3982 | |
| 3983 /** | |
| 3967 * Preselects pod, if needed. | 3984 * Preselects pod, if needed. |
| 3968 */ | 3985 */ |
| 3969 maybePreselectPod: function() { | 3986 maybePreselectPod: function() { |
| 3970 var pod = this.preselectedPod; | 3987 var pod = this.preselectedPod; |
| 3971 this.focusPod(pod); | 3988 this.focusPod(pod); |
| 3972 | 3989 |
| 3973 // Hide user-type-bubble in case all user pods are disabled and we focus | 3990 // Hide user-type-bubble in case all user pods are disabled and we focus |
| 3974 // first pod. | 3991 // first pod. |
| 3975 if (pod && pod.multiProfilesPolicyApplied) { | 3992 if (pod && pod.multiProfilesPolicyApplied) { |
| 3976 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3993 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3977 } | 3994 } |
| 3978 } | 3995 } |
| 3979 }; | 3996 }; |
| 3980 | 3997 |
| 3981 return { | 3998 return { |
| 3982 PodRow: PodRow | 3999 PodRow: PodRow |
| 3983 }; | 4000 }; |
| 3984 }); | 4001 }); |
| OLD | NEW |