Upgrade to ExtJS 3.2.2 - Released 06/02/2010
[extjs.git] / docs / source / prototype-bridge.html
index 77e613d..e094b47 100644 (file)
@@ -1,44 +1,30 @@
-<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">(function(){
+<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.2
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+(function(){
 
 var libFlyweight,
     version = Prototype.Version.split('.'),
     mouseEnterSupported = (parseInt(version[0]) >= 2) || (parseInt(version[1]) >= 7) || (parseInt(version[2]) >= 1),
     mouseCache = {},
-    isXUL = Ext.isGecko ? function(node){ 
-        return Object.prototype.toString.call(node) == '[object XULElement]';
-    } : function(){},
-    isTextNode = Ext.isGecko ? function(node){
-        try{
-            return node.nodeType == 3;
-        }catch(e) {
-            return false;
-        }
-
-    } : function(node){
-        return node.nodeType == 3;
-    },
     elContains = function(parent, child) {
-       if(parent && parent.firstChild){  
+       if(parent && parent.firstChild){
          while(child) {
             if(child === parent) {
                 return true;
             }
-            try {
-                child = child.parentNode;
-            } catch(e) {
-                // In FF if you mouseout an text input element
-                // thats inside a div sometimes it randomly throws
-                // Permission denied to get property HTMLDivElement.parentNode
-                // See https://bugzilla.mozilla.org/show_bug.cgi?id=208427
-                return false;
-            }                
+            child = child.parentNode;
             if(child && (child.nodeType != 1)) {
                 child = null;
             }
@@ -47,8 +33,7 @@ var libFlyweight,
         return false;
     },
     checkRelatedTarget = function(e) {
-        var related = Ext.lib.Event.getRelatedTarget(e);
-        return !(isXUL(related) || elContains(e.currentTarget,related));
+        return !elContains(e.currentTarget, Ext.lib.Event.getRelatedTarget(e));
     };
 
 Ext.lib.Dom = {
@@ -96,27 +81,22 @@ Ext.lib.Dom = {
     },
 
     isAncestor : function(p, c){ // missing from prototype?
+        var ret = false;
+
         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){
@@ -239,8 +219,17 @@ Ext.lib.Event = {
         return Event.element(e.browserEvent || e);
     },
 
-    resolveTextNode: function(node) {
-        return node && !isXUL(node) && isTextNode(node) ? node.parentNode : 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) { // missing from prototype?
@@ -269,7 +258,7 @@ Ext.lib.Event = {
 
     un : function(el, eventName, fn){
         if((eventName == 'mouseenter' || eventName == 'mouseleave') && !mouseEnterSupported){
-            var item = mouseCache[el.id], 
+            var item = mouseCache[el.id],
                 ev = item && item[eventName];
 
             if(ev){
@@ -326,22 +315,44 @@ Ext.lib.Event = {
 Ext.lib.Ajax = function(){
     var createSuccess = function(cb){
          return cb.success ? function(xhr){
-            cb.success.call(cb.scope||window, {
-                responseText: xhr.responseText,
-                responseXML : xhr.responseXML,
-                argument: cb.argument
-            });
+            cb.success.call(cb.scope||window, createResponse(cb, xhr));
          } : Ext.emptyFn;
     };
     var createFailure = function(cb){
          return cb.failure ? function(xhr){
-            cb.failure.call(cb.scope||window, {
-                responseText: xhr.responseText,
-                responseXML : xhr.responseXML,
-                argument: cb.argument
-            });
+            cb.failure.call(cb.scope||window, createResponse(cb, xhr));
          } : Ext.emptyFn;
     };
+    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 = {
@@ -393,7 +404,7 @@ Ext.lib.Ajax = function(){
         abort : function(trans){
             return false;
         },
-        
+
         serializeForm : function(form){
             return Form.serialize(form.dom||form);
         }
@@ -402,7 +413,7 @@ Ext.lib.Ajax = function(){
 
 
 Ext.lib.Anim = function(){
-    
+
     var easings = {
         easeOut: function(pos) {
             return 1-Math.pow(1-pos,2);
@@ -500,7 +511,7 @@ function fly(el){
     libFlyweight.dom = el;
     return libFlyweight;
 }
-    
+
 Ext.lib.Region = function(t, r, b, l) {
     this.top = t;
     this[1] = t;
@@ -598,6 +609,6 @@ if(Ext.isIE) {
     }
     window.attachEvent("onunload", fnCleanUp);
 }
-})();</pre>    \r
-</body>\r
+})();</pre>    
+</body>
 </html>
\ No newline at end of file