Make discussion count jump to last when read

This commit is contained in:
Toby Zerner 2015-02-03 19:06:50 +10:30
parent d2ef15455e
commit bc3aa449e7
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');
}.property('countType', 'discussion.isUnread'),
countTitle: function() {
return this.get('discussion.isUnread') ? 'Mark as Read' : 'Jump to Last';
}.property('discussion.isUnread'),
displayLastPost: function() {
return this.get('terminalPostType') === 'last' && this.get('discussion.repliesCount');
}.property('terminalPostType', 'discussion.repliesCount'),
@ -56,10 +60,6 @@ export default Ember.Component.extend({
$this.animate({opacity: 1}, 'fast');
}, 100);
if (this.get('discussion.isUnread')) {
this.$().find('.count').tooltip({container: 'body'});
}
// var view = this;
// this.$().find('a.info').click(function() {
@ -148,6 +148,13 @@ export default Ember.Component.extend({
if ( ! this.get('controls.length')) {
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;
color: @fl-body-muted-color;
font-size: 11px;
cursor: pointer;
text-decoration: none;
& strong {
font-size: 20px;
@ -242,7 +244,6 @@
.unread&, .unread& strong {
color: @fl-body-heading-color;
font-weight: bold;
cursor: pointer;
}
}
}

View File

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

View File

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