Index: tableofcontents.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tableofcontents/tableofcontents.module,v
retrieving revision 1.2.4.2.2.14
diff -u -r1.2.4.2.2.14 tableofcontents.module
--- tableofcontents.module	14 Dec 2008 03:07:12 -0000	1.2.4.2.2.14
+++ tableofcontents.module	1 Jan 2009 17:54:12 -0000
@@ -53,7 +53,7 @@
   
   if ($long) {
     if ($override) {
-      return t('Every instance of "&lt;!--tableofcontents--&gt;" in the input text will be replaced with a collapsible mediawiki-style table of contents. Accepts options for title, list style, minimum heading level, and maximum heading level, and attachments as follows: &lt;!--tableofcontents list: ol; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;--&gt;. All arguments are optional.');
+      return t('Every instance of "&lt;!--tableofcontents--&gt;" in the input text will be replaced with a collapsible mediawiki-style table of contents. Accepts options for title, show / hide toggle, list style, minimum heading level, and maximum heading level, and attachments as follows: &lt;!--tableofcontents list: ol; toggle: 1; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;--&gt;. All arguments are optional.');
     }
     else {
       return t('Every instance of "&lt;!--tableofcontents--&gt;" in the input text will be replaced with a collapsible mediawiki-style table of contents.');
@@ -61,7 +61,7 @@
   }
   else {
     if ($override) {
-      return t('Insert &lt;!--tableofcontents [list: ol; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;]--&gt; to insert a mediawiki style collapsible table of contents. Arguments within [] are optional.');
+      return t('Insert &lt;!--tableofcontents [toggle: 1; list: ol; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;]--&gt; to insert a mediawiki style collapsible table of contents. Arguments within [] are optional.');
     }
     else {
       return t('Insert &lt;!--tableofcontents--&gt; to insert a mediawiki style collapsible table of contents.');
@@ -103,6 +103,7 @@
         
         // We save a translate call and only translate this when we process the options.
         $toc_options["title"] = variable_get('tableofcontents_title_' . $format, 'Table of Contents');
+        $toc_options['toggle'] = variable_get('tableofcontents_display_toggle_' . $format, TRUE);
         $toc_options["list"] = variable_get('tableofcontents_list_type_' . $format, 'ol');
         $toc_options["minlevel"] = variable_get('tableofcontents_minlevel_' . $format, 2);
         $toc_options["maxlevel"] = variable_get('tableofcontents_maxlevel_' . $format, 3);
@@ -126,6 +127,10 @@
 
           // validate option values, use defaults for invalid values, build & display error message
           $error_status = false;
+          if (!($toc_options["toggle"] === TRUE || $toc_options["toggle"] === "1" || $toc_options["toggle"] === FALSE || $toc_options["toggle"] === "0")) {
+            $error_message[] = t("!toggle is an invalid toogle option. The toggle option must be set to '1' to display or '0' to hide.", array('!toggle' => $toc_options["toggle"]));
+            $error_status = true;
+          }
           if (($toc_options["list"] != "ol") && ($toc_options["list"] != "ul")) {
             $error_message[] = $toc_options["list"]." is an invalid list type. The only valid values for list are 'ol' or 'ul'. Using default value of ol.\n";
             $error_status = true;
@@ -265,6 +270,13 @@
     '#description' => t('Enter a default title for each Table of Contents. This will be translated for each individual page.'),
   );
   
+  $form['tableofcontents']['tableofcontents_display_toggle_' .  $format] = array(
+    '#title' => t('Display show / hide toggle link'),
+    '#type' => 'checkbox',
+    '#default_value' => variable_get('tableofcontents_display_toggle_' . $format, TRUE),
+    '#description' => t('If enabled, a JavaScript link will be inserted into the Table of Contents allowing it to be shown or hidden.'),
+  );
+  
   $form['tableofcontents']['tableofcontents_list_type_' . $format] = array(
     '#title' => t('List Type'),
     '#type' => 'radios',
@@ -359,9 +371,13 @@
  *   Rendered HTML to be displayed.
  */
 function theme_tableofcontents_toc($toc, $options, $files = array()) {
-  $output = "<div class=\"toc\">\n<div class=\"toc-title\">" .
-  $options["title"] . " [<a href=\"#\" class=\"toc-toggle\">hide</a>]</div>\n<div class=\"toc-list\">\n<" .
-  $options["list"] . ">\n";
+  $output = "<div class=\"toc\">\n<div class=\"toc-title\">" . $options["title"];
+
+  if ($options['toggle']) {
+    $output .= " [<a href=\"#\" class=\"toc-toggle\">" . t('hide') . "</a>]";
+  }
+  
+  $output .= "</div>\n<div class=\"toc-list\">\n<" . $options["list"] . ">\n";
 
   $depth = $options["minlevel"];
   foreach ($toc as $index=>$title) {
