From 96a783e8fc1114907693048720785cd5e5a2af89 Mon Sep 17 00:00:00 2001 From: TakahashiNZ Date: Mon, 16 Feb 2015 13:59:04 +1300 Subject: [PATCH] JSLint compliance slight modifications to pass jslint checking Bug: T86573 Change-Id: Ic2e36a13a308637de3063cef4d27129179980eff --- resources/ajaxpoll.js | 122 ++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 70 deletions(-) diff --git a/resources/ajaxpoll.js b/resources/ajaxpoll.js index 75ca7f4..0b70a79 100644 --- a/resources/ajaxpoll.js +++ b/resources/ajaxpoll.js @@ -1,77 +1,59 @@ +/*global $, mw, useAjax*/ + var ajaxpollTmp; -var setupEventHandlers = function(){ - $(".ajaxpoll-answer-vote").on("mouseover", - function(){ - var sp=$(this).find("span"); - ajaxpollTmp=sp.html(); - sp.text(sp.attr("title")); - sp.attr("title",""); - } - ); +var setupEventHandlers = function () { + "use strict"; + $(".ajaxpoll-answer-vote").on("mouseover", function () { + var sp = $(this).find("span"); + ajaxpollTmp = sp.html(); + sp.text(sp.attr("title")); + sp.attr("title", ""); + }); - $(".ajaxpoll-answer-vote").on("mouseout", - function(){ - var sp=$(this).find("span"); - sp.attr("title",sp.text()); - sp.text(ajaxpollTmp); - } - ); + $(".ajaxpoll-answer-vote").on("mouseout", function () { + var sp = $(this).find("span"); + sp.attr("title", sp.text()); + sp.text(ajaxpollTmp); + }); - /* attach click handler */ - $(".ajaxpoll-answer-name label") - .on("click", - function(event){ - event.preventDefault(); - event.stopPropagation(); - $this = $(this).parent().parent(); - var poll = $this.attr( "poll" ); - var answer = $this.attr( "answer" ); - var token = $this.parent().find("input[name='ajaxPollToken']").val(); - $this.find(".ajaxpoll-hover-vote").addClass("ajaxpoll-checkevent"); - $this.find("input").prop("checked","checked"); - $( "#ajaxpoll-ajax-"+poll ) - .text( mw.message( 'ajaxpoll-submitting' ).text() ) - .css("display","inline-block"); - if (useAjax){ - $.get( - mw.util.wikiScript(), - { - action: 'ajax', - rs: "AJAXPoll::submitVote", - rsargs: [poll,answer,token] - }, - function(newHTML){ - $("#ajaxpoll-container-"+poll).html(newHTML); - setupEventHandlers(); - } - ); - } else { - $("#ajaxpoll-answer-id-"+poll).submit(); - } - } - ) + /* attach click handler */ + $(".ajaxpoll-answer-name label").on("click", function (event) { + var choice = $(this).parent().parent(), poll, answer, token; + event.preventDefault(); + event.stopPropagation(); + poll = choice.attr("poll"); + answer = choice.attr("answer"); + token = choice.parent().find("input[name='ajaxPollToken']").val(); + choice.find(".ajaxpoll-hover-vote").addClass("ajaxpoll-checkevent"); + choice.find("input").prop("checked", "checked"); + $("#ajaxpoll-ajax-" + poll).text(mw.message('ajaxpoll-submitting').text()).css("display", "inline-block"); + if (useAjax) { + $.get(mw.util.wikiScript(), { + action : 'ajax', + rs : "AJAXPoll::submitVote", + rsargs : [ poll, answer, token ] + }, function (newHTML) { + $("#ajaxpoll-container-" + poll).html(newHTML); + setupEventHandlers(); + }); + } else { + $("#ajaxpoll-answer-id-" + poll).submit(); + } + }); - $(".ajaxpoll-answer-name:not(.ajaxpoll-answer-name-revoke) label").on("mouseover", - function(){ - $(this).addClass("ajaxpoll-hover-vote"); - } - ); - $(".ajaxpoll-answer-name:not(.ajaxpoll-answer-name-revoke) label").on("mouseout", - function(){ - $(this).removeClass("ajaxpoll-hover-vote"); - } - ); + $(".ajaxpoll-answer-name:not(.ajaxpoll-answer-name-revoke) label").on("mouseover", function () { + $(this).addClass("ajaxpoll-hover-vote"); + }); + $(".ajaxpoll-answer-name:not(.ajaxpoll-answer-name-revoke) label").on("mouseout", function () { + $(this).removeClass("ajaxpoll-hover-vote"); + }); - $(".ajaxpoll-answer-name-revoke label").on("mouseover", - function(){ - $(this).addClass("ajaxpoll-hover-revoke"); - } - ); - $(".ajaxpoll-answer-name-revoke label").on("mouseout", - function(){ - $(this).removeClass("ajaxpoll-hover-revoke"); - } - ); -} + $(".ajaxpoll-answer-name-revoke label").on("mouseover", function () { + $(this).addClass("ajaxpoll-hover-revoke"); + }); + $(".ajaxpoll-answer-name-revoke label").on("mouseout", function () { + $(this).removeClass("ajaxpoll-hover-revoke"); + }); +}; setupEventHandlers(); \ No newline at end of file