From bbfd75e9d199ede5be5a549a6b07588270cf4629 Mon Sep 17 00:00:00 2001 From: rurban Date: Tue, 9 Mar 2004 11:51:54 +0000 Subject: [PATCH] support jshide=1: DHTML button hide/unhide TOC git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3123 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/plugin/CreateToc.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/plugin/CreateToc.php b/lib/plugin/CreateToc.php index 9a2245b6f..edf8d3b98 100644 --- a/lib/plugin/CreateToc.php +++ b/lib/plugin/CreateToc.php @@ -1,5 +1,5 @@ 0, // omit

Table of Contents

'align' => 'left', 'with_toclink' => 0, // link back to TOC - // not yet 'jshide' => 0, // collapsed TOC as DHTML button ); } @@ -148,14 +147,11 @@ extends WikiPlugin $current = $page->getCurrentRevision(); $content = $current->getContent(); $html = HTML::div(array('class' => 'toc','align' => $align)); - if (!$noheader) - $html->pushContent(HTML::h1(HTML::a(array('name'=>'TOC'),_("Table Of Contents")))); - $list = HTML::ul(array('class' => 'toc')); + $list = HTML::ul(array('name'=>'toclist','id'=>'toclist','class' => 'toc')); if (!strstr($headers,",")) { $headers = array($headers); } else { $headers = explode(",",$headers); - //$headers = $levels[0]; } $levels = array(); foreach ($headers as $h) { @@ -184,12 +180,27 @@ extends WikiPlugin $list->pushContent(HTML::li($li)); } } + if ($jshide) { + $list->setAttr('style','display:none;'); + $html->pushContent(Javascript("function toggletoc(){toc=document.getElementById('toclist'); if (toc.style.display=='none') { toc.style.display='block';} else {toc.style.display='none';}}")); + $html->pushContent(HTML::h1(HTML::a(array('name'=>'TOC','class'=>'gridbutton','title'=>_("Click to display"), + 'onclick'=>"toggletoc()"), + _("Table Of Contents")))); + } else { + if (!$noheader) + $html->pushContent(HTML::h1(HTML::a(array('name'=>'TOC'),_("Table Of Contents")))); + else + $html->pushContent(HTML::a(array('name'=>'TOC'),"")); + } $html->pushContent($list); return $html; } }; // $Log: not supported by cvs2svn $ +// Revision 1.6 2004/03/09 10:25:37 rurban +// slightly better formatted TOC indentation +// // Revision 1.5 2004/03/09 08:57:10 rurban // convert space to "_" instead of "x20." in anchors // proper heading indent -- 2.45.0