Upgrade to ExtJS 3.2.1 - Released 04/27/2010
[extjs.git] / docs / source / jquery-bridge.html
index cd7c838..9b95000 100644 (file)
@@ -1,11 +1,18 @@
-<html>\r
-<head>\r
-  <title>The source code</title>\r
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js">if(typeof jQuery == "undefined"){
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
+  <title>The source code</title>
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body  onload="prettyPrint();">
+    <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+if(typeof jQuery == "undefined"){
     throw "Unable to load Ext, jQuery not found.";
 }
 
     throw "Unable to load Ext, jQuery not found.";
 }
 
@@ -24,27 +31,22 @@ Ext.lib.Dom = {
     },
 
     isAncestor : function(p, c){
     },
 
     isAncestor : function(p, c){
+        var ret = false;
+
         p = Ext.getDom(p);
         c = Ext.getDom(c);
         p = Ext.getDom(p);
         c = Ext.getDom(c);
-        if (!p || !c) {return false;}
-
-        if(p.contains && !Ext.isSafari) {
-            return p.contains(c);
-        }else if(p.compareDocumentPosition) {
-            return !!(p.compareDocumentPosition(c) & 16);
-        }else{
-            var parent = c.parentNode;
-            while (parent) {
-                if (parent == p) {
-                    return true;
+        if (p && c) {
+            if (p.contains) {
+                return p.contains(c);
+            } else if (p.compareDocumentPosition) {
+                return !!(p.compareDocumentPosition(c) & 16);
+            } else {
+                while (c = c.parentNode) {
+                    ret = c == p || ret;
                 }
                 }
-                else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
-                    return false;
-                }
-                parent = parent.parentNode;
             }
             }
-            return false;
         }
         }
+        return ret;
     },
 
     getRegion : function(el){
     },
 
     getRegion : function(el){
@@ -233,12 +235,17 @@ Ext.lib.Event = {
         var iid = setInterval(f, 50);
     },
 
         var iid = setInterval(f, 50);
     },
 
-    resolveTextNode: function(node) {
-        if (node && 3 == node.nodeType) {
-            return node.parentNode;
-        } else {
-            return node;
+    resolveTextNode: Ext.isGecko ? function(node){
+        if(!node){
+            return;
+        }
+        var s = HTMLElement.prototype.toString.call(node);
+        if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
+            return;
         }
         }
+        return node.nodeType == 3 ? node.parentNode : node;
+    } : function(node){
+        return node && node.nodeType == 3 ? node.parentNode : node;
     },
 
     getRelatedTarget: function(ev) {
     },
 
     getRelatedTarget: function(ev) {
@@ -260,20 +267,43 @@ Ext.lib.Ajax = function(){
     var createComplete = function(cb){
          return function(xhr, status){
             if((status == 'error' || status == 'timeout') && cb.failure){
     var createComplete = function(cb){
          return function(xhr, status){
             if((status == 'error' || status == 'timeout') && cb.failure){
-                cb.failure.call(cb.scope||window, {
-                    responseText: xhr.responseText,
-                    responseXML : xhr.responseXML,
-                    argument: cb.argument
-                });
+                cb.failure.call(cb.scope||window, createResponse(cb, xhr));
             }else if(cb.success){
             }else if(cb.success){
-                cb.success.call(cb.scope||window, {
-                    responseText: xhr.responseText,
-                    responseXML : xhr.responseXML,
-                    argument: cb.argument
-                });
+                cb.success.call(cb.scope||window, createResponse(cb, xhr));
             }
          };
     };
             }
          };
     };
+
+    var createResponse = function(cb, xhr){
+        var headerObj = {},
+            headerStr,
+            t,
+            s;
+
+        try {
+            headerStr = xhr.getAllResponseHeaders();
+            Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
+                t = v.indexOf(':');
+                if(t >= 0){
+                    s = v.substr(0, t).toLowerCase();
+                    if(v.charAt(t + 1) == ' '){
+                        ++t;
+                    }
+                    headerObj[s] = v.substr(t + 1);
+                }
+            });
+        } catch(e) {}
+
+        return {
+            responseText: xhr.responseText,
+            responseXML : xhr.responseXML,
+            argument: cb.argument,
+            status: xhr.status,
+            statusText: xhr.statusText,
+            getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
+            getAllResponseHeaders : function(){return headerStr}
+        };
+    };
     return {
         request : function(method, uri, cb, data, options){
             var o = {
     return {
         request : function(method, uri, cb, data, options){
             var o = {
@@ -433,6 +463,12 @@ Ext.lib.Anim = function(){
                         if (args.top.from)
                             e.setTop(args.top.from);
                     break;
                         if (args.top.from)
                             e.setTop(args.top.from);
                     break;
+                        // jQuery can't handle callback, scope, and xy arguments, so break here
+                    case 'callback':
+                    case 'scope':
+                    case 'xy':
+                    break;
+
                     default:
                         o[k] = args[k].to;
                         if (args[k].from)
                     default:
                         o[k] = args[k].to;
                         if (args[k].from)
@@ -544,6 +580,6 @@ if(Ext.isIE) {
     }
     window.attachEvent("onunload", fnCleanUp);
 }
     }
     window.attachEvent("onunload", fnCleanUp);
 }
-})();</pre>    \r
-</body>\r
+})();</pre>    
+</body>
 </html>
\ No newline at end of file
 </html>
\ No newline at end of file