1 var stpicopen = '../../../images/slimtree/folder.gif';
2 var stpicclose = '../../../images/slimtree/folderopen.gif';
3 var stpicblank = '../../../images/slimtree/page.gif';
4 var stpicline = '../../../images/slimtree/line.gif';
5 var stpicjoin = '../../../images/slimtree/join.gif';
6 var stpicjoinb = '../../../images/slimtree/joinbottom.gif';
8 var stimgopen = elem('img',{src:stpicopen,border:0});
9 var stimgclose = elem('img',{src:stpicclose,border:0});
10 var stimgblank = elem('img',{src:stpicblank,border:0});
11 var stimgline = elem('img',{src:stpicline,border:0});
12 var stimgjoin = elem('img',{src:stpicjoin,border:0, style:'display:inline;'});
14 function _apc(root,node) { root.appendChild(node); }
16 function SlimTree(context, handle, rootimg) {
17 this.context = context;
19 this.cache = new Object();
21 this.rootimg = elem('img', {src:rootimg,border:0});
24 SlimTree.prototype.cacheMe = function( id, pid, name, action, title ) {
25 if(this.cache[id]) return;
27 this.cache[id].pid = pid
28 this.cache[id].name = name
29 this.cache[id].action = action
30 this.cache[id].title = title
33 SlimTree.prototype.flushCache = function() {
34 for( var c in this.cache ) {
35 var obj = this.cache[c];
36 if(obj && getId(obj.pid)) {
38 this.addNode(c,obj.pid, obj.name, obj.action,obj.title);
43 SlimTree.prototype.addNode = function( id, pid, name, action, title ) {
45 if( pid != -1 && !getId(pid)) {
47 var obj = this.cache[pid];
48 this.addNode(pid, obj.pid,obj.name, obj.action,obj.title );
49 this.cache[pid] = null;
51 this.cacheMe(id, pid, name, action, title);
56 var div = elem('div',{id:id});
57 var topdiv = elem('div',{style:'vertical-align:middle'});
58 var link = elem('a', {id:'stlink_' + id});
59 var actionref = elem('a',{href:action}, name);
60 var contdiv = elem('div',{id:'stcont_' + id});
61 if(action) actionref.setAttribute('href',action);
62 if(title) actionref.setAttribute('title',title);
63 else actionref.setAttribute('title',name);
66 _apc(topdiv,actionref);
72 _apc(this.context,div);
73 if(this.rootimg) _apc(link,this.rootimg.cloneNode(true));
74 else _apc(link,stimgblank.cloneNode(true));
76 if(pid == this.rootid) this.open(pid);
78 getId(pid).setAttribute('haschild','1');
79 _apc(link,stimgblank.cloneNode(true));
80 div.style.paddingLeft = '18px';
81 div.style.backgroundImage = 'url('+stpicjoinb+')';
82 div.style.backgroundRepeat = 'no-repeat';
83 _apc(getId('stcont_' + pid), div);
84 if (div.previousSibling) stMakePaths(div);
89 function stMakePaths(div) {
90 _apc(div.previousSibling.firstChild,stimgjoin.cloneNode(true));
91 _apc(div.previousSibling.firstChild,div.previousSibling.firstChild.firstChild);
92 _apc(div.previousSibling.firstChild,div.previousSibling.firstChild.firstChild);
93 div.previousSibling.firstChild.firstChild.style.marginLeft = '-18px';
94 div.previousSibling.style.backgroundImage = 'url('+stpicline+')';
95 div.previousSibling.style.backgroundRepeat = 'repeat-y';
98 SlimTree.prototype.expandAll = function() { this.flex(this.rootid, 'open'); }
99 SlimTree.prototype.closeAll = function() { this.flex(this.rootid,'close'); }
100 SlimTree.prototype.flex = function(id, type) {
101 if(type=='open') this.open(id);
102 else { if (id != this.rootid) this.close(id); }
103 var n = getId('stcont_' + id);
104 for( var c = 0; c != n.childNodes.length; c++ ) {
105 var ch = n.childNodes[c];
106 if(ch.nodeName.toLowerCase() == 'div') {
107 if(getId(ch.id).getAttribute('haschild') == '1')
108 this.flex(ch.id, type);
113 SlimTree.prototype.open = function(id) {
114 var link = getId('stlink_' + id);
115 if(id != this.rootid || !this.rootimg) {
116 removeChildren(link);
117 _apc(link,stimgclose.cloneNode(true));
119 link.setAttribute('href','javascript:' + this.handle + '.close("'+id+'");');
120 unHideMe(getId('stcont_' + id));
123 SlimTree.prototype.close = function(id) {
124 var link = getId('stlink_' + id);
125 if(id != this.rootid || !this.rootimg) {
126 removeChildren(link);
127 _apc(link,stimgopen.cloneNode(true));
129 link.setAttribute('href','javascript:' + this.handle + '.open("'+id+'");');
130 hideMe(getId('stcont_' + id));