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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/login/bubble.css » ('j') | ui/login/bubble.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/login/account_picker/screen_account_picker.js
diff --git a/ui/login/account_picker/screen_account_picker.js b/ui/login/account_picker/screen_account_picker.js
index b70d43e440d1dde35048862979fbf1b9a82a59c2..5c8f446333229abcf177fc6c51555e7644be6177 100644
--- a/ui/login/account_picker/screen_account_picker.js
+++ b/ui/login/account_picker/screen_account_picker.js
@@ -179,47 +179,84 @@ login.createScreen('AccountPickerScreen', 'account-picker', function() {
}
// Update the pod row display if incorrect password.
$('pod-row').setFocusedPodErrorDisplay(true);
- // We want bubble's arrow to point to the first letter of input.
- /** @const */ var BUBBLE_OFFSET = 7;
- /** @const */ var BUBBLE_PADDING = 4;
- // Anchor the bubble to the pod instead of the input if the pin keyboard
- // is showing to avoid covering parts of the pin keyboard.
+ /** @const */ var BUBBLE_OFFSET = 25;
+ // -8 = 4 - 2(bubble margin) - 10 (internal bubble adjustment)
+ var bubblePositioningPadding = -8;
+
var bubbleAnchor;
- if (activatedPod.pinContainer)
+ var position;
+ if (activatedPod.pinContainer) {
+ // Anchor the bubble to the input field.
+ var elements = activatedPod.getElementsByClassName('auth-container');
+ if (elements.length == 1) {
+ bubbleAnchor = elements[0];
+ } else {
+ console.error('auth-container not found');
+ bubbleAnchor = activatedPod.mainInput;
+ }
+ position = cr.ui.Bubble.Attachment.RIGHT;
+ } else {
+ // Anchor the bubble to the pod instead of the input.
bubbleAnchor = activatedPod;
- else
- bubbleAnchor = activatedPod.mainInput;
+ position = cr.ui.Bubble.Attachment.BOTTOM;
+ }
- // We want the bubble to point to where the input is after it is done
- // transitioning.
- var showBottomCallback = function() {
+ var bubble = $('bubble');
+ // Cannot use cr.ui.LoginUITools.get* on bubble until it is attached to
+ // the element.
+ // 4 = bubble distance from element
+ var maxHeight =
+ cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping(bubbleAnchor)
+ - bubbleAnchor.offsetHeight - 4;
+ var maxWidth = cr.ui.LoginUITools.getMaxWidthToFit(bubbleAnchor)
+ - bubbleAnchor.offsetWidth - 4;
+
+ // Change bubble visibility temporary to calculate height.
+ var bubbleClassListHasFaded = bubble.classList.contains('bubble');
+ var bubbleVisibility = bubble.style.visibility;
+ 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.
+ var bubbleHidden = bubble.hidden;
+ bubble.style.visibility = 'hidden';
+ bubble.style.display = 'block';
+ 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.
+ bubble.hidden = false;
+ // Now we need the bubble to have the new content before calculating
+ // size.
+ bubble.replaceContent(error);
+ // Get bubble size.
+ var bubbleOffsetHeight = parseInt(bubble.offsetHeight);
+ var bubbleOffsetWidth = parseInt(bubble.offsetWidth);
+ // Restore attributes.
+ bubble.style.visibility = bubbleVisibility;
+ bubble.style.display = bubbleDisplay;
+ bubble.hidden = bubbleHidden;
+ if (bubbleClassListHasFaded)
+ bubble.classList.add('faded');
+
+ if (position == cr.ui.Bubble.Attachment.BOTTOM) {
+ // Move error bubble if it overlaps the shelf.
+ if (maxHeight < bubbleOffsetHeight)
+ position = cr.ui.Bubble.Attachment.TOP;
+ } else {
+ // Move error bubble if it doesn't fit screen.
+ if (maxWidth < bubbleOffsetWidth) {
+ bubblePositioningPadding = 2;
+ position = cr.ui.Bubble.Attachment.LEFT;
+ }
+ }
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
+ var showBubbleCallback = function() {
activatedPod.removeEventListener("webkitTransitionEnd",
- showBottomCallback);
+ showBubbleCallback);
$('bubble').showContentForElement(bubbleAnchor,
- cr.ui.Bubble.Attachment.BOTTOM,
+ position,
error,
- BUBBLE_OFFSET, BUBBLE_PADDING);
+ BUBBLE_OFFSET,
+ bubblePositioningPadding, true);
};
activatedPod.addEventListener("webkitTransitionEnd",
- showBottomCallback);
+ showBubbleCallback);
ensureTransitionEndEvent(activatedPod);
-
- // Move error bubble up if it overlaps the shelf.
- var maxHeight =
- cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping($('bubble'));
- if (maxHeight < $('bubble').offsetHeight) {
- var showTopCallback = function() {
- activatedPod.removeEventListener("webkitTransitionEnd",
- showTopCallback);
- $('bubble').showContentForElement(bubbleAnchor,
- cr.ui.Bubble.Attachment.TOP,
- error,
- BUBBLE_OFFSET, BUBBLE_PADDING);
- };
- activatedPod.addEventListener("webkitTransitionEnd", showTopCallback);
- ensureTransitionEndEvent(activatedPod);
- }
}
},
« 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