Only emit the javascript to set editbox focus when we're really editing
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 10 Dec 2003 10:30:14 +0000 (10:30 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 10 Dec 2003 10:30:14 +0000 (10:30 +0000)
includes/EditPage.php
includes/OutputPage.php
includes/Skin.php

index db9f17d..ef6f6af 100644 (file)
@@ -288,6 +288,7 @@ class EditPage {
                        $editsummary="{$summary}: <input tabindex=3 type=text value=\"{$wpSummary}\" name=\"wpSummary\" maxlength=200 size=60><br>";
                }
 
+               $wgOut->setOnloadHandler( "document.editform.wpTextbox1.focus()" );
                $wgOut->addHTML( "
 <form id=\"editform\" name=\"editform\" method=\"post\" action=\"$action\"
 enctype=\"application/x-www-form-urlencoded\">
index e7df1a2..cdd84c2 100644 (file)
@@ -12,6 +12,7 @@ class OutputPage {
 
        var $mDTopen, $mLastSection; # Used for processing DL, PRE
        var $mLanguageLinks, $mSupressQuickbar;
+       var $mOnloadHandler;
 
        function OutputPage()
        {
@@ -19,7 +20,8 @@ class OutputPage {
                $this->mKeywords = $this->mLinktags = array();
                $this->mHTMLtitle = $this->mPagetitle = $this->mBodytext =
                $this->mLastSection = $this->mRedirect = $this->mLastModified =
-               $this->mSubtitle = $this->mDebugtext = $this->mRobotpolicy = "";
+               $this->mSubtitle = $this->mDebugtext = $this->mRobotpolicy = 
+               $this->mOnloadHandler = "";
                $this->mIsarticle = $this->mPrintable = true;
                $this->mSupressQuickbar = $this->mDTopen = $this->mPrintable = false;
                $this->mLanguageLinks = array();
@@ -94,6 +96,8 @@ class OutputPage {
        function isArticle() { return $this->mIsarticle; }
        function setPrintable() { $this->mPrintable = true; }
        function isPrintable() { return $this->mPrintable; }
+       function setOnloadHandler( $js ) { $this->mOnloadHandler = $js; }
+       function getOnloadHandler() { return $this->mOnloadHandler; }
 
        function getLanguageLinks() {
                global $wgTitle, $wgLanguageCode;
index ad3c704..4853b2a 100644 (file)
@@ -168,14 +168,7 @@ class Skin {
                        $a += array ("ondblclick" => $s);
 
                }
-               if($action=="edit") { # set focus in edit box
-                       $foc = "document.editform.wpTextbox1.focus()";
-                       if($a['onload']) {
-                               $a['onload'] .= ";$foc";
-                       } else {
-                               $a['onload'] = $foc;
-                       }
-               }
+               $a['onload'] = $wgOut->getOnloadHandler();
                return $a;
        }