Author: mcbrown
Date: 2007-11-23 10:24:36 +0100 (Fri, 23 Nov 2007)
New Revision: 8844
Log:
Swapping the toggle for the entire TOC so that it collapses to the top-level header only
Changing the # link so that we don't move to the top of the page
Modified:
trunk/tools/add-toc-toggle.pl
Modified: trunk/tools/add-toc-toggle.pl
===================================================================
--- trunk/tools/add-toc-toggle.pl 2007-11-23 03:17:42 UTC (rev 8843)
+++ trunk/tools/add-toc-toggle.pl 2007-11-23 09:24:36 UTC (rev 8844)
Changed blocks: 1, Lines Added: 8, Lines Deleted: 5; 1987 bytes
@@ -14,24 +14,27 @@
my $counter = 0;
- $filetext =~ s{<p><b>Table of Contents</b></p>.*?<dl>}{<p><b>Table of Contents</b> <small>[<a href="#" onclick="toggle('tocdetail');">Toggle</a>]</small></p><dl id="tocdetail">}msg;
+ $filetext =~ s{<div class="toc"><dl>}{<div class="toc"><p><small>[<a href="#nolinkhere" onclick="toggle('tocdetail-$counter');">Toggle Contents</a>]</small></p><dl id="tocdetail-$counter">}msg;
- $filetext =~ s{<div class="toc"><dl>}{<div class="toc"><p><small>[<a href="#" onclick="toggle('tocdetail-$counter');">Toggle Contents</a>]</small></p><dl id="tocdetail-$counter">}msg;
-
$counter++;
my @matches = ($filetext =~ m{(</a></span></dt>\s+<dd>)}msg);
- print join("\n",@matches);
+ my @toccollapse;
foreach my $match (@matches)
{
- my $repltext = sprintf(" <small>[<a href=\"#\" onclick=\"toggle('tocdetail-%d');\">Toggle</a>]</small><dd id=\"tocdetail-%d\">",$counter,$counter);
+ my $repltext = sprintf("</a></span> <small>[<a href=\"#nolinkhere\" onclick=\"toggle('tocdetail-%d');\">Toggle</a>]</small></dt><dd id=\"tocdetail-%d\">",$counter,$counter);
$filetext =~ s{$match}{$repltext}ms;
+ push @toccollapse,sprintf("toggle('tocdetail-%s');",$counter);
$counter++;
}
+ my $togglelist = join('',@toccollapse);
+
+ $filetext =~ s{<p><b>Table of Contents</b></p>.*?<dl>}{<p><b>Table of Contents</b> <small>[<a href="#nolinkhere" onclick="$togglelist">Toggle</a>]</small></p><dl id="tocdetail">}msg;
+
$fh = IO::File->new($file,'w') or die "Couldn't open $file: $!\n";
binmode($fh,':utf8');
print $fh $filetext;
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r8844 - trunk/tools | mcbrown | 23 Nov |