Index: trunk/core/admin_templates/js/tree.js =================================================================== diff -u -N -r6656 -r7391 --- trunk/core/admin_templates/js/tree.js (.../tree.js) (revision 6656) +++ trunk/core/admin_templates/js/tree.js (.../tree.js) (revision 7391) @@ -1,3 +1,6 @@ +var last_hightlighted = null; +var last_highlighted_key = null; + function TreeItem(title, url, icon, onclick) { this.Title = title; @@ -7,11 +10,12 @@ this.Level = 0; this.Icon = icon; this.Onclick = onclick; + this.Children = false; } -TreeItem.prototype.Render = function(before) +TreeItem.prototype.Render = function(before, force) { - if (!this.Rendered) { + if (!this.Rendered || force) { if (!isset(before)) {before = null} tr = document.createElement('tr'); @@ -32,6 +36,12 @@ } } +TreeItem.prototype.remove = function() +{ + var p = this.Tr.parentNode; + p.removeChild(this.Tr); +} + TreeItem.prototype.appendLevel = function(td) { for (var i=0; i < this.Level; i++) @@ -73,7 +83,7 @@ { var $node_text = document.createElement('span'); $node_text.innerHTML = this.Title; - + link = document.createElement('a'); link.nodeValue = this.Title; link.href = this.Url; @@ -105,23 +115,41 @@ // ensures, that click is made before AJAX request will be sent if (res === true) { // only in case of "true" is returned, used in catalog - window.parent.getFrame(link.target).location.href = this.href; + getFrame(link.target).location.href = this.href; } - + if (!this.treeItem.Expanded && typeof(this.treeItem.folderClick) == 'function') { if (this.treeItem.folderClick()); } - return false; + this.treeItem.highLight(); + return false; } } td.appendChild(link); + + /* + if (this.LateLoadURL) { + var span = document.createElement('span'); + span.innerHTML = ' Reload'; + span.treeItem = this; + span.onclick = function(ev) { + this.treeItem.reload(); + } + td.appendChild(span); + } + */ } TreeItem.prototype.display = function() { this.Tr.style.display = is.ie ? 'block' : 'table-row'; this.Displayed = true; + + var do_sub = TreeManager.isExpanded(this.Key); + if (this.Children && do_sub && !this.Expanding) { + this.expand(); + } } TreeItem.prototype.hide = function() @@ -130,6 +158,25 @@ this.Displayed = false; } +TreeItem.prototype.highLight = function() +{ + if (last_hightlighted) last_hightlighted.Tr.className = ''; + if (this.Children && this.Children.length > 0 && this.Children[0].Url.replace('&', '&') == this.Url.replace('&', '&')) { + if (!this.Expanded) { + this.expand(); + } + this.Children[0].highLight(); + return; + } + + this.Tr.className = "highlighted"; + last_hightlighted = this; + last_highlighted_key = this.Key; + if (!this.Expanded) { + this.expand(); + } +} + TreeItem.prototype.expand = function() { this.display() } TreeItem.prototype.collapse = function() { this.hide() } @@ -174,6 +221,23 @@ { return this; } + +TreeItem.prototype.locateItemByURL = function(url) +{ + if (this.Url == url) return this; + return false; +} + +TreeItem.prototype.locateItemByKey = function(key) +{ + if (this.Key == key) return this; + return false; +} + +TreeItem.prototype.reload = function() +{ +} + /* FOLDER */ function TreeFolder(parent_id, title, url, icon, late_load_url, onclick) @@ -183,13 +247,18 @@ this.ParentElement = document.getElementById(parent_id); render = true; } + else { + + } + this.Title = title; this.Url = url; this.Rendered = false; this.Displayed = false; this.Expanded = false; this.Level = 0; + this.Id = 0; this.Tr = null; this.Icon = icon; this.LateLoadURL = isset(late_load_url) ? late_load_url : false; @@ -219,6 +288,36 @@ return last_item; } +TreeFolder.prototype.locateItemByURL = function(url) +{ + last_item = false; + if (this.Url == url) { + return this; + } + + for (var i=0; i