1) moved some toc layout elements to stylesheet
authorErik Moeller <erik@users.mediawiki.org>
Sun, 20 Jul 2003 13:13:06 +0000 (13:13 +0000)
committerErik Moeller <erik@users.mediawiki.org>
Sun, 20 Jul 2003 13:13:06 +0000 (13:13 +0000)
2) fixed edit section bug (would not trigger on <h[1-6]> elements
3) show/hide javascript toggle text changes when clicked
4) toc centered, smaller font

includes/Article.php
includes/Skin.php
stylesheets/wikibits.js
stylesheets/wikistandard.css

index aedebdb..c7dfdce 100644 (file)
@@ -79,7 +79,7 @@ class Article {
                                if($action=="edit") {
                                        if($section!="") {
 
-                                               $secs=preg_split("/(^=+.*?=+)/m",
+                                               $secs=preg_split("/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
                                                 $this->mContent, -1,
                                                 PREG_SPLIT_DELIM_CAPTURE);
                                                if($section==0) {
@@ -656,7 +656,7 @@ name=\"wpSummary\" maxlength=200 size=60><br>
                // of the article
                if ($section != "") {
                        $oldtext=$this->getContent();
-                       $secs=preg_split("/(^=+.*?=+)/m",$oldtext,-1,PREG_SPLIT_DELIM_CAPTURE);
+                       $secs=preg_split("/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",$oldtext,-1,PREG_SPLIT_DELIM_CAPTURE);
                        $secs[$section*2]=$text."\n\n"; // replace with edited
                        if($section) { $secs[$section*2-1]=""; } // erase old headline
                        $text=join("",$secs);           
index fc52a2e..cf4a492 100644 (file)
@@ -1721,20 +1721,13 @@ class Skin {
        }
 
        function tocTable($toc) {
-
-/* does not auto-expand, use table for now
-       return "
-       <div><div style=\"border-width:1px;background-color:#f3f3ff;border-color:#8888aa;border-style:solid;padding:1em;padding-bottom:1em;\">
-       <b>".wfMsg("toc")."</b><P>
-       $toc</div></div>";
-*/
+       // note to CSS fanatics: putting this in a div does not works -- div won't auto-expand
        return
-       "<table border=\"0\" bgcolor=\"#8888aa\" cellpadding=\"0\" cellspacing=\"1\"><tr><td>\n" .
-       "<table border=\"0\" bgcolor=\"#f3f3ff\" CELLPADDING=5><tr><td>\n".
+       "<table border=\"0\" align=\"center\" id=\"toc\"><tr><td align=\"center\">\n".
        "<b>".wfMsg("toc")."</b>" .
        " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>" .
-       "</td></tr><tr id='tocinside'><td>\n".
-       $toc."</td></tr></table></td></tr></table><P>\n";
+       "</td></tr><tr id='tocinside'><td align=\"left\">\n".
+       $toc."</td></tr></table><P>\n";
        }
 
        function editSectionLink($section) {
index d57d5b0..2d22bf3 100644 (file)
@@ -47,26 +47,30 @@ function guessTimezone(box) {
        document.preferences.wpHourDiff.value = fetchTimezone();
 }
 
-var tocShow, tocHide;
 function showTocToggle(show,hide) {
        if(document.getElementById) {
-               document.writeln('<small>[<a href="javascript:toggleToc()" id="toctoggle">' +
-                       hide + '/' + show + '</a>]</small>');
-               tocShow = show;
-               tocHide = hide;
+               document.writeln('<small>[<a href="javascript:toggleToc()" class="internal">' +
+               '<span id="showlink" style="display:none;">' + show + '</span>' +
+               '<span id="hidelink">' + hide + '</span>' 
+               + '</a>]</small>');
        }
 }
 
 function toggleToc() {
        var toc = document.getElementById('tocinside');
-       var tog = document.getElementById('toctoggle');
+       var showlink=document.getElementById('showlink');
+       var hidelink=document.getElementById('hidelink');
        if(toc.style.display == 'none') {
-               toc.style.display = tocWas;
-               // tog.innerHtml = tocHide;
+               toc.style.display = tocWas;             
+               hidelink.style.display='';
+               showlink.style.display='none';
+
        } else {
                tocWas = toc.style.display;
                toc.style.display = 'none';
-               // tog.innerHtml = tocShow;
+               hidelink.style.display='none';
+               showlink.style.display='';
+
        }
 }
 
index cf63ca6..5b6cc04 100644 (file)
@@ -7,6 +7,7 @@
 }
 #quickbar { width: 140px; padding: 4px; visibility: visible; z-index: 99; }
 #topbar { padding: 4px; }
+#toc { border:1px solid #8888aa; background-color:#f3f3ff;padding:5px;font-size:90%; }
 .bodytext { }
 a.interwiki, a.external { color: #3366BB; }
 a.printable { text-decoration: underline; }