diff --git a/polygerrit-ui/app/elements/gr-account-link.html b/polygerrit-ui/app/elements/gr-account-link.html index 8b682367ea..55791c61f5 100644 --- a/polygerrit-ui/app/elements/gr-account-link.html +++ b/polygerrit-ui/app/elements/gr-account-link.html @@ -30,7 +30,7 @@ limitations under the License. a:hover span { text-decoration: underline; } - img { + gr-avatar { height: 1.3em; width: 1.3em; vertical-align: -.3em; @@ -39,7 +39,8 @@ limitations under the License. - + [[account.name]] ([[account.email]]) @@ -56,7 +57,7 @@ limitations under the License. properties: { account: Object, - avatarSize: { + avatarImageSize: { type: Number, value: 32, }, diff --git a/polygerrit-ui/app/elements/gr-avatar.html b/polygerrit-ui/app/elements/gr-avatar.html index 8e808eefd5..48eec6a691 100644 --- a/polygerrit-ui/app/elements/gr-avatar.html +++ b/polygerrit-ui/app/elements/gr-avatar.html @@ -20,7 +20,9 @@ limitations under the License. @@ -31,14 +33,12 @@ limitations under the License. Polymer({ is: 'gr-avatar', - extends: 'img', - properties: { account: { type: Object, observer: '_accountChanged', }, - size: { + imageSize: { type: Number, value: 16, }, @@ -50,27 +50,30 @@ limitations under the License. ready: function() { app.configReady.then(function(cfg) { - var showAvatar = !!(cfg && cfg.plugin && cfg.plugin.has_avatars); - if (showAvatar) { + var hasAvatars = !!(cfg && cfg.plugin && cfg.plugin.has_avatars); + if (hasAvatars) { this.hidden = false; - this.updateAvatarSrc(this.account); // src needs to be set if avatar becomes visible + this._updateAvatarURL(this.account); // src needs to be set if avatar becomes visible } }.bind(this)); }, _accountChanged: function(account) { - this.updateAvatarSrc(account); + this._updateAvatarURL(account); }, - updateAvatarSrc: function(account) { + _updateAvatarURL: function(account) { if (!this.hidden && account) { - this.setAttribute('src', this._buildAvatarURL(account)); + var url = this._buildAvatarURL(this.account); + if (url) { + this.style.backgroundImage = 'url("' + url + '")'; + } } }, _buildAvatarURL: function(account) { if (!account) { return ''; } - return '/accounts/' + account._account_id + '/avatar?s=' + this.size; + return '/accounts/' + account._account_id + '/avatar?s=' + this.imageSize; }, }); diff --git a/polygerrit-ui/app/elements/gr-message.html b/polygerrit-ui/app/elements/gr-message.html index c1d0e2ef77..584021eafe 100644 --- a/polygerrit-ui/app/elements/gr-message.html +++ b/polygerrit-ui/app/elements/gr-message.html @@ -30,7 +30,7 @@ limitations under the License. :host(:not([expanded])) { cursor: pointer; } - [is="gr-avatar"] { + gr-avatar { position: absolute; left: var(--default-horizontal-margin); } @@ -53,12 +53,12 @@ limitations under the License. margin-left: 0; padding: 10px 75px 10px 0; } - .collapsed [is="gr-avatar"] { + .collapsed gr-avatar { top: 8px; height: 1.75em; width: 1.75em; } - .expanded [is="gr-avatar"] { + .expanded gr-avatar { top: 12px; height: 2.5em; width: 2.5em; @@ -92,7 +92,7 @@ limitations under the License. }
- +
[[message.author.name]]
diff --git a/polygerrit-ui/app/test/gr-avatar-test.html b/polygerrit-ui/app/test/gr-avatar-test.html index 22fa2db795..cb32dca18a 100644 --- a/polygerrit-ui/app/test/gr-avatar-test.html +++ b/polygerrit-ui/app/test/gr-avatar-test.html @@ -26,7 +26,7 @@ limitations under the License. @@ -49,20 +49,18 @@ limitations under the License. test('dom for existing account', function() { assert.isTrue(element.hasAttribute('hidden'), 'element not hidden initially'); element.hidden = false; - assert.isFalse(element.hasAttribute('hidden'), 'element hidden'); - - element.size = 64; + element.imageSize = 64; element.account = { _account_id: 123 }; - - assert.equal(element.getAttribute('src'), '/accounts/123/avatar?s=64'); + assert.isFalse(element.hasAttribute('hidden'), 'element hidden'); + assert.isTrue(element.style.backgroundImage.indexOf('/accounts/123/avatar?s=64') > -1); }); test('dom for non available account', function() { assert.isTrue(element.hasAttribute('hidden'), 'element not hidden initially'); element.account = undefined; - assert.isFalse(element.hasAttribute('src'), 'src not set'); + assert.isTrue(element.hasAttribute('hidden'), 'element not hidden'); }); });