mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
Add discussion author tooltip
This commit is contained in:
parent
1751f3fb82
commit
48d84edff6
|
@ -2,6 +2,7 @@ import Ember from 'ember';
|
|||
|
||||
import HasItemLists from 'flarum/mixins/has-item-lists';
|
||||
import FadeIn from 'flarum/mixins/fade-in';
|
||||
import humanTime from 'flarum/utils/human-time';
|
||||
|
||||
/**
|
||||
Component for a discussion listing on the discussions index. It has `info`
|
||||
|
@ -38,10 +39,14 @@ export default Ember.Component.extend(FadeIn, HasItemLists, {
|
|||
return this.get('terminalPostType') === 'last' && this.get('discussion.repliesCount');
|
||||
}),
|
||||
|
||||
start: Ember.computed('discussion.lastPostNumber', 'discussion.readNumber', function() {
|
||||
jumpTo: Ember.computed('discussion.lastPostNumber', 'discussion.readNumber', function() {
|
||||
return Math.min(this.get('discussion.lastPostNumber'), (this.get('discussion.readNumber') || 0) + 1);
|
||||
}),
|
||||
|
||||
authorInfo: Ember.computed('discussion.startUser.username', 'discussion.startTime', function() {
|
||||
return (this.get('discussion.startUser.username') || '[deleted]')+' started '+humanTime(this.get('discussion.startTime'));
|
||||
}),
|
||||
|
||||
relevantPosts: Ember.computed('discussion.relevantPosts', 'discussion.startPost', 'discussion.lastPost', function() {
|
||||
if (this.get('controller.show') !== 'posts') { return []; }
|
||||
if (this.get('controller.searchQuery')) {
|
||||
|
@ -53,6 +58,10 @@ export default Ember.Component.extend(FadeIn, HasItemLists, {
|
|||
}
|
||||
}),
|
||||
|
||||
didInsertElement: function() {
|
||||
this.$('.author').tooltip({ placement: 'right' });
|
||||
},
|
||||
|
||||
populateControls: function(items) {
|
||||
this.addActionItem(items, 'delete', 'Delete', 'times', 'discussion.canDelete');
|
||||
},
|
||||
|
|
|
@ -6,7 +6,11 @@ export default Ember.Handlebars.makeBoundHelper(function(user, options) {
|
|||
|
||||
if (user) {
|
||||
var username = user.get('username') || '?';
|
||||
attributes += ' title="'+Ember.Handlebars.Utils.escapeExpression(username)+'"';
|
||||
|
||||
if (typeof options.hash.title === 'undefined') {
|
||||
options.hash.title = Ember.Handlebars.Utils.escapeExpression(username);
|
||||
}
|
||||
attributes += ' title="'+options.hash.title+'"';
|
||||
|
||||
var avatarUrl = user.get('avatarUrl');
|
||||
if (avatarUrl) {
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
menuClass="pull-right"}}
|
||||
{{/if}}
|
||||
|
||||
{{#link-to "user" discussion.startUser class="author"}}{{user-avatar discussion.startUser}}{{/link-to}}
|
||||
{{#link-to "user" discussion.startUser class="author" title=authorInfo}}{{user-avatar discussion.startUser title=""}}{{/link-to}}
|
||||
|
||||
{{ui/item-list items=discussion.badges class="badges"}}
|
||||
|
||||
{{#link-to "discussion" discussion (query-params start=start) current-when="discussion" class="main"}}
|
||||
{{#link-to "discussion" discussion (query-params start=jumpTo) current-when="discussion" class="main"}}
|
||||
<h3 class="title">{{highlight-words discussion.title searchQuery}}</h3>
|
||||
{{ui/item-list items=info class="info"}}
|
||||
{{/link-to}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user