Author: nbelaevski
Date: 2009-02-27 15:24:32 -0500 (Fri, 27 Feb 2009)
New Revision: 12782
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
trunk/framework/impl/src/main/javascript/prototype/prototype-1.6.0.3.js
Log:
https://jira.jboss.org/jira/browse/RF-3745
https://jira.jboss.org/jira/browse/RF-4030
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2009-02-27 20:00:01 UTC
(rev 12781)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2009-02-27 20:24:32 UTC
(rev 12782)
@@ -1066,27 +1066,42 @@
var oldDocOpen = window.document.open;
if (isIE) {
LOG.debug("setup custom document.open method");
- window.document.open = function() {
- oldDocOpen.apply(this, arguments);
+ window.document.open = function(sUrl, sName, sFeatures, bReplace) {
+ oldDocOpen(sUrl, sName, sFeatures, bReplace);
}
}
// /maksimkaszynski
window.setTimeout(function() {
var isDocOpen=false;
try {
- window.document.open(req.getContentType(),true);
- LOG.debug("window.document has opened for writing");
+ var contentType = req.getContentType();
+ var responseText = isIE ?
+ req.getResponseText().replace(/(<script(?!\s+src=))/igm, "$1
defer ") :
+ req.getResponseText();
+
+ window.document.open(contentType, "replace");
+ if (window.LOG) {
+ LOG.debug("window.document has opened for writing");
+ }
isDocOpen=true;
- window.document.write(req.getResponseText());
- LOG.debug("window.document has been writed");
+
+ window.document.write(responseText);
+
+ if (window.LOG) {
+ LOG.debug("window.document has been writed");
+ }
window.document.close();
- LOG.debug("window.document has been closed for writing");
+ if (window.LOG) {
+ LOG.debug("window.document has been closed for writing");
+ }
if(isIE){
// For Ie , scripts on page not activated.
window.location.reload(false);
}
} catch(e) {
- LOG.debug("exception during write page content "+e.Message);
+ if (window.LOG) {
+ LOG.debug("exception during write page content "+e.Message);
+ }
if(isDocOpen){
window.document.close();
}
@@ -1094,12 +1109,16 @@
// Use dom manipulation instead.
var oDomDoc = (new DOMParser()).parseFromString(req.getResponseText(),
"text/xml");
if(Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
- LOG.debug("response has parsed as DOM documnet.");
+ if (window.LOG) {
+ LOG.debug("response has parsed as DOM documnet.");
+ }
Sarissa.clearChildNodes(window.document.documentElement);
var docNodes = oDomDoc.documentElement.childNodes;
for(var i = 0;i<docNodes.length;i++){
if(docNodes[i].nodeType == 1){
- LOG.debug("append new node in document");
+ if (window.LOG) {
+ LOG.debug("append new node in document");
+ }
var node = window.document.importNode(docNodes[i], true);
window.document.documentElement.appendChild(node);
}
@@ -1109,13 +1128,17 @@
// window.RichFaces.Memory.clean(oldnode);
//}
} else {
- LOG.error("Error parsing
response",Sarissa.getParseErrorText(oDomDoc));
+ if (window.LOG) {
+ LOG.error("Error parsing
response",Sarissa.getParseErrorText(oDomDoc));
+ }
}
// TODO - scripts reloading ?
} finally {
window.document.open = oldDocOpen;
}
- LOG.debug("page content has been replaced");
+ if (window.LOG) {
+ LOG.debug("page content has been replaced");
+ }
},0);
}
Modified: trunk/framework/impl/src/main/javascript/prototype/prototype-1.6.0.3.js
===================================================================
--- trunk/framework/impl/src/main/javascript/prototype/prototype-1.6.0.3.js 2009-02-27
20:00:01 UTC (rev 12781)
+++ trunk/framework/impl/src/main/javascript/prototype/prototype-1.6.0.3.js 2009-02-27
20:24:32 UTC (rev 12782)
@@ -4155,12 +4155,18 @@
if (document.readyState != "complete") { // added by Pavel Yaschenko
document.write("<script id=__onDOMContentLoaded defer
src=//:><\/script>");
- $("__onDOMContentLoaded").onreadystatechange = function() {
- if (this.readyState == "complete") {
- this.onreadystatechange = null;
- fireContentLoadedEvent();
- }
- };
+ var contentLoadedScript = $("__onDOMContentLoaded");
+
+ //modified by Nick Belaevski - RF-3745
+ if (contentLoadedScript) {
+ contentLoadedScript.onreadystatechange = function() {
+ if (this.readyState == "complete") {
+ this.onreadystatechange = null;
+ fireContentLoadedEvent();
+ }
+ };
+ }
+ //modified by Nick Belaevski
} // added by Pavel Yaschenko
}
})();