2007-06-13 02:18:21 +04:00
|
|
|
var symbolClosed = '+';
|
|
|
|
var symbolOpen = '-';
|
|
|
|
|
|
|
|
function Tree_AutoInit()
|
|
|
|
{
|
|
|
|
var candidates = document.getElementsByTagName('ul');
|
|
|
|
|
|
|
|
for (i in candidates) {
|
2007-06-29 18:10:15 +04:00
|
|
|
if (hasClassName(candidates[i], 'tree')) {
|
2007-06-13 02:18:21 +04:00
|
|
|
Tree_Init(candidates[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function Tree_Init(element)
|
|
|
|
{
|
|
|
|
for (var i in element.childNodes) {
|
|
|
|
|
|
|
|
var li = element.childNodes[i];
|
|
|
|
|
|
|
|
if (li.tagName && li.tagName.toLowerCase() == 'li') {
|
|
|
|
|
|
|
|
var subTree = Tree_FindChild(li, 'ul');
|
|
|
|
|
|
|
|
if (subTree) {
|
|
|
|
var expander = document.createElement('a');
|
|
|
|
|
|
|
|
expander.className = 'expander';
|
|
|
|
expander.href = 'javascript:void(0);';
|
|
|
|
expander.onclick = Tree_Toggle;
|
|
|
|
|
2007-06-29 18:10:15 +04:00
|
|
|
if (hasClassName(subTree, 'closed')) {
|
2007-06-13 02:18:21 +04:00
|
|
|
expander.innerHTML = symbolClosed;
|
|
|
|
} else {
|
|
|
|
expander.innerHTML = symbolOpen;
|
|
|
|
}
|
|
|
|
|
|
|
|
li.insertBefore(expander, li.firstChild);
|
|
|
|
|
|
|
|
Tree_Init(subTree);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function Tree_FindChild(element, childTag)
|
|
|
|
{
|
|
|
|
for (i in element.childNodes) {
|
|
|
|
child = element.childNodes[i];
|
|
|
|
if (child.tagName && child.tagName.toLowerCase() == childTag) {
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function Tree_Toggle()
|
|
|
|
{
|
|
|
|
expander = this;
|
|
|
|
li = expander.parentNode;
|
|
|
|
subTree = Tree_FindChild(li, 'ul');
|
|
|
|
|
2007-06-29 18:10:15 +04:00
|
|
|
if (hasClassName(subTree, 'closed')) {
|
|
|
|
removeClassName(subTree, 'closed');
|
2007-06-13 02:18:21 +04:00
|
|
|
expander.innerHTML = symbolOpen;
|
|
|
|
} else {
|
2007-06-29 18:10:15 +04:00
|
|
|
addClassName(subTree, 'closed');
|
2007-06-13 02:18:21 +04:00
|
|
|
expander.innerHTML = symbolClosed;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
appendLoader(Tree_AutoInit);
|