Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: ui/login/account_picker/screen_account_picker.js

Issue 2467783002: ChromeOS: update alignment of user POD error bubble. (Closed)
Patch Set: Update after review Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/login/bubble.css » ('j') | ui/login/bubble.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Account picker screen implementation. 6 * @fileoverview Account picker screen implementation.
7 */ 7 */
8 8
9 login.createScreen('AccountPickerScreen', 'account-picker', function() { 9 login.createScreen('AccountPickerScreen', 'account-picker', function() {
10 /** 10 /**
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 chrome.send('maxIncorrectPasswordAttempts', 172 chrome.send('maxIncorrectPasswordAttempts',
173 [activatedPod.user.emailAddress]); 173 [activatedPod.user.emailAddress]);
174 activatedPod.showSigninUI(); 174 activatedPod.showSigninUI();
175 } else { 175 } else {
176 if (loginAttempts == 1) { 176 if (loginAttempts == 1) {
177 chrome.send('firstIncorrectPasswordAttempt', 177 chrome.send('firstIncorrectPasswordAttempt',
178 [activatedPod.user.emailAddress]); 178 [activatedPod.user.emailAddress]);
179 } 179 }
180 // Update the pod row display if incorrect password. 180 // Update the pod row display if incorrect password.
181 $('pod-row').setFocusedPodErrorDisplay(true); 181 $('pod-row').setFocusedPodErrorDisplay(true);
182 // We want bubble's arrow to point to the first letter of input.
183 /** @const */ var BUBBLE_OFFSET = 7;
184 /** @const */ var BUBBLE_PADDING = 4;
185 182
186 // Anchor the bubble to the pod instead of the input if the pin keyboard 183 /** @const */ var BUBBLE_OFFSET = 25;
187 // is showing to avoid covering parts of the pin keyboard. 184 // -8 = 4 - 2(bubble margin) - 10 (internal bubble adjustment)
185 var bubblePositioningPadding = -8;
186
188 var bubbleAnchor; 187 var bubbleAnchor;
189 if (activatedPod.pinContainer) 188 var attachment;
189 if (activatedPod.pinContainer) {
190 // Anchor the bubble to the input field.
191 var elements = activatedPod.getElementsByClassName('auth-container');
jdufault 2016/11/03 23:37:03 Are there ever multiple auth-container elements on
Alexander Alekseev 2016/11/04 00:47:05 This is just in case I missed some specific use ca
Alexander Alekseev 2016/11/04 00:53:07 There is no "getElementByClassName" .
192 if (elements.length == 1) {
193 bubbleAnchor = elements[0];
194 } else {
195 console.error('auth-container not found');
196 bubbleAnchor = activatedPod.mainInput;
197 }
198 attachment = cr.ui.Bubble.Attachment.RIGHT;
199 } else {
200 // Anchor the bubble to the pod instead of the input.
190 bubbleAnchor = activatedPod; 201 bubbleAnchor = activatedPod;
191 else 202 attachment = cr.ui.Bubble.Attachment.BOTTOM;
192 bubbleAnchor = activatedPod.mainInput; 203 }
193 204
194 // We want the bubble to point to where the input is after it is done 205 var bubble = $('bubble');
195 // transitioning. 206 // Cannot use cr.ui.LoginUITools.get* on bubble until it is attached to
196 var showBottomCallback = function() { 207 // the element.
jdufault 2016/11/03 23:37:03 Please describe why.
Alexander Alekseev 2016/11/04 00:47:05 Done.
208 // 4 = bubble distance from element
jdufault 2016/11/03 23:37:03 Make 4 a constant at the top of the file?
Alexander Alekseev 2016/11/04 00:47:05 Done.
209 var maxHeight =
210 cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping(bubbleAnchor)
211 - bubbleAnchor.offsetHeight - 4;
212 var maxWidth = cr.ui.LoginUITools.getMaxWidthToFit(bubbleAnchor)
213 - bubbleAnchor.offsetWidth - 4;
214
215 // Change bubble visibility temporary to calculate height.
216 var bubbleVisibility = bubble.style.visibility;
217 bubble.style.visibility = 'hidden';
218 bubble.hidden = false;
219 // Now we need the bubble to have the new content before calculating
220 // size.
221 bubble.replaceContent(error);
222 // Get bubble size.
223 var bubbleOffsetHeight = parseInt(bubble.offsetHeight);
224 var bubbleOffsetWidth = parseInt(bubble.offsetWidth);
225 // Restore attributes.
226 bubble.style.visibility = bubbleVisibility;
227 bubble.hidden = true;
228
229 if (attachment == cr.ui.Bubble.Attachment.BOTTOM) {
230 // Move error bubble if it overlaps the shelf.
231 if (maxHeight < bubbleOffsetHeight)
232 attachment = cr.ui.Bubble.Attachment.TOP;
233 } else {
234 // Move error bubble if it doesn't fit screen.
235 if (maxWidth < bubbleOffsetWidth) {
236 bubblePositioningPadding = 2;
237 attachment = cr.ui.Bubble.Attachment.LEFT;
238 }
239 }
240 var showBubbleCallback = function() {
197 activatedPod.removeEventListener("webkitTransitionEnd", 241 activatedPod.removeEventListener("webkitTransitionEnd",
198 showBottomCallback); 242 showBubbleCallback);
199 $('bubble').showContentForElement(bubbleAnchor, 243 $('bubble').showContentForElement(bubbleAnchor,
200 cr.ui.Bubble.Attachment.BOTTOM, 244 attachment,
201 error, 245 error,
202 BUBBLE_OFFSET, BUBBLE_PADDING); 246 BUBBLE_OFFSET,
247 bubblePositioningPadding, true);
203 }; 248 };
204 activatedPod.addEventListener("webkitTransitionEnd", 249 activatedPod.addEventListener("webkitTransitionEnd",
205 showBottomCallback); 250 showBubbleCallback);
206 ensureTransitionEndEvent(activatedPod); 251 ensureTransitionEndEvent(activatedPod);
207
208 // Move error bubble up if it overlaps the shelf.
209 var maxHeight =
210 cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping($('bubble'));
211 if (maxHeight < $('bubble').offsetHeight) {
212 var showTopCallback = function() {
213 activatedPod.removeEventListener("webkitTransitionEnd",
214 showTopCallback);
215 $('bubble').showContentForElement(bubbleAnchor,
216 cr.ui.Bubble.Attachment.TOP,
217 error,
218 BUBBLE_OFFSET, BUBBLE_PADDING);
219 };
220 activatedPod.addEventListener("webkitTransitionEnd", showTopCallback);
221 ensureTransitionEndEvent(activatedPod);
222 }
223 } 252 }
224 }, 253 },
225 254
226 /** 255 /**
227 * Loads the PIN keyboard if any of the users can login with a PIN. Disables 256 * Loads the PIN keyboard if any of the users can login with a PIN. Disables
228 * the PIN keyboard for users who are not allowed to use PIN unlock. 257 * the PIN keyboard for users who are not allowed to use PIN unlock.
229 * @param {array} users Array of user instances. 258 * @param {array} users Array of user instances.
230 */ 259 */
231 initializePinKeyboardStateForUsers_: function(users) { 260 initializePinKeyboardStateForUsers_: function(users) {
232 for (var i = 0; i < users.length; ++i) { 261 for (var i = 0; i < users.length; ++i) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 * @param {string} userID The user ID of the public session 457 * @param {string} userID The user ID of the public session
429 * @param {string} locale The locale to which this list of keyboard layouts 458 * @param {string} locale The locale to which this list of keyboard layouts
430 * applies 459 * applies
431 * @param {!Object} list List of available keyboard layouts 460 * @param {!Object} list List of available keyboard layouts
432 */ 461 */
433 setPublicSessionKeyboardLayouts: function(userID, locale, list) { 462 setPublicSessionKeyboardLayouts: function(userID, locale, list) {
434 $('pod-row').setPublicSessionKeyboardLayouts(userID, locale, list); 463 $('pod-row').setPublicSessionKeyboardLayouts(userID, locale, list);
435 } 464 }
436 }; 465 };
437 }); 466 });
OLDNEW
« no previous file with comments | « no previous file | ui/login/bubble.css » ('j') | ui/login/bubble.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698