2014-12-20 14:26:46 +08:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Handlebars.makeBoundHelper(function(user, options) {
|
2015-02-26 10:17:50 +08:00
|
|
|
var attributes = 'class="avatar '+(options.hash.class || '')+'"';
|
2015-02-13 09:15:14 +08:00
|
|
|
var content = '';
|
2014-12-20 14:26:46 +08:00
|
|
|
|
2015-02-13 09:15:14 +08:00
|
|
|
if (user) {
|
|
|
|
var username = user.get('username') || '?';
|
|
|
|
attributes += ' title="'+Ember.Handlebars.Utils.escapeExpression(username)+'"';
|
2014-12-20 14:26:46 +08:00
|
|
|
|
2015-02-13 09:15:14 +08:00
|
|
|
var avatarUrl = user.get('avatarUrl');
|
|
|
|
if (avatarUrl) {
|
|
|
|
return new Ember.Handlebars.SafeString('<img src="'+avatarUrl+'" '+attributes+'>');
|
2015-01-21 11:59:00 +08:00
|
|
|
}
|
2014-12-20 14:26:46 +08:00
|
|
|
|
2015-02-13 09:15:14 +08:00
|
|
|
content = username.charAt(0).toUpperCase();
|
|
|
|
attributes += ' style="background:'+user.get('color')+'"';
|
|
|
|
}
|
2014-12-20 14:26:46 +08:00
|
|
|
|
2015-02-13 09:15:14 +08:00
|
|
|
return new Ember.Handlebars.SafeString('<span '+attributes+'>'+content+'</span>');
|
2014-12-20 14:26:46 +08:00
|
|
|
});
|
|
|
|
|