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

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: Implemented side positioning. Removed debug. 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 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;
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 bubbleClassListHasFaded = bubble.classList.contains('bubble');
217 var bubbleVisibility = bubble.style.visibility;
218 var bubbleDisplay = bubble.style.display;
xiyuan 2016/11/02 16:17:21 I don't think bubble changes (or should change) it
Alexander Alekseev 2016/11/03 01:27:43 Done.
219 var bubbleHidden = bubble.hidden;
220 bubble.style.visibility = 'hidden';
221 bubble.style.display = 'block';
222 bubble.classList.remove('faded');
xiyuan 2016/11/02 16:17:21 "faded" controls the opacity and should not affect
Alexander Alekseev 2016/11/03 01:27:43 Done.
223 bubble.hidden = false;
224 // Now we need the bubble to have the new content before calculating
225 // size.
226 bubble.replaceContent(error);
227 // Get bubble size.
228 var bubbleOffsetHeight = parseInt(bubble.offsetHeight);
229 var bubbleOffsetWidth = parseInt(bubble.offsetWidth);
230 // Restore attributes.
231 bubble.style.visibility = bubbleVisibility;
232 bubble.style.display = bubbleDisplay;
233 bubble.hidden = bubbleHidden;
234 if (bubbleClassListHasFaded)
235 bubble.classList.add('faded');
236
237 if (position == cr.ui.Bubble.Attachment.BOTTOM) {
238 // Move error bubble if it overlaps the shelf.
239 if (maxHeight < bubbleOffsetHeight)
240 position = cr.ui.Bubble.Attachment.TOP;
241 } else {
242 // Move error bubble if it doesn't fit screen.
243 if (maxWidth < bubbleOffsetWidth) {
244 bubblePositioningPadding = 2;
245 position = cr.ui.Bubble.Attachment.LEFT;
246 }
247 }
xiyuan 2016/11/02 16:17:21 The code block to calculate size and choose the ar
Alexander Alekseev 2016/11/03 01:27:43 Leaving it here as we decided that implementing as
248 var showBubbleCallback = function() {
197 activatedPod.removeEventListener("webkitTransitionEnd", 249 activatedPod.removeEventListener("webkitTransitionEnd",
198 showBottomCallback); 250 showBubbleCallback);
199 $('bubble').showContentForElement(bubbleAnchor, 251 $('bubble').showContentForElement(bubbleAnchor,
200 cr.ui.Bubble.Attachment.BOTTOM, 252 position,
201 error, 253 error,
202 BUBBLE_OFFSET, BUBBLE_PADDING); 254 BUBBLE_OFFSET,
255 bubblePositioningPadding, true);
203 }; 256 };
204 activatedPod.addEventListener("webkitTransitionEnd", 257 activatedPod.addEventListener("webkitTransitionEnd",
205 showBottomCallback); 258 showBubbleCallback);
206 ensureTransitionEndEvent(activatedPod); 259 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 } 260 }
224 }, 261 },
225 262
226 /** 263 /**
227 * Loads the PIN keyboard if any of the users can login with a PIN. Disables 264 * 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. 265 * the PIN keyboard for users who are not allowed to use PIN unlock.
229 * @param {array} users Array of user instances. 266 * @param {array} users Array of user instances.
230 */ 267 */
231 initializePinKeyboardStateForUsers_: function(users) { 268 initializePinKeyboardStateForUsers_: function(users) {
232 for (var i = 0; i < users.length; ++i) { 269 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 465 * @param {string} userID The user ID of the public session
429 * @param {string} locale The locale to which this list of keyboard layouts 466 * @param {string} locale The locale to which this list of keyboard layouts
430 * applies 467 * applies
431 * @param {!Object} list List of available keyboard layouts 468 * @param {!Object} list List of available keyboard layouts
432 */ 469 */
433 setPublicSessionKeyboardLayouts: function(userID, locale, list) { 470 setPublicSessionKeyboardLayouts: function(userID, locale, list) {
434 $('pod-row').setPublicSessionKeyboardLayouts(userID, locale, list); 471 $('pod-row').setPublicSessionKeyboardLayouts(userID, locale, list);
435 } 472 }
436 }; 473 };
437 }); 474 });
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