/***************************************************************************************************************** Automatic collapsible list generation script written by Mark Wilton-Jones - 2002 Version 2.1 - updated July 2003 to allow automatic collapsing and classes - fully compatible with original script ****************************************************************************************************************** Please see http://www.howtocreate.co.uk/jslibs/ for details and a demo of this script Please see http://www.howtocreate.co.uk/jslibs/termsOfUse.html for terms of use _________________________________________________________________________ You can put as lists on the page as you like, each list may have a different format To use: _________________________________________________________________________ Inbetween the
tags, put: _________________________________________________________________________ For best results, all images should be the same height, slightly taller than the text around them. I would recommend about 21px. Now, wherever you want the list (not in a layer or positioned element due to Netscape 4 style bug), put: ******************************************************************************************************* And here's the actual code ******************************************************************************************************/ window.collapsibleListRef = []; window.imageCache = []; window.autoCloseRef = []; //iCab can change display, but does not say so, and does notunderstand '' so I use a browser detect var is_Icab = window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1; function collapsibleList() { //hold tree information about the list and the images used this.treeImg = arguments[0]; this.expdImg = arguments[1]; this.isAutoClose = arguments[2]; this.subClass = arguments[3]; this.sub = []; } function sub() { //hold information about the list item this.text = arguments[0]; this.expanded = arguments[1]; this.sub = []; } //done because WebTV does not understand inline object syntax function ColLexPdOb(plI,miI) { this.plI = plI; this.miI = miI; this.subs = []; } function ColLexPdIT(name,expanded) { this.name = name; this.expanded = expanded; } function createList(listObject,currentExt,imgExt,oLev,oBase) { if( !currentExt ) { //create the list, start by defining aditional stuff that is required, counting the lists etc. window.collapsibleListRef[window.collapsibleListRef.length] = new ColLexPdOb( listObject.expdImg[4], listObject.expdImg[5] ); currentExt = 'treeList_'+( window.collapsibleListRef.length - 1 ); imgExt = ''; oLev = 0; oBase = listObject; document.write( '' );
oBase.menuUniqueNum = window.collapsibleListRef.length - 1; window.autoCloseRef[oBase.menuUniqueNum] = [];
}
document.write( '' );
for( var x = 0; x < listObject.sub.length; x++ ) {
//for every child object, create their line
var text = '';
var spanClose = '';
var alignText = 'align="absmiddle" ';
if (oLev || x) {//the line break on all except the very first line
text += '\n
';
}
if (oBase.subClass
&& oBase.subClass[oLev]
&& oBase.subClass[oLev][listObject.sub[x].sub.length?1:0]
&& !( document.layers && navigator.mimeTypes['*'] )) {//what may or may not remain of the trunk
text += '';
spanClose = '';
}
text += imgExt;
if (oLev ) {//this branch
text += '';
}
if (listObject.sub[x].sub.length) {//the expand / collapse link or not as the case may be
text += '';
text += '';
text += '';
}
else {
text +='';
}
document.write(
text +
//the text of the branch
listObject.sub[x].text +
spanClose
);
if( listObject.sub[x].sub.length ) {
//add the span id to a list so we can easily find it and collapse it later
window.collapsibleListRef[window.collapsibleListRef.length - 1].subs[window.collapsibleListRef[window.collapsibleListRef.length - 1].subs.length] = new ColLexPdIT( currentExt + '_' + x, listObject.sub[x].expanded && !oBase.isAutoClose );
//create children
createList( listObject.sub[x], currentExt + '_' + x, oLev ? ( imgExt + ( ( x < listObject.sub.length - 1 ) ? '' : '' ) ) : '', oLev + 1, oBase );
}
}
document.write( '' );
if( !oLev ) {
//end the list and prepare to collapse as soon as the browser lays it out
document.write( '