mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
/**
|
|
This view is for rendering an icon representing the status of a topic
|
|
|
|
@class TopicStatusComponent
|
|
@extends Ember.Component
|
|
@namespace Discourse
|
|
@module Discourse
|
|
**/
|
|
Discourse.TopicStatusComponent = Ember.Component.extend({
|
|
classNames: ['topic-statuses'],
|
|
|
|
hasDisplayableStatus: Em.computed.or('topic.closed', 'topic.pinned', 'topic.invisible', 'topic.archetypeObject.notDefault'),
|
|
shouldRerender: Discourse.View.renderIfChanged('topic.closed', 'topic.pinned', 'topic.visible'),
|
|
|
|
render: function(buffer) {
|
|
if (!this.get('hasDisplayableStatus')) { return; }
|
|
|
|
var self = this,
|
|
renderIconIf = function(conditionProp, name, key) {
|
|
if (!self.get(conditionProp)) { return; }
|
|
var title = I18n.t("topic_statuses." + key + ".help");
|
|
buffer.push("<span title='" + title + "' class='topic-status'><i class='fa fa-" + name + "'></i></span>");
|
|
};
|
|
|
|
// Allow a plugin to add a custom icon to a topic
|
|
this.trigger('addCustomIcon', buffer);
|
|
|
|
renderIconIf('topic.closed', 'lock', 'locked');
|
|
renderIconIf('topic.pinned', 'thumb-tack', 'pinned');
|
|
renderIconIf('topic.invisible', 'eye-close', 'invisible');
|
|
}
|
|
});
|
|
|
|
|
|
Discourse.View.registerHelper('topicStatus', Discourse.TopicStatusComponent);
|