1 //****************************************************************
2 // You are free to copy the "Folder-Tree" script as long as you
3 // keep this copyright notice:
4 // Script found in: http://www.geocities.com/Paris/LeftBank/2178/
5 // Author: Marcelino Alves Martins (martins@hks.com) December '97.
6 //****************************************************************
9 // 17 Feb 98 - Fix initialization flashing problem with Netscape
11 // 27 Jan 98 - Root folder starts open; support for USETEXTLINKS;
12 // make the ftien4 a js file
14 // DvH: Dec 2000 - Made some minor changes to support external
17 // Definition of class Folder
18 // *****************************************************************
20 function Folder(folderDescription, tagName, hreference) //constructor
23 this.desc = folderDescription
24 this.tagName = tagName
25 this.hreference = hreference
34 this.iconSrc = "ftv2folderopen.png"
35 this.children = new Array
39 this.initialize = initializeFolder
40 this.setState = setStateFolder
41 this.addChild = addChild
42 this.createIndex = createEntryIndex
43 this.hide = hideFolder
44 this.display = display
45 this.renderOb = drawFolder
46 this.totalHeight = totalHeight
47 this.subEntries = folderSubEntries
48 this.outputLink = outputFolderLink
51 function setStateFolder(isOpen)
58 if (isOpen == this.isOpen)
61 if (browserVersion == 2)
64 for (i=0; i < this.nChildren; i++)
65 totalHeight = totalHeight + this.children[i].navObj.clip.height
66 subEntries = this.subEntries()
68 totalHeight = 0 - totalHeight
69 for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++)
70 indexOfEntries[fIt].navObj.moveBy(0, totalHeight)
73 propagateChangesInState(this)
76 function propagateChangesInState(folder)
83 if (folder.isLastNode)
84 folder.nodeImg.src = "ftv2mlastnode.png"
86 folder.nodeImg.src = "ftv2mnode.png"
87 folder.iconImg.src = "ftv2folderopen.png"
88 for (i=0; i<folder.nChildren; i++)
89 folder.children[i].display()
94 if (folder.isLastNode)
95 folder.nodeImg.src = "ftv2plastnode.png"
97 folder.nodeImg.src = "ftv2pnode.png"
98 folder.iconImg.src = "ftv2folderclosed.png"
99 for (i=0; i<folder.nChildren; i++)
100 folder.children[i].hide()
104 function hideFolder()
106 if (browserVersion == 1 || browserVersion == 3) {
107 if (this.navObj.style.display == "none")
109 this.navObj.style.display = "none"
111 if (this.navObj.visibility == "hidden")
113 this.navObj.visibility = "hidden"
119 function initializeFolder(level, lastNode, leftSide)
133 if (browserVersion > 0)
134 auxEv = "<a href='javascript:clickOnNode("+this.id+")'>"
139 if (lastNode) //the last 'brother' in the children array
141 this.renderOb(leftSide + auxEv + "<img name='nodeIcon" + this.id + "' src='ftv2mlastnode.png' width=16 height=22 border=0></a>")
142 // leftSide = leftSide + "<img src='ftv2blank.png' width=16 height=22>"
147 this.renderOb(leftSide + auxEv + "<img name='nodeIcon" + this.id + "' src='ftv2mnode.png' width=16 height=22 border=0></a>")
148 leftSide = leftSide + "<img src='ftv2vertline.png' width=16 height=22>"
157 for (i=0 ; i < this.nChildren; i++)
159 if (i == this.nChildren-1)
160 this.children[i].initialize(level, 1, leftSide)
162 this.children[i].initialize(level, 0, leftSide)
167 function drawFolder(leftSide)
169 if (browserVersion == 2) {
172 doc.write("<layer id='folder" + this.id + "' top=" + doc.yPos + " visibility=hidden>")
174 if (browserVersion == 3)
176 doc.write("<div id='folder" + this.id + "' style='visibility:hide;'>")
179 doc.write("\n<table ")
180 if (browserVersion == 1)
181 doc.write(" id='folder" + this.id + "' style='position:block;' ")
182 doc.write(" border=0 cellspacing=0 cellpadding=0>")
183 doc.write("\n<tr><td>")
186 doc.write("<img name='folderIcon" + this.id + "' ")
187 doc.write("src='" + this.iconSrc+"' border=0></a>")
188 doc.write("</td>\n<td valign=middle nowrap>")
192 doc.write(this.desc + "</a>")
198 if (this.tagName!="")
200 doc.write(" [external]")
204 doc.write("\n</table>\n")
206 if (browserVersion == 2) {
207 doc.write("</layer>")
209 if (browserVersion == 3) {
213 if (browserVersion == 1) {
214 this.navObj = doc.all["folder"+this.id]
215 this.iconImg = doc.all["folderIcon"+this.id]
216 this.nodeImg = doc.all["nodeIcon"+this.id]
217 } else if (browserVersion == 2) {
218 this.navObj = doc.layers["folder"+this.id]
219 this.iconImg = this.navObj.document.images["folderIcon"+this.id]
220 this.nodeImg = this.navObj.document.images["nodeIcon"+this.id]
221 doc.yPos=doc.yPos+this.navObj.clip.height
222 } else if (browserVersion == 3) {
223 this.navObj = doc.getElementById("folder"+this.id)
224 this.iconImg = doc.images.namedItem("folderIcon"+this.id)
225 this.nodeImg = doc.images.namedItem("nodeIcon"+this.id)
229 function outputFolderLink()
236 doc.write("doxygen='" + this.tagName + "' ");
238 doc.write("href='" + this.hreference + "' TARGET=\"basefrm\" ")
239 if (browserVersion > 0)
240 doc.write("onClick='javascript:clickOnFolder("+this.id+")'")
247 function addChild(childNode)
249 this.children[this.nChildren] = childNode
254 function folderSubEntries()
257 var se = this.nChildren
259 for (i=0; i < this.nChildren; i++){
260 if (this.children[i].children) //is a folder
261 se = se + this.children[i].subEntries()
268 // Definition of class Item (a document or link inside a Folder)
269 // *************************************************************
271 function Item(itemDescription, tagName, itemLink) // Constructor
274 this.desc = itemDescription
275 this.tagName = tagName
277 this.id = -1 //initialized in initalize()
278 this.navObj = 0 //initialized in render()
279 this.iconImg = 0 //initialized in render()
280 this.iconSrc = "ftv2doc.png"
283 this.initialize = initializeItem
284 this.createIndex = createEntryIndex
286 this.display = display
287 this.renderOb = drawItem
288 this.totalHeight = totalHeight
293 if (browserVersion == 1 || browserVersion == 3) {
294 if (this.navObj.style.display == "none")
296 this.navObj.style.display = "none"
298 if (this.navObj.visibility == "hidden")
300 this.navObj.visibility = "hidden"
304 function initializeItem(level, lastNode, leftSide)
309 if (lastNode) //the last 'brother' in the children array
311 this.renderOb(leftSide + "<img src='ftv2lastnode.png' width=16 height=22>")
312 leftSide = leftSide + "<img src='ftv2blank.png' width=16 height=22>"
316 this.renderOb(leftSide + "<img src='ftv2node.png' width=16 height=22>")
317 leftSide = leftSide + "<img src='ftv2vertline.png' width=16 height=22>"
323 function drawItem(leftSide)
325 if (browserVersion == 2)
326 doc.write("<layer id='item" + this.id + "' top=" + doc.yPos + " visibility=hidden>")
327 if (browserVersion == 3)
328 doc.write("<div id='item" + this.id + "' style='display:block;'>")
330 doc.write("\n<table ")
331 if (browserVersion == 1)
332 doc.write(" id='item" + this.id + "' style='position:block;' ")
333 doc.write(" border=0 cellspacing=0 cellpadding=0>\n")
334 doc.write("<tr><td>")
338 doc.write("<a href=" + this.link + ">")
340 doc.write("<img id='itemIcon"+this.id+"' ")
341 doc.write("src='"+this.iconSrc+"' border=0>")
346 doc.write("</td>\n<td valign=middle nowrap>")
347 if (USETEXTLINKS && this.link!="")
348 doc.write("<a href=" + this.link + ">" + this.desc + "</a>")
352 if (this.tagName!="")
354 doc.write(" [external]");
357 doc.write("\n</table>\n")
359 if (browserVersion == 2)
360 doc.write("</layer>")
361 if (browserVersion == 3)
364 if (browserVersion == 1) {
365 this.navObj = doc.all["item"+this.id]
366 this.iconImg = doc.all["itemIcon"+this.id]
367 } else if (browserVersion == 2) {
368 this.navObj = doc.layers["item"+this.id]
369 this.iconImg = this.navObj.document.images["itemIcon"+this.id]
370 doc.yPos=doc.yPos+this.navObj.clip.height
371 } else if (browserVersion == 3) {
372 this.navObj = doc.getElementById("item"+this.id)
373 this.iconImg = doc.images.namedItem("itemIcon"+this.id)
378 // Methods common to both objects (pseudo-inheritance)
379 // ********************************************************
383 if (browserVersion == 1 || browserVersion == 3)
384 this.navObj.style.display = "block"
386 this.navObj.visibility = "show"
389 function createEntryIndex()
392 indexOfEntries[nEntries] = this
396 // total height of subEntries open
397 function totalHeight() //used with browserVersion == 2
399 var h = this.navObj.clip.height
402 if (this.isOpen) //is a folder and _is_ open
403 for (i=0 ; i < this.nChildren; i++)
404 h = h + this.children[i].totalHeight()
411 // *********************************************************
413 function clickOnFolder(folderId)
415 var clicked = indexOfEntries[folderId]
418 clickOnNode(folderId)
422 if (clicked.isSelected)
426 function clickOnNode(folderId)
428 var clickedFolder = 0
431 clickedFolder = indexOfEntries[folderId]
432 state = clickedFolder.isOpen
434 clickedFolder.setState(!state) //open<->close
437 function initializeDocument()
441 browserVersion = 1 //IE4
444 browserVersion = 2 //NS4
445 else if(navigator.userAgent.toLowerCase().indexOf('gecko') != -1)
446 browserVersion = 3 //mozilla
448 browserVersion = 0 //other
450 foldersTree.initialize(0, 1, "")
451 foldersTree.display()
453 if (browserVersion > 0)
455 if(browserVersion != 3)
456 doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+"> </layer>")
458 // close the whole tree
460 // open the root folder
465 // Auxiliary Functions for Folder-Treee backward compatibility
466 // *********************************************************
468 function gFld(description, tagName, hreference)
470 folder = new Folder(description, tagName, hreference)
474 function gLnk(description, tagName, linkData)
480 fullLink = "'"+linkData+"' target=\"basefrm\""
483 linkItem = new Item(description, tagName, fullLink)
487 function insFld(parentFolder, childFolder)
489 return parentFolder.addChild(childFolder)
492 function insDoc(parentFolder, document)
494 parentFolder.addChild(document)
501 indexOfEntries = new Array