Index: trunk/extensions/AJAXPoll/AJAXPoll_body.php |
— | — | @@ -321,11 +321,14 @@ |
322 | 322 | for ( $i = 1; $i < count( $lines ); $i++ ) { |
323 | 323 | |
324 | 324 | $vote = !( $canRevoke && ( $i == count( $lines ) - 1 ) ); |
325 | | - $voteValue = ( $vote ) ? $i : 0; |
326 | 325 | |
327 | | - $ans_no = $i - 1; |
328 | | - $xid = "$id-$ans_no"; |
| 326 | + // answers are counted from 1 ... n |
| 327 | + // last answer is pseudo-answer for "I want to revoke vote" |
| 328 | + // and becomes answer number 0 |
329 | 329 | |
| 330 | + $answer = ( $vote ) ? $i : 0; |
| 331 | + $xid = $id . "-" . $answer; |
| 332 | + |
330 | 333 | if ( $amountOfVotes == 0 ) { |
331 | 334 | $percent = 0; |
332 | 335 | } else { |
— | — | @@ -341,7 +344,7 @@ |
342 | 345 | if ( $wgUser->isAllowed( 'ajaxpoll-vote' ) ) { |
343 | 346 | |
344 | 347 | if ( $wgUseAjax ) { |
345 | | - $submitJS = "sajax_do_call(\"AJAXPoll::submitVote\",[\"" . $id . "\",\"" . $voteValue . "\"],$(\"#ajaxpoll-container-" . $id . "\")[0]);"; |
| 348 | + $submitJS = "sajax_do_call(\"AJAXPoll::submitVote\",[\"" . $id . "\",\"" . $answer . "\"],$(\"#ajaxpoll-container-" . $id . "\")[0]);"; |
346 | 349 | } else { |
347 | 350 | $submitJS = "$(\"#ajaxpoll-answer-id-" . $id . "\").submit();"; |
348 | 351 | } |
— | — | @@ -352,13 +355,13 @@ |
353 | 356 | |
354 | 357 | if ( $vote ) { |
355 | 358 | $ret .= " |
356 | | -<div id='ajaxpoll-answer-$xid' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-$xid' onclick='$(\"#ajaxpoll-ajax-" . $id . "\").html(\"" . wfMsg( 'ajaxpoll-submitting' ) . "\");$(\"#ajaxpoll-ajax-" . $id . "\").css(\"display\",\"block\");$(this).addClass(\"ajaxpoll-checkevent\").prop(\"checked\",true); " . $submitJS . "'><input type='radio' id='ajaxpoll-post-answer-$xid' name='ajaxpoll-post-answer-$xid' value='" . $voteValue . "' " . ( $our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) . |
| 359 | +<div id='ajaxpoll-answer-$xid' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-$xid' onclick='$(\"#ajaxpoll-ajax-" . $xid . "\").html(\"" . wfMsg( 'ajaxpoll-submitting' ) . "\").css(\"display\",\"block\");$(this).addClass(\"ajaxpoll-checkevent\").prop(\"checked\",true);" . $submitJS . "'><input type='radio' id='ajaxpoll-post-answer-$xid' name='ajaxpoll-post-answer-$xid' value='" . $answer . "' " . ( $our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) . |
357 | 360 | "</label></div><div class='ajaxpoll-answer-vote" . ( $our ? ' ajaxpoll-our-vote' : '' ) ."'><span title='" . wfMsg( 'ajaxpoll-percent-votes', sprintf( $percent ) ) . "'>" . ( ( isset( $poll_result ) && !empty( $poll_result[$i + 1] ) ) ? $poll_result[$i + 1] : 0 ) . "</span><div style='width: " . $percent . "%;" . ( $percent == 0 ? ' border:0;' : '' ) . "'></div></div> |
358 | 361 | </div> |
359 | 362 | "; |
360 | 363 | } else { |
361 | 364 | $ret .= " |
362 | | -<div id='ajaxpoll-answer-$xid' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name ajaxpoll-answer-name-revoke'><label for='ajaxpoll-post-answer-$xid' onclick='$(\"#ajaxpoll-ajax-" . $id . "\").html(\"" . wfMsg( 'ajaxpoll-submitting' ) . "\");$(\"#ajaxpoll-ajax-" . $id . "\").css(\"display\",\"block\");$(this).addClass(\"ajaxpoll-checkevent\").prop(\"checked\",true); " . $submitJS . "'><input type='radio' id='ajaxpoll-post-answer-$xid' name='ajaxpoll-post-answer-$xid' value='" . $voteValue . "' " . ( $our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) . |
| 365 | +<div id='ajaxpoll-answer-$xid' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name ajaxpoll-answer-name-revoke'><label for='ajaxpoll-post-answer-$xid' onclick='$(\"#ajaxpoll-ajax-" . $xid . "\").html(\"" . wfMsg( 'ajaxpoll-submitting' ) . "\").css(\"display\",\"block\");$(this).addClass(\"ajaxpoll-checkevent\").prop(\"checked\",true);" . $submitJS . "'><input type='radio' id='ajaxpoll-post-answer-$xid' name='ajaxpoll-post-answer-$xid' value='" . $answer . "' " . ( $our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) . |
363 | 366 | "</label></div> |
364 | 367 | </div> |
365 | 368 | "; |
— | — | @@ -367,7 +370,7 @@ |
368 | 371 | } else { |
369 | 372 | |
370 | 373 | $ret .= " |
371 | | -<div id='ajaxpoll-answer-" . $id . "' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-" . $id . "' onclick='$(\"#ajaxpoll-ajax-" . $id . "\").html(\"" . wfMsg( 'ajaxpoll-vote-permission' ) . "\");$(\"#ajaxpoll-ajax-" . $id . "\").css(\"display\",\"block\");'><input disabled='disabled' type='radio' id='ajaxpoll-post-answer-" . $id . "' name='ajaxpoll-post-answer-" . $id . "' value='" . $voteValue . "'/>" . strip_tags( $lines[$i] ) . |
| 374 | +<div id='ajaxpoll-answer-" . $xid . "' class='ajaxpoll-answer'><div class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-" . $xid . "' onclick='$(\"#ajaxpoll-ajax-" . $xid . "\").html(\"" . wfMsg( 'ajaxpoll-vote-permission' ) . "\").css(\"display\",\"block\");'><input disabled='disabled' type='radio' id='ajaxpoll-post-answer-" . $xid . "' name='ajaxpoll-post-answer-" . $xid . "' value='" . $answer . "'/>" . strip_tags( $lines[$i] ) . |
372 | 375 | "</label></div><div class='ajaxpoll-answer-vote" . ( $our ? ' ajaxpoll-our-vote' : '' ) ."'><span title='" . wfMsg( 'ajaxpoll-percent-votes', sprintf( $percent ) ) . "'>" . ( ( isset( $poll_result ) && !empty( $poll_result[$i + 1] ) ) ? $poll_result[$i + 1] : 0 ) . "</span><div style='width: " . $percent . "%;" . ( $percent == 0 ? ' border:0;' : '' ) . "'></div></div> |
373 | 376 | </div> |
374 | 377 | "; |
Index: trunk/extensions/AJAXPoll/AJAXPoll.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * @author Jack Phoenix <jack@countervandalism.net> |
21 | 21 | * @author Thomas Gries |
22 | 22 | * @maintainer Thomas Gries |
23 | | - * @version 1.73 |
| 23 | + * @version 1.74 |
24 | 24 | * @link http://www.mediawiki.org/wiki/Extension:AJAX_Poll Documentation |
25 | 25 | */ |
26 | 26 | |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | $wgExtensionCredits['parserhook'][] = array( |
33 | 33 | 'path' => __FILE__, |
34 | 34 | 'name' => 'AJAX Poll', |
35 | | - 'version' => '1.73 20120314', |
| 35 | + 'version' => '1.74 20120315', |
36 | 36 | 'author' => array( 'Dariusz Siedlecki', 'Jack Phoenix', 'Thomas Gries' ), |
37 | 37 | 'descriptionmsg' => 'ajaxpoll-desc', |
38 | 38 | 'url' => 'https://www.mediawiki.org/wiki/Extension:AJAX_Poll', |