[richfaces-svn-commits] JBoss Rich Faces SVN: r5287 - in branches/3.1.x: ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts and 2 other directories.

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


Author: nbelaevski
Date: 2008-01-10 21:54:52 -0500 (Thu, 10 Jan 2008)
New Revision: 5287

Modified:
   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/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
   branches/3.1.x/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
   branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js
   branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
   branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
   branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js
   branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ShuttleUtils.js
Log:
http://jira.jboss.com/jira/browse/RF-1841

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 02:19:28 UTC (rev 5286)
+++ branches/3.1.x/framework/impl/src/main/javascript/prototype/patches.js	2008-01-11 02:54:52 UTC (rev 5287)
@@ -78,12 +78,13 @@
     	
         for (var eventName in cache) {
         	var wrappers = cache[eventName];
+        	var domEventName = Event.getDOMEventName(eventName);
         	
         	wrappers.each(function(wrapper) {
 				if (node.removeEventListener) {
-					node.removeEventListener(eventName, wrapper, false);
+					node.removeEventListener(domEventName, wrapper, false);
 				} else {
-					node.detachEvent("on" + eventName, wrapper);
+					node.detachEvent("on" + domEventName, wrapper);
 				}
             });            	
     		
@@ -92,6 +93,18 @@
 
         delete Event.cache[eventID];
 	}
+	
+	var component = node.component;
+	if (component) {
+		var destructorName = component["rich:destructor"];
+		//destructor name is required to be back-compatible
+		if (destructorName) {
+			var destructor = component[destructorName];
+			if (destructor) {
+				destructor.call(component);
+			}
+		}
+	}
 }
 
 Event.unloadElementsCache = function(oldNode) {

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 02:19:28 UTC (rev 5286)
+++ branches/3.1.x/framework/impl/src/main/javascript/prototype/prototype1.6.0.js	2008-01-11 02:54:52 UTC (rev 5287)
@@ -3805,6 +3805,12 @@
   }
 })();
 
+//added by nick
+Event.getDOMEventName = function(eventName) {
+    if (eventName && eventName.include(':')) return "dataavailable";
+    return eventName;
+};
+
 Object.extend(Event, (function() {
   var cache = Event.cache;
 
@@ -3814,10 +3820,12 @@
     return element._eventID = ++arguments.callee.id;
   }
 
-  function getDOMEventName(eventName) {
-    if (eventName && eventName.include(':')) return "dataavailable";
-    return eventName;
-  }
+//	commented by nick
+//
+//  function getDOMEventName(eventName) {
+//    if (eventName && eventName.include(':')) return "dataavailable";
+//    return eventName;
+//  }
 
   function getCacheForID(id) {
     return cache[id] = cache[id] || { };
@@ -3873,7 +3881,7 @@
   return {
     observe: function(element, eventName, handler) {
       element = $(element);
-      var name = getDOMEventName(eventName);
+      var name = Event.getDOMEventName(eventName);
 
       var wrapper = createWrapper(element, eventName, handler);
       if (!wrapper) return element;
@@ -3889,7 +3897,7 @@
 
     stopObserving: function(element, eventName, handler) {
       element = $(element);
-      var id = getEventID(element), name = getDOMEventName(eventName);
+      var id = getEventID(element), name = Event.getDOMEventName(eventName);
 
       if (!handler && eventName) {
         getWrappersForEventName(id, eventName).each(function(wrapper) {

Modified: branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js	2008-01-11 02:19:28 UTC (rev 5286)
+++ branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js	2008-01-11 02:54:52 UTC (rev 5287)
@@ -44,6 +44,11 @@
 Richfaces.ListShuttle.prototype = {
 	initialize: function(targetList, sourceList, clientId, controlIds, switchByClick, sourceLayoutManager, targetLayoutManager, onlistchanged) {
 		this.containerId = clientId;
+		this["rich:destructor"] = "destroy";
+		
+		this.container = $(this.containerId);
+		this.container.component = this;
+		
 		this.targetList = targetList;
 		this.sourceList = sourceList;
 		
@@ -75,10 +80,16 @@
 	
 		if (onlistchanged) {
 			this.targetList.container.observe("rich:onorderchanged", onlistchanged);
-			$(this.containerId).observe("rich:onlistchanged", onlistchanged);
+			this.container.observe("rich:onlistchanged", onlistchanged);
 		}
 	},
 	
+	destroy: function() {
+		this.container.component = null;
+		this.targetList.destroy();
+		this.sourceList.destroy();
+	},
+	
 	initControlList : function(clientId, ids) {
 		for (var i = 0; i < ids.length; i++) {
 			var id = ids[i];
@@ -150,7 +161,7 @@
 			this.targetLayoutManager.widthSynchronization();
 			this.sourceLayoutManager.widthSynchronization();
 		
-			$(this.containerId).fire("rich:onlistchanged", {});
+			this.container.fire("rich:onlistchanged", {});
 		}
 	},
 	
@@ -217,7 +228,7 @@
 		this.targetLayoutManager.widthSynchronization();
 		this.sourceLayoutManager.widthSynchronization();
 		
-		$(this.containerId).fire("rich:onlistchanged", {});
+		this.container.fire("rich:onlistchanged", {});
 	}
 	
 }

Modified: branches/3.1.x/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
--- branches/3.1.x/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js	2008-01-11 02:19:28 UTC (rev 5286)
+++ branches/3.1.x/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js	2008-01-11 02:54:52 UTC (rev 5287)
@@ -48,25 +48,6 @@
 
 ModalPanel.panels = new Array();
 
-A4J.AJAX.AddListener({
-	onafterajax: function(req, event, data) {
-		var i = 0;
-		while (i < ModalPanel.panels.length) {
-			var panel = ModalPanel.panels[i];
-
-			if (Element.isUninitialized(panel.markerId)) {
-				panel.destroy();
-
-				ModalPanel.panels.splice(i, 1);
-				//check all panels again. maybe we've removed parent of any panel just now
-				i = 0;
-			} else {
-				i++;
-			}
-		}
-	}
-});
-
 ModalPanel.Context = Class.create();
 ModalPanel.Context.prototype = {
 	initialize: function(modalPanel) {
@@ -105,7 +86,8 @@
 
 ModalPanel.prototype = {
 	initialize: function(id, options) {
-
+		this["rich:destructor"] = "destroy";
+	
 		this.markerId = $(id);
 
 		this.id = $(id + "Container");
@@ -191,7 +173,8 @@
 	},
 
 	destroy: function() {
-
+		ModalPanel.panels = ModalPanel.panels.without(this);
+		
         this.traverseSelects(true);
         
         this.parent = null;
@@ -207,14 +190,16 @@
 		}
 		this.borders = null;
 
-		if (this.floatedToBody) {
-			var element = this.id;
-			var parent = element.parentNode;
-			if (parent) {
-				parent.removeChild(element);
-				discardElement(element);
+		setTimeout(function() {
+			if (this.floatedToBody) {
+				var element = this.id;
+				var parent = element.parentNode;
+				if (parent) {
+					parent.removeChild(element);
+					discardElement(element);
+				}
 			}
-		}
+		}.bind(this), 0);
         this.markerId.component = null;
         this.markerId = null;
 	},

Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js	2008-01-11 02:19:28 UTC (rev 5286)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js	2008-01-11 02:54:52 UTC (rev 5287)
@@ -4,13 +4,7 @@
 	this.headerDiv = (this.headerTable) ? this.headerTable.parentNode : null;
 	this.contentDiv = this.contentTable.parentNode;
 	
-	var obj = this;
-	if (window.attachEvent) {
-		this.contentDiv.attachEvent("onscroll", function() {obj.scrollHandler(obj)});
-	} else {
-		this.contentDiv.addEventListener("scroll", function() {obj.scrollHandler(obj)}, true);
-	}
-
+	Event.observe(this.contentDiv, "scroll", this.scrollHandler.bindAsEventListener(this));
 }
 
 LayoutManager.SCROLL_WIDTH = 17;
@@ -52,9 +46,9 @@
 	return 0;
 }
 
-LayoutManager.prototype.scrollHandler = function(obj) {
-	if (obj.headerDiv) {
-		obj.headerDiv.scrollLeft = obj.contentDiv.scrollLeft;
+LayoutManager.prototype.scrollHandler = function() {
+	if (this.headerDiv) {
+		this.headerDiv.scrollLeft = this.contentDiv.scrollLeft;
 	} 
 }
 

Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js	2008-01-11 02:19:28 UTC (rev 5286)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js	2008-01-11 02:54:52 UTC (rev 5287)
@@ -1,19 +1,18 @@
 if(!window.Richfaces) window.Richfaces = {};
-Richfaces.disableSelectionText = function(target) {
-	target.onselectstart = function(e) {
-		e = window.event||e;
-		if (e.srcElement) {
-			if (e.srcElement.tagName) {
-				var tagName = e.srcElement.tagName.toUpperCase();
-				
-				if (tagName != "INPUT" && tagName != "TEXTAREA" /* any items more? */) {
-					return false;
-				}
+Richfaces.disableSelectionText = function(e) {
+	e = window.event||e;
+	if (e.srcElement) {
+		if (e.srcElement.tagName) {
+			var tagName = e.srcElement.tagName.toUpperCase();
+			
+			if (tagName != "INPUT" && tagName != "TEXTAREA" /* any items more? */) {
+				return false;
 			}
 		}
 	}
-}
+};
 
+
 Richfaces.ListBase = Class.create();
 
 Richfaces.ListBase.compare = function(obj1, obj2) {
@@ -34,12 +33,13 @@
 Richfaces.ListBase.prototype = {
 	initialize : function(containerId, contentTableId, headerTableId, focusKeeperId, 
 				   		  onclickControlId, controlClass) {
+		this["rich:destructor"] = "destroy";
 		this.selectedItems = new Array();
 		
 		//this.layoutManager = layoutManager;
 		this.container = $(containerId);
 		this.shuttleTable = $(contentTableId);
-		Richfaces.disableSelectionText(this.shuttleTable);
+		this.shuttleTable.onselectstart = Richfaces.disableSelectionText;
 		this.focusKeeper = $(focusKeeperId);
 		this.focusKeeper.focused = false;
 		//this.setFocus();
@@ -61,6 +61,14 @@
 		this.shuttleTable.observe("click", this.clckHandler);
 	},
 	
+	destroy: function() {
+		this.shuttleTable.onselectstart = null;
+		var items = this.shuttleItems;
+		for (var i = 0; i < items.length; i++) {
+			items[i].destroy();
+		}
+	},
+	
 	setActiveItem : function(newActiveItem) {
 		this.pseudoActiveItem = newActiveItem;
 		this.activeItem = newActiveItem;

Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js	2008-01-11 02:19:28 UTC (rev 5286)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js	2008-01-11 02:54:52 UTC (rev 5287)
@@ -23,12 +23,20 @@
 	initialize: function($super, containerId, contentTableId, headerTableId, focusKeeperId, ids, onclickControlId, onorderchanged, controlClass) {
 		$super(containerId, contentTableId, headerTableId, focusKeeperId, onclickControlId, controlClass);
 		
+		this.container.component = this;
+		
 		if (onorderchanged) {
 			this.container.observe("rich:onorderchanged", onorderchanged);
 		}
 		this.controlList = new Array();
 		this.initControlList(containerId, ids);
 	},
+
+	destroy: function($super) {
+		$super();
+		
+		this.container.component = null;
+	},
 	
 	initControlList : function(containerId, ids) {
 		for (var i = 0; i < ids.length; i++) {

Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js	2008-01-11 02:19:28 UTC (rev 5286)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js	2008-01-11 02:54:52 UTC (rev 5287)
@@ -17,6 +17,10 @@
 		this.active = /^s?a/.test(this.input.value);
 	},
 	
+	destroy: function() {
+		this._node.item = null;
+	},
+	
 	doActive : function() {
 		var classes = this.CLASSES; 
 		var row = this._node;

Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ShuttleUtils.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ShuttleUtils.js	2008-01-11 02:19:28 UTC (rev 5286)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ShuttleUtils.js	2008-01-11 02:54:52 UTC (rev 5287)
@@ -1,26 +1,48 @@
 Object.extend(Event, {
-   _domReady : function() {
-       if (arguments.callee.done) return;
-       arguments.callee.done = true;
-              if (Event._timer) clearInterval(Event._timer);
-              Event._readyCallbacks.each(function(f) { f() });
-       Event._readyCallbacks = null;
-   },
+	_domReady : function() {
+		var domReady = arguments.callee
+		if (!domReady.done) {
+			domReady.done = true;
+	
+			Event._readyCallbacks.each(function(f) { f() });
+			Event._readyCallbacks = null;
+
+			if (Event._timer) {
+				clearInterval(Event._timer);
+			}
+	
+			if (document.removeEventListener) {
+				document.removeEventListener("DOMContentLoaded", domReady, false);
+			}
+	
+			Event.stopObserving(window, 'load', domReady);
+		}
+	},
+   
    onReady : function(f) {
+       var domReady = this._domReady;
+       if (domReady.done) {
+    	   return f();
+       }
+
        if (!this._readyCallbacks) {
-           var domReady = this._domReady;
-                  if (domReady.done) return f();
-                  if (document.addEventListener)
-           document.addEventListener("DOMContentLoaded", domReady, false);
+           
+           this._readyCallbacks = [];
+
+           if (document.addEventListener) {
+        	   document.addEventListener("DOMContentLoaded", domReady, false);
+           }
+           
            if (/WebKit/i.test(navigator.userAgent)) {
                this._timer = setInterval(function() {
                    if (/loaded|complete/.test(document.readyState)) domReady();
                }, 10);
            }
-           Event.observe(window, 'load', domReady);
-           Event._readyCallbacks = [];
+           
+           this.observe(window, 'load', domReady);
        }
-       Event._readyCallbacks.push(f);
+       
+       this._readyCallbacks.push(f);
    }
 }); 
 




More information about the richfaces-svn-commits mailing list