1
0
mirror of https://github.com/flarum/core.git synced 2025-07-31 21:50:50 +02:00

Implement user hover cards and basic profile pages

This commit is contained in:
Toby Zerner
2015-03-12 10:40:03 +10:30
parent 9891e5af18
commit 2fc562e8d1
16 changed files with 252 additions and 18 deletions

View File

@@ -0,0 +1,62 @@
import Ember from 'ember';
import HasItemLists from 'flarum/mixins/has-item-lists';
export default Ember.Component.extend(HasItemLists, {
layoutName: 'components/user/user-card',
classNames: ['user-card'],
attributeBindings: ['style'],
itemLists: ['controls', 'info'],
style: Ember.computed('user.color', function() {
return 'background-color: '+this.get('user.color');
}),
bioEditable: Ember.computed.and('user.canEdit', 'editable'),
showBio: Ember.computed.or('user.bioHtml', 'bioEditable'),
didInsertElement: function() {
this.$().on('click', '.user-bio a', function(e) {
e.stopPropagation();
});
},
actions: {
editBio: function() {
if (!this.get('bioEditable')) {
return;
}
this.set('editingBio', true);
var component = this;
Ember.run.scheduleOnce('afterRender', this, function() {
this.$('.user-bio textarea').focus().blur(function() {
component.send('saveBio', $(this).val());
});
});
},
saveBio: function(value) {
var user = this.get('user');
user.set('bio', value);
user.save();
this.set('editingBio', false);
}
},
populateControls: function(items) {
this.addActionItem(items, 'edit', 'Edit', 'pencil');
this.addActionItem(items, 'delete', 'Delete', 'times');
},
populateInfo: function(items) {
items.pushObjectWithTag(Ember.Component.extend({
layout: Ember.Handlebars.compile('{{fa-icon "circle"}} Online')
}), 'lastActiveTime');
items.pushObjectWithTag(Ember.Component.extend({
layout: Ember.Handlebars.compile('Joined {{human-time user.joinTime}}'),
user: this.get('user')
}), 'joinTime');
}
});