r15883 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r15882‎ | r15883 | r15884 >
Date:22:34, 29 July 2006
Author:daniel
Status:old
Tags:
Comment:
call JS onload hooks at the end of the html body in all skins
Modified paths:
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/skins/MonoBook.php (modified) (history)
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -390,6 +390,7 @@
391391 $tpl->setRef( 'debug', $out->mDebugtext );
392392 $tpl->set( 'reporttime', $out->reportTime() );
393393 $tpl->set( 'sitenotice', wfGetSiteNotice() );
 394+ $tpl->set( 'bottomscripts', $this->bottomScripts() );
394395
395396 $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
396397 $out->mBodytext .= $printfooter ;
Index: trunk/phase3/includes/Skin.php
@@ -255,6 +255,8 @@
256256
257257 $out->out( $this->afterContent() );
258258
 259+ $out->out( $this->bottomScripts() );
 260+
259261 $out->out( $out->reportTime() );
260262
261263 $out->out( "\n</body></html>" );
@@ -620,14 +622,23 @@
621623 }
622624
623625 /**
624 - * This gets called immediately before the \</body\> tag.
625 - * @return String HTML to be put after \</body\> ???
 626+ * This gets called shortly before the \</body\> tag.
 627+ * @return String HTML to be put before \</body\>
626628 */
627629 function afterContent() {
628630 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
629631 return $printfooter . $this->doAfterContent();
630632 }
631633
 634+ /**
 635+ * This gets called shortly before the \</body\> tag.
 636+ * @return String HTML-wrapped JS code to be put before \</body\>
 637+ */
 638+ function bottomScripts() {
 639+ global $wgJsMimeType;
 640+ return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
 641+ }
 642+
632643 /** @return string Retrievied from HTML text */
633644 function printSource() {
634645 global $wgTitle;
Index: trunk/phase3/skins/MonoBook.php
@@ -265,7 +265,8 @@
266266 ?>
267267 </ul>
268268 </div>
269 - <script type="text/javascript"> if (window.runOnloadHook) runOnloadHook();</script>
 269+
 270+ <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
270271 </div>
271272 <?php $this->html('reporttime') ?>
272273
Index: trunk/phase3/skins/common/wikibits.js
@@ -49,6 +49,8 @@
5050 attachEvent("on" + hookName, hookFunct);
5151 }
5252
 53+//note: all skins shoud call runOnloadHook() at the end of html output,
 54+// so the below should be redundant. It's there just in case.
5355 hookEvent("load", runOnloadHook);
5456
5557 // document.write special stylesheet links