日期:2011-05-02 浏览次数:20417 次
本原码从网上下载,经本人改写,功能更强大,使用更方便,可以有无限级目录,一次性载入,可以分别设置树结点和叶结点的颜色及图标,可以展开和收缩,可以显示当前所处的路径位置,点击树结点时只在展开时显示树结点的超链接,不过,据测试,一次性载入500个节点时浏览器会显示“该脚本会使浏览器变慢”的提示,不过,选择不取消执行不会影响浏览器的性能。
function Folder(folderDescription, hreference,parentid,target) {
//constant data;
this.desc = folderDescription;
this.parentid=parentid;
this.hreference = hreference;
this.target=target;
this.id = index;
this.navObj = 0;
this.iconImg = 0;
this.nodeImg = 0;
this.isLastNode = 0;
// dynamic data
this.isRoot = true;
this.isOpen = true;
this.iconSrc=imageURL+"ftv2folderopen.gif";
this.iconRoot =imageURL+"ftv2folderopen.gif";
this.children = new Array;
this.nChildren = 0;
// methods
this.initialize = initializeFolder;
this.setState = setStateFolder;
this.addChild = addChild;
this.createIndex = createEntryIndex;
this.hide = hideFolder;
this.display = display;
this.renderOb = drawFolder;
this.totalHeight = totalHeight;
this.subEntries = folderSubEntries;
this.outputLink = outputFolderLink;
}
function setStateFolder(isOpen) {
var subEntries;
var totalHeight;
var fIt = 0;
var i = 0;
if(isOpen == this.isOpen)
return;
if(browserVersion == 2) {
totalHeight = 0
for(i = 0; i < this.nChildren; i++)
totalHeight = totalHeight + this.children[i].navObj.clip.height;
subEntries = this.subEntries();
if(this.isOpen)
totalHeight = 0 - totalHeight;
for(fIt = this.id + subEntries + 1; fIt < nEntries; fIt++)
indexOfEntries[fIt].navObj.moveBy(0, totalHeight);
}
this.isOpen = isOpen;
propagateChangesInState(this);
}
function propagateChangesInState(folder) {
var i = 0;
if(folder.isOpen) {
if(folder.nodeImg) {
if(folder.isLastNode)
folder.nodeImg.src = imageURL+"ftv2mlastnode.gif";
else
folder.nodeImg.src = imageURL+"ftv2mnode.gif";
}
if(this.isRoot)
&nb