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',
22 {src:rootimg,border:0,style:'padding-right: 4px;'});
25 SlimTree.prototype.addCachedChildren = function(pid) {
27 while( child = this.cache[pid].shift() )
28 this.addNode( child.id, child.pid,
29 child.name, child.action, child.title );
30 this.cache[pid] = null;
33 SlimTree.prototype.addNode = function( id, pid, name, action, title ) {
35 if( pid != -1 && !$(pid)) {
36 if(!this.cache[pid]) this.cache[pid] = new Array();
38 {id:id,pid:pid,name:name,action:action,title:title });
42 var div = elem('div',{id:id});
43 var topdiv = elem('div',{style:'vertical-align:middle'});
44 var link = elem('a', {id:'stlink_' + id});
45 var actionref = elem('a',{href:action}, name);
46 var contdiv = elem('div',{id:'stcont_' + id});
47 if(action) actionref.setAttribute('href',action);
48 if(title) actionref.setAttribute('title',title);
49 else actionref.setAttribute('title',name);
52 _apc(topdiv,actionref);
59 _apc(this.context,div);
60 if(this.rootimg) _apc(link,this.rootimg.cloneNode(true));
61 else _apc(link,stimgblank.cloneNode(true));
65 if(pid == this.rootid) this.open(pid);
67 $(pid).setAttribute('haschild','1');
68 _apc(link,stimgblank.cloneNode(true));
69 div.style.paddingLeft = '18px';
70 div.style.backgroundImage = 'url('+stpicjoinb+')';
71 div.style.backgroundRepeat = 'no-repeat';
72 _apc($('stcont_' + pid), div);
73 if (div.previousSibling) stMakePaths(div);
75 if(this.cache[id]) this.addCachedChildren(id);
78 function stMakePaths(div) {
79 _apc(div.previousSibling.firstChild,stimgjoin.cloneNode(true));
80 _apc(div.previousSibling.firstChild,div.previousSibling.firstChild.firstChild);
81 _apc(div.previousSibling.firstChild,div.previousSibling.firstChild.firstChild);
82 div.previousSibling.firstChild.firstChild.style.marginLeft = '-18px';
83 div.previousSibling.style.backgroundImage = 'url('+stpicline+')';
84 div.previousSibling.style.backgroundRepeat = 'repeat-y';
87 SlimTree.prototype.expandAll = function() { this.flex(this.rootid, 'open'); }
88 SlimTree.prototype.closeAll = function() { this.flex(this.rootid,'close'); }
89 SlimTree.prototype.flex = function(id, type) {
90 if(type=='open') this.open(id);
91 else { if (id != this.rootid) this.close(id); }
92 var n = $('stcont_' + id);
93 for( var c = 0; c != n.childNodes.length; c++ ) {
94 var ch = n.childNodes[c];
95 if(ch.nodeName.toLowerCase() == 'div') {
96 if($(ch.id).getAttribute('haschild') == '1')
97 this.flex(ch.id, type);
102 SlimTree.prototype.toggle = function(id) {
103 if($(id).getAttribute('ostate') == '1') this.open(id);
104 else if($(id).getAttribute('ostate') == '2') this.close(id);
107 SlimTree.prototype.open = function(id) {
108 if($(id).getAttribute('ostate') == '2') return;
109 var link = $('stlink_' + id);
110 if(id != this.rootid || !this.rootimg) {
111 removeChildren(link);
112 _apc(link,stimgclose.cloneNode(true));
114 link.setAttribute('href','javascript:' + this.handle + '.close("'+id+'");');
115 unHideMe($('stcont_' + id));
116 $(id).setAttribute('ostate','2');
119 SlimTree.prototype.close = function(id) {
120 var link = $('stlink_' + id);
121 if(id != this.rootid || !this.rootimg) {
122 removeChildren(link);
123 _apc(link,stimgopen.cloneNode(true));
125 link.setAttribute('href','javascript:' + this.handle + '.open("'+id+'");');
126 hideMe($('stcont_' + id));
127 $(id).setAttribute('ostate','1');