couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1071191 - /couchdb/branches/1.1.x/share/www/script/jquery.couch.js
Date Wed, 16 Feb 2011 09:44:01 GMT
Author: rnewson
Date: Wed Feb 16 09:44:00 2011
New Revision: 1071191

URL: http://svn.apache.org/viewvc?rev=1071191&view=rev
Log:
Make compatible with jQuery 1.5.x

Modified:
    couchdb/branches/1.1.x/share/www/script/jquery.couch.js

Modified: couchdb/branches/1.1.x/share/www/script/jquery.couch.js
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/share/www/script/jquery.couch.js?rev=1071191&r1=1071190&r2=1071191&view=diff
==============================================================================
--- couchdb/branches/1.1.x/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/branches/1.1.x/share/www/script/jquery.couch.js [utf-8] Wed Feb 16 09:44:00 2011
@@ -91,7 +91,7 @@
             xhr.setRequestHeader('Accept', 'application/json');
         },
         complete: function(req) {
-          var resp = $.httpData(req, "json");
+          var resp = httpData(req, "json");
           if (req.status == 200) {
             if (options.success) options.success(resp);
           } else if (options.error) {
@@ -130,7 +130,7 @@
             xhr.setRequestHeader('Accept', 'application/json');
         },
         complete: function(req) {
-          var resp = $.httpData(req, "json");
+          var resp = httpData(req, "json");
           if (req.status == 200) {
             if (options.success) options.success(resp);
           } else if (options.error) {
@@ -150,7 +150,7 @@
             xhr.setRequestHeader('Accept', 'application/json');
         },
         complete: function(req) {
-          var resp = $.httpData(req, "json");
+          var resp = httpData(req, "json");
           if (req.status == 200) {
             if (options.success) options.success(resp);
           } else if (options.error) {
@@ -394,7 +394,7 @@
             dataType: "json", data: toJSON(doc),
             beforeSend : beforeSend,
             complete: function(req) {
-              var resp = $.httpData(req, "json");
+              var resp = httpData(req, "json");
               if (req.status == 200 || req.status == 201 || req.status == 202) {
                 doc._id = resp.id;
                 doc._rev = resp.rev;
@@ -459,7 +459,7 @@
         copyDoc: function(docId, options, ajaxOptions) {
           ajaxOptions = $.extend(ajaxOptions, {
             complete: function(req) {
-              var resp = $.httpData(req, "json");
+              var resp = httpData(req, "json");
               if (req.status == 201) {
                 if (options.success) options.success(resp);
               } else if (options.error) {
@@ -602,6 +602,27 @@
     }
   });
 
+  var httpData = $.httpData || function( xhr, type, s ) { // lifted from jq1.4.4
+    var ct = xhr.getResponseHeader("content-type") || "",
+      xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+      data = xml ? xhr.responseXML : xhr.responseText;
+
+    if ( xml && data.documentElement.nodeName === "parsererror" ) {
+      $.error( "parsererror" );
+    }
+    if ( s && s.dataFilter ) {
+      data = s.dataFilter( data, type );
+    }
+    if ( typeof data === "string" ) {
+      if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+        data = $.parseJSON( data );
+      } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0
) {
+        $.globalEval( data );
+      }
+    }
+    return data;
+  };
+
   function ajax(obj, options, errorMessage, ajaxOptions) {
     options = $.extend({successStatus: 200}, options);
     ajaxOptions = $.extend({contentType: "application/json"}, ajaxOptions);
@@ -617,7 +638,7 @@
       },
       complete: function(req) {
         try {
-          var resp = $.httpData(req, "json");
+          var resp = httpData(req, "json");
         } catch(e) {
           if (options.error) {
             options.error(req.status, req, e);



Mime
View raw message