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

Unified Diff: ui/login/bubble.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 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..ca9b9d1bcac654305a49f3648de749daeb3b4de0 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) {
+ this.setAttribute('match-width', '');
+ var elWidth =
+ window.getComputedStyle(el, null).getPropertyValue('width');
+ var paddingLeft = parseInt(window.getComputedStyle(this, null)
+ .getPropertyValue('padding-left'));
+ var paddingRight = parseInt(window.getComputedStyle(this, null)
+ .getPropertyValue('padding-right'));
+ if (elWidth)
+ this.style.width =
+ (parseInt(elWidth) - paddingLeft - paddingRight) + 'px';
+ }
this.anchor_ = el;
this.showContentAt_(pos, opt_content);
« ui/login/bubble.css ('K') | « ui/login/bubble.css ('k') | ui/login/login_ui_tools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698