javascript 目录树

上传人:第*** 文档编号:30557193 上传时间:2018-01-30 格式:DOC 页数:19 大小:70.50KB
返回 下载 相关 举报
javascript 目录树_第1页
第1页 / 共19页
javascript 目录树_第2页
第2页 / 共19页
javascript 目录树_第3页
第3页 / 共19页
javascript 目录树_第4页
第4页 / 共19页
javascript 目录树_第5页
第5页 / 共19页
点击查看更多>>
资源描述

《javascript 目录树》由会员分享,可在线阅读,更多相关《javascript 目录树(19页珍藏版)》请在金锄头文库上搜索。

1、1.简单目录树的实现利用 div.style.display=none block 实现。参考 http:/ cursor:pointer;.T2 padding-left:20px;function hidden(j)var URL=http:/ i=0;i无忧脚本 1第一项 1第一项 1第二项 1第三项 1第四项 1第五项 1无忧脚本 2第一项 2第一项 2第二项 2第三项 2第四项 2第五项 2无忧脚本 3第一项 3第一项 3第二项 3第三项 3第四项 3第五项 3百度2.高级目录树参考 http:/ 地址:svn:/ TreeDestroydrop Javascripts TreeEx

2、ampleopen all | close all2002-2003 Geir Landr2. dtree.js/*-| dTree 2.05 | |-| Copyright (c) 2002-2003 Geir Landr? | | This script can be used freely as long as all | copyright messages are intact. | | Updated: 17.04.2003 |-*/ Node objectfunction Node(id, pid, name, url, title, target, icon, iconOpe

3、n, open) this.id = id;this.pid = pid;this.name = name;this.url = url;this.title = title;this.target = target;this.icon = icon;this.iconOpen = iconOpen;this._io = open | false;this._is = false;this._ls = false;this._hc = false;this._ai = 0;this._p;/ Tree objectfunction dTree(objName) this.config = ta

4、rget : null,folderLinks : true,useSelection : true,useCookies : true,useLines : true,useIcons : true,useStatusText : false,closeSameLevel : false,inOrder : falsethis.icon = root : img/base.gif,folder : img/folder.gif,folderOpen : img/folderopen.gif,node : img/page.gif,empty : img/empty.gif,line : im

5、g/line.gif,join : img/join.gif,joinBottom : img/joinbottom.gif,plus : img/plus.gif,plusBottom : img/plusbottom.gif,minus : img/minus.gif,minusBottom : img/minusbottom.gif, nlPlus : img/nolines_plus.gif,nlMinus : img/nolines_minus.gif;this.obj = objName;this.aNodes = ;this.aIndent = ;this.root = new

6、Node(-1);this.selectedNode = null;this.selectedFound = false;pleted = false;/ Adds a new node to the node arraydTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) this.aNodesthis.aNodes.length = new Node(id, pid, name, url, title, target, icon, iconOpen, open);/ O

7、pen/close all nodesdTree.prototype.openAll = function() this.oAll(true);dTree.prototype.closeAll = function() this.oAll(false);/ Outputs the tree to the pagedTree.prototype.toString = function() var str = n;if (document.getElementById) if (this.config.useCookies) this.selectedNode = this.getSelected

8、();str += this.addNode(this.root); else str += Browser not supported.;str += ;if (!this.selectedFound) this.selectedNode = null;pleted = true;return str;/ Creates the tree structuredTree.prototype.addNode = function(pNode) var str = ;var n=0;if (this.config.inOrder) n = pNode._ai;for (n; n + this.in

9、dent(node, nodeId);if (this.config.useIcons) if (!node.icon) node.icon = (this.root.id = node.pid) ? this.icon.root : (node._hc) ? this.icon.folder : this.icon.node);if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;if (this.root.id = node.pid) node.icon = this.i

10、con.root;node.iconOpen = this.icon.root;str += ;if (node.url) str += ;else if (!this.config.folderLinks | !node.url) & node._hc & node.pid != this.root.id)str += ;str += node.name;if (node.url | (!this.config.folderLinks | !node.url) & node._hc) str += ;str += ;if (node._hc) str += ;str += this.addN

11、ode(node);str += ;this.aIndent.pop();return str;/ Adds the empty and line iconsdTree.prototype.indent = function(node, nodeId) var str = ;if (this.root.id != node.pid) for (var n=0; n;(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);if (node._hc) str += ; else str += ;return str;/ Checks if

12、a node has any children and if it is the last siblingdTree.prototype.setCS = function(node) var lastId;for (var n=0; nthis.aNodes.length; n+) if (this.aNodesn.pid = node.id) node._hc = true;if (this.aNodesn.pid = node.pid) lastId = this.aNodesn.id;if (lastId=node.id) node._ls = true;/ Returns the se

13、lected nodedTree.prototype.getSelected = function() var sn = this.getCookie(cs + this.obj);return (sn) ? sn : null;/ Highlights the selected nodedTree.prototype.s = function(id) if (!this.config.useSelection) return;var cn = this.aNodesid;if (cn._hc if (this.selectedNode != id) if (this.selectedNode | this.selectedNode=0) eOld = document.getElementById(s + this.obj + this.selectedNode);eOld.className = node;eNew = document.getElementById(s + this.obj + id);eNew.className = nodeSel;this.selectedNode = id;if (this.config.useCookies) this.setCookie(cs + this.o

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号