Index: trunk/kernel/admin_templates/incs/tree.js =================================================================== diff -u -r4464 -r4468 --- trunk/kernel/admin_templates/incs/tree.js (.../tree.js) (revision 4464) +++ trunk/kernel/admin_templates/incs/tree.js (.../tree.js) (revision 4468) @@ -1,11 +1,12 @@ -function TreeItem(title, url, icon) +function TreeItem(title, url, icon, onclick) { this.Title = title; this.Url = url; this.Rendered = false; this.Displayed = false; this.Level = 0; this.Icon = icon; + this.Onclick = onclick; } TreeItem.prototype.Render = function(before) @@ -74,6 +75,18 @@ link.href = this.Url; link.target = 'main'; link.appendChild( document.createTextNode(this.Title) ) + + link.treeItem = this; + addEvent(link, 'click', + function(ev) { +// alert(ev); + if (!this.treeItem.Expanded) { + if (this.treeItem.folderClick()); + } + //alert('onClick in '+this.treeItem.Title); + } + ) + td.appendChild( link ); // td.appendChild( document.createTextNode(this.Title) ); } @@ -136,7 +149,7 @@ } /* FOLDER */ -function TreeFolder(parent_id, title, url, icon, late_load_url) +function TreeFolder(parent_id, title, url, icon, late_load_url, onclick) { var render = false; if (isset(parent_id)) { @@ -154,6 +167,7 @@ this.Icon = icon; this.LateLoadURL = isset(late_load_url) ? late_load_url : false; this.Loaded = false; + this.Onclick = onclick; this.Children = new Array(); this.ChildIndex = 0; @@ -216,16 +230,18 @@ { child = node.childNodes.item(i); if (child.tagName == 'folder') { - this.LastFolder = this.LastFolder.AddItem(new TreeFolder(null, child.getAttribute('name'), child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('load_url')), render); + var backupLastFolder = this.LastFolder; + this.LastFolder = this.LastFolder.AddItem(new TreeFolder(null, child.getAttribute('name'), child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('load_url'), child.getAttribute('onclick')), render); if (child.hasChildNodes) { this.ProcessXMLNode(child); } - this.LastFolder = this; + this.LastFolder = backupLastFolder; } else if (child.tagName == 'item') { - this.LastFolder.AddItem(new TreeItem(child.firstChild.nodeValue, child.getAttribute('href'), child.getAttribute('icon')), render) + this.LastFolder.AddItem(new TreeItem(child.firstChild.nodeValue, child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('onclick')), render) } else if (child.tagName == 'tree') { + this.LastFolder = this; this.ProcessXMLNode(child); } }