Author-it: Expand TOC completely when Web help is opened
filed in AuthorIT on Jan.03, 2008
This one comes in response to a question on the Author-it users’ forum from Kathi Bruce, who asked:
Is there a way to change the default to have the TOC expanded on open? We would like smaller books (with fewer Chapters and topics)to open with the TOC expanded, but to open larger books with the TOC collapsed. We currently publish to XHTML using the DHTML User Guide template with a custom frameset, and are still using AIT 4.5.
It can be done by adding a little extra Javascript to the dhtml_toc.js template file. Here’s how:
Step 1. Add this function to the dhtml_toc.js template.
function expandTOC()
{
// Expand all TOC links if ExpandTOC variable is set to true
var expandall = <authorit:ExpandTOC>;
if (expandall == true)
{
var aSpans=top.TOC.document.getElementsByTagName('span');
for (i=0;i<aSpans.length;i++)
{
exp(aSpans[i].id.substr(1));
}
}
}
Step 2. In dhtml_toc.htm, add a call to the new function in the onload section of the BODY tag.
<body ... onload="expandTOC();" ... >
If you have multiple functions in the onload, separate them with semicolons.
Step 3. Create a List of Values variable named ExpandTOC. This variable will serve as the toggle switch on books that determines whether or not the book’s TOC should expand by default. This variable should have two values, true and false, with false as the default.
Step 4. Assign the ExpandTOC variable to a book and publish!
Leave a Reply