From eba662b988908358612e40053d07df4d2911e509 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 11 Jul 2013 12:04:39 -0400 Subject: [PATCH] FIX: Topic Status Icons had weird margins after font awesome update --- .../javascripts/discourse/models/archetype.js | 14 ++++---- .../javascripts/discourse/models/topic.js | 6 ++-- .../discourse/views/topic_status_view.js | 35 ++++++------------- .../stylesheets/application/topic.css.scss | 2 +- 4 files changed, 22 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/discourse/models/archetype.js b/app/assets/javascripts/discourse/models/archetype.js index 5073da8c9..a975334c8 100644 --- a/app/assets/javascripts/discourse/models/archetype.js +++ b/app/assets/javascripts/discourse/models/archetype.js @@ -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') }); diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index 1b41c7c76..a74f76cdf 100644 --- a/app/assets/javascripts/discourse/models/topic.js +++ b/app/assets/javascripts/discourse/models/topic.js @@ -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); diff --git a/app/assets/javascripts/discourse/views/topic_status_view.js b/app/assets/javascripts/discourse/views/topic_status_view.js index 3f12da1fe..08fe459f7 100644 --- a/app/assets/javascripts/discourse/views/topic_status_view.js +++ b/app/assets/javascripts/discourse/views/topic_status_view.js @@ -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(""); - }, - 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(""); + }; + // 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'); } }); diff --git a/app/assets/stylesheets/application/topic.css.scss b/app/assets/stylesheets/application/topic.css.scss index d5ce90ad0..b4e75cce7 100644 --- a/app/assets/stylesheets/application/topic.css.scss +++ b/app/assets/stylesheets/application/topic.css.scss @@ -37,7 +37,7 @@ } > .icon { display: inline-block; - margin-top: 8px; + margin-top: 2px; vertical-align: top; } }