https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113772
Revision: 113772
Author: wikinaut
Date: 2012-03-13 22:31:46 +0000 (Tue, 13 Mar 2012)
Log Message:
-----------
follow up r113554 . fixing a regression which was introduced in r113554. Making
now all all ids unique even when you have several polls on a mw page. using,
new, the resourceloader to load common methods. just a little bit ... more of
jquery. fixing a forgotten wgParser to parser variable problem. introducing and
moving js and css to resources.
Modified Paths:
--------------
trunk/extensions/AJAXPoll/AJAXPoll.php
trunk/extensions/AJAXPoll/AJAXPoll_body.php
Added Paths:
-----------
trunk/extensions/AJAXPoll/resources/
trunk/extensions/AJAXPoll/resources/ajaxpoll.css
trunk/extensions/AJAXPoll/resources/ajaxpoll.js
Removed Paths:
-------------
trunk/extensions/AJAXPoll/AJAXPoll.css
Deleted: trunk/extensions/AJAXPoll/AJAXPoll.css
===================================================================
--- trunk/extensions/AJAXPoll/AJAXPoll.css 2012-03-13 22:08:28 UTC (rev
113771)
+++ trunk/extensions/AJAXPoll/AJAXPoll.css 2012-03-13 22:31:46 UTC (rev
113772)
@@ -1,106 +0,0 @@
-/**
- * CSS for AJAX Poll extension
- * @file
- * @ingroup Extensions
- * @author Dariusz Siedlecki
- * @author Thomas Gries
- */
-
-.ajaxpoll {
- width: 400px;
- border: 1px dashed #999;
- background: #FAFAFA;
- padding: 10px 20px 10px 10px
-}
-
-.ajaxpoll .ajaxpoll-question {
- font-weight: bold;
-}
-
-.ajaxpoll .ajaxpoll-answer-name {
- margin-top: 5px;
- padding-left: 0px;
- font-size: 0.9em;
-}
-
-.ajaxpoll .ajaxpoll-hover-vote {
- background: cyan;
-}
-
-.ajaxpoll .ajaxpoll-hover-revoke {
- background: gold;
-}
-
-.ajaxpoll .ajaxpoll-answer-vote {
- border: 1px solid #CCC;
- width: 100%;
- margin-left: 0px;
- height: 12px;
- font-size: 10px;
- position: relative;
-}
-
-.ajaxpoll .ajaxpoll-answer-vote div {
- border-right: 1px solid #CCC;
- background: #E5E5E5;
- position: absolute;
- top: 0;
- left: 0;
- height: 12px;
- font-size: 1px;
- line-height: 12px;
- z-index: 2;
-}
-
-.ajaxpoll .ajaxpoll-our-vote div {
- border: 1px solid #008000;
- top: -1px;
- left: -1px;
-}
-
-.ajaxpoll .ajaxpoll-answer-vote span {
- position: absolute;
- top: -3px;
- left: 3px;
- z-index: 4;
-}
-
-.ajaxpoll label {
- cursor: pointer;
-}
-.ajaxpoll input {
- cursor: pointer;
- vertical-align: middle;
- margin-top: 0px;
- margin-bottom: 0px;
- margin-left: 0px;
-}
-
-.ajaxpoll .ajaxpoll-checkevent {
- background: cyan;
-}
-
-.ajaxpoll .ajaxpoll-misc {
- margin-bottom: 10px;
- color: grey;
-}
-
-.ajaxpoll .ajaxpoll-ajax {
- background: #FFFFCF;
- padding: 1px 4px;
- width: 200px;
- border-radius: 0.5em;
- -moz-border-radius: 0.5em;
- display: none;
-}
-
-.ajaxpoll .ajaxpoll-info {
- margin-top: 20px;
- color: grey;
-}
-
-.ajaxpoll .ajaxpoll-id-info {
- color:#FAFAFA;
- font-size: 100%;
- float: right;
-}
Modified: trunk/extensions/AJAXPoll/AJAXPoll.php
===================================================================
--- trunk/extensions/AJAXPoll/AJAXPoll.php 2012-03-13 22:08:28 UTC (rev
113771)
+++ trunk/extensions/AJAXPoll/AJAXPoll.php 2012-03-13 22:31:46 UTC (rev
113772)
@@ -19,7 +19,7 @@
* @author Jack Phoenix <[email protected]>
* @author Thomas Gries
* @maintainer Thomas Gries
- * @version 1.69
+ * @version 1.70
* @link http://www.mediawiki.org/wiki/Extension:AJAX_Poll Documentation
*/
@@ -31,19 +31,35 @@
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'AJAX Poll',
- 'version' => '1.69 20120313',
+ 'version' => '1.70 20120313',
'author' => array( 'Dariusz Siedlecki', 'Jack Phoenix', 'Thomas Gries'
),
'descriptionmsg' => 'ajaxpoll-desc',
'url' => 'https://www.mediawiki.org/wiki/Extension:AJAX_Poll',
);
// Internationalization + AJAX function
-$dir = dirname( __FILE__ ) . '/';
-$wgExtensionMessagesFiles['AJAXPoll'] = $dir . 'AJAXPoll.i18n.php';
-$wgAutoloadClasses['AJAXPoll'] = $dir . 'AJAXPoll_body.php';
+$dir = dirname( __FILE__ );
+$wgExtensionMessagesFiles['AJAXPoll'] = $dir . '/AJAXPoll.i18n.php';
+$wgAutoloadClasses['AJAXPoll'] = $dir . '/AJAXPoll_body.php';
$wgAjaxExportList[] = 'AJAXPoll::submitVote';
$wgHooks['ParserFirstCallInit'][] = 'AJAXPoll::AJAXPollParserInit';
+$myResourceTemplate = array(
+ 'localBasePath' => dirname( __FILE__ ) . "/resources",
+ 'remoteExtPath' => 'AJAXPoll/resources',
+ 'group' => 'ext.ajaxpoll',
+);
+$wgResourceModules['ext.ajaxpoll'] = $myResourceTemplate + array(
+ 'scripts' => array(
+ 'ajaxpoll.js',
+ ),
+ 'styles' => array(
+ 'ajaxpoll.css',
+ ),
+ 'dependencies' => array(
+ )
+);
+
# new user rights
$wgAvailableRights[] = 'ajaxpoll-vote';
Modified: trunk/extensions/AJAXPoll/AJAXPoll_body.php
===================================================================
--- trunk/extensions/AJAXPoll/AJAXPoll_body.php 2012-03-13 22:08:28 UTC (rev
113771)
+++ trunk/extensions/AJAXPoll/AJAXPoll_body.php 2012-03-13 22:31:46 UTC (rev
113772)
@@ -22,7 +22,9 @@
* @return Boolean: true
*/
static function AJAXPollParserInit( $parser ) {
+ global $wgOut;
$parser->setHook( 'poll', array( __CLASS__, 'AJAXPollRender' )
);
+ $wgOut->addModules( 'ext.ajaxpoll' );
return true;
}
@@ -53,11 +55,6 @@
$input = trim( strip_tags( $input->getText() ) );
$lines = explode( "\n", trim( $input ) );
- // Deprecating AJAX
- /*if ( isset( $_POST['ajaxpoll-post-id'] ) && isset(
$_POST['ajaxpoll-post-answer'] ) && $_POST['ajaxpoll-post-id'] == $id ) {
- AJAXPoll::submitVote( $_POST['ajaxpoll-post-id'],
intval( $_POST['ajaxpoll-post-answer'] ) );
- }*/
-
$dbw = wfGetDB( DB_MASTER );
$dbw->begin( __METHOD__ );
@@ -79,15 +76,13 @@
'poll_id' => $id,
'poll_txt' => $input,
'poll_date' => wfTimestampNow(),
- 'poll_title' =>
$wgParser->mTitle->getText()
+ 'poll_title' =>
$parser->mTitle->getText()
),
__METHOD__
);
}
$dbw->commit( __METHOD__ );
- // Add CSS
- $wgOut->addExtensionStyle( $wgScriptPath .
'/extensions/AJAXPoll/AJAXPoll.css' );
switch( $lines[0] ) {
case 'STATS':
$retVal = AJAXPoll::buildStats( $id, $user );
@@ -300,19 +295,6 @@
// @see
https://bugzilla.wikimedia.org/show_bug.cgi?id=1319
$ret = '<div id="ajaxpoll-id-' . $id . '"
class="ajaxpoll">
<div id="ajaxpoll-ajax-' . $id . '" class="ajaxpoll-ajax"' . $attributes . '>'
. $ajaxMessage . '</div>
-<script>var tmp;
-function mover(x){
- var sp=$(x).find("span");
- tmp=sp.html();
- sp.text(sp.attr("title"));
- sp.attr("title","");
-}
-function mout(x){
- var sp=$(x).find("span");
- sp.attr("title",sp.text());
- sp.text(tmp);
-}
-</script>
<div class="ajaxpoll-question">' . strip_tags( $lines[0] ) . '</div>';
// Different message depending on if the user has
already voted or not, or is entitled to vote
@@ -343,6 +325,7 @@
$voteValue = ( $vote ) ? $i : 0;
$ans_no = $i - 1;
+ $xid = "$id-$ans_no";
if ( $amountOfVotes == 0 ) {
$percent = 0;
@@ -359,7 +342,7 @@
if ( $wgUser->isAllowed( 'ajaxpoll-vote' ) ) {
if ( $wgUseAjax ) {
- $submitJS =
"sajax_do_call(\"AJAXPoll::submitVote\",[\"" . $id . "\",\"" . $voteValue .
"\"], $(\"#ajaxpoll-container-" . $id . "\")[0]);";
+ $submitJS =
"sajax_do_call(\"AJAXPoll::submitVote\",[\"" . $id . "\",\"" . $voteValue .
"\"],$(\"#ajaxpoll-container-" . $id . "\")[0]);";
} else {
$submitJS =
"$(\"#ajaxpoll-answer-id-" . $id . "\").submit();";
}
@@ -370,13 +353,13 @@
if ( $vote ) {
$ret .= "
-<div id='ajaxpoll-answer-" . $ans_no . "' class='ajaxpoll-answer'><div
class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-" . $ans_no . "'
onmouseover='$(this).addClass(\"ajaxpoll-hover-vote\");'
onmouseout='$(this).removeClass(\"ajaxpoll-hover-vote\");'
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-" . $ans_no .
"' name='ajaxpoll-post-answer-" . $ans_no . "' value='" . $voteValue . "' " . (
$our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) .
-"</label></div><div class='ajaxpoll-answer-vote" . ( $our ? '
ajaxpoll-our-vote' : '' ) ."' onmouseover='mover(this)'
onmouseout='mout(this);'><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>
+<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] ) .
+"</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>
</div>
";
} else {
$ret .= "
-<div id='ajaxpoll-answer-" . $ans_no . "' class='ajaxpoll-answer'><div
class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-" . $ans_no . "'
onmouseover='$(this).addClass(\"ajaxpoll-hover-revoke\");'
onmouseout='$(this).removeClass(\"ajaxpoll-hover-revoke\");'
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-" . $ans_no .
"' name='ajaxpoll-post-answer-" . $ans_no . "' value='" . $voteValue . "' " . (
$our ? 'checked=true ' : '' ) . "/>" . strip_tags( $lines[$i] ) .
+<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] ) .
"</label></div>
</div>
";
@@ -385,8 +368,8 @@
} else {
$ret .= "
-<div id='ajaxpoll-answer-" . $ans_no . "' class='ajaxpoll-answer'><div
class='ajaxpoll-answer-name'><label for='ajaxpoll-post-answer-" . $ans_no . "'
onclick='$(\"#ajaxpoll-ajax-" . $id . "\").html(\"" . wfMsg(
'ajaxpoll-vote-permission' ) . "\");$(\"#ajaxpoll-ajax-" . $id .
"\").css(\"display\",\"block\");'><input disabled='disabled' type='radio'
id='ajaxpoll-post-answer-" . $ans_no . "' name='ajaxpoll-post-answer-" .
$ans_no . "' value='" . $i . "'/>" . strip_tags( $lines[$i] ) .
-"</label></div><div class='ajaxpoll-answer-vote" . ( $our ? '
ajaxpoll-our-vote' : '' ) ."' onmouseover='mover(this)'
onmouseout='mout(this);'><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>
+<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] ) .
+"</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>
</div>
";
}
Added: trunk/extensions/AJAXPoll/resources/ajaxpoll.css
===================================================================
--- trunk/extensions/AJAXPoll/resources/ajaxpoll.css
(rev 0)
+++ trunk/extensions/AJAXPoll/resources/ajaxpoll.css 2012-03-13 22:31:46 UTC
(rev 113772)
@@ -0,0 +1,106 @@
+/**
+ * CSS for AJAX Poll extension
+ * @file
+ * @ingroup Extensions
+ * @author Dariusz Siedlecki
+ * @author Thomas Gries
+ */
+
+.ajaxpoll {
+ width: 400px;
+ border: 1px dashed #999;
+ background: #FAFAFA;
+ padding: 10px 20px 10px 10px
+}
+
+.ajaxpoll .ajaxpoll-question {
+ font-weight: bold;
+}
+
+.ajaxpoll .ajaxpoll-answer-name,.ajaxpoll-answer-name-revoke {
+ margin-top: 5px;
+ padding-left: 0px;
+ font-size: 0.9em;
+}
+
+.ajaxpoll .ajaxpoll-hover-vote {
+ background: cyan;
+}
+
+.ajaxpoll .ajaxpoll-hover-revoke {
+ background: gold;
+}
+
+.ajaxpoll .ajaxpoll-answer-vote {
+ border: 1px solid #CCC;
+ width: 100%;
+ margin-left: 0px;
+ height: 12px;
+ font-size: 10px;
+ position: relative;
+}
+
+.ajaxpoll .ajaxpoll-answer-vote div {
+ border-right: 1px solid #CCC;
+ background: #E5E5E5;
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 12px;
+ font-size: 1px;
+ line-height: 12px;
+ z-index: 2;
+}
+
+.ajaxpoll .ajaxpoll-our-vote div {
+ border: 1px solid #008000;
+ top: -1px;
+ left: -1px;
+}
+
+.ajaxpoll .ajaxpoll-answer-vote span {
+ position: absolute;
+ top: -3px;
+ left: 3px;
+ z-index: 4;
+}
+
+.ajaxpoll label {
+ cursor: pointer;
+}
+.ajaxpoll input {
+ cursor: pointer;
+ vertical-align: middle;
+ margin-top: 0px;
+ margin-bottom: 0px;
+ margin-left: 0px;
+}
+
+.ajaxpoll .ajaxpoll-checkevent {
+ background: cyan;
+}
+
+.ajaxpoll .ajaxpoll-misc {
+ margin-bottom: 10px;
+ color: grey;
+}
+
+.ajaxpoll .ajaxpoll-ajax {
+ background: #FFFFCF;
+ padding: 1px 4px;
+ width: 200px;
+ border-radius: 0.5em;
+ -moz-border-radius: 0.5em;
+ display: none;
+}
+
+.ajaxpoll .ajaxpoll-info {
+ margin-top: 20px;
+ color: grey;
+}
+
+.ajaxpoll .ajaxpoll-id-info {
+ color:#FAFAFA;
+ font-size: 100%;
+ float: right;
+}
Property changes on: trunk/extensions/AJAXPoll/resources/ajaxpoll.css
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/AJAXPoll/resources/ajaxpoll.js
===================================================================
--- trunk/extensions/AJAXPoll/resources/ajaxpoll.js
(rev 0)
+++ trunk/extensions/AJAXPoll/resources/ajaxpoll.js 2012-03-13 22:31:46 UTC
(rev 113772)
@@ -0,0 +1,41 @@
+var ajaxpolltmp;
+
+$(".ajaxpoll-answer-vote").live("mouseover",
+ function(){
+ var sp=$(this).find("span");
+ ajaxpolltmp=sp.html();
+ sp.text(sp.attr("title"));
+ sp.attr("title","");
+ }
+);
+
+$(".ajaxpoll-answer-vote").live("mouseout",
+ function(){
+ var sp=$(this).find("span");
+ sp.attr("title",sp.text());
+ sp.text(ajaxpolltmp);
+ }
+);
+
+
+$(".ajaxpoll-answer-name:not(.ajaxpoll-answer-name-revoke)").live("mouseover",
+ function(){
+ $(this).addClass("ajaxpoll-hover-vote");
+ }
+);
+$(".ajaxpoll-answer-name:not(.ajaxpoll-answer-name-revoke)").live("mouseout",
+ function(){
+ $(this).removeClass("ajaxpoll-hover-vote");
+ }
+);
+
+$(".ajaxpoll-answer-name-revoke").live("mouseover",
+ function(){
+ $(this).addClass("ajaxpoll-hover-revoke");
+ }
+);
+$(".ajaxpoll-answer-name-revoke").live("mouseout",
+ function(){
+ $(this).removeClass("ajaxpoll-hover-revoke");
+ }
+);
Property changes on: trunk/extensions/AJAXPoll/resources/ajaxpoll.js
___________________________________________________________________
Added: svn:eol-style
+ native
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs