Author: nbelaevski
Date: 2007-12-19 09:02:43 -0500 (Wed, 19 Dec 2007)
New Revision: 4918
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
trunk/framework/impl/src/main/javascript/prototype/patches.js
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
Log:
http://jira.jboss.com/jira/browse/RF-1567
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-12-19 14:02:26 UTC
(rev 4917)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-12-19 14:02:43 UTC
(rev 4918)
@@ -363,6 +363,12 @@
LOG.debug("Replace content of node by replaceChild()");
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){
@@ -884,9 +890,10 @@
window.document.documentElement.appendChild(node);
}
}
- if (typeof Event != "undefined" && typeof
Event.unloadElementsCache == "function") {
- Event.unloadElementsCache();
- }
+ //TODO - unloading cached observers?
+ //if (typeof Event != "undefined" && typeof
Event.unloadElementsCache == "function") {
+ //Event.unloadElementsCache();
+ //}
} else {
LOG.error("Error parsing
response",Sarissa.getParseErrorText(oDomDoc));
}
@@ -921,11 +928,6 @@
*/
A4J.AJAX.finishRequest = function(request){
var options = request.options;
- // Remove unload prototype events for a removed elements.
- if ((typeof Event != "undefined") && (typeof
Event.unloadElementsCache == "function")) {
- Event.unloadElementsCache();
- }
-
// we can set listener for complete request - for example,
// it can shedule next request for update page.
var oncomplete = request.getElementById('org.ajax4jsf.oncomplete');
Modified: trunk/framework/impl/src/main/javascript/prototype/patches.js
===================================================================
--- trunk/framework/impl/src/main/javascript/prototype/patches.js 2007-12-19 14:02:26 UTC
(rev 4917)
+++ trunk/framework/impl/src/main/javascript/prototype/patches.js 2007-12-19 14:02:43 UTC
(rev 4918)
@@ -62,19 +62,32 @@
}
};
-Event.unloadElementsCache = function() {
- if (!Event.observers) return;
- //refer to window.unload handling conditions in prototype script
- if (!Prototype.Browser.IE) return;
+Event.unloadElementsCache = function(oldNode) {
+ //refer to window.unload handling conditions in prototype script
+ if (!window.attachEvent) return;
+
+ if (!oldNode) return;
- var observers = Event.observers;
- for (var i = observers.length - 1; i >= 0; i--) {
- var observer = observers[i];
- var elt = observer[0];
-
- if (Element.isUninitialized(elt)) {
- Event.stopObserving.apply(Event, observer);
- observers.splice(i, 1);
+ if (oldNode) {
+ if (oldNode._eventID) {
+ var cache = Event.cache[oldNode._eventID];
+
+ for (var eventName in cache) {
+ cache[eventName] = null;
+ }
+
+ delete Event.cache[oldNode._eventID];
}
+
+ var firstNode = oldNode.firstChild;
+ if (firstNode) {
+ Event.unloadElementsCache(firstNode);
+
+ var nextNode = firstNode.nextSibling;
+ while (nextNode) {
+ Event.unloadElementsCache(nextNode);
+ nextNode = nextNode.nextSibling;
+ }
+ }
}
};
\ No newline at end of file
Modified:
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
---
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-12-19
14:02:26 UTC (rev 4917)
+++
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2007-12-19
14:02:43 UTC (rev 4918)
@@ -18,6 +18,7 @@
document.body.appendChild(garbageBin);
}
+ Event.unloadElementsCache(element);
// move the element to the garbage bin
garbageBin.appendChild(element);
garbageBin.innerHTML = '';
@@ -129,7 +130,7 @@
this.markerId = $(id);
- this.id = id + "Container";
+ this.id = $(id + "Container");
this.options = options;
@@ -201,8 +202,8 @@
this.eventFirstOnfocus = this.firstOnfocus.bindAsEventListener(this);
this.eventLastOnfocus = this.lastOnfocus.bindAsEventListener(this);
- this.firstHref = this.id + "FirstHref";
- this.lastHref = this.id + "LastHref";
+ this.firstHref = id + "FirstHref";
+ this.lastHref = id + "LastHref";
this.selectBehavior = options.selectBehavior;
},
@@ -225,7 +226,7 @@
this.borders = null;
if (this.floatedToBody) {
- var element = $(this.id);
+ var element = this.id;
var parent = element.parentNode;
if (parent) {
parent.removeChild(element);
@@ -263,10 +264,9 @@
}
var children = document.body.childNodes;
- var element = $(this.id);
for (var k = 0; k < children.length; k++) {
var child = children[k];
- if (child != element && child.getElementsByTagName) {
+ if (child != this.id && child.getElementsByTagName) {
var selects = child.getElementsByTagName("SELECT");
@@ -439,7 +439,7 @@
},
show: function(event, opts) {
- var element = $(this.id);
+ var element = this.id;
if(this.invokeEvent("show",event,null,element)){
this.preventFocus();
@@ -461,13 +461,12 @@
var eIframe;
if (ModalPanel.disableSelects && !this.iframe) {
+ this.iframe = this.id.id + "IFrame";
new Insertion.Top(eCdiv,
- "<iframe src=\"javascript:''\" frameborder=\"0\"
scrolling=\"no\" id=\"" + this.id + "IFrame\"" +
- "style=\"position: absolute; width: 1px; height: 1px; background-color:
white; overflow-y: hidden; z-index: 1;\">" +
+ "<iframe src=\"javascript:''\"
frameborder=\"0\" scrolling=\"no\" id=\"" + this.iframe +
"\" " +
+ "style=\"position: absolute; width: 1px; height: 1px; background-color:
white; overflow-y: hidden; z-index: 1;\">" +
"</iframe>");
- this.iframe = this.id + "IFrame";
-
eIframe = $(this.iframe);
//alert("IFrame:" + eIframe + "created!");
@@ -858,8 +857,8 @@
if (e && target) {
var input = document.createElement("input");
input.type = "hidden";
- input.id = this.id + "OpenedState";
- input.name = this.id + "OpenedState";
+ input.id = this.id.id + "OpenedState";
+ input.name = this.id.id + "OpenedState";
input.value = this.shown ? "true" : "false";
target.appendChild(input);
@@ -868,8 +867,8 @@
for (var i = 0; i < keys.length; i++) {
input = document.createElement("input");
input.type = "hidden";
- input.id = this.id + "StateOption_" + keys[i];
- input.name = this.id + "StateOption_" + keys[i];
+ input.id = this.id.id + "StateOption_" + keys[i];
+ input.name = this.id.id + "StateOption_" + keys[i];
input.value = this.userOptions[keys[i]];
target.appendChild(input);