Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/tree.js =================================================================== diff -u -r6899 -r7089 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/tree.js (.../tree.js) (revision 6899) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/tree.js (.../tree.js) (revision 7089) @@ -1,3 +1,6 @@ +var last_hightlighted = null; +var last_highlighted_key = null; + function TreeItem(title, url, icon, onclick) { this.Title = title; @@ -9,9 +12,9 @@ this.Onclick = onclick; } -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 +35,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 +82,7 @@ { var $node_text = document.createElement('span'); $node_text.innerHTML = this.Title; - + link = document.createElement('a'); link.nodeValue = this.Title; link.href = this.Url; @@ -107,21 +116,38 @@ // only in case of "true" is returned, used in catalog 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 +156,14 @@ this.Displayed = false; } +TreeItem.prototype.highLight = function() +{ + if (last_hightlighted) last_hightlighted.Tr.className = ''; + this.Tr.className = "highlighted"; + last_hightlighted = this; + last_highlighted_key = this.Key; +} + TreeItem.prototype.expand = function() { this.display() } TreeItem.prototype.collapse = function() { this.hide() } @@ -174,6 +208,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 +234,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 +275,36 @@ return last_item; } +TreeFolder.prototype.locateItemByURL = function(url) +{ + last_item = false; + if (this.Url == url) { + return this; + } + + for (var i=0; i