Commit 52293ccd authored by Jacob Schatz's avatar Jacob Schatz

refactoring javascript to put starring functionality in a function

parent 8bbcbe78
......@@ -16,11 +16,13 @@
var $this = $(this);
var $starSpan = $this.find('span');
var $starIcon = $this.find('i');
var toggleStar = function(isStarred) {
$this
.parent()
.find('span.count')
.text(data.star_count);
if($starSpan.hasClass('starred')){
if(isStarred){
$starSpan
.removeClass('starred')
.text('Star');
......@@ -36,6 +38,9 @@
.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');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment