call JS onload hooks at the end of the html body in all skins
authorDaniel Kinzler <daniel@users.mediawiki.org>
Sat, 29 Jul 2006 22:34:22 +0000 (22:34 +0000)
committerDaniel Kinzler <daniel@users.mediawiki.org>
Sat, 29 Jul 2006 22:34:22 +0000 (22:34 +0000)
includes/Skin.php
includes/SkinTemplate.php
skins/MonoBook.php
skins/common/wikibits.js

index d8dbc16..a99ff0a 100644 (file)
@@ -255,6 +255,8 @@ class Skin extends Linker {
 
                $out->out( $this->afterContent() );
 
+               $out->out( $this->bottomScripts() );
+
                $out->out( $out->reportTime() );
 
                $out->out( "\n</body></html>" );
@@ -620,14 +622,23 @@ END;
        }
 
        /**
-        * This gets called immediately before the \</body\> tag.
-        * @return String HTML to be put after \</body\> ???
+        * This gets called shortly before the \</body\> tag.
+        * @return String HTML to be put before \</body\> 
         */
        function afterContent() {
                $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
                return $printfooter . $this->doAfterContent();
        }
 
+       /**
+        * This gets called shortly before the \</body\> tag.
+        * @return String HTML-wrapped JS code to be put before \</body\> 
+        */
+       function bottomScripts() {
+               global $wgJsMimeType;
+               return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
+       }
+
        /** @return string Retrievied from HTML text */
        function printSource() {
                global $wgTitle;
index ddbc40b..64d75cd 100644 (file)
@@ -390,6 +390,7 @@ class SkinTemplate extends Skin {
                $tpl->setRef( 'debug', $out->mDebugtext );
                $tpl->set( 'reporttime', $out->reportTime() );
                $tpl->set( 'sitenotice', wfGetSiteNotice() );
+               $tpl->set( 'bottomscripts', $this->bottomScripts() );
 
                $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
                $out->mBodytext .= $printfooter ;
index 9532eab..81e9236 100644 (file)
@@ -265,7 +265,8 @@ class MonoBookTemplate extends QuickTemplate {
 ?>
                        </ul>
                </div>
-       <script type="text/javascript"> if (window.runOnloadHook) runOnloadHook();</script>
+               
+       <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
 </div>
 <?php $this->html('reporttime') ?>
 
index d95c4dc..0cfb600 100644 (file)
@@ -49,6 +49,8 @@ function hookEvent(hookName, hookFunct) {
                attachEvent("on" + hookName, hookFunct);
 }
 
+//note: all skins shoud call runOnloadHook() at the end of html output,
+//      so the below should be redundant. It's there just in case.
 hookEvent("load", runOnloadHook);
 
 // document.write special stylesheet links