You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

819 lines
26 KiB
JavaScript

/*---------------------------------------------------------------------------*\
| Subject: Web TreeView Class |
| Version: 1.0 |
| Author: <EFBFBD>Ʒ<EFBFBD><EFBFBD>١<EFBFBD>meizz<EFBFBD><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD>ѩ<EFBFBD><EFBFBD> |
| FileName: MzTreeView.js |
| Created: 2004-10-18 |
| LastModified: 2005-03-10 |
| Download: http://www.meizz.com/Web/Download/MzTreeView10.rar |
| Explain: http://www.meizz.com/Web/Article.asp?id=436 |
| Demo: http://www.meizz.com/Web/Demo/MzTreeView10.htm |
| |
| You may use this code on your item |
| this entire copyright notice appears unchanged |
| and you clearly display a link to http://www.meizz.com/ |
| |
|-----------------------------------------------------------------------------|
| MSN: huangfr@msn.com QQ: 112889082 http://www.meizz.com |
| CSDN Community ID: meizz Copyright (c) 2004-2005 meizz |
\*---------------------------------------------------------------------------*/
//Version: 1.2
//20:31 2007-8-25 http://www.lxasp.com
//Ϊ<><CEAA><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ʡ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>С<EFBFBD><D0A1><EFBFBD>޸<EFBFBD><DEB8>˽ӿڣ<D3BF><DAA3><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>Сд<D0A1><D0B4><EFBFBD><EFBFBD>
//
//ԭ<><D4AD><EFBFBD><EFBFBD> nodes["pnt_cur"]="text:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;method:js<6A><73><EFBFBD><EFBFBD>()";
//
//<2F><>Ϊ<EFBFBD><CEAA> N["pnt_cur"]="T:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;C:js<6A><73><EFBFBD><EFBFBD>()";
//MzTreeView1.0<EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>
function MzTreeView(Tname)
{
if(typeof(Tname) != "string" || Tname == "")
throw(new Error(-1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD>'));
//<2F><>property<74><79>
this.url = "#";
this.target = "_self";
this.name = Tname;
this.wordLine = false;
this.currentNode = null;
this.useArrow = true;
this.N = {};
this.node = {};
this.names = "";
this._d = "\x0f";
this.index = 0;
this.divider = "_";
this.node["0"] =
{
"id": "0",
"path": "0",
"isLoad": false,
"childNodes": [],
"childAppend": "",
"sourceIndex": "0"
};
this.colors =
{
"highLight" : "#0A246A",
"highLightText" : "#FFFFFF",
"mouseOverBgColor" : "#D4D0C8"
};
this.icons = {
L0 : 'L0.gif', //<2F><>
L1 : 'L1.gif', //<2F><>
L2 : 'L2.gif', //<2F><>
L3 : 'L3.gif', //<2F><>
L4 : 'L4.gif', //<2F><>
PM0 : 'P0.gif', //<2F><><EFBFBD><EFBFBD>
PM1 : 'P1.gif', //<2F><><EFBFBD><EFBFBD>
PM2 : 'P2.gif', //<2F><><EFBFBD><EFBFBD>
PM3 : 'P3.gif', //<2F><><EFBFBD><EFBFBD>
empty : 'L5.gif', //<2F>հ<EFBFBD>ͼ
root : 'root.gif', //ȱʡ<C8B1>ĸ<EFBFBD><C4B8>ڵ<EFBFBD>ͼ<EFBFBD><CDBC>
folder : 'folder.gif', //ȱʡ<C8B1><CAA1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ͼ<EFBFBD><CDBC>
file : 'file.gif', //ȱʡ<C8B1><CAA1><EFBFBD>ļ<EFBFBD>ͼ<EFBFBD><CDBC>
exit : 'exit.gif'
};
this.iconsExpand = { //<2F><><EFBFBD>Žڵ<C5BD>ͼƬ<CDBC><C6AC>չ<EFBFBD><D5B9>ʱ<EFBFBD>Ķ<EFBFBD>ӦͼƬ
PM0 : 'M0.gif', //<2F><><EFBFBD><EFBFBD>
PM1 : 'M1.gif', //<2F><><EFBFBD><EFBFBD>
PM2 : 'M2.gif', //<2F><><EFBFBD><EFBFBD>
PM3 : 'M3.gif', //<2F><><EFBFBD><EFBFBD>
folder : 'fopen.gif',
exit : 'exit.gif'
};
//<2F><>չ document.getElementById(id) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//id Ҫ<><D2AA><EFBFBD>ҵĶ<D2B5><C4B6><EFBFBD> id
this.getElementById = function(id)
{
if (typeof(id) != "string" || id == "") return null;
if (document.getElementById) return document.getElementById(id);
if (document.all) return document.all(id);
try {return eval(id);} catch(e){ return null;}
};
//MzTreeView <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD>
this.toString = function()
{
this.browserCheck();
this.dataFormat();
this.setStyle();
this.load("0");
var rootCN = this.node["0"].childNodes;
var str = "<A id='"+ this.name +"_RootLink' href='#' style='DISPLAY: none'></A>";
if(rootCN.length>0)
{
this.node["0"].hasChild = true;
for(var i=0; i<rootCN.length; i++)
str += this.nodeToHTML(rootCN[i], i==rootCN.length-1);
setTimeout(this.name +".expand('"+ rootCN[0].id +"', true); "+
this.name +".focusClientNode('"+ rootCN[0].id +"'); "+ this.name +".atRootIsEmpty()",10);
}
if (this.useArrow) //ʹ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ϼ<EFBFBD><CFBC>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><D3BC>ڵ<EFBFBD>
{
if (document.attachEvent)
document.attachEvent("onkeydown", this.onkeydown);
else if (document.addEventListener)
document.addEventListener('keydown', this.onkeydown, false);
}
return "<DIV class='MzTreeView' "+
"onclick='"+ this.name +".clickHandle(event)' "+
"ondblclick='"+ this.name +".dblClickHandle(event)' "+
">"+ str +"</DIV>";
};
this.onkeydown= function(e)
{
e = window.event || e; var key = e.keyCode || e.which;
switch(key)
{
case 37 : eval(Tname).upperNode(); break; //Arrow left, shrink child node
case 38 : eval(Tname).pervNode(); break; //Arrow up
case 39 : eval(Tname).lowerNode(); break; //Arrow right, expand child node
case 40 : eval(Tname).nextNode(); break; //Arrow down
}
};
};
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><E6B1BE><EFBFBD><EFBFBD>
MzTreeView.prototype.browserCheck = function()
{
var ua = window.navigator.userAgent.toLowerCase(), bname;
if(/msie/i.test(ua))
{
this.navigator = /opera/i.test(ua) ? "opera" : "";
if(!this.navigator) this.navigator = "msie";
}
else if(/gecko/i.test(ua))
{
var vendor = window.navigator.vendor.toLowerCase();
if(vendor == "firefox") this.navigator = "firefox";
else if(vendor == "netscape") this.navigator = "netscape";
else if(vendor == "") this.navigator = "mozilla";
}
else this.navigator = "msie";
if(window.opera) this.wordLine = false;
};
//<2F><> TreeView <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
MzTreeView.prototype.setStyle = function()
{
/*
width: 16px; \
height: 16px; \
width: 20px; \
height: 20px; \
*/
var style = "<style>"+
"DIV.MzTreeView DIV IMG{border: 0px solid #FFFFFF;}"+
"DIV.MzTreeView DIV SPAN IMG{border: 0px solid #FFFFFF;}";
if(this.wordLine)
{
style +="\n DIV.MzTreeView DIV\n {\n height: 20px;"+
(this.navigator=="firefox" ? "line-height: 20px;" : "" ) +
(this.navigator=="netscape" ? "" : "overflow: hidden;" ) +"\n }\n DIV.MzTreeView DIV SPAN\n {\n vertical-align: middle; font-size: 21px; height: 20px; color: #D4D0C8; cursor: default;\n }\n DIV.MzTreeView DIV SPAN.pm\n {\n width: "+ (this.navigator=="msie"||this.navigator=="opera" ? "11" : "9") +"px;\n height: "+ (this.navigator=="netscape"?"9":(this.navigator=="firefox"?"10":"11")) +"px;\n font-size: 7pt;\n overflow: hidden;\n margin-left: -16px;\n margin-right: 5px;\n color: #000080; \n vertical-align: middle;\n border: 1px solid #D4D0C8;\n cursor: "+ (this.navigator=="msie" ? "hand" : "pointer") +";\n padding: 0 2px 0 2px;\n text-align: center;\n background-color: #F0F0F0;\n }";
}
style += "<\/style>";
document.write(style);
};
//<2F><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>Ϊ<EFBFBD>յ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
MzTreeView.prototype.atRootIsEmpty = function()
{
var RCN = this.node["0"].childNodes;
for(var i=0; i<RCN.length; i++)
{
if(!RCN[i].isLoad) this.expand(RCN[i].id);
if (RCN[i].T=="")
{
var node = RCN[i].childNodes[0], HCN = node.hasChild;
if(this.wordLine)
{
var span = this.getElementById(this.name +"_tree_"+ node.id);
span = span.childNodes[0].childNodes[0].childNodes[0];
span.innerHTML = RCN[i].childNodes.length>1 ? "<22><>" : "<22><>";
}
else
{
node.iconExpand = RCN[i].childNodes.length>1 ? HCN ? "PM0" : "L0" : HCN ? "PM3" : "L3";
this.getElementById(this.name +"_expand_"+ node.id).src = this.icons[node.iconExpand].src;
}
}
}
};
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ټ<EFBFBD><D9BC><EFBFBD>
MzTreeView.prototype.dataFormat = function()
{
var a = new Array();
for (var id in this.N) a[a.length] = id;
this.names = a.join(this._d + this._d);
this.totalNode = a.length; a = null;
};
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽڵ<DDBD>
//id <20>ͻ<EFBFBD><CDBB>˽ڵ<CBBD><DAB5><EFBFBD>Ӧ<EFBFBD><D3A6>id
MzTreeView.prototype.load = function(id)
{
var node = this.node[id], d = this.divider, _d = this._d;
var sid = node.sourceIndex.substr(node.sourceIndex.indexOf(d) + d.length);
var reg = new RegExp("(^|"+_d+")"+ sid +d+"[^"+_d+d +"]+("+_d+"|$)", "g");
var cns = this.names.match(reg), tcn = this.node[id].childNodes; if (cns){
reg = new RegExp(_d, "g"); for (var i=0; i<cns.length; i++)
tcn[tcn.length] = this.nodeInit(cns[i].replace(reg, ""), id); }
node.isLoad = true;
};
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>Ϣ, <20><><EFBFBD><EFBFBD> this.N <20><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>ɽڵ<C9BD><DAB5><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ
//sourceIndex <20><><EFBFBD><EFBFBD>Դ<EFBFBD>еĸ<D0B5><C4B8>ӽڵ<D3BD><DAB5><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>ַ<EFBFBD><D6B7><EFBFBD> 0_1
//parentId <20><>ǰ<EFBFBD><C7B0><EFBFBD>ڵ<EFBFBD><DAB5>ڿͻ<DABF><CDBB>˵ĸ<CBB5><C4B8>ڵ<EFBFBD><DAB5><EFBFBD> id
MzTreeView.prototype.nodeInit = function(sourceIndex, parentId)
{
this.index++;
var source= this.N[sourceIndex], d = this.divider;
var T = this.getAttribute(source, "T");
var hint = this.getAttribute(source, "hint");
var ctrl = this.getAttribute(source, "ctrl"); //Rexliu modify on 2007-1-23 13:50
var checked = this.getAttribute(source, "checked"); //Rexliu modifty on 2007-1-23 14:27
var sid = sourceIndex.substr(sourceIndex.indexOf(d) + d.length);
this.node[this.index] =
{
"id" : this.index,
"T" : T,
"hint" : hint ? hint : T,
"icon" : this.getAttribute(source, "icon"),
"path" : this.node[parentId].path + d + this.index,
"isLoad": false,
"isExpand": false,
"parentId": parentId,
"parentNode": this.node[parentId],
"sourceIndex" : sourceIndex,
"childAppend" : "",
"ctrl" : ctrl, //Rexliu modify on 2007-1-23 13:52
"checked" : checked //Rexliu modify on 2007-1-23 14:28
};
this.N[sourceIndex] = "index:"+ this.index +";"+ source;
this.node[this.index].hasChild = this.names.indexOf(this._d + sid + d)>-1;
if(this.node[this.index].hasChild) this.node[this.index].childNodes = [];
return this.node[this.index];
};
//<2F><>XML<4D><4C>ʽ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>Ϣ
//source <20><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>Ľڵ<C4BD><DAB5><EFBFBD>Ϣ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>(<28>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9>XML<4D><4C>֧<EFBFBD><D6A7>)
//name Ҫ<><D2AA>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MzTreeView.prototype.getAttribute = function(source, name)
{
var reg = new RegExp("(^|;|\\s)"+ name +"\\s*:\\s*([^;]*)(\\s|;|$)", "i");
if (reg.test(source)) return RegExp.$2.replace(/[\x0f]/g, ";"); return "";
};
//<2F><><EFBFBD>ݽڵ<DDBD><DAB5><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>HTML
//node <20><><EFBFBD>ڿͻ<DABF><CDBB>˵Ľڵ<C4BD><DAB5><EFBFBD><EFBFBD><EFBFBD>
//AtEnd <20><><EFBFBD><EFBFBD>ֵ <20><>ǰҪת<D2AA><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ӽڵ㼯<DAB5>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
MzTreeView.prototype.nodeToHTML = function(node, AtEnd)
{
var source = this.N[node.sourceIndex];
var target = this.getAttribute(source, "target");
var data = this.getAttribute(source, "data");
var url = this.getAttribute(source, "url");
if(!url) url = this.url;
if(data) url += (url.indexOf("?")==-1?"?":"&") + data;
if(!target) target = this.target;
var id = node.id;
var HCN = node.hasChild, isRoot = node.parentId=="0";
if(isRoot && node.icon=="") node.icon = "root";
if(node.icon=="" || typeof(this.icons[node.icon])=="undefined")
node.icon = HCN ? "folder" : "file";
node.iconExpand = AtEnd ? "<22><>" : "<22><>";
//20:03 2007-8-25 <20><><EFBFBD>Լ<EFBFBD><D4BC>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>HTML<4D><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿһ<C3BF><EFBFBD><EEA3AC><EFBFBD>DZ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><E5B7BD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
//var MzTreeViewTH="<table class='MzTreeViewRow'><tr><td class='MzTreeViewCell0'>";
var HTMTH="";
try {
if ( typeof MzTreeViewTH != "undefined" ) HTMTH=MzTreeViewTH;
} catch(e){}
var HTML = "<DIV noWrap='True'><NOBR>"+HTMTH;
if(!isRoot)
{
node.childAppend = node.parentNode.childAppend + (AtEnd ? "<22><>" : "<22><>");
if(this.wordLine)
{
HTML += "<SPAN>"+ node.parentNode.childAppend + (AtEnd ? "<22><>" : "<22><>") +"</SPAN>";
if(HCN) HTML += "<SPAN class='pm' id='"+ this.name +"_expand_"+ id +"'>+</SPAN>";
}
else
{
node.iconExpand = HCN ? AtEnd ? "PM2" : "PM1" : AtEnd ? "L2" : "L1";
HTML += "<SPAN>"+ this.word2image(node.parentNode.childAppend) +"<IMG "+
"align='absmiddle' id='"+ this.name +"_expand_"+ id +"' "+
"src='"+ this.icons[node.iconExpand].src +"' style='cursor: "+ (!node.hasChild ? "":
(this.navigator=="msie"||this.navigator=="opera"? "hand" : "pointer")) +"'></SPAN>";
}
}
//ȡ<><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿID
var sid = node.sourceIndex.substr(node.sourceIndex.indexOf(this.divider) + this.divider.length);
//2:06 2007-8-25 <20><><EFBFBD><EFBFBD>checkbox<6F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var HTMCHK="",HTMCHKED="";
if (node.checked=='true'||node.checked=='1') HTMCHKED="checked='checked'";
if( node.ctrl.length > 0 ) HTMCHK = "<input type='checkbox' name='"+ node.ctrl +"' value='"+ sid +
"' id='"+ this.name +"_checbox_"+ id +"' style='height:15px;'"+
" onclick=\""+ this.name +".checkChild('"+ id +"')\" "+ HTMCHKED +">"; //Rexliu add on 2007-1-23 14:29
//20:04 2007-8-25 <20><><EFBFBD>Լ<EFBFBD><D4BC>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>HTML<4D><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿһ<C3BF><EFBFBD><EEA3AC><EFBFBD>ǵ<EFBFBD>Ԫ<EFBFBD>񲿷֣<F1B2BFB7><D6A3><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><E5B7BD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
//var MzTreeViewTD="\"</td><td class='MzTreeViewCell1'>\"+ sid +\"</td></tr></table>\"";
//ע<><D7A2><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>Ҫ<EFBFBD><D2AA>ǰ<EFBFBD><C7B0><EFBFBD>ı<EFBFBD>ͷ<EFBFBD><CDB7>Ӧ
var HTMTD="";
try {
if ( typeof MzTreeViewTD != "undefined" ) HTMTD=eval(MzTreeViewTD);
} catch(e){}
HTML += "<IMG "+
"align='absMiddle' "+
"id='"+ this.name +"_icon_"+ id +"' "+
"src='"+ this.icons[node.icon].src +"'>" + HTMCHK + "<A "+
"class='MzTreeview' hideFocus "+
"id='"+ this.name +"_link_"+ id +"' "+
"href='"+ url +"' "+
"target='"+ target +"' "+
"title='"+ node.hint +"' "+
"onfocus=\""+ this.name +".focusLink('"+ id +"')\" "+
"onclick=\"return "+ this.name +".nodeClick('"+ id +"')\">"+ node.T +
"</A>"+ HTMTD +"</NOBR></DIV>";
if(isRoot && node.T=="") HTML = "";
HTML = "\r\n<SPAN id='"+ this.name +"_tree_"+ id +"'>"+ HTML ;
HTML +="<SPAN style='DISPLAY: none'></SPAN></SPAN>";
return HTML;
};
//<2F><>ʹ<EFBFBD><CAB9>ͼƬ<CDBC><C6AC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> node.childAppend <20><>ת<EFBFBD><D7AA>
MzTreeView.prototype.word2image = function(word)
{
var str = "";
for(var i=0; i<word.length; i++)
{
var img = "";
switch (word.charAt(i))
{
case "<22><>" : img = "L4"; break;
case "<22><>" : img = "L2"; break;
case "<22><>" : img = "empty"; break;
case "<22><>" : img = "L1"; break;
case "<22><>" : img = "L3"; break;
case "<22><>" : img = "L0"; break;
}
if(img!="")
str += "<IMG align='absMiddle' src='"+ this.icons[img].src +"' height='20'>";
}
return str;
};
//<2F><>ij<EFBFBD><C4B3><EFBFBD>ڵ<EFBFBD><DAB5>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><HTML>Ԫ<>ر<EFBFBD><D8B1><EFBFBD>
//id <20><><EFBFBD>Ŀͻ<C4BF><CDBB>˽ڵ<CBBD> id
MzTreeView.prototype.buildNode = function(id)
{
if(this.node[id].hasChild)
{
var tcn = this.node[id].childNodes, str = "";
for (var i=0; i<tcn.length; i++)
str += this.nodeToHTML(tcn[i], i==tcn.length-1);
var temp = this.getElementById(this.name +"_tree_"+ id).childNodes;
temp[temp.length-1].innerHTML = str;
}
};
//<2F>ۼ<EFBFBD><DBBC><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>
//id <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>id
MzTreeView.prototype.focusClientNode = function(id)
{
try {
if(!this.currentNode) this.currentNode=this.node["0"];
var a = this.getElementById(this.name +"_link_"+ id); if(a){ a.focus();
var link = this.getElementById(this.name +"_link_"+ this.currentNode.id);
if(link)with(link.style){color=""; backgroundColor="";}
with(a.style){color = this.colors.highLightText;
backgroundColor = this.colors.highLight;}
this.currentNode= this.node[id];}
} catch(e){}
};
//<2F><><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD><DBBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľڵ<C4BD><DAB5><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
//id <20>ͻ<EFBFBD><CDBB>˽ڵ<CBBD> id
MzTreeView.prototype.focusLink= function(id)
{
if(this.currentNode && this.currentNode.id==id) return;
this.focusClientNode(id);
};
//<2F><><EFBFBD><EFBFBD>չ<EFBFBD><D5B9><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5>Ķ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
MzTreeView.prototype.expand = function(id, sureExpand)
{
var node = this.node[id];
if (sureExpand && node.isExpand) return;
if (!node.hasChild) return;
var area = this.getElementById(this.name +"_tree_"+ id);
if (area) area = area.childNodes[area.childNodes.length-1];
if (area)
{
var icon = this.icons[node.icon];
var iconE = this.iconsExpand[node.icon];
var Bool = node.isExpand = sureExpand || area.style.display == "none";
var img = this.getElementById(this.name +"_icon_"+ id);
if (img) img.src = !Bool ? icon.src :typeof(iconE)=="undefined" ? icon.src : iconE.src;
var exp = this.icons[node.iconExpand];
var expE = this.iconsExpand[node.iconExpand];
var expand= this.getElementById(this.name +"_expand_"+ id);
if (expand)
{
if(this.wordLine) expand.innerHTML = !Bool ? "+" : "-";
else expand.src = !Bool ? exp.src : typeof(expE) =="undefined" ? exp.src : expE.src;
}
if(!Bool && this.currentNode.path.indexOf(node.path)==0 && this.currentNode.id!=id)
{
try{this.getElementById(this.name +"_link_"+ id).click();}
catch(e){this.focusClientNode(id);}
}
area.style.display = !Bool ? "none" : "block";//(this.navigator=="netscape" ? "block" : "");
if(!node.isLoad)
{
this.load(id);
if(node.id=="0") return;
//<2F><><EFBFBD>ӽڵ<D3BD><DAB5><EFBFBD><EFBFBD><EFBFBD>ʱ, <20><><EFBFBD>û<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC>ص<EFBFBD><D8B5><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
if(node.hasChild && node.childNodes.length>200)
{
setTimeout(this.name +".buildNode('"+ id +"')", 1);
var temp = this.getElementById(this.name +"_tree_"+ id).childNodes;
temp[temp.length-1].innerHTML = "<DIV noWrap><NOBR><SPAN>"+ (this.wordLine ?
node.childAppend +"<22><>" : this.word2image(node.childAppend +"<22><>")) +"</SPAN>"+
"<IMG border='0' height='16' align='absmiddle' src='"+this.icons["file"].src+"'>"+
"<A style='background-Color: "+ this.colors.highLight +"; color: "+
this.colors.highLightText +"; font-size: 9pt'><3E><><EFBFBD>Ժ<EFBFBD>...</A></NOBR></DIV>";
}
else this.buildNode(id);
}
}
};
//<2F>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//id <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD> id
MzTreeView.prototype.nodeClick = function(id)
{
var source = this.N[this.node[id].sourceIndex];
eval(this.getAttribute(source, "C"));
return !(!this.getAttribute(source, "url") && this.url=="#");
};
//Ϊ<><CEAA><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>ʼ<EFBFBD>ۼ<EFBFBD>ij<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>д<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>, <20>õ<EFBFBD>ij<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
//sourceId <20><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>Ľڵ<C4BD> id
MzTreeView.prototype.getPath= function(sourceId)
{
Array.prototype.indexOf = function(item)
{
for(var i=0; i<this.length; i++)
{
if(this[i]==item) return i;
}
return -1;
};
var _d = this._d, d = this.divider;
var A = new Array(), id=sourceId; A[0] = id;
while(id!="0" && id!="")
{
var str = "(^|"+_d+")([^"+_d+d+"]+"+d+ id +")("+_d+"|$)";
if (new RegExp(str).test(this.names))
{
id = RegExp.$2.substring(0, RegExp.$2.indexOf(d));
if(A.indexOf(id)>-1) break;
A[A.length] = id;
}
else break;
}
return A.reverse();
};
//<2F><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> MzTreeView <20><>ʼ<EFBFBD>ۼ<EFBFBD><DBBC><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>ڵ<EFBFBD>
//sourceId <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD> id
MzTreeView.prototype.focus = function(sourceId, defer)
{
try {
if (!defer)
{
setTimeout(this.name +".focus('"+ sourceId +"', true)", 100);
return;
}
var path = this.getPath(sourceId);
if(path[0]!="0")
{
alert("<22>ڵ<EFBFBD> "+ sourceId +" û<><C3BB><EFBFBD><EFBFBD>ȷ<EFBFBD>Ĺҿ<C4B9><D2BF><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ڵ<EFBFBD><DAB5>ϣ<EFBFBD>\r\n"+
"<22>ڵ<EFBFBD> id <20><><EFBFBD><EFBFBD> = "+ path.join(this.divider));
return;
}
var root = this.node["0"], len = path.length;
for(var i=1; i<len; i++)
{
if(root.hasChild)
{
var sourceIndex= path[i-1] + this.divider + path[i];
for (var k=0; k<root.childNodes.length; k++)
{
if (root.childNodes[k].sourceIndex == sourceIndex)
{
root = root.childNodes[k];
if(i<len - 1) this.expand(root.id, true);
else this.focusClientNode(root.id);
break;
}
}
}
}
}catch(e){}
};
//<2F><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MzTreeView.prototype.clickHandle = function(e)
{
e = window.event || e; e = e.srcElement || e.target;
//alert(e.tagName)
switch(e.tagName)
{
case "IMG" :
if(e.id)
{
if(e.id.indexOf(this.name +"_icon_")==0)
this.focusClientNode(e.id.substr(e.id.lastIndexOf("_") + 1));
else if (e.id.indexOf(this.name +"_expand_")==0)
this.expand(e.id.substr(e.id.lastIndexOf("_") + 1));
}
break;
case "A" :
if(e.id) this.focusClientNode(e.id.substr(e.id.lastIndexOf("_") + 1));
break;
case "SPAN" :
if(e.className=="pm")
this.expand(e.id.substr(e.id.lastIndexOf("_") + 1));
break;
default :
if(this.navigator=="netscape") e = e.parentNode;
if(e.tagName=="SPAN" && e.className=="pm")
this.expand(e.id.substr(e.id.lastIndexOf("_") + 1));
break;
}
};
//MzTreeView ˫<><CBAB><EFBFBD>¼<EFBFBD><C2BC>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MzTreeView.prototype.dblClickHandle = function(e)
{
e = window.event || e; e = e.srcElement || e.target;
if((e.tagName=="A" || e.tagName=="IMG")&& e.id)
{
var id = e.id.substr(e.id.lastIndexOf("_") + 1);
if(this.node[id].hasChild) this.expand(id);
}
};
//<2F>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ڵ<EFBFBD><DAB5>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>ڵ<EFBFBD>
MzTreeView.prototype.upperNode = function()
{
if(!this.currentNode) return;
if(this.currentNode.id=="0" || this.currentNode.parentId=="0") return;
if (this.currentNode.hasChild && this.currentNode.isExpand)
this.expand(this.currentNode.id, false);
else this.focusClientNode(this.currentNode.parentId);
};
//չ<><D5B9><EFBFBD><EFBFBD>ǰ<EFBFBD>ڵ㲢
MzTreeView.prototype.lowerNode = function()
{
if (!this.currentNode) this.currentNode = this.node["0"];
if (this.currentNode.hasChild)
{
if (this.currentNode.isExpand)
this.focusClientNode(this.currentNode.childNodes[0].id);
else this.expand(this.currentNode.id, true);
}
};
//<2F>ۼ<EFBFBD><DBBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ڵ<EFBFBD>
MzTreeView.prototype.pervNode = function()
{
if(!this.currentNode) return; var e = this.currentNode;
if(e.id=="0") return; var a = this.node[e.parentId].childNodes;
for(var i=0; i<a.length; i++){if(a[i].id==e.id){if(i>0){e=a[i-1];
while(e.hasChild){this.expand(e.id, true);
e = e.childNodes[e.childNodes.length - 1];}
this.focusClientNode(e.id); return;} else {
this.focusClientNode(e.parentId); return;}}}
};
//<2F>ۼ<EFBFBD><DBBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ڵ<EFBFBD>
MzTreeView.prototype.nextNode = function()
{
var e = this.currentNode; if(!e) e = this.node["0"];
if (e.hasChild){this.expand(e.id, true);
this.focusClientNode(e.childNodes[0].id); return;}
while(typeof(e.parentId)!="undefined"){
var a = this.node[e.parentId].childNodes;
for(var i=0; i<a.length; i++){ if(a[i].id==e.id){
if(i<a.length-1){this.focusClientNode(a[i+1].id); return;}
else e = this.node[e.parentId];}}}
};
//չ<><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>нڵ<D0BD>
MzTreeView.prototype.expandAll = function()
{
if(this.totalNode>500) if(
confirm("<22><><EFBFBD>Ƿ<EFBFBD>Ҫֹͣչ<D6B9><D5B9>ȫ<EFBFBD><C8AB><EFBFBD>ڵ㣿\r\n\r\n<>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>࣡չ<E0A3A1><D5B9><EFBFBD>ܺ<EFBFBD>ʱ")) return;
if(this.node["0"].childNodes.length==0) return;
var e = this.node["0"].childNodes[0];
var isdo = t = false;
while(e.id != "0")
{
var p = this.node[e.parentId].childNodes, pn = p.length;
if(p[pn-1].id==e.id && (isdo || !e.hasChild)){e=this.node[e.parentId]; isdo = true;}
else
{
if(e.hasChild && !isdo)
{
this.expand(e.id, true), t = false;
for(var i=0; i<e.childNodes.length; i++)
{
if(e.childNodes[i].hasChild){e = e.childNodes[i]; t = true; break;}
}
if(!t) isdo = true;
}
else
{
isdo = false;
for(var i=0; i<pn; i++)
{
if(p[i].id==e.id) {e = p[i+1]; break;}
}
}
}
}
};
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ö<EFBFBD><C3B6><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD>弰Ԥ<E5BCB0>غ<EFBFBD><D8BA><EFBFBD>
//path ͼƬ<CDBC><C6AC><EFBFBD>ŵ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>
MzTreeView.prototype.setIconPath = function(path)
{
var k = 0, d = new Date().getTime();
for(var i in this.icons)
{
var tmp = this.icons[i];
this.icons[i] = new Image();
this.icons[i].src = path + tmp;
if(k==9 && (new Date().getTime()-d)>200)
this.wordLine = true; k++;
}
for(var i in this.iconsExpand)
{
var tmp = this.iconsExpand[i];
this.iconsExpand[i]=new Image();
this.iconsExpand[i].src = path + tmp;
}
};
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//url Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ʼֵΪ #
MzTreeView.prototype.setURL = function(url){this.url = url;};
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϵ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> target
//target Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ʼֵΪ _self
MzTreeView.prototype.setTarget = function(target){this.target = target;};
//
//<2F>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B5A5>(<28>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>㲻Ҫ<E3B2BB>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>)
//1:27 2007-8-25
MzTreeView.prototype.focusClickNode = function(id)
{
try {
if(!this.currentNode) this.currentNode=this.node["0"];
var a = this.getElementById(this.name +"_link_"+ id); if(a){ a.focus();
var link = this.getElementById(this.name +"_link_"+ this.currentNode.id);
if(link)with(link.style){color=""; backgroundColor="";}
with(a.style){color = this.colors.highLightText;
backgroundColor = this.colors.highLight;}
this.currentNode= this.node[id];
this.nodeClick(id);
}
} catch(e){}
};
//<2F>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B5A5>(<28><><EFBFBD><EFBFBD><EFBFBD>ô˹<C3B4><CBB9><EFBFBD>)<29><><EFBFBD><EFBFBD> tree.Click(2201)
//1:24 2007-8-25
MzTreeView.prototype.Click = function(sourceId, defer)
{
try {
if (!defer)
{
setTimeout(this.name +".Click('"+ sourceId +"', true)", 100);
return;
}
var path = this.getPath(sourceId);
if(path[0]!="0")
{
alert("<22>ڵ<EFBFBD> "+ sourceId +" û<><C3BB><EFBFBD><EFBFBD>ȷ<EFBFBD>Ĺҿ<C4B9><D2BF><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ڵ<EFBFBD><DAB5>ϣ<EFBFBD>\r\n"+
"<22>ڵ<EFBFBD> id <20><><EFBFBD><EFBFBD> = "+ path.join(this.divider));
return;
}
var root = this.node["0"], len = path.length;
for(var i=1; i<len; i++)
{
if(root.hasChild)
{
var sourceIndex= path[i-1] + this.divider + path[i];
for (var k=0; k<root.childNodes.length; k++)
{
if (root.childNodes[k].sourceIndex == sourceIndex)
{
root = root.childNodes[k];
if(i<len - 1) this.expand(root.id, true);
else this.focusClickNode(root.id);
break;
}
}
}
}
}catch(e){}
};
//checkbox<6F><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
//REXLIU ADD ON 2007-1-24 15:29
MzTreeView.prototype.checkChild = function(id)
{
this.selChild(id);
this.selParent(id);
};
MzTreeView.prototype.selParent = function(id)
{
var tcn = this.node[id];
if(tcn.parentId != "0")
{
var pnode = tcn.parentNode;
var isChecked = false;
for(var i=0; i<pnode.childNodes.length; i++)
{
//ȡ<><C8A1>CHECKBOX
var ckboxID = this.name +"_checbox_"+ pnode.childNodes[i].id;
var ckbox = this.getElementById(ckboxID);
if(ckbox.checked)
{
isChecked = true;
break;
}
}
var pckboxid = this.name +"_checbox_"+ pnode.id;
var pckbox = this.getElementById(pckboxid);
pckbox.checked = isChecked;
this.selParent(pnode.id);
}
};
MzTreeView.prototype.selChild = function(id)
{
var tcn = this.node[id];
//<2F><><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD>
if(tcn.hasChild)
{
for(var i=0; i<tcn.childNodes.length; i++)
{
//ȡ<><C8A1>CHECKBOX
var pckboxID = this.name +"_checbox_"+ id;
var pckbox = this.getElementById(pckboxID);
//ȡ<><C8A1>CHECKBOX
var ckboxID = this.name +"_checbox_"+ this.node[id].childNodes[i].id;
var ckbox = this.getElementById(ckboxID);
ckbox.checked = pckbox.checked;
this.selChild(this.node[id].childNodes[i].id);
}
}
};
// -->