Chromium Code Reviews| Index: ui/login/account_picker/user_pod_row.js |
| diff --git a/ui/login/account_picker/user_pod_row.js b/ui/login/account_picker/user_pod_row.js |
| index 912c21b627800894d98c375437371600261c3cf5..6c439212665c2b1f748a53f10ddd9da3f208dd48 100644 |
| --- a/ui/login/account_picker/user_pod_row.js |
| +++ b/ui/login/account_picker/user_pod_row.js |
| @@ -59,6 +59,9 @@ cr.define('login', function() { |
| var POD_ROW_PADDING = 10; |
| var DESKTOP_ROW_PADDING = 32; |
| var CUSTOM_ICON_CONTAINER_SIZE = 40; |
| + var CROS_PIN_POD_WIDTH = 270; |
| + var CROS_PIN_POD_HEIGHT = 594; |
| + var PIN_EXTRA_WIDTH = 90; |
| /** |
| * Minimal padding between user pod and virtual keyboard. |
| @@ -820,22 +823,6 @@ cr.define('login', function() { |
| }, |
| /** |
| - * Gets the authorization element of the pod. |
| - * @type {!HTMLDivElement} |
| - */ |
| - get authElement() { |
| - return this.querySelector('.auth-container'); |
| - }, |
| - |
| - /** |
| - * Gets image pane element. |
| - * @type {!HTMLDivElement} |
| - */ |
| - get imagePaneElement() { |
| - return this.querySelector('.user-image-pane'); |
| - }, |
| - |
| - /** |
| * Gets image element. |
| * @type {!HTMLImageElement} |
| */ |
| @@ -885,14 +872,6 @@ cr.define('login', function() { |
| }, |
| /** |
| - * Gets the pin-container of the pod. |
| - * @type {!HTMLDivElement} |
| - */ |
| - get pinContainer() { |
| - return this.querySelector('.pin-container'); |
| - }, |
| - |
| - /** |
| * Gets the pin-keyboard of the pod. |
| * @type {!HTMLElement} |
| */ |
| @@ -909,14 +888,6 @@ cr.define('login', function() { |
| }, |
| /** |
| - * Gets the signed in indicator of the pod. |
| - * @type {!HTMLDivElement} |
| - */ |
| - get signInElement() { |
| - return this.querySelector('.signed-in-indicator'); |
| - }, |
| - |
| - /** |
| * Gets the container holding the launch app button. |
| * @type {!HTMLButtonElement} |
| */ |
| @@ -1121,15 +1092,17 @@ cr.define('login', function() { |
| this.classList.toggle('flying-pin-pod', enable); |
| }, |
| - setPinVisibility: function(visible) { |
| - var elements = [this, this.authElement, this.imagePaneElement, |
| - this.imageElement, this.pinContainer]; |
| + setPinClass_: function(element, enable) { |
| + element.classList.toggle('pin-enabled', enable); |
| + element.classList.toggle('pin-disabled', !enable); |
| + }, |
| - for (var idx = 0; idx < elements.length; idx++) { |
| - var currentElement = elements[idx]; |
| - currentElement.classList.toggle('pin-enabled', visible); |
| - currentElement.classList.toggle('pin-disabled', !visible); |
| - } |
| + setPinVisibility: function(visible) { |
| + [].forEach.call( |
|
jdufault
2016/07/19 18:22:19
I don't think the forEach improves readability her
sammiequon
2016/07/20 17:11:06
Done.
|
| + this.getElementsByClassName('pin-tag'), function(el) { |
| + this.setPinClass_(el, visible); |
| + }, this); |
| + this.setPinClass_(this, visible); |
| // Set the focus to the input element after showing/hiding pin keyboard. |
| if (visible) |
| @@ -1138,6 +1111,10 @@ cr.define('login', function() { |
| this.mainInput.focus(); |
| }, |
| + isPinShown: function() { |
| + return this.classList.contains('pin-enabled'); |
| + }, |
| + |
| setUserPodIconType: function(userTypeClass) { |
| this.userTypeIconAreaElement.classList.add(userTypeClass); |
| this.userTypeIconAreaElement.hidden = false; |
| @@ -1173,7 +1150,7 @@ cr.define('login', function() { |
| */ |
| get mainInput() { |
| if (this.isAuthTypePassword) { |
| - if (this.pinContainer.classList.contains('pin-enabled')) |
| + if (this.isPinShown() && this.pinKeyboard.inputElement) |
| return this.pinKeyboard.inputElement; |
| return this.passwordElement; |
| } else if (this.isAuthTypeOnlineSignIn) { |
| @@ -2983,6 +2960,30 @@ cr.define('login', function() { |
| }, |
| /** |
| + * Calculates the row and column of the |pod| with the pin keyboard (if |
| + * any), otherwise returns a column and row greater than |maxPods|. |
| + * @return {{columns: number, rows: number}} |
|
jdufault
2016/07/19 18:22:19
Add type annotations for parameters.
Return type
sammiequon
2016/07/20 17:11:06
Added type annotations. Return type can be nullabl
jdufault
2016/07/20 17:41:26
console.error doesn't abort JS execution, so { col
jdufault
2016/07/20 18:20:04
Please address this comment :)
sammiequon
2016/07/20 19:00:37
As per offline conversation, {column: -1, row: -1}
|
| + */ |
| + findPinPodLocation_: function(pod, columns, rows, maxPods) { |
|
jdufault
2016/07/19 18:22:19
Rename to findPodLocation_
sammiequon
2016/07/20 17:11:06
Done.
|
| + var column = maxPods + 1; |
| + var row = maxPods + 1; |
| + if (pod && pod.isPinShown()) { |
|
jdufault
2016/07/19 18:22:19
pod should always be valid.
This function doesn't
sammiequon
2016/07/20 17:11:06
I moved this check outside as suggested, put focus
|
| + this.pods.forEach(function(currentPod, index) { |
| + var currentColumn = index % columns; |
| + var currentRow = Math.floor(index / columns); |
| + if (currentPod == pod) { |
| + row = currentRow; |
| + column = currentColumn; |
| + } else if (currentPod.isPinShown()) { |
| + // Only the focused pod should ever show the PIN keyboard. |
|
jdufault
2016/07/19 18:22:19
Remove error message, this function doesn't need t
sammiequon
2016/07/20 17:11:06
Done.
|
| + console.error('Non-focused pod is showing a PIN keyboard.'); |
| + } |
| + }); |
| + } |
| + return {column: column, row: row}; |
|
jdufault
2016/07/19 18:22:19
Initialize column/row to undefined. If they're und
sammiequon
2016/07/20 17:11:06
Done.
|
| + }, |
| + |
| + /** |
| * Places pods onto their positions onto pod grid. |
| * @private |
| */ |
| @@ -3002,25 +3003,37 @@ cr.define('login', function() { |
| this.columnsToWidth_(columns), this.rowsToHeight_(rows)); |
| var height = this.userPodHeight_; |
| var width = this.userPodWidth_; |
| + var pinPodLocation = this.findPinPodLocation_( |
|
jdufault
2016/07/19 18:22:19
Initialize pinPodLocation by default to { column+1
sammiequon
2016/07/20 17:11:06
Done.
|
| + this.focusedPod_, columns, rows, maxPodsNumber); |
| + |
| this.pods.forEach(function(pod, index) { |
| if (index >= maxPodsNumber) { |
| pod.hidden = true; |
| return; |
| } |
| pod.hidden = false; |
| - if (pod.offsetHeight != height) { |
| + if (pod.offsetHeight != height && |
| + pod.offsetHeight != CROS_PIN_POD_HEIGHT) { |
| console.error('Pod offsetHeight (' + pod.offsetHeight + |
| ') and POD_HEIGHT (' + height + ') are not equal.'); |
| } |
| - if (pod.offsetWidth != width) { |
| + if (pod.offsetWidth != width && |
| + pod.offsetWidth != CROS_PIN_POD_WIDTH) { |
| console.error('Pod offsetWidth (' + pod.offsetWidth + |
| ') and POD_WIDTH (' + width + ') are not equal.'); |
| } |
| var column = index % columns; |
| var row = Math.floor(index / columns); |
| + var offsetFromPin = 0; |
| + if (row == pinPodLocation.row) { |
| + offsetFromPin = PIN_EXTRA_WIDTH / 2; |
| + if (column <= pinPodLocation.column) |
| + offsetFromPin *= -1; |
| + } |
| + |
| var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : |
| POD_ROW_PADDING; |
| - pod.left = rowPadding + column * (width + margin); |
| + pod.left = rowPadding + column * (width + margin) + offsetFromPin; |
| // On desktop, we want the rows to always be equally spaced. |
| pod.top = isDesktopUserManager ? row * (height + rowPadding) : |
| @@ -3091,6 +3104,7 @@ cr.define('login', function() { |
| if (pod != podToFocus) { |
| pod.isActionBoxMenuHovered = false; |
| pod.classList.remove('focused'); |
| + pod.setPinVisibility(false); |
| // On Desktop, the faded style is not set correctly, so we should |
| // manually fade out non-focused pods if there is a focused pod. |
| if (pod.user.isDesktopUser && podToFocus) |
| @@ -3108,6 +3122,7 @@ cr.define('login', function() { |
| var hadFocus = !!this.focusedPod_; |
| this.focusedPod_ = podToFocus; |
| if (podToFocus) { |
| + this.setFocusedPodPinVisibility(true); |
| podToFocus.classList.remove('faded'); |
| podToFocus.classList.add('focused'); |
| if (!podToFocus.multiProfilesPolicyApplied) { |
| @@ -3130,6 +3145,7 @@ cr.define('login', function() { |
| this.scrollFocusedPodIntoView(); |
| } |
| this.insideFocusPod_ = false; |
| + this.placePods_(); |
| }, |
| /** |