diff options
author | telis94 <dossas07@hotmail.com> | 2014-03-11 15:15:48 +0400 |
---|---|---|
committer | Alexander Shorin <kxepal@apache.org> | 2014-03-11 15:17:39 +0400 |
commit | e7548b2e51ffed71b8a770207a5dd33d7ed49049 (patch) | |
tree | 90e249bab7a5e2ebabba59b95d3c8a75587d0595 | |
parent | fffc5b73d6714076b60ff5a2434d4bfaa8264183 (diff) | |
download | couchdb-e7548b2e51ffed71b8a770207a5dd33d7ed49049.tar.gz |
Add deferred support to jquery.couch.js
COUCHDB-1036 COUCHDB-1180
This closes #169
Signed-off-by: Alexander Shorin <kxepal@apache.org>
-rw-r--r-- | share/www/script/jquery.couch.js | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js index e78b67e91..facaf9ca1 100644 --- a/share/www/script/jquery.couch.js +++ b/share/www/script/jquery.couch.js @@ -70,7 +70,7 @@ * /#jQuery-ajax-settings">jQuery ajax settings</a> */ activeTasks: function(options) { - ajax( + return ajax( {url: this.urlPrefix + "/_active_tasks"}, options, "Active task status could not be retrieved" @@ -85,7 +85,7 @@ * /#jQuery-ajax-settings">jQuery ajax settings</a> */ allDbs: function(options) { - ajax( + return ajax( {url: this.urlPrefix + "/_all_dbs"}, options, "An error occurred retrieving the list of all databases" @@ -123,7 +123,7 @@ req.processData = false } - ajax(req, options, + return ajax(req, options, "An error occurred retrieving/updating the server configuration" ); }, @@ -138,7 +138,7 @@ */ session: function(options) { options = options || {}; - ajax({ + return ajax({ type: "GET", url: this.urlPrefix + "/_session", beforeSend: function(xhr) { xhr.setRequestHeader('Accept', 'application/json'); @@ -203,7 +203,7 @@ */ login: function(options) { options = options || {}; - $.ajax({ + return $.ajax({ type: "POST", url: this.urlPrefix + "/_session", dataType: "json", data: {name: options.name, password: options.password}, beforeSend: function(xhr) { @@ -233,7 +233,7 @@ */ logout: function(options) { options = options || {}; - $.ajax({ + return $.ajax({ type: "DELETE", url: this.urlPrefix + "/_session", dataType: "json", username : "_", password : "_", beforeSend: function(xhr) { @@ -296,7 +296,7 @@ */ compact: function(options) { $.extend(options, {successStatus: 202}); - ajax({ + return ajax({ type: "POST", url: this.uri + "_compact", data: "", processData: false }, @@ -314,7 +314,7 @@ */ viewCleanup: function(options) { $.extend(options, {successStatus: 202}); - ajax({ + return ajax({ type: "POST", url: this.uri + "_view_cleanup", data: "", processData: false }, @@ -337,7 +337,7 @@ */ compactView: function(groupname, options) { $.extend(options, {successStatus: 202}); - ajax({ + return ajax({ type: "POST", url: this.uri + "_compact/" + groupname, data: "", processData: false }, @@ -355,7 +355,7 @@ */ create: function(options) { $.extend(options, {successStatus: 201}); - ajax({ + return ajax({ type: "PUT", url: this.uri, contentType: "application/json", data: "", processData: false }, @@ -373,7 +373,7 @@ * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a> */ drop: function(options) { - ajax( + return ajax( {type: "DELETE", url: this.uri}, options, "The database could not be deleted" @@ -388,7 +388,7 @@ * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a> */ info: function(options) { - ajax( + return ajax( {url: this.uri}, options, "Database information could not be retrieved" @@ -501,7 +501,7 @@ delete options["keys"]; data = toJSON({ "keys": keys }); } - ajax({ + return ajax({ type: type, data: data, url: this.uri + "_all_docs" + encodeOptions(options) @@ -517,7 +517,7 @@ * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a> */ allDesignDocs: function(options) { - this.allDocs($.extend( + return this.allDocs($.extend( {startkey:"_design", endkey:"_design0"}, options)); }, @@ -532,7 +532,7 @@ options = options || {}; var self = this; if (options.eachApp) { - this.allDesignDocs({ + return this.allDesignDocs({ success: function(resp) { $.each(resp.rows, function() { self.openDoc(this.id, { @@ -591,7 +591,8 @@ } }); } - ajax({url: this.uri + encodeDocId(docId) + encodeOptions(options)}, + return ajax( + {url: this.uri + encodeDocId(docId) + encodeOptions(options)}, options, "The document could not be retrieved", ajaxOptions @@ -622,7 +623,7 @@ var uri = this.uri + encodeDocId(doc._id); } var versioned = maybeApplyVersion(doc); - $.ajax({ + return $.ajax({ type: method, url: uri + encodeOptions(options), contentType: "application/json", dataType: "json", data: toJSON(doc), @@ -663,7 +664,7 @@ bulkSave: function(docs, options) { var beforeSend = fullCommit(options); $.extend(options, {successStatus: 201, beforeSend : beforeSend}); - ajax({ + return ajax({ type: "POST", url: this.uri + "_bulk_docs" + encodeOptions(options), contentType: "application/json", data: toJSON(docs) @@ -684,7 +685,7 @@ * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a> */ removeDoc: function(doc, options) { - ajax({ + return ajax({ type: "DELETE", url: this.uri + encodeDocId(doc._id) + @@ -710,7 +711,7 @@ } ); $.extend(options, {successStatus: 201}); - ajax({ + return ajax({ type: "POST", url: this.uri + "_bulk_docs" + encodeOptions(options), data: toJSON(docs) @@ -744,7 +745,7 @@ } } }); - ajax({ + return ajax({ type: "COPY", url: this.uri + encodeDocId(docId) }, @@ -779,7 +780,7 @@ : "(" + reduceFun.toString() + ")"; body.reduce = reduceFun; } - ajax({ + return ajax({ type: "POST", url: this.uri + "_temp_view" + encodeOptions(options), contentType: "application/json", data: toJSON(body) @@ -814,7 +815,7 @@ delete options['keys']; data = toJSON({'keys': keys }); } - ajax({ + return ajax({ type: type, data: data, url: this.uri + '_design/' + list[0] + @@ -847,7 +848,7 @@ delete options["keys"]; data = toJSON({ "keys": keys }); } - ajax({ + return ajax({ type: type, data: data, url: this.uri + "_design/" + name[0] + @@ -866,7 +867,7 @@ * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a> */ getDbProperty: function(propName, options, ajaxOptions) { - ajax({url: this.uri + propName + encodeOptions(options)}, + return ajax({url: this.uri + propName + encodeOptions(options)}, options, "The property could not be retrieved", ajaxOptions @@ -883,7 +884,7 @@ * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a> */ setDbProperty: function(propName, propValue, options, ajaxOptions) { - ajax({ + return ajax({ type: "PUT", url: this.uri + propName + encodeOptions(options), data : JSON.stringify(propValue) @@ -910,7 +911,7 @@ * jQuery.ajax/#jQuery-ajax-settings">jQuery ajax settings</a> */ info: function(options) { - ajax( + return ajax( {url: this.urlPrefix + "/"}, options, "Server information could not be retrieved" @@ -932,7 +933,7 @@ if (repOpts.continuous && !repOpts.cancel) { ajaxOptions.successStatus = 202; } - ajax({ + return ajax({ type: "POST", url: this.urlPrefix + "/_replicate", data: JSON.stringify(repOpts), contentType: "application/json" |