Merge pull request #487 from ZogStriP/keep-favorite-title-in-sync-with-status

keep favorite/star button's title in sync with starred status
This commit is contained in:
Sam 2013-03-18 21:48:12 -07:00
commit 0e1174dbe8
7 changed files with 18 additions and 6 deletions

View File

@ -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');

View File

@ -1,7 +1,7 @@
{{#if Discourse.currentUser.id}}
<td class='star'>
<a {{bindAttr class=":star :icon-star starred:starred"}} {{action toggleStar this target="controller"}} href='#' title='{{i18n favorite.help}}'></a>
<a {{bindAttr class=":star :icon-star starred:starred"}} {{action toggleStar this target="controller"}} href='#' {{bindAttr title="favoriteTooltip"}}></a>
</td>
{{/if}}

View File

@ -6,7 +6,7 @@
<div class='container'>
<div class='inner'>
{{#if view.showFavoriteButton}}
<a {{bindAttr class=":star view.topic.starred:starred"}} {{action toggleStar target="controller"}} href='#' title="{{i18n favorite.help}}"></a>
<a {{bindAttr class=":star view.topic.starred:starred"}} {{action toggleStar target="controller"}} href='#' {{bindAttr title="favoriteTooltip"}}></a>
{{/if}}
{{#if view.editingTopic}}
<input id='edit-title' type='text' {{bindAttr value="view.topic.title"}} autofocus>

View File

@ -1,5 +1,5 @@
{{#if view.showFavoriteButton}}
<a {{bindAttr class=":star view.topic.starred:starred"}} {{action toggleStar target="controller"}} href='#' title="{{i18n favorite.help}}"></a>
<a {{bindAttr class=":star view.topic.starred:starred"}} {{action toggleStar target="controller"}} href='#' {{bindAttr title="view.topic.favoriteTooltip"}}></a>
{{/if}}
<h1>

View File

@ -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();

View File

@ -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:

View File

@ -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: