2 var stpicopen = '../../../../images/slimtree/folder.gif';
3 var stpicclose = '../../../../images/slimtree/folderopen.gif';
5 var stpicopen = '../../../../images/slimtree/folder2.gif';
6 var stpicclose = '../../../../images/slimtree/folderopen2.gif';
7 var stpicblank = '../../../../images/slimtree/page.gif';
8 var stpicline = '../../../../images/slimtree/line.gif';
9 var stpicjoin = '../../../../images/slimtree/join.gif';
10 var stpicjoinb = '../../../../images/slimtree/joinbottom.gif';
18 function _apc(root,node) { root.appendChild(node); }
20 function SlimTree(context, handle, rootimg) {
23 stimgopen = elem('img',{src:stpicopen,border:0, style:'height:13px;width:31px;'});
24 stimgclose = elem('img',{src:stpicclose,border:0, style:'height:13px;width:31px;'});
25 stimgblank = elem('img',{src:stpicblank,border:0, style:'height:18px;width:18px;'});
26 stimgline = elem('img',{src:stpicline,border:0, style:'height:18px;width:18px;'});
27 stimgjoin = elem('img',{src:stpicjoin,border:0, style:'display:inline;height:18px;width:18px;'});
30 this.context = context;
32 this.cache = new Object();
34 this.rootimg = elem('img',
35 {src:rootimg,border:0,style:'padding-right: 4px;'});
38 SlimTree.prototype.addCachedChildren = function(pid) {
40 while( child = this.cache[pid].shift() )
41 this.addNode( child.id, child.pid,
42 child.name, child.action, child.title );
43 this.cache[pid] = null;
46 SlimTree.prototype.addNode = function( id, pid, name, action, title, cls ) {
48 if( pid != -1 && !$(pid)) {
49 if(!this.cache[pid]) this.cache[pid] = new Array();
51 {id:id,pid:pid,name:name,action:action,title:title });
56 action='javascript:'+this.handle+'.toggle("'+id+'");';
59 if( typeof action == 'string' )
60 actionref = elem('a',{href:action}, name);
62 actionref = elem('a',{href:'javascript:void(0);'}, name);
63 actionref.onclick = action;
66 var div = elem('div',{id:id});
67 var topdiv = elem('div',{style:'vertical-align:middle'});
68 var link = elem('a', {id:'stlink_' + id});
69 var contdiv = elem('div',{id:'stcont_' + id});
71 if(cls) addCSSClass(actionref, cls);
73 //actionref.setAttribute('href',action);
74 if(title) actionref.setAttribute('title',title);
75 else actionref.setAttribute('title',name);
78 _apc(topdiv,actionref);
85 _apc(this.context,div);
86 if(this.rootimg) _apc(link,this.rootimg.cloneNode(true));
87 else _apc(link,stimgblank.cloneNode(true));
91 if(pid == this.rootid) this.open(pid);
93 $(pid).setAttribute('haschild','1');
94 _apc(link,stimgblank.cloneNode(true));
95 div.style.paddingLeft = '18px';
96 div.style.backgroundImage = 'url('+stpicjoinb+')';
97 div.style.backgroundRepeat = 'no-repeat';
98 _apc($('stcont_' + pid), div);
99 if (div.previousSibling) stMakePaths(div);
101 if(this.cache[id]) this.addCachedChildren(id);
104 function stMakePaths(div) {
105 _apc(div.previousSibling.firstChild,stimgjoin.cloneNode(true));
106 _apc(div.previousSibling.firstChild,div.previousSibling.firstChild.firstChild);
107 _apc(div.previousSibling.firstChild,div.previousSibling.firstChild.firstChild);
108 div.previousSibling.firstChild.firstChild.style.marginLeft = '-18px';
109 div.previousSibling.style.backgroundImage = 'url('+stpicline+')';
110 div.previousSibling.style.backgroundRepeat = 'repeat-y';
113 SlimTree.prototype.expandAll = function() { this.flex(this.rootid, 'open'); }
114 SlimTree.prototype.closeAll = function() { this.flex(this.rootid,'close'); }
115 SlimTree.prototype.flex = function(id, type) {
116 if(type=='open') this.open(id);
117 else { if (id != this.rootid) this.close(id); }
118 var n = $('stcont_' + id);
119 for( var c = 0; c != n.childNodes.length; c++ ) {
120 var ch = n.childNodes[c];
121 if(ch.nodeName.toLowerCase() == 'div') {
122 if($(ch.id).getAttribute('haschild') == '1')
123 this.flex(ch.id, type);
128 SlimTree.prototype.toggle = function(id) {
129 if($(id).getAttribute('ostate') == '1') this.open(id);
130 else if($(id).getAttribute('ostate') == '2') this.close(id);
133 SlimTree.prototype.open = function(id) {
134 if($(id).getAttribute('ostate') == '2') return;
135 var link = $('stlink_' + id);
137 if(id != this.rootid || !this.rootimg) {
138 removeChildren(link);
139 _apc(link,stimgclose.cloneNode(true));
141 link.setAttribute('href','javascript:' + this.handle + '.close("'+id+'");');
142 unHideMe($('stcont_' + id));
143 $(id).setAttribute('ostate','2');
146 SlimTree.prototype.close = function(id) {
147 var link = $('stlink_' + id);
149 if(id != this.rootid || !this.rootimg) {
150 removeChildren(link);
151 _apc(link,stimgopen.cloneNode(true));
153 link.setAttribute('href','javascript:' + this.handle + '.open("'+id+'");');
154 hideMe($('stcont_' + id));
155 $(id).setAttribute('ostate','1');