This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
discourse/app/assets/javascripts/discourse/views/buttons/favorite_button.js
2013-10-01 11:16:27 -04:00

26 lines
644 B
JavaScript

/**
A button for favoriting a topic
@class FavoriteButton
@extends Discourse.ButtonView
@namespace Discourse
@module Discourse
**/
Discourse.FavoriteButton = Discourse.ButtonView.extend({
textKey: 'favorite.title',
helpKeyBinding: 'controller.favoriteTooltipKey',
attributeBindings: ['disabled'],
shouldRerender: Discourse.View.renderIfChanged('controller.starred'),
click: function() {
this.get('controller').send('toggleStar');
},
renderIcon: function(buffer) {
buffer.push("<i class='icon-star " +
(this.get('controller.starred') ? ' starred' : '') +
"'></i>");
}
});