1
0
mirror of https://github.com/flarum/core.git synced 2025-08-03 23:17:43 +02:00

Make discussion count jump to last when read

This commit is contained in:
Toby Zerner
2015-02-03 19:06:50 +10:30
parent 06d976adba
commit b03740f363
4 changed files with 24 additions and 13 deletions

View File

@@ -25,6 +25,10 @@ export default Ember.Component.extend({
return this.get('countType') === 'unread' && this.get('discussion.isUnread'); return this.get('countType') === 'unread' && this.get('discussion.isUnread');
}.property('countType', 'discussion.isUnread'), }.property('countType', 'discussion.isUnread'),
countTitle: function() {
return this.get('discussion.isUnread') ? 'Mark as Read' : 'Jump to Last';
}.property('discussion.isUnread'),
displayLastPost: function() { displayLastPost: function() {
return this.get('terminalPostType') === 'last' && this.get('discussion.repliesCount'); return this.get('terminalPostType') === 'last' && this.get('discussion.repliesCount');
}.property('terminalPostType', 'discussion.repliesCount'), }.property('terminalPostType', 'discussion.repliesCount'),
@@ -56,10 +60,6 @@ export default Ember.Component.extend({
$this.animate({opacity: 1}, 'fast'); $this.animate({opacity: 1}, 'fast');
}, 100); }, 100);
if (this.get('discussion.isUnread')) {
this.$().find('.count').tooltip({container: 'body'});
}
// var view = this; // var view = this;
// this.$().find('a.info').click(function() { // this.$().find('a.info').click(function() {
@@ -148,6 +148,13 @@ export default Ember.Component.extend({
if ( ! this.get('controls.length')) { if ( ! this.get('controls.length')) {
this.trigger('populateControls', this.get('controls')); this.trigger('populateControls', this.get('controls'));
} }
},
markAsRead: function() {
if (this.get('discussion.isUnread')) {
window.event.stopPropagation();
this.sendAction('markAsRead', this.get('discussion'));
}
} }
} }

View File

@@ -233,6 +233,8 @@
text-transform: uppercase; text-transform: uppercase;
color: @fl-body-muted-color; color: @fl-body-muted-color;
font-size: 11px; font-size: 11px;
cursor: pointer;
text-decoration: none;
& strong { & strong {
font-size: 20px; font-size: 20px;
@@ -242,7 +244,6 @@
.unread&, .unread& strong { .unread&, .unread& strong {
color: @fl-body-heading-color; color: @fl-body-heading-color;
font-weight: bold; font-weight: bold;
cursor: pointer;
} }
} }
} }

View File

@@ -26,13 +26,15 @@
</span> </span>
{{/link-to}} {{/link-to}}
<div class="count" title="Mark as Read" {{action "markAsRead"}}> {{#link-to "discussion" discussion.content (query-params start=discussion.lastPostNumber) current-when=null class="count" title=countTitle}}
{{#if displayUnread}} <span {{action "markAsRead"}}>
<strong>{{abbreviate-number discussion.unreadCount}}</strong> unread {{#if displayUnread}}
{{else}} <strong>{{abbreviate-number discussion.unreadCount}}</strong> unread
<strong>{{abbreviate-number discussion.repliesCount}}</strong> replies {{else}}
{{/if}} <strong>{{abbreviate-number discussion.repliesCount}}</strong> replies
</div> {{/if}}
</span>
{{/link-to}}
{{#if relevantPosts}} {{#if relevantPosts}}
<div class="relevant-posts"> <div class="relevant-posts">

View File

@@ -30,7 +30,8 @@
discussion=discussion discussion=discussion
searchQuery=searchQuery searchQuery=searchQuery
terminalPostType=terminalPostType terminalPostType=terminalPostType
countType=countType}} countType=countType
markAsRead="markAsRead"}}
{{/each}} {{/each}}
</ul> </ul>