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

Unified Diff: ui/login/bubble.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
Index: ui/login/bubble.js
diff --git a/ui/login/bubble.js b/ui/login/bubble.js
index 1340f28213b8cf3706e5e4abb6e81bfa8614c727..b5c3ae4e44214d6b6374de9c9a9f96313546c38c 100644
--- a/ui/login/bubble.js
+++ b/ui/login/bubble.js
@@ -147,15 +147,23 @@ cr.define('cr.ui', function() {
if (typeof pos[k] == 'number')
this.style[k] = pos[k] + 'px';
}
- if (opt_content !== undefined) {
- this.innerHTML = '';
- this.appendChild(opt_content);
- }
+ if (opt_content !== undefined)
+ this.replaceContent(opt_content);
+
this.hidden = false;
this.classList.remove('faded');
},
/**
+ * Replaces error message content with the given DOM element.
+ * @param {HTMLElement} content Content to show in bubble.
+ */
+ replaceContent: function(content) {
+ this.innerHTML = '';
+ this.appendChild(content);
+ },
+
+ /**
* Shows the bubble for given anchor element. Bubble content is not cleared.
* @param {!HTMLElement} el Anchor element of the bubble.
* @param {!Attachment} attachment Bubble attachment (on which side of the
@@ -183,7 +191,7 @@ cr.define('cr.ui', function() {
* @param {number=} opt_padding Optional padding of the bubble.
*/
showContentForElement: function(el, attachment, opt_content,
- opt_offset, opt_padding) {
+ opt_offset, opt_padding, opt_match_width) {
/** @const */ var ARROW_OFFSET = 25;
/** @const */ var DEFAULT_PADDING = 18;
@@ -237,6 +245,20 @@ cr.define('cr.ui', function() {
break;
}
}
+ this.style.width = '';
+ this.removeAttribute('match-width');
+ if (opt_match_width) {
xiyuan 2016/11/02 16:17:22 Would does match_width mean when bubble is on the
Alexander Alekseev 2016/11/03 01:27:43 From design mocks I guess that yes, we should use
+ this.setAttribute('match-width', '');
+ var el_width =
xiyuan 2016/11/02 16:17:21 el_width -> elWidth, JS uses lowerThenCamelCase st
Alexander Alekseev 2016/11/03 01:27:43 Done.
+ window.getComputedStyle(el, null).getPropertyValue('width');
+ var padding_left = parseInt(window.getComputedStyle(this, null)
xiyuan 2016/11/02 16:17:22 padding_left -> paddingLeft
Alexander Alekseev 2016/11/03 01:27:43 Done.
+ .getPropertyValue('padding-left'));
+ var padding_right = parseInt(window.getComputedStyle(this, null)
xiyuan 2016/11/02 16:17:21 padding_right -> paddingRight
Alexander Alekseev 2016/11/03 01:27:43 Done.
+ .getPropertyValue('padding-right'));
+ if (el_width)
+ this.style.width =
+ (parseInt(el_width) - padding_left - padding_right) + 'px';
+ }
this.anchor_ = el;
this.showContentAt_(pos, opt_content);

Powered by Google App Engine
This is Rietveld 408576698