FIX: Topic Status Icons had weird margins after font awesome update

This commit is contained in:
Robin Ward 2013-07-11 12:04:39 -04:00
parent 4540a51a8f
commit eba662b988
4 changed files with 22 additions and 35 deletions

View file

@ -8,14 +8,14 @@
**/
Discourse.Archetype = Discourse.Model.extend({
hasOptions: function() {
if (!this.get('options')) return false;
return this.get('options').length > 0;
}.property('options.@each'),
hasOptions: Em.computed.gt('options.length', 0),
isDefault: function() {
return this.get('id') === Discourse.Site.instance().get('default_archetype');
}.property('id')
site: function() {
return Discourse.Site.instance();
}.property(),
isDefault: Discourse.computed.propertyEqual('id', 'site.default_archetype'),
notDefault: Em.computed.not('isDefault')
});

View file

@ -16,6 +16,8 @@ Discourse.Topic = Discourse.Model.extend({
return Discourse.TopicDetails.create({topic: this});
}.property(),
invisible: Em.computed.not('visible'),
canConvertToRegular: function() {
var a = this.get('archetype');
return a !== 'regular' && a !== 'private_message';
@ -130,9 +132,7 @@ Discourse.Topic = Discourse.Model.extend({
return Discourse.Site.instance().get('archetypes').findProperty('id', this.get('archetype'));
}.property('archetype'),
isPrivateMessage: (function() {
return this.get('archetype') === 'private_message';
}).property('archetype'),
isPrivateMessage: Em.computed.equal('archetype', 'private_message'),
toggleStatus: function(property) {
this.toggleProperty(property);

View file

@ -9,38 +9,25 @@
Discourse.TopicStatusView = Discourse.View.extend({
classNames: ['topic-statuses'],
hasDisplayableStatus: function() {
if (this.get('topic.closed')) return true;
if (this.get('topic.pinned')) return true;
if (!this.get('topic.archetype.isDefault')) return true;
if (!this.get('topic.visible')) return true;
return false;
}.property('topic.closed', 'topic.pinned', 'topic.visible'),
hasDisplayableStatus: Em.computed.or('topic.closed', 'topic.pinned', 'topic.invisible', 'topic.archetypeObject.notDefault'),
shouldRerender: Discourse.View.renderIfChanged('topic.closed', 'topic.pinned', 'topic.visible'),
renderIcon: function(buffer, name, key) {
var title = I18n.t("topic_statuses." + key + ".help");
return buffer.push("<span title='" + title + "' class='topic-status'><i class='icon icon-" + name + "'></i></span>");
},
render: function(buffer) {
if (!this.get('hasDisplayableStatus')) { return; }
var topicStatusView = this;
var renderIconIf = function(conditionProp, name, key) {
if (!topicStatusView.get(conditionProp)) { return; }
var title = I18n.t("topic_statuses." + key + ".help");
buffer.push("<span title='" + title + "' class='topic-status'><i class='icon icon-" + name + "'></i></span>");
};
// Allow a plugin to add a custom icon to a topic
this.trigger('addCustomIcon', buffer);
if (this.get('topic.closed')) {
this.renderIcon(buffer, 'lock', 'locked');
}
if (this.get('topic.pinned')) {
this.renderIcon(buffer, 'pushpin', 'pinned');
}
if (!this.get('topic.visible')) {
this.renderIcon(buffer, 'eye-close', 'invisible');
}
renderIconIf('topic.closed', 'lock', 'locked');
renderIconIf('topic.pinned', 'pushpin', 'pinned');
renderIconIf('topic.invisible', 'eye-close', 'invisible');
}
});

View file

@ -37,7 +37,7 @@
}
> .icon {
display: inline-block;
margin-top: 8px;
margin-top: 2px;
vertical-align: top;
}
}