2017-01-10 18:02:20 -05:00
|
|
|
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-unused-vars, one-var, no-var, one-var-declaration-per-line, prefer-arrow-callback, no-new, max-len */
|
2016-12-14 00:26:26 -05:00
|
|
|
/* global Flash */
|
|
|
|
|
2016-07-24 16:45:11 -04:00
|
|
|
(function() {
|
|
|
|
this.Star = (function() {
|
|
|
|
function Star() {
|
|
|
|
$('.project-home-panel .toggle-star').on('ajax:success', function(e, data, status, xhr) {
|
|
|
|
var $starIcon, $starSpan, $this, toggleStar;
|
|
|
|
$this = $(this);
|
|
|
|
$starSpan = $this.find('span');
|
|
|
|
$starIcon = $this.find('i');
|
|
|
|
toggleStar = function(isStarred) {
|
|
|
|
$this.parent().find('.star-count').text(data.star_count);
|
|
|
|
if (isStarred) {
|
|
|
|
$starSpan.removeClass('starred').text('Star');
|
|
|
|
$starIcon.removeClass('fa-star').addClass('fa-star-o');
|
|
|
|
} else {
|
|
|
|
$starSpan.addClass('starred').text('Unstar');
|
|
|
|
$starIcon.removeClass('fa-star-o').addClass('fa-star');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
toggleStar($starSpan.hasClass('starred'));
|
|
|
|
}).on('ajax:error', function(e, xhr, status, error) {
|
|
|
|
new Flash('Star toggle failed. Try again later.', 'alert');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return Star;
|
|
|
|
})();
|
2017-02-10 01:50:50 -05:00
|
|
|
}).call(window);
|