diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index 0f76f8470..5626efdc1 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 23ac61c18..783734992 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("<h4 class='title'>" + (this.get('title')) + "</h4>"); + buffer.push("<h4 class='title'>" + this.get('title') + "</h4>"); buffer.push("<button class='btn standard dropdown-toggle' data-toggle='dropdown'>"); buffer.push(this.get('text')); buffer.push("</button>"); buffer.push("<ul class='dropdown-menu'>"); this.get('dropDownContent').each(function(row) { - var description, id, textKey, title; - id = row[0]; - textKey = row[1]; - title = Em.String.i18n("" + textKey + ".title"); - description = Em.String.i18n("" + textKey + ".description"); + var id = row[0], + textKey = row[1], + title = Em.String.i18n("" + textKey + ".title"), + description = Em.String.i18n("" + textKey + ".description"); buffer.push("<li data-id=\"" + id + "\"><a href='#'>"); buffer.push("<span class='title'>" + title + "</span>"); buffer.push("<span>" + description + "</span>"); - return buffer.push("</a></li>"); + buffer.push("</a></li>"); }); buffer.push("</ul>"); if (desc = this.get('longDescription')) { buffer.push("<p>"); buffer.push(desc); - return buffer.push("</p>"); + buffer.push("</p>"); } } }); - - 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 ae4002e69..e0647ee1c 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("<i class='icon icon-plus'></i>"); @@ -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 '<i class="icon-circle heatmap-high"></i> '; - case 'tracking': - return '<i class="icon-circle heatmap-low"></i> '; - case 'regular': - return ''; - case 'muted': - return '<i class="icon-remove-sign"></i> '; - } - })(); - return icon + (Ember.String.i18n("topic.notifications." + key + ".title")) + "<span class='caret'></span>"; - }).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 '<i class="icon-circle heatmap-high"></i> '; + case 'tracking': return '<i class="icon-circle heatmap-low"></i> '; + case 'regular': return ''; + case 'muted': return '<i class="icon-remove-sign"></i> '; + } + })(); + return icon + (Ember.String.i18n("topic.notifications." + key + ".title")) + "<span class='caret'></span>"; + }.property('topic.notification_level'), + clicked: function(id) { return this.get('topic').updateNotifications(id); }