diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index 0f76f847043..5626efdc181 100644 --- a/app/assets/javascripts/discourse/models/topic.js +++ b/app/assets/javascripts/discourse/models/topic.js @@ -288,14 +288,13 @@ Discourse.Topic = Discourse.Model.extend({ }).then(afterTopicLoaded, errorLoadingTopic); }, - notificationReasonText: (function() { - var locale_string; - locale_string = "topic.notifications.reasons." + this.notification_level; - if (typeof this.notifications_reason_id === 'number') { - locale_string += "_" + this.notifications_reason_id; + notificationReasonText: function() { + var locale_string = "topic.notifications.reasons." + this.get('notification_level'); + if (typeof this.get('notifications_reason_id') === 'number') { + locale_string += "_" + this.get('notifications_reason_id'); } return Em.String.i18n(locale_string, { username: Discourse.currentUser.username.toLowerCase() }); - }).property('notifications_reason_id'), + }.property('notification_level', 'notifications_reason_id'), updateNotifications: function(v) { this.set('notification_level', v); diff --git a/app/assets/javascripts/discourse/views/dropdown_button_view.js b/app/assets/javascripts/discourse/views/dropdown_button_view.js index 23ac61c18a7..78373499274 100644 --- a/app/assets/javascripts/discourse/views/dropdown_button_view.js +++ b/app/assets/javascripts/discourse/views/dropdown_button_view.js @@ -23,35 +23,32 @@ Discourse.DropdownButtonView = Discourse.View.extend({ return null; }, - textChanged: (function() { - return this.rerender(); - }).observes('text', 'longDescription'), + textChanged: function() { + this.rerender(); + }.observes('text', 'longDescription'), render: function(buffer) { var desc; - buffer.push("

" + (this.get('title')) + "

"); + buffer.push("

" + this.get('title') + "

"); buffer.push(""); buffer.push(""); if (desc = this.get('longDescription')) { buffer.push("

"); buffer.push(desc); - return buffer.push("

"); + buffer.push("

"); } } }); - - diff --git a/app/assets/javascripts/discourse/views/topic_footer_buttons_view.js b/app/assets/javascripts/discourse/views/topic_footer_buttons_view.js index ae4002e6993..e0647ee1c15 100644 --- a/app/assets/javascripts/discourse/views/topic_footer_buttons_view.js +++ b/app/assets/javascripts/discourse/views/topic_footer_buttons_view.js @@ -100,14 +100,14 @@ Discourse.TopicFooterButtonsView = Ember.ContainerView.extend({ helpKey: 'topic.reply.help', disabled: !this.get('controller.content.can_create_post'), - text: (function() { + text: function() { var archetype, customTitle; archetype = this.get('controller.content.archetype'); if (customTitle = this.get("parentView.replyButtonText" + (archetype.capitalize()))) { return customTitle; } return Em.String.i18n("topic.reply.title"); - }).property(), + }.property(), renderIcon: function(buffer) { buffer.push(""); @@ -123,37 +123,6 @@ Discourse.TopicFooterButtonsView = Ember.ContainerView.extend({ topic: topic, title: Em.String.i18n('topic.notifications.title'), longDescriptionBinding: 'topic.notificationReasonText', - - text: (function() { - var icon, key; - key = (function() { - switch (this.get('topic.notification_level')) { - case Discourse.Topic.NotificationLevel.WATCHING: - return 'watching'; - case Discourse.Topic.NotificationLevel.TRACKING: - return 'tracking'; - case Discourse.Topic.NotificationLevel.REGULAR: - return 'regular'; - case Discourse.Topic.NotificationLevel.MUTE: - return 'muted'; - } - }).call(this); - - icon = (function() { - switch (key) { - case 'watching': - return ' '; - case 'tracking': - return ' '; - case 'regular': - return ''; - case 'muted': - return ' '; - } - })(); - return icon + (Ember.String.i18n("topic.notifications." + key + ".title")) + ""; - }).property('topic.notification_level'), - dropDownContent: [ [Discourse.Topic.NotificationLevel.WATCHING, 'topic.notifications.watching'], [Discourse.Topic.NotificationLevel.TRACKING, 'topic.notifications.tracking'], @@ -161,6 +130,27 @@ Discourse.TopicFooterButtonsView = Ember.ContainerView.extend({ [Discourse.Topic.NotificationLevel.MUTE, 'topic.notifications.muted'] ], + text: function() { + var key = (function() { + switch (this.get('topic.notification_level')) { + case Discourse.Topic.NotificationLevel.WATCHING: return 'watching'; + case Discourse.Topic.NotificationLevel.TRACKING: return 'tracking'; + case Discourse.Topic.NotificationLevel.REGULAR: return 'regular'; + case Discourse.Topic.NotificationLevel.MUTE: return 'muted'; + } + }).call(this); + + var icon = (function() { + switch (key) { + case 'watching': return ' '; + case 'tracking': return ' '; + case 'regular': return ''; + case 'muted': return ' '; + } + })(); + return icon + (Ember.String.i18n("topic.notifications." + key + ".title")) + ""; + }.property('topic.notification_level'), + clicked: function(id) { return this.get('topic').updateNotifications(id); }