/* build the org tree */
/* ----------------------------------------------------------------------- */
function drawOrgTree() {
- G.ui.common.org_tree.innerHTML = buildOrgSelector().toString();
- //buildOrgSelector(G.ui.common.org_tree);
+ //G.ui.common.org_tree.innerHTML = buildOrgSelector().toString();
+ buildOrgSelector(G.ui.common.org_tree, orgTreeSelector);
}
var orgTreeSelector;
function buildOrgSelector(node) {
- var tree = new dTree("orgTreeSelector");
- //var tree = new SlimTree(node);
+ //var tree = new dTree("orgTreeSelector");
+ var tree = new SlimTree(node,'orgTreeSelector');
+ orgTreeSelector = tree;
for( var i in orgArraySearcher ) {
var node = orgArraySearcher[i];
if( node == null ) continue;
if(node.parent_ou() == null)
- tree.add(node.id(), -1, node.name(),
+ tree.addNode(node.id(), -1, node.name(),
"javascript:orgSelect(" + node.id() + ");", node.name());
else {
- tree.add(node.id(), findOrgUnit(node.parent_ou()).id(), node.name(),
+ tree.addNode(node.id(), findOrgUnit(node.parent_ou()).id(), node.name(),
"javascript:orgSelect(" + node.id() + ");", node.name());
}
}
- orgTreeSelector = tree;
return tree;
}
this.handle = handle;
this.cache = new Object();
if(rootimg)
- this.rootimg = elem('img', {src:rootimg,border:0,style:'padding-right: 4px;'});
+ this.rootimg = elem('img',
+ {src:rootimg,border:0,style:'padding-right: 4px;'});
}
-SlimTree.prototype.cacheMe = function( id, pid, name, action, title ) {
- if(this.cache[id]) return;
- this.cache[id] = {};
- this.cache[id].pid = pid
- this.cache[id].name = name
- this.cache[id].action = action
- this.cache[id].title = title
-}
-
-SlimTree.prototype.flushCache = function() {
- for( var c in this.cache ) {
- var obj = this.cache[c];
- if(obj && getId(obj.pid)) {
- this.cache[c] = null;
- this.addNode(c,obj.pid, obj.name, obj.action,obj.title);
- }
- }
+SlimTree.prototype.addCachedChildren = function(pid) {
+ var child;
+ while( child = this.cache[pid].shift() )
+ this.addNode( child.id, child.pid,
+ child.name, child.action, child.title );
+ this.cache[pid] = null;
}
SlimTree.prototype.addNode = function( id, pid, name, action, title ) {
- if( pid != -1 && !getId(pid)) {
- if(this.cache[pid]) {
- var obj = this.cache[pid];
- this.addNode(pid, obj.pid,obj.name, obj.action,obj.title );
- this.cache[pid] = null;
- } else {
- this.cacheMe(id, pid, name, action, title);
- return;
- }
+ if( pid != -1 && !$(pid)) {
+ if(!this.cache[pid]) this.cache[pid] = new Array();
+ this.cache[pid].push(
+ {id:id,pid:pid,name:name,action:action,title:title });
+ return;
}
var div = elem('div',{id:id});
_apc(div,contdiv);
if( pid == -1 ) {
+
this.rootid = id;
_apc(this.context,div);
if(this.rootimg) _apc(link,this.rootimg.cloneNode(true));
else _apc(link,stimgblank.cloneNode(true));
+
} else {
+
if(pid == this.rootid) this.open(pid);
else this.close(pid);
- getId(pid).setAttribute('haschild','1');
+ $(pid).setAttribute('haschild','1');
_apc(link,stimgblank.cloneNode(true));
div.style.paddingLeft = '18px';
div.style.backgroundImage = 'url('+stpicjoinb+')';
div.style.backgroundRepeat = 'no-repeat';
- _apc(getId('stcont_' + pid), div);
+ _apc($('stcont_' + pid), div);
if (div.previousSibling) stMakePaths(div);
}
- this.flushCache();
+ if(this.cache[id]) this.addCachedChildren(id);
}
function stMakePaths(div) {
SlimTree.prototype.flex = function(id, type) {
if(type=='open') this.open(id);
else { if (id != this.rootid) this.close(id); }
- var n = getId('stcont_' + id);
+ var n = $('stcont_' + id);
for( var c = 0; c != n.childNodes.length; c++ ) {
var ch = n.childNodes[c];
if(ch.nodeName.toLowerCase() == 'div') {
- if(getId(ch.id).getAttribute('haschild') == '1')
+ if($(ch.id).getAttribute('haschild') == '1')
this.flex(ch.id, type);
}
}
}
+SlimTree.prototype.toggle = function(id) {
+ if($(id).getAttribute('ostate') == '1') this.open(id);
+ else if($(id).getAttribute('ostate') == '2') this.close(id);
+}
+
SlimTree.prototype.open = function(id) {
- var link = getId('stlink_' + id);
+ if($(id).getAttribute('ostate') == '2') return;
+ var link = $('stlink_' + id);
if(id != this.rootid || !this.rootimg) {
removeChildren(link);
_apc(link,stimgclose.cloneNode(true));
}
link.setAttribute('href','javascript:' + this.handle + '.close("'+id+'");');
- unHideMe(getId('stcont_' + id));
+ unHideMe($('stcont_' + id));
+ $(id).setAttribute('ostate','2');
}
SlimTree.prototype.close = function(id) {
- var link = getId('stlink_' + id);
+ var link = $('stlink_' + id);
if(id != this.rootid || !this.rootimg) {
removeChildren(link);
_apc(link,stimgopen.cloneNode(true));
}
link.setAttribute('href','javascript:' + this.handle + '.open("'+id+'");');
- hideMe(getId('stcont_' + id));
+ hideMe($('stcont_' + id));
+ $(id).setAttribute('ostate','1');
}
document.getElementById('subject_sidebar_tree_div'),
'subjectSidebarTree', '../../../images/slimtree/related.jpg');
subjectSidebarTree.addNode( 'subjectSidebarTreeRoot', -1,
- "&sidebar.relevantSubjects.headerLabel;", null);
+ "&sidebar.relevantSubjects.headerLabel;",
+ 'javascript:subjectSidebarTree.toggle(' +
+ '"subjectSidebarTreeRoot");');
</script>
</div>
document.getElementById('author_sidebar_tree_div'),
'authorSidebarTree','../../../images/slimtree/people.jpg');
authorSidebarTree.addNode( 'authorSidebarTreeRoot', -1,
- "&sidebar.relevantAuthors.headerLabel;", null);
+ "&sidebar.relevantAuthors.headerLabel;",
+ 'javascript:authorSidebarTree.toggle(' +
+ '"authorSidebarTreeRoot");');
</script>
</div>
<script language='javascript'>
var seriesSidebarTree = new SlimTree(
document.getElementById('series_sidebar_tree_div'),
- 'seriesSidebarTree','../../../images/slimtree/houses.jpg');
+ 'seriesSidebarTree',
+ '../../../images/slimtree/houses.jpg');
seriesSidebarTree.addNode( 'seriesSidebarTreeRoot', -1,
- "&sidebar.relevantSeries.headerLabel;", null);
+ "&sidebar.relevantSeries.headerLabel;",
+ 'javascript:seriesSidebarTree.toggle(' +
+ '"seriesSidebarTreeRoot");');
</script>
</div>