mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-24 08:09:13 -05:00
Merge pull request #806 from ZogStriP/clear-pin-link-in-list-topics-view
Add a clear pin link in the list topics view
This commit is contained in:
commit
3ca263568e
3 changed files with 17 additions and 5 deletions
|
@ -53,6 +53,11 @@ Discourse.ListTopicsController = Discourse.ObjectController.extend({
|
|||
topic.toggleStar();
|
||||
},
|
||||
|
||||
// clear a pinned topic
|
||||
clearPin: function(topic) {
|
||||
topic.clearPin();
|
||||
},
|
||||
|
||||
toggleRankDetails: function() {
|
||||
this.toggleProperty('rankDetailsVisible');
|
||||
},
|
||||
|
|
|
@ -371,13 +371,17 @@ Discourse.Topic = Discourse.Model.extend({
|
|||
},
|
||||
|
||||
hasExcerpt: function() {
|
||||
return this.get('excerpt') && this.get('excerpt').length > 0;
|
||||
}.property('excerpt'),
|
||||
return this.get('pinned') && this.get('excerpt') && this.get('excerpt').length > 0;
|
||||
}.property('pinned', 'excerpt'),
|
||||
|
||||
excerptTruncated: function() {
|
||||
var e = this.get('excerpt');
|
||||
return( e && e.substr(e.length - 8,8) === '…' );
|
||||
}.property('excerpt')
|
||||
}.property('excerpt'),
|
||||
|
||||
canClearPin: function() {
|
||||
return this.get('pinned') && (this.get('last_read_post_number') === this.get('highest_post_number'));
|
||||
}.property('pinned', 'last_read_post_number', 'highest_post_number')
|
||||
});
|
||||
|
||||
Discourse.Topic.reopenClass({
|
||||
|
|
|
@ -29,11 +29,14 @@
|
|||
<a href="{{lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
||||
{{/if}}
|
||||
|
||||
{{#if excerpt}}
|
||||
{{#if hasExcerpt}}
|
||||
<div class="topic-excerpt">
|
||||
{{excerpt}}
|
||||
{{#if excerptTruncated}}
|
||||
<a href="{{lastReadUrl}}">{{i18n read_more}}</a>
|
||||
{{#unless canClearPin}}<a href="{{lastReadUrl}}">{{i18n read_more}}</a>{{/unless}}
|
||||
{{/if}}
|
||||
{{#if canClearPin}}
|
||||
<a href="#" {{action clearPin this target="controller"}} title="{{unbound i18n topic.clear_pin.help}}">{{i18n topic.clear_pin.title}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in a new issue