[Zope3-checkins] CVS: Zope3/src/zope/app/browser/skins/rotterdam - xmltree.js:1.10

Godefroid Chapelle gotcha@swing.be
Tue, 14 Jan 2003 17:15:24 -0500


Update of /cvs-repository/Zope3/src/zope/app/browser/skins/rotterdam
In directory cvs.zope.org:/tmp/cvs-serv9708

Modified Files:
	xmltree.js 
Log Message:
small refactoring plus correction of potential memory leak


=== Zope3/src/zope/app/browser/skins/rotterdam/xmltree.js 1.9 => 1.10 ===
--- Zope3/src/zope/app/browser/skins/rotterdam/xmltree.js:1.9	Tue Jan 14 17:03:36 2003
+++ Zope3/src/zope/app/browser/skins/rotterdam/xmltree.js	Tue Jan 14 17:15:21 2003
@@ -83,10 +83,7 @@
         // If this collection is empty, load it from server
         // todo xxx optimize for the case where collection has null length
         if (isEmpty) {
-                loadingNode = createLoadingNode();
-                domNode.appendChild(loadingNode);
-                var url = baseurl + path + XML_CHILDREN_VIEW;
-                loadtreexml(url, this);
+                startLoadingChildren();
                 }
         else
                 {
@@ -96,6 +93,24 @@
         }
 } 
 
+navigationTreeNode.prototype.startLoadingChildren = function() {
+with (this) {
+        loadingNode = createLoadingNode();
+        domNode.appendChild(loadingNode);
+        var url = baseurl + path + XML_CHILDREN_VIEW;
+        loadtreexml(url, this);
+        }
+}
+
+navigationTreeNode.prototype.finishLoadingChildren = function() {
+with (this) {
+        isEmpty = 0;
+        refreshExpansion();
+        domNode.removeChild(loadingNode);
+        loadingNode = null;
+        }
+}
+
 navigationTreeNode.prototype.refreshExpansion = function() {
 with (this) {
         if (isCollapsed) {
@@ -328,9 +343,7 @@
                 else {
                         //expanding nodes
                         addNavigationTreeNodes(data, node, 0);
-                        node.isEmpty = 0;
-                        node.refreshExpansion();
-                        node.domNode.removeChild(node.loadingNode);
+                        node.finishLoadingChildren();
                         }
                 }             
         }