Properly use htmlSafe styles

This commit is contained in:
Matthew Beale 2015-11-20 17:45:43 -05:00
parent 43bb09ef23
commit 6aa171077e
5 changed files with 9 additions and 7 deletions

View File

@ -25,7 +25,7 @@ export default Ember.Component.extend({
}),
authorAvatarBackground: Ember.computed('authorAvatar', function () {
return `background-image: url(${this.get('authorAvatar')})`.htmlSafe();
return Ember.String.htmlSafe(`background-image: url(${this.get('authorAvatar')})`);
}),
viewOrEdit: Ember.computed('previewIsHidden', function () {

View File

@ -48,10 +48,12 @@ export default Ember.Component.extend({
const email = this.get('validEmail'),
size = this.get('size');
let style = '';
if (email) {
let url = `http://www.gravatar.com/avatar/${md5(email)}?s=${size}&d=blank`;
return Ember.String.htmlSafe(`background-image: url(${url})`);
style = `background-image: url(${url})`;
}
return Ember.String.htmlSafe(style);
}),
didInsertElement: function () {

View File

@ -14,7 +14,7 @@ export default Ember.Component.extend({
userImageBackground: Ember.computed('user.image', 'userDefault', function () {
var url = this.get('user.image') || this.get('userDefault');
return `background-image: url(${url})`.htmlSafe();
return Ember.String.htmlSafe(`background-image: url(${url})`);
}),
lastLogin: Ember.computed('user.last_login', function () {

View File

@ -56,7 +56,7 @@ export default Ember.Controller.extend(ValidationEngine, {
userImageBackground: Ember.computed('user.image', 'userDefault', function () {
var url = this.get('user.image') || this.get('userDefault');
return `background-image: url(${url})`.htmlSafe();
return Ember.String.htmlSafe(`background-image: url(${url})`);
}),
// end duplicated
@ -68,7 +68,7 @@ export default Ember.Controller.extend(ValidationEngine, {
coverImageBackground: Ember.computed('user.cover', 'coverDefault', function () {
var url = this.get('user.cover') || this.get('coverDefault');
return `background-image: url(${url})`.htmlSafe();
return Ember.String.htmlSafe(`background-image: url(${url})`);
}),
coverTitle: Ember.computed('user.name', function () {

View File

@ -36,7 +36,7 @@
<div class="view-container settings-user">
<figure class="user-cover" style="{{coverImageBackground}}">
<figure class="user-cover" style={{coverImageBackground}}>
<button class="btn btn-default user-cover-edit js-modal-cover" {{action "openModal" "upload" user "cover"}}>Change Cover</button>
</figure>
@ -49,7 +49,7 @@
<fieldset class="user-details-top">
<figure class="user-image">
<div id="user-image" class="img" style="{{userImageBackground}}"><span class="hidden">{{user.name}}"s Picture</span></div>
<div id="user-image" class="img" style={{userImageBackground}}><span class="hidden">{{user.name}}"s Picture</span></div>
<button type="button" {{action "openModal" "upload" user "image"}} class="edit-user-image js-modal-image">Edit Picture</button>
</figure>