myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arobinso...@apache.org
Subject svn commit: r923460 - /myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
Date Mon, 15 Mar 2010 22:06:07 GMT
Author: arobinson74
Date: Mon Mar 15 22:06:06 2010
New Revision: 923460

URL: http://svn.apache.org/viewvc?rev=923460&view=rev
Log:
TRINIDAD-1756 - fix for safari on mac (multilpe cdata blocks)

Modified:
    myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js

Modified: myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js?rev=923460&r1=923459&r2=923460&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
(original)
+++ myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
Mon Mar 15 22:06:06 2010
@@ -6,9 +6,9 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -47,7 +47,7 @@ TrPage.prototype.getRequestQueue = funct
  * posts and, for multipart/form posts, IFRAME-based transmission.
  * @param actionForm{FormElement} the HTML form to post
  * @param params{Object} additional parameters to send
- * @param headerParams{Object} HTTP headers to include (ignored if 
+ * @param headerParams{Object} HTTP headers to include (ignored if
  *   the request must be a multipart/form post)
  */
 TrPage.prototype.sendPartialFormPost = function(
@@ -65,7 +65,7 @@ TrPage.prototype._requestStatusChanged =
   if (requestEvent.getStatus() == TrXMLRequestEvent.STATUS_COMPLETE)
   {
     var statusCode = requestEvent.getResponseStatusCode();
-    
+
     // The server might not return successfully, for example if an
     // exception is thrown.  When that happens, a non-200 (OK) status
     // code is returned as part of the HTTP prototcol.
@@ -108,7 +108,7 @@ TrPage.prototype._requestStatusChanged =
 TrPage.prototype._handlePprResponse = function(documentElement)
 {
   var rootNodeName = TrPage._getNodeName(documentElement);
-  
+
   if (rootNodeName == "content")
   {
     // Update the form action
@@ -116,15 +116,15 @@ TrPage.prototype._handlePprResponse = fu
 
     var childNodes = documentElement.childNodes;
     var length = childNodes.length;
-    
+
     for (var i = 0; i < length; i++)
     {
       var childNode = childNodes[i];
       var childNodeName = TrPage._getNodeName(childNode);
-      
+
       if (childNodeName == "fragment")
-      {     
-        this._handlePprResponseFragment(childNode);  
+      {
+        this._handlePprResponseFragment(childNode);
       }
       else if (childNodeName == "script")
       {
@@ -150,7 +150,7 @@ TrPage.prototype._handlePprResponse = fu
     if (nodeText == null)
       nodeText = "Unknown error during PPR";
     alert(nodeText);
-  }  
+  }
   else if (rootNodeName == "noop")
   {
     // No op
@@ -263,7 +263,7 @@ TrPage.prototype._resetForm = function(f
     if (eval(trueResetCallback))
       doReload = true;
   }
-  
+
   return doReload;
 }
 
@@ -284,11 +284,11 @@ TrPage.prototype._handlePprResponseActio
 
   if (action)
   {
-    var doc = window.document;    
+    var doc = window.document;
 
     // Replace the form action used by the next postback
     // Particularly important for PageFlowScope which might
-    // change value of the pageflow scope token url parameter.    
+    // change value of the pageflow scope token url parameter.
     // TODO: track submitted form name at client, instead of
     // just updating the first form
     doc.forms[0].action = action;
@@ -433,14 +433,14 @@ TrPage._isDomAncestorOf = function(child
       break;
     child = parentOfChild;
   }
-  
+
   return false;
 }
 
 
 /**
- * Replaces the a dom element contained in a peer. 
- * 
+ * Replaces the a dom element contained in a peer.
+ *
  * @param newElement{DOMElement} the new dom element
  * @param oldElement{DOMElement} the old dom element
  */
@@ -448,32 +448,32 @@ TrPage.prototype.__replaceDomElement = f
 {
   oldElement.parentNode.replaceChild(newElement, oldElement);
 }
-  
-// Extracts the text contents from a rich response fragment node and 
+
+// Extracts the text contents from a rich response fragment node and
 // creates an HTML element for the first element that is found.
 TrPage.prototype._getFirstElementFromFragment = function(fragmentNode)
 {
   // Fragment nodes contain a single CDATA section
   var fragmentChildNodes = fragmentNode.childNodes;
-  // assert((fragmentChildNodes.length == 1), "invalid fragment child count");
-
-  var cdataNode = fragmentNode.childNodes[0];
-  // assert((cdataNode.nodeType == 4), "invalid fragment content");
-  // assert(cdataNode.data, "null fragment content");
-
-  // The new HTML content is in the CDATA section.
-  // TODO: Is CDATA content ever split across multiple nodes?
-  var outerHTML = cdataNode.data;
+  // assert((fragmentChildNodes.length == 0), "invalid fragment child count");
+  var outerHTML = "";
+  for (var i = 0, size = fragmentChildNodes.length; i < size; ++i)
+  {
+    // The new HTML content is in the CDATA section.
+    if (fragmentChildNodes[i].nodeType == 4)
+    {
+      outerHTML += fragmentChildNodes[i].data;
+    }
+  }
 
   // We get our html node by slamming the fragment contents into a div.
-  var doc = window.document;  
+  var doc = window.document;
   var div = doc.createElement("div");
 
   // Slam the new HTML content into the div to create DOM
   div.innerHTML = outerHTML;
-  
+
   return TrPage._getFirstElementWithId(div);
-  
 }
 
 // Returns the first element underneath the specified dom node
@@ -483,7 +483,7 @@ TrPage._getFirstElementWithId = function
 
   var childNodes = domNode.childNodes;
   var length = childNodes.length;
-  
+
   for (var i = 0; i < length; i++)
   {
     var childNode = childNodes[i];
@@ -512,7 +512,7 @@ TrPage.prototype._loadScript = function(
   var loadedLibraries = this._loadedLibraries;
   if (loadedLibraries[source])
     return;
-    
+
   loadedLibraries[source] = true;
   var xmlHttp = new TrXMLRequest();
   xmlHttp.setSynchronous(true);
@@ -569,11 +569,11 @@ TrPage._getTextContent = function(elemen
     var textContent = element.innerText;
     if (textContent == undefined)
       textContent = element.text;
-        
+
     return textContent;
   }
 
-  // Safari doesn't have "innerText", "text" or "textContent" - 
+  // Safari doesn't have "innerText", "text" or "textContent" -
   // (at least not for XML nodes).  So sum up all the text children
   if (_agent.isSafari)
   {
@@ -666,12 +666,12 @@ TrPage.prototype.removeDomReplaceListene
   // remove the listener/instance combination
   var domReplaceListeners = this._domReplaceListeners;
   var length = domReplaceListeners.length;
-  
+
   for (var i = 0; i < length; i++)
   {
     var currListener = domReplaceListeners[i];
     i++;
-    
+
     if (currListener == listener)
     {
       var currInstance = domReplaceListeners[i];
@@ -682,17 +682,17 @@ TrPage.prototype.removeDomReplaceListene
       }
     }
   }
-  
+
   // remove array, if empty
   if (domReplaceListeners.length == 0)
   {
     this._domReplaceListeners = null;
   }
 }
- 
+
 /**
  * Adds the styleClassMap entries to the existing internal
- * styleClassMap. Styles can then be accessed via the 
+ * styleClassMap. Styles can then be accessed via the
  * getStyleClass function.
  * @param styleClassMap() {key: styleClass, ...}
  */
@@ -708,7 +708,7 @@ TrPage.prototype.addStyleClassMap = func
   for (var key in styleClassMap)
     this._styleClassMap[key] = styleClassMap[key];
 }
- 
+
 /**
  * Return the styleClass for the given key.
  * @param key(String) Unique key to retrieve the styleClass
@@ -728,7 +728,7 @@ TrPage.prototype.getStyleClass = functio
 
 /**
  * Causes a partial submit to occur on a given component.  The specified
- * component will always be validated first (if appropriate), then optionally 
+ * component will always be validated first (if appropriate), then optionally
  * the whole form, prior to submission.
  * @param formId(String) Id of the form to partial submit.
  * @param inputId(String) Id of the element causing the partial submit.  If this
@@ -747,7 +747,7 @@ TrPage._autoSubmit = function(formId, in
       event = window.event;
   }
 
-  // If onchange is used for validation, then first validate 
+  // If onchange is used for validation, then first validate
   // just the current input
   var isValid = true;
   if (_TrEventBasedValidation)
@@ -760,7 +760,7 @@ TrPage._autoSubmit = function(formId, in
       params = new Object();
     params.event = "autosub";
     params.source = inputId;
-  
+
     _submitPartialChange(formId, validateForm, params);
   }
 }



Mime
View raw message