# HG changeset patch # User Adrien Di Mascio # Date 1276079995 -7200 # Node ID 5c8fa1650299bed7c8bb373b4b178bbc8994b0dc # Parent ec1ce7198ef405c643a05ffa0d4a85d81f0d4a7a [javascript] move Deferred implementation to cubicweb.ajax.js diff -r ec1ce7198ef4 -r 5c8fa1650299 web/data/cubicweb.ajax.js --- a/web/data/cubicweb.ajax.js Wed Jun 09 12:32:54 2010 +0200 +++ b/web/data/cubicweb.ajax.js Wed Jun 09 12:39:55 2010 +0200 @@ -17,8 +17,76 @@ * with CubicWeb. If not, see . */ -CubicWeb.require('python.js'); -CubicWeb.require('htmlhelpers.js'); +/** + * .. function:: Deferred + * + * dummy ultra minimalist implementation on deferred for jQuery + */ +function Deferred() { + this.__init__(this); +} + +jQuery.extend(Deferred.prototype, { + __init__: function() { + this._onSuccess = []; + this._onFailure = []; + this._req = null; + this._result = null; + this._error = null; + }, + + addCallback: function(callback) { + if (this._req.readyState == 4) { + if (this._result) { + var args = [this._result, this._req]; + jQuery.merge(args, cw.utils.sliceList(arguments, 1)); + callback.apply(null, args); + } + } + else { + this._onSuccess.push([callback, cw.utils.sliceList(arguments, 1)]); + } + return this; + }, + + addErrback: function(callback) { + if (this._req.readyState == 4) { + if (this._error) { + callback.apply(null, [this._error, this._req]); + } + } + else { + this._onFailure.push([callback, cw.utils.sliceList(arguments, 1)]); + } + return this; + }, + + success: function(result) { + this._result = result; + try { + for (var i = 0; i < this._onSuccess.length; i++) { + var callback = this._onSuccess[i][0]; + var args = [result, this._req]; + jQuery.merge(args, this._onSuccess[i][1]); + callback.apply(null, args); + } + } catch(error) { + this.error(this.xhr, null, error); + } + }, + + error: function(xhr, status, error) { + this._error = error; + for (var i = 0; i < this._onFailure.length; i++) { + var callback = this._onFailure[i][0]; + var args = [error, this._req]; + jQuery.merge(args, this._onFailure[i][1]); + callback.apply(null, args); + } + } + +}); + var JSON_BASE_URL = baseuri() + 'json?'; diff -r ec1ce7198ef4 -r 5c8fa1650299 web/data/cubicweb.compat.js --- a/web/data/cubicweb.compat.js Wed Jun 09 12:32:54 2010 +0200 +++ b/web/data/cubicweb.compat.js Wed Jun 09 12:39:55 2010 +0200 @@ -104,76 +104,6 @@ ); /** - * .. function:: Deferred - * - * dummy ultra minimalist implementation on deferred for jQuery - */ -function Deferred() { - this.__init__(this); -} - -jQuery.extend(Deferred.prototype, { - __init__: function() { - this._onSuccess = []; - this._onFailure = []; - this._req = null; - this._result = null; - this._error = null; - }, - - addCallback: function(callback) { - if (this._req.readyState == 4) { - if (this._result) { - var args = [this._result, this._req]; - jQuery.merge(args, cw.utils.sliceList(arguments, 1)); - callback.apply(null, args); - } - } - else { - this._onSuccess.push([callback, cw.utils.sliceList(arguments, 1)]); - } - return this; - }, - - addErrback: function(callback) { - if (this._req.readyState == 4) { - if (this._error) { - callback.apply(null, [this._error, this._req]); - } - } - else { - this._onFailure.push([callback, cw.utils.sliceList(arguments, 1)]); - } - return this; - }, - - success: function(result) { - this._result = result; - try { - for (var i = 0; i < this._onSuccess.length; i++) { - var callback = this._onSuccess[i][0]; - var args = [result, this._req]; - jQuery.merge(args, this._onSuccess[i][1]); - callback.apply(null, args); - } - } catch(error) { - this.error(this.xhr, null, error); - } - }, - - error: function(xhr, status, error) { - this._error = error; - for (var i = 0; i < this._onFailure.length; i++) { - var callback = this._onFailure[i][0]; - var args = [error, this._req]; - jQuery.merge(args, this._onFailure[i][1]); - callback.apply(null, args); - } - } - -}); - -/** * The only known usage of KEYS is in the tag cube. Once cubicweb-tag 1.7.0 is out, * this current definition can be removed. */