Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- $(document).ready(function() {
- snax.updateVoteState = function(itemId, type, $box) {
- var typeCookie = 'snax_vote_type_' + itemId;
- var scoreCookie = 'snax_vote_score_' + itemId;
- var currentValue = snax.readCookie(typeCookie);
- // Cookie can't be read immediately so we need to update CSS classes manually.
- $box.find('.snax-user-voted').removeClass('snax-user-voted');
- // User voted and now he wants to remove the vote.
- if (currentValue === type) {
- snax.deleteCookie(typeCookie);
- } else {
- snax.createCookie(typeCookie, type, 30);
- // Cookie can't be read immediately so we need to update CSS classes manually.
- $box.find('.snax-voting-' + type).addClass('snax-user-voted');
- }
- // Update score.
- var score = parseInt($box.find('.snax-voting-score strong').text(), 10);
- snax.createCookie(scoreCookie, score, 30);
- window.location.reload(true);
- };
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement