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>")
196 if (this.tagName!="")
198 doc.write(" [external]")
201 doc.write("\n</table>\n")
203 if (browserVersion == 2) {
204 doc.write("</layer>")
206 if (browserVersion == 3) {
210 if (browserVersion == 1) {
211 this.navObj = doc.all["folder"+this.id]
212 this.iconImg = doc.all["folderIcon"+this.id]
213 this.nodeImg = doc.all["nodeIcon"+this.id]
214 } else if (browserVersion == 2) {
215 this.navObj = doc.layers["folder"+this.id]
216 this.iconImg = this.navObj.document.images["folderIcon"+this.id]
217 this.nodeImg = this.navObj.document.images["nodeIcon"+this.id]
218 doc.yPos=doc.yPos+this.navObj.clip.height
219 } else if (browserVersion == 3) {
220 this.navObj = doc.getElementById("folder"+this.id)
221 this.iconImg = doc.images.namedItem("folderIcon"+this.id)
222 this.nodeImg = doc.images.namedItem("nodeIcon"+this.id)
226 function outputFolderLink()
233 doc.write("doxygen='" + this.tagName + "' ");
235 doc.write("href='" + this.hreference + "' TARGET=\"basefrm\" ")
236 if (browserVersion > 0)
237 doc.write("onClick='javascript:clickOnFolder("+this.id+")'")
244 function addChild(childNode)
246 this.children[this.nChildren] = childNode
251 function folderSubEntries()
254 var se = this.nChildren
256 for (i=0; i < this.nChildren; i++){
257 if (this.children[i].children) //is a folder
258 se = se + this.children[i].subEntries()
265 // Definition of class Item (a document or link inside a Folder)
266 // *************************************************************
268 function Item(itemDescription, tagName, itemLink) // Constructor
271 this.desc = itemDescription
272 this.tagName = tagName
274 this.id = -1 //initialized in initalize()
275 this.navObj = 0 //initialized in render()
276 this.iconImg = 0 //initialized in render()
277 this.iconSrc = "ftv2doc.png"
280 this.initialize = initializeItem
281 this.createIndex = createEntryIndex
283 this.display = display
284 this.renderOb = drawItem
285 this.totalHeight = totalHeight
290 if (browserVersion == 1 || browserVersion == 3) {
291 if (this.navObj.style.display == "none")
293 this.navObj.style.display = "none"
295 if (this.navObj.visibility == "hidden")
297 this.navObj.visibility = "hidden"
301 function initializeItem(level, lastNode, leftSide)
306 if (lastNode) //the last 'brother' in the children array
308 this.renderOb(leftSide + "<img src='ftv2lastnode.png' width=16 height=22>")
309 leftSide = leftSide + "<img src='ftv2blank.png' width=16 height=22>"
313 this.renderOb(leftSide + "<img src='ftv2node.png' width=16 height=22>")
314 leftSide = leftSide + "<img src='ftv2vertline.png' width=16 height=22>"
320 function drawItem(leftSide)
322 if (browserVersion == 2)
323 doc.write("<layer id='item" + this.id + "' top=" + doc.yPos + " visibility=hidden>")
324 if (browserVersion == 3)
325 doc.write("<div id='item" + this.id + "' style='display:block;'>")
327 doc.write("\n<table ")
328 if (browserVersion == 1)
329 doc.write(" id='item" + this.id + "' style='position:block;' ")
330 doc.write(" border=0 cellspacing=0 cellpadding=0>\n")
331 doc.write("<tr><td>")
335 doc.write("<a href=" + this.link + ">")
337 doc.write("<img id='itemIcon"+this.id+"' ")
338 doc.write("src='"+this.iconSrc+"' border=0>")
343 doc.write("</td>\n<td valign=middle nowrap>")
344 if (USETEXTLINKS && this.link!="")
345 doc.write("<a href=" + this.link + ">" + this.desc + "</a>")
348 if (this.tagName!="")
350 doc.write(" [external]");
352 doc.write("\n</table>\n")
354 if (browserVersion == 2)
355 doc.write("</layer>")
356 if (browserVersion == 3)
359 if (browserVersion == 1) {
360 this.navObj = doc.all["item"+this.id]
361 this.iconImg = doc.all["itemIcon"+this.id]
362 } else if (browserVersion == 2) {
363 this.navObj = doc.layers["item"+this.id]
364 this.iconImg = this.navObj.document.images["itemIcon"+this.id]
365 doc.yPos=doc.yPos+this.navObj.clip.height
366 } else if (browserVersion == 3) {
367 this.navObj = doc.getElementById("item"+this.id)
368 this.iconImg = doc.images.namedItem("itemIcon"+this.id)
373 // Methods common to both objects (pseudo-inheritance)
374 // ********************************************************
378 if (browserVersion == 1 || browserVersion == 3)
379 this.navObj.style.display = "block"
381 this.navObj.visibility = "show"
384 function createEntryIndex()
387 indexOfEntries[nEntries] = this
391 // total height of subEntries open
392 function totalHeight() //used with browserVersion == 2
394 var h = this.navObj.clip.height
397 if (this.isOpen) //is a folder and _is_ open
398 for (i=0 ; i < this.nChildren; i++)
399 h = h + this.children[i].totalHeight()
406 // *********************************************************
408 function clickOnFolder(folderId)
410 var clicked = indexOfEntries[folderId]
413 clickOnNode(folderId)
417 if (clicked.isSelected)
421 function clickOnNode(folderId)
423 var clickedFolder = 0
426 clickedFolder = indexOfEntries[folderId]
427 state = clickedFolder.isOpen
429 clickedFolder.setState(!state) //open<->close
432 function initializeDocument()
436 browserVersion = 1 //IE4
439 browserVersion = 2 //NS4
440 else if(navigator.userAgent.toLowerCase().indexOf('gecko') != -1)
441 browserVersion = 3 //mozilla
443 browserVersion = 0 //other
445 foldersTree.initialize(0, 1, "")
446 foldersTree.display()
448 if (browserVersion > 0)
450 if(browserVersion != 3)
451 doc.write("<layer top="+indexOfEntries[nEntries-1].navObj.top+"> </layer>")
453 // close the whole tree
455 // open the root folder
460 // Auxiliary Functions for Folder-Treee backward compatibility
461 // *********************************************************
463 function gFld(description, tagName, hreference)
465 folder = new Folder(description, tagName, hreference)
469 function gLnk(description, tagName, linkData)
475 fullLink = "'"+linkData+"' target=\"basefrm\""
478 linkItem = new Item(description, tagName, fullLink)
482 function insFld(parentFolder, childFolder)
484 return parentFolder.addChild(childFolder)
487 function insDoc(parentFolder, document)
489 parentFolder.addChild(document)
496 indexOfEntries = new Array