Add title to user header. Refactor statusIcon a bit.

This commit is contained in:
Robin Ward 2015-01-12 14:45:19 -05:00
parent 6ee2849df6
commit dba57a4a25
4 changed files with 25 additions and 19 deletions

View file

@ -0,0 +1,20 @@
import registerUnbound from 'discourse/helpers/register-unbound';
var safe = Handlebars.SafeString;
registerUnbound('user-status', function(user) {
if (!user) { return; }
var name = Handlebars.Utils.escapeExpression(user.get('name'));
if(Discourse.User.currentProp("admin") || Discourse.User.currentProp("moderator")) {
if(user.get('admin')) {
var adminDesc = I18n.t('user.admin', {user: name});
return new safe('<i class="fa fa-shield" title="' + adminDesc + '" alt="' + adminDesc + '"></i>');
}
}
if(user.get('moderator')){
var modDesc = I18n.t('user.moderator', {user: name});
return new safe('<i class="fa fa-shield" title="' + modDesc + '" alt="' + modDesc + '"></i>');
}
});

View file

@ -78,23 +78,6 @@ Discourse.User = Discourse.Model.extend({
return 'background-image: url(' + background + ')';
}.property('profile_background'),
statusIcon: function() {
var name = Handlebars.Utils.escapeExpression(this.get('name')),
desc;
if(Discourse.User.currentProp("admin") || Discourse.User.currentProp("moderator")) {
if(this.get('admin')) {
desc = I18n.t('user.admin', {user: name});
return '<i class="fa fa-shield" title="' + desc + '" alt="' + desc + '"></i>';
}
}
if(this.get('moderator')){
desc = I18n.t('user.moderator', {user: name});
return '<i class="fa fa-shield" title="' + desc + '" alt="' + desc + '"></i>';
}
return null;
}.property('admin','moderator'),
/**
Path to this user.

View file

@ -5,7 +5,7 @@
<div class="names">
<span>
<h1 {{bind-attr class="staff new_user"}}>
{{#link-to 'user' user}}{{username}}{{{user.statusIcon}}}{{/link-to}}
{{#link-to 'user' user}}{{username}} {{user-status user}}{{/link-to}}
</h1>
{{#if user.name}}

View file

@ -60,8 +60,11 @@
</section>
<div class="primary-textual">
<h1>{{username}} {{{statusIcon}}}</h1>
<h1>{{username}} {{user-status model}}</h1>
<h2>{{name}}</h2>
{{#if title}}
<h3>{{title}}</h3>
{{/if}}
<h3>
{{#if location}}{{fa-icon "map-maker"}}{{location}}{{/if}}
{{#if websiteName}}