Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*** js ***/
- mw.loader.using(['jquery.cookie'], function () {
- $('.ajax-poll').each(function () {
- var $poll = $(this),
- pollId = $poll.attr('id').split('-')[2],
- cookieName = 'mainpage-poll',
- cookie = $.cookie(cookieName);
- console.log(pollId);
- if (cookie === pollId) {
- $poll.addClass('voted')
- } else {
- // setting value to null removes it
- $.cookie(cookieName, null);
- }
- $poll.find('input[type="submit"]').on('click', function () {
- $poll.addClass('voted');
- $.cookie(cookieName, pollId, { path: '/', expires: 365 });
- });
- });
- });
- /*** css ***/
- .ajax-poll .pollAnswerVotes {
- display: none;
- }
- .ajax-poll.voted .pollAnswerVotes {
- display: block;
- }
Add Comment
Please, Sign In to add comment