/*--------------------------------------------------| | dTree 2.05 | www.destroydrop.com/javascript/tree/ | |---------------------------------------------------| | Copyright (c) 2002-2003 Geir Landrö | | | | This script can be used freely as long as all | | copyright messages are intact. | | | | Updated: 17.04.2003 | |--------------------------------------------------*/ /* The content of attribute values should be quoted properly by using the equivalent entities. */ function dTreeQuote(str) { return str.escapeHTML(); } // Node object function dTreeNode(id, pid, name, isParent, url, dataname, datatype, title, target, icon, iconOpen, open) { this.isParent = isParent; 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.dataname = dataname; this.datatype = datatype; this._io = open || false; this._is = false; this._ls = false; this._hc = false; this._ai = 0; this._p; }; // Tree object function dTree(objName) { this.obj = objName; this.config = { target: null, useCookies: false }; this.icon = { root: 'img/base.gif', folder: 'img/folder.gif', folderOpen: 'img/folderopen.gif', node: 'img/page.gif', empty: 'img/empty.gif', line: 'img/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.images = {}; this.objects = {}; this.aNodes = []; this.aIndent = []; this.root = new dTreeNode(-1); this.selectedNode = null; this.selectedFound = false; this.completed = false; return this; }; dTree.prototype = { obj: null, config: null, icon: null, aNodes: null, aIndent: null, root: null, selectedNode: null, selectedFound: false, completed: false, // Adds a new node to the node array add: function(id, pid, name, isParent, url, datatype, title, target, icon, iconOpen, open) { this.aNodes[this.aNodes.length] = new dTreeNode(id, pid, name, isParent, url, datatype, title, target, icon, iconOpen, open, false); }, preload: function () { this.images['line'] = new Element ("img", {"src": this.icon.line}); this.images['empty'] = new Element ("img", {"src": this.icon.empty}); this.images['plus'] = new Element ("img", {"src": this.icon.plus}); this.images['minus'] = new Element ("img", {"src": this.icon.minus}); this.images['plusbottom'] = new Element ("img", {"src": this.icon.plusBottom}); this.images['minusbottom'] = new Element ("img", {"src": this.icon.minusBottom}); this.images['join'] = new Element ("img", {"src": this.icon.join}); this.images['joinbottom'] = new Element ("img", {"src": this.icon.joinBottom}); this.objects['link'] = new Element ("a", {"href": "#"}); this.objects['nodelink'] = new Element ("a", {"href": "#", "class": "node"}); this.objects['div'] = new Element ("div"); this.objects['nodediv'] = new Element ("div", {"class": "dTreeNode"}); this.objects['clipdiv'] = new Element ("div", {"class": "clip"}); this.objects['namespan'] = new Element ("span", {"class": "nodeName"}); this.objects['image'] = new Element ("img"); }, // Open/close all nodes openAll: function() { this.oAll(true); }, closeAll: function() { this.oAll(false); }, // Outputs the tree to the page domObject: function() { var div = this.objects["div"].cloneNode (true); div.id = this.obj; div.addClassName ("dtree"); if (this.config.useCookies) this.selectedNode = this.getSelected(); this.addNode (this.root, div); if (!this.selectedFound) this.selectedNode = null; this.completed = true; return div; }, // Creates the tree structure addNode: function(pNode, container) { var n=0; for (n; n