From 967b03fcfc63fbb4393200de6b3b46d2bc94bab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sun, 17 Mar 2013 16:27:11 -0700 Subject: [PATCH] keep favorite/star button's title in sync with starred status --- app/assets/javascripts/discourse/models/topic.js | 8 ++++++++ .../templates/list/topic_list_item.js.handlebars | 2 +- .../javascripts/discourse/templates/topic.js.handlebars | 2 +- .../discourse/templates/topic_extra_info.js.handlebars | 2 +- .../discourse/views/topic_footer_buttons_view.js | 2 +- config/locales/client.en.yml | 4 +++- config/locales/client.fr.yml | 4 +++- 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index 538093642d6..4af79a69535 100644 --- a/app/assets/javascripts/discourse/models/topic.js +++ b/app/assets/javascripts/discourse/models/topic.js @@ -141,6 +141,14 @@ Discourse.Topic = Discourse.Model.extend({ }); }, + favoriteTooltipKey: (function() { + return this.get('starred') ? 'favorite.help.unstar' : 'favorite.help.star'; + }).property('starred'), + + favoriteTooltip: (function() { + return Em.String.i18n(this.get('favoriteTooltipKey')); + }).property('favoriteTooltipKey'), + toggleStar: function() { var topic = this; topic.toggleProperty('starred'); diff --git a/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars b/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars index d651cf94e5e..0f66a1c4fd1 100644 --- a/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars +++ b/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars @@ -1,7 +1,7 @@ {{#if Discourse.currentUser.id}} - + {{/if}} diff --git a/app/assets/javascripts/discourse/templates/topic.js.handlebars b/app/assets/javascripts/discourse/templates/topic.js.handlebars index cc163274e52..af48dff6208 100644 --- a/app/assets/javascripts/discourse/templates/topic.js.handlebars +++ b/app/assets/javascripts/discourse/templates/topic.js.handlebars @@ -6,7 +6,7 @@
{{#if view.showFavoriteButton}} - + {{/if}} {{#if view.editingTopic}} diff --git a/app/assets/javascripts/discourse/templates/topic_extra_info.js.handlebars b/app/assets/javascripts/discourse/templates/topic_extra_info.js.handlebars index 8809fa5a70e..3880b9421b1 100644 --- a/app/assets/javascripts/discourse/templates/topic_extra_info.js.handlebars +++ b/app/assets/javascripts/discourse/templates/topic_extra_info.js.handlebars @@ -1,5 +1,5 @@ {{#if view.showFavoriteButton}} - + {{/if}}

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 a68ee7ca4c1..ae4002e6993 100644 --- a/app/assets/javascripts/discourse/views/topic_footer_buttons_view.js +++ b/app/assets/javascripts/discourse/views/topic_footer_buttons_view.js @@ -40,7 +40,7 @@ Discourse.TopicFooterButtonsView = Ember.ContainerView.extend({ this.addObject(Discourse.ButtonView.createWithMixins({ textKey: 'favorite.title', - helpKey: 'favorite.help', + helpKeyBinding: 'controller.content.favoriteTooltipKey', favoriteChanged: (function() { this.rerender(); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 824057c8b75..381c2254d92 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -357,7 +357,9 @@ en: favorite: title: 'Favorite' - help: 'add this topic to your favorites list' + help: + star: 'add this topic to your favorites list' + unstar: 'remove this topic from your favorites list' topics: none: diff --git a/config/locales/client.fr.yml b/config/locales/client.fr.yml index 64a053f0d82..5d8ff52679b 100644 --- a/config/locales/client.fr.yml +++ b/config/locales/client.fr.yml @@ -361,7 +361,9 @@ fr: favorite: title: 'Favoris' - help: 'ajouter cette discussion à vos favoris' + help: + star: 'ajouter cette discussion à vos favoris' + unstar: 'enlever cette discussion de vos favoris' topics: none: