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

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. Also fixed CSS styles. 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.css » ('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 position;
189 if (activatedPod.pinContainer) {
190 // Anchor the bubble to the input field.
191 var elements = activatedPod.getElementsByClassName('auth-container');
192 if (elements.length == 1) {
193 bubbleAnchor = elements[0];
194 } else {
195 console.error('auth-container not found');
196 bubbleAnchor = activatedPod.mainInput;
197 }
198 position = cr.ui.Bubble.Attachment.RIGHT;
xiyuan 2016/11/03 16:54:40 nit: position -> attachment (or arrowPosition) "p
Alexander Alekseev 2016/11/03 22:15:29 Done.
199 } else {
200 // Anchor the bubble to the pod instead of the input.
190 bubbleAnchor = activatedPod; 201 bubbleAnchor = activatedPod;
191 else 202 position = 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.
208 // 4 = bubble distance from element
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 var bubbleHidden = bubble.hidden;
xiyuan 2016/11/03 16:54:40 nit: we don't need to cache bubble.hidden then res
Alexander Alekseev 2016/11/03 22:15:29 Done.
218 bubble.style.visibility = 'hidden';
219 bubble.hidden = false;
220 // Now we need the bubble to have the new content before calculating
221 // size.
222 bubble.replaceContent(error);
223 // Get bubble size.
224 var bubbleOffsetHeight = parseInt(bubble.offsetHeight);
225 var bubbleOffsetWidth = parseInt(bubble.offsetWidth);
226 // Restore attributes.
227 bubble.style.visibility = bubbleVisibility;
228 bubble.hidden = bubbleHidden;
229
230 if (position == cr.ui.Bubble.Attachment.BOTTOM) {
231 // Move error bubble if it overlaps the shelf.
232 if (maxHeight < bubbleOffsetHeight)
233 position = cr.ui.Bubble.Attachment.TOP;
234 } else {
235 // Move error bubble if it doesn't fit screen.
236 if (maxWidth < bubbleOffsetWidth) {
237 bubblePositioningPadding = 2;
238 position = cr.ui.Bubble.Attachment.LEFT;
239 }
240 }
241 var showBubbleCallback = function() {
197 activatedPod.removeEventListener("webkitTransitionEnd", 242 activatedPod.removeEventListener("webkitTransitionEnd",
198 showBottomCallback); 243 showBubbleCallback);
199 $('bubble').showContentForElement(bubbleAnchor, 244 $('bubble').showContentForElement(bubbleAnchor,
200 cr.ui.Bubble.Attachment.BOTTOM, 245 position,
201 error, 246 error,
202 BUBBLE_OFFSET, BUBBLE_PADDING); 247 BUBBLE_OFFSET,
248 bubblePositioningPadding, true);
203 }; 249 };
204 activatedPod.addEventListener("webkitTransitionEnd", 250 activatedPod.addEventListener("webkitTransitionEnd",
205 showBottomCallback); 251 showBubbleCallback);
206 ensureTransitionEndEvent(activatedPod); 252 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 } 253 }
224 }, 254 },
225 255
226 /** 256 /**
227 * Loads the PIN keyboard if any of the users can login with a PIN. Disables 257 * 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. 258 * the PIN keyboard for users who are not allowed to use PIN unlock.
229 * @param {array} users Array of user instances. 259 * @param {array} users Array of user instances.
230 */ 260 */
231 initializePinKeyboardStateForUsers_: function(users) { 261 initializePinKeyboardStateForUsers_: function(users) {
232 for (var i = 0; i < users.length; ++i) { 262 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 458 * @param {string} userID The user ID of the public session
429 * @param {string} locale The locale to which this list of keyboard layouts 459 * @param {string} locale The locale to which this list of keyboard layouts
430 * applies 460 * applies
431 * @param {!Object} list List of available keyboard layouts 461 * @param {!Object} list List of available keyboard layouts
432 */ 462 */
433 setPublicSessionKeyboardLayouts: function(userID, locale, list) { 463 setPublicSessionKeyboardLayouts: function(userID, locale, list) {
434 $('pod-row').setPublicSessionKeyboardLayouts(userID, locale, list); 464 $('pod-row').setPublicSessionKeyboardLayouts(userID, locale, list);
435 } 465 }
436 }; 466 };
437 }); 467 });
OLDNEW
« no previous file with comments | « no previous file | ui/login/bubble.css » ('j') | ui/login/bubble.css » ('J')

Powered by Google App Engine
This is Rietveld 408576698