From 5916ac22da8686eebe47cd0f48ba33a601f4a7fb Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 6 Aug 2010 18:22:49 +0000 Subject: [PATCH] Monotone-Parent: 52144e5b0340281632f7e7aadc9ca155bba27c61 Monotone-Revision: e2123af89707f4bc2b9f980dfef0f57731970142 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-08-06T18:22:49 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 +++ UI/WebServerResources/generic.js | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/ChangeLog b/ChangeLog index eb58201d6..b5e489b02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-08-06 Wolfgang Sourdeau + * UI/WebServerResources/generic.js: (AjaxRequestsChain): new class + that implements the chaining of ajax requests. + * UI/WebServerResources/MailerUI.js: (dropAction): ensure that the destination mailbox is in the same mail account as the message being dragged. diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 1ca0491e0..59ee29e3e 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -318,6 +318,44 @@ function triggerAjaxRequest(url, callback, userdata, content, headers) { return http; } +function AjaxRequestsChain(callback, callbackData) { + this.requests = []; + this.counter = 0; + this.callback = callback; + this.callbackData = callbackData; +} + +AjaxRequestsChain.prototype = { + requests: null, + counter: 0, + callback: null, + callbackData: null, + + _step: function ARC__step() { + if (this.counter < this.requests.length) { + var request = this.requests[this.counter]; + this.counter++; + var chain = this; + var origCallback = request[1]; + request[1] = function ARC__step_callback(http) { + if (origCallback) { + http.callback = origCallback; + origCallback.apply(http, [http]); + } + chain._step(); + }; + triggerAjaxRequest.apply(window, request); + } + else { + this.callback.apply(this, [this.callbackData]); + } + }, + + start: function ARC_start() { + this._step(); + } +}; + function startAnimation(parent, nextNode) { var anim = $("progressIndicator"); if (!anim) {