Skip to content

Commit

Permalink
Toggle the button's text & icon in a better way.
Browse files Browse the repository at this point in the history
  • Loading branch information
Talina06 committed Jul 29, 2014
1 parent 9cbedb8 commit 3b4874a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions root/static/js/cpan.js
Expand Up @@ -342,21 +342,18 @@ function starModule(form) {
var count = 0;
if (button.hasClass('active')) {
count = 1;
button.remove();
form.append('<button type="submit" class="stargazer active"><i class="icon-star"></i> Unstar</button>');
button.html('<i class="icon-star"></i> Unstar');
form.append('<input type="hidden" name="remove" value="1">');
if (!count){
button.toggleClass('highlight');
button.remove();
form.append('<button type="submit" class="stargazer highlight"><i class="icon-star-empty"></i> Star</button>');
button.html('<i class="icon-star-empty"></i> Star');
}
} else {
count=0;
form.find('input[name="remove"]').remove();
if (count === 0) {
button.toggleClass('highlight');
button.remove();
form.append('<button type="submit" class="stargazer highlight"><i class="icon-star-empty"></i> Star</button>');
button.html('<i class="icon-star-empty"></i> Star');
}
}
},
Expand Down

0 comments on commit 3b4874a

Please sign in to comment.