FIX: Use placeholder for avatar image size in expansion

This commit is contained in:
Robin Ward 2014-07-24 17:15:40 -04:00
parent eda0e40094
commit f2b554be13
2 changed files with 24 additions and 13 deletions

View file

@ -4,6 +4,8 @@ function daysSinceEpoch(dt) {
return dt.getTime() / 86400000; return dt.getTime() / 86400000;
} }
var safe = Handlebars.SafeString;
/** /**
Converts a date to a coldmap class Converts a date to a coldmap class
@ -68,7 +70,7 @@ function categoryLinkHTML(category, options) {
categoryOptions.categories = Em.Handlebars.get(this, options.hash.categories, options); categoryOptions.categories = Em.Handlebars.get(this, options.hash.categories, options);
} }
} }
return new Handlebars.SafeString(Discourse.HTML.categoryBadge(category, categoryOptions)); return new safe(Discourse.HTML.categoryBadge(category, categoryOptions));
} }
/** /**
@ -171,7 +173,7 @@ Handlebars.registerHelper('avatar', function(user, options) {
var uploadedAvatarId = Em.get(user, 'uploaded_avatar_id') || Em.get(user, 'user.uploaded_avatar_id'); var uploadedAvatarId = Em.get(user, 'uploaded_avatar_id') || Em.get(user, 'user.uploaded_avatar_id');
var avatarTemplate = Discourse.User.avatarTemplate(username,uploadedAvatarId); var avatarTemplate = Discourse.User.avatarTemplate(username,uploadedAvatarId);
return new Handlebars.SafeString(Discourse.Utilities.avatarImg({ return new safe(Discourse.Utilities.avatarImg({
size: options.hash.imageSize, size: options.hash.imageSize,
extraClasses: Em.get(user, 'extras') || options.hash.extraClasses, extraClasses: Em.get(user, 'extras') || options.hash.extraClasses,
title: title || username, title: title || username,
@ -189,7 +191,9 @@ Handlebars.registerHelper('avatar', function(user, options) {
@for Handlebars @for Handlebars
**/ **/
Em.Handlebars.helper('bound-avatar', function(user, size, uploadId) { Em.Handlebars.helper('bound-avatar', function(user, size, uploadId) {
if (Em.isEmpty(user)) { return; } if (Em.isEmpty(user)) {
return new safe("<div class='avatar-placeholder'></div>");
}
var username = Em.get(user, 'username'); var username = Em.get(user, 'username');
if(arguments.length < 4){ if(arguments.length < 4){
@ -198,7 +202,7 @@ Em.Handlebars.helper('bound-avatar', function(user, size, uploadId) {
var avatarTemplate = Discourse.User.avatarTemplate(username, uploadId); var avatarTemplate = Discourse.User.avatarTemplate(username, uploadId);
return new Handlebars.SafeString(Discourse.Utilities.avatarImg({ return new safe(Discourse.Utilities.avatarImg({
size: size, size: size,
avatarTemplate: avatarTemplate avatarTemplate: avatarTemplate
})); }));
@ -208,7 +212,7 @@ Em.Handlebars.helper('bound-avatar', function(user, size, uploadId) {
* Used when we only have a template * Used when we only have a template
*/ */
Em.Handlebars.helper('bound-avatar-template', function(avatarTemplate, size) { Em.Handlebars.helper('bound-avatar-template', function(avatarTemplate, size) {
return new Handlebars.SafeString(Discourse.Utilities.avatarImg({ return new safe(Discourse.Utilities.avatarImg({
size: size, size: size,
avatarTemplate: avatarTemplate avatarTemplate: avatarTemplate
})); }));
@ -243,7 +247,7 @@ Em.Handlebars.helper('bound-raw-date', function (date) {
**/ **/
Handlebars.registerHelper('age', function(property, options) { Handlebars.registerHelper('age', function(property, options) {
var dt = new Date(Ember.Handlebars.get(this, property, options)); var dt = new Date(Ember.Handlebars.get(this, property, options));
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(dt)); return new safe(Discourse.Formatter.autoUpdatingRelativeAge(dt));
}); });
/** /**
@ -254,7 +258,7 @@ Handlebars.registerHelper('age', function(property, options) {
**/ **/
Handlebars.registerHelper('age-with-tooltip', function(property, options) { Handlebars.registerHelper('age-with-tooltip', function(property, options) {
var dt = new Date(Ember.Handlebars.get(this, property, options)); var dt = new Date(Ember.Handlebars.get(this, property, options));
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(dt, {title: true})); return new safe(Discourse.Formatter.autoUpdatingRelativeAge(dt, {title: true}));
}); });
/** /**
@ -286,7 +290,7 @@ Handlebars.registerHelper('number', function(property, options) {
} }
result += ">" + n + "</span>"; result += ">" + n + "</span>";
return new Handlebars.SafeString(result); return new safe(result);
}); });
/** /**
@ -310,12 +314,12 @@ Handlebars.registerHelper('date', function(property, options) {
var val = Ember.Handlebars.get(this, property, options); var val = Ember.Handlebars.get(this, property, options);
if (val) { if (val) {
var date = new Date(val); var date = new Date(val);
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(date, {format: 'medium', title: true, leaveAgo: leaveAgo})); return new safe(Discourse.Formatter.autoUpdatingRelativeAge(date, {format: 'medium', title: true, leaveAgo: leaveAgo}));
} }
}); });
Em.Handlebars.helper('bound-date', function(dt) { Em.Handlebars.helper('bound-date', function(dt) {
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(new Date(dt), {format: 'medium', title: true })); return new safe(Discourse.Formatter.autoUpdatingRelativeAge(new Date(dt), {format: 'medium', title: true }));
}); });
/** /**
@ -337,7 +341,7 @@ Handlebars.registerHelper('custom-html', function(name, contextString, options)
}); });
Em.Handlebars.helper('human-size', function(size) { Em.Handlebars.helper('human-size', function(size) {
return new Handlebars.SafeString(I18n.toHumanSize(size)); return new safe(I18n.toHumanSize(size));
}); });
/** /**
@ -356,7 +360,7 @@ Handlebars.registerHelper('link-domain', function(property, options) {
if (!Em.isEmpty(domain)) { if (!Em.isEmpty(domain)) {
var s = domain.split('.'); var s = domain.split('.');
domain = s[s.length-2] + "." + s[s.length-1]; domain = s[s.length-2] + "." + s[s.length-1];
return new Handlebars.SafeString("<span class='domain'>" + domain + "</span>"); return new safe("<span class='domain'>" + domain + "</span>");
} }
} }
} }
@ -378,5 +382,5 @@ Handlebars.registerHelper('icon', function(icon, options) {
if (labelKey) { if (labelKey) {
html += "<span class='sr-only'>" + I18n.t(labelKey) + "</span>"; html += "<span class='sr-only'>" + I18n.t(labelKey) + "</span>";
} }
return new Handlebars.SafeString(html); return new safe(html);
}); });

View file

@ -10,6 +10,13 @@
background-color: $secondary; background-color: $secondary;
padding: 12px 12px 5px 12px; padding: 12px 12px 5px 12px;
.avatar-placeholder {
width: 120px;
height: 120px;
float: left;
padding-right: 10px;
}
h1 { h1 {
display: inline-block; display: inline-block;
min-width: 120px; min-width: 120px;