[richfaces-svn-commits] JBoss Rich Faces SVN: r5286 - in branches/3.1.x: framework/impl/src/main/javascript/prototype and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Jan 10 21:19:28 EST 2008


Author: nbelaevski
Date: 2008-01-10 21:19:28 -0500 (Thu, 10 Jan 2008)
New Revision: 5286

Modified:
   branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
   branches/3.1.x/framework/impl/src/main/javascript/prototype/patches.js
   branches/3.1.x/framework/impl/src/main/javascript/prototype/prototype1.6.0.js
   branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
http://jira.jboss.com/jira/browse/RF-1567

Modified: branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js	2008-01-11 01:30:24 UTC (rev 5285)
+++ branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js	2008-01-11 02:19:28 UTC (rev 5286)
@@ -315,6 +315,12 @@
 		if( ! newnode ) { LOG.error("New node for ID "+id+" is not present in response");return;}
 		var oldnode = window.document.getElementById(id);
 		if ( oldnode  ) {
+			
+	   	    // Remove unload prototype events for a removed elements.
+			if ((typeof Event != "undefined") && (typeof Event.unloadElementsCache == "function")) {
+			  	Event.unloadElementsCache(oldnode);
+			}        	  
+			
 			var anchor = oldnode.parentNode;
 			if(!window.opera && oldnode.outerHTML && !oldnode.tagName.match( /(tbody|thead|tfoot|tr|th|td)/i ) ){
    		        LOG.debug("Replace content of node by outerHTML()");
@@ -334,11 +340,6 @@
 				anchor.replaceChild(importednode,oldnode);
 			} 
 			
-	   	    // Remove unload prototype events for a removed elements.
-			if ((typeof Event != "undefined") && (typeof Event.unloadElementsCache == "function")) {
-			  	Event.unloadElementsCache(oldnode);
-			}        	  
-			
 	// re-execute all script fragments in imported subtree...
 	// TODO - opera 8 run scripts at replace content stage.
 			if(!A4J.AJAX._scriptEvaluated){

Modified: branches/3.1.x/framework/impl/src/main/javascript/prototype/patches.js
===================================================================
--- branches/3.1.x/framework/impl/src/main/javascript/prototype/patches.js	2008-01-11 01:30:24 UTC (rev 5285)
+++ branches/3.1.x/framework/impl/src/main/javascript/prototype/patches.js	2008-01-11 02:19:28 UTC (rev 5286)
@@ -62,32 +62,62 @@
 	}
 };
 
-Event.unloadElementsCache = function(oldNode) {
-	//refer to window.unload handling conditions in prototype script
-    if (!window.attachEvent) return;
+//That's prototype version-dependent
 
-    if (!oldNode) return;
-    
-    if (oldNode) {
-    	if (oldNode._eventID) {
-        	var cache = Event.cache[oldNode._eventID];
+if (window.attachEvent) {
+    window.attachEvent("onunload", function() {
+    	Event.unloadElementsCache(document);
+    	Event.unloadElementsCache(window);
+    });
+}
+
+Event.destroyEventCache = function(node) {
+	var eventID = node._eventID;
+	if (eventID) {
+		var cache = Event.cache[eventID];
+    	
+        for (var eventName in cache) {
+        	var wrappers = cache[eventName];
         	
-            for (var eventName in cache) {
-                cache[eventName] = null;
-            }
+        	wrappers.each(function(wrapper) {
+				if (node.removeEventListener) {
+					node.removeEventListener(eventName, wrapper, false);
+				} else {
+					node.detachEvent("on" + eventName, wrapper);
+				}
+            });            	
+    		
+            cache[eventName] = null;
+        }
 
-            delete Event.cache[oldNode._eventID];
-    	}
+        delete Event.cache[eventID];
+	}
+}
 
-    	var firstNode = oldNode.firstChild;
-    	if (firstNode) {
-    		Event.unloadElementsCache(firstNode);
-        	
-    		var nextNode = firstNode.nextSibling;
-        	while (nextNode) {
-        		Event.unloadElementsCache(nextNode);
-        		nextNode = nextNode.nextSibling;
-        	}
-    	}
+Event.unloadElementsCache = function(oldNode) {
+    if (oldNode) {
+		Event.destroyEventCache(oldNode);
+	
+		//node.all is quicker than recursive traversing
+	    //window doesn't have "all" attribute
+	    var all = oldNode.all;
+	    
+	    if (all) {
+	        var counter = 0;
+	        var length = all.length;
+	        
+	        for (var counter = 0; counter < length; counter++ ) {
+	        	Event.destroyEventCache(all[counter]);
+	        }
+	    } else {
+	    	var node = oldNode.firstChild;
+	    	while (node) {
+	    		Event.unloadElementsCache(node);
+	        	node = node.nextSibling;
+	    	}
+	    }
     }
-};
\ No newline at end of file
+    
+};
+
+//

Modified: branches/3.1.x/framework/impl/src/main/javascript/prototype/prototype1.6.0.js
===================================================================
--- branches/3.1.x/framework/impl/src/main/javascript/prototype/prototype1.6.0.js	2008-01-11 01:30:24 UTC (rev 5285)
+++ branches/3.1.x/framework/impl/src/main/javascript/prototype/prototype1.6.0.js	2008-01-11 02:19:28 UTC (rev 5286)
@@ -3858,16 +3858,18 @@
     c[eventName] = c[eventName].without(findWrapper(id, eventName, handler));
   }
 
-  function destroyCache() {
-    for (var id in cache)
-      for (var eventName in cache[id])
-        cache[id][eventName] = null;
-  }
+//  Commented by Nick
+//  
+//  function destroyCache() {
+//    for (var id in cache)
+//      for (var eventName in cache[id])
+//        cache[id][eventName] = null;
+//  }
+//
+//  if (window.attachEvent) {
+//    window.attachEvent("onunload", destroyCache);
+//  }
 
-  if (window.attachEvent) {
-    window.attachEvent("onunload", destroyCache);
-  }
-
   return {
     observe: function(element, eventName, handler) {
       element = $(element);

Modified: branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js	2008-01-11 01:30:24 UTC (rev 5285)
+++ branches/3.1.x/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js	2008-01-11 02:19:28 UTC (rev 5286)
@@ -723,10 +723,13 @@
 		} while (obj = obj.nextSibling);
 		
 		// set content
-		var obj=obj.nextSibling;
+		obj=obj.nextSibling;
 		obj.component = this;
 		obj.richfacesComponent="richfaces:calendar";
 		
+		obj = null;
+		span = null;
+		
 		if(this.params.submitFunction)	this.submitFunction = this.params.submitFunction.bind(this);
 		this.prepareEvents();
 		




More information about the richfaces-svn-commits mailing list