r74629 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74628‎ | r74629 | r74630 >
Date:15:32, 11 October 2010
Author:platonides
Status:deferred
Tags:
Comment:
Fix the javascript after r74626.
It won't appear on cached pages, will need a RL module...
Modified paths:
  • /trunk/extensions/ArticleComments/ArticleComments.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleComments/ArticleComments.php
@@ -3,7 +3,7 @@
44 * ArticleComments.php - A MediaWiki extension for adding comment sections to articles.
55 * @author Jim R. Wilson
66 * @author Platonides
7 - * @version 0.5
 7+ * @version 0.5.1
88 * @copyright Copyright (C) 2007 Jim R. Wilson
99 * @license The MIT License - http://www.opensource.org/licenses/mit-license.php
1010 * -----------------------------------------------------------------------
@@ -172,7 +172,7 @@
173173 * @param Array $params A hash of parameters containing rendering options.
174174 */
175175 function wfArticleCommentForm( $title, $params = array() ) {
176 - global $wgArticleCommentDefaults;
 176+ global $wgArticleCommentDefaults, $wgOut;
177177
178178 # Merge in global defaults if specified
179179 $tmp = $wgArticleCommentDefaults;
@@ -211,10 +211,10 @@
212212 }
213213
214214 # Inline JavaScript to make form behavior more rich (must degrade well in JS-disabled browsers)
215 - $content .= "<script type='text/javascript'>//<![CDATA[\n(function(){\n";
 215+ $js .= "<script type=\"text/javascript\">//<![CDATA[\n(function(){\n";
216216
217217 # Prefill the name field if the user is logged in.
218 - $content .=
 218+ $js .=
219219 'var prefillUserName = function(){' . "\n" .
220220 'var ptu=document.getElementById("pt-userpage");' . "\n" .
221221 'if (ptu) document.getElementById("commenterName").value=' .
@@ -230,7 +230,7 @@
231231 # to manually delete it) and would break parser output caching
232232 $pretext = wfMsgForContent( 'article-comments-prefilled-comment-text' );
233233 if ( $pretext ) {
234 - $content .=
 234+ $js .=
235235 'var comment = document.getElementById("comment");' . "\n" .
236236 'comment._everFocused=false;' . "\n" .
237237 'comment.innerHTML="' . htmlspecialchars( $pretext ) . '";' . "\n" .
@@ -248,9 +248,9 @@
249249 # Hides the commentForm until the "Make a comment" link is clicked
250250 # Note: To disable, set $wgArticleCommentDefaults['hideForm']=false in LocalSettings.php
251251 if ( !isset( $params['hideform'] ) ||
252 - ( $params['hideform'] != 'false' &&
 252+ ( $params['hideform'] !== 'false' &&
253253 !$params['hideform'] === false ) ) {
254 - $content .=
 254+ $js .=
255255 'var cf=document.getElementById("commentForm");' . "\n" .
256256 'cf.style.display="none";' . "\n" .
257257 'var p=document.createElement("p");' . "\n" .
@@ -261,7 +261,9 @@
262262 'cf.parentNode.insertBefore(p,cf);' . "\n";
263263 }
264264
265 - $content .= "})();\n//]]></script>";
 265+ $js .= "})();\n//]]></script>";
 266+ $wgOut->addScript( $js );
 267+
266268 return $content;
267269 }
268270

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74626Remove the base64 pass.platonides14:25, 11 October 2010

Status & tagging log