From 500102c20767d48e7a40949ec9a5aab12ea1efdf Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 23 Sep 2015 18:09:47 +0200 Subject: [PATCH] Add progress and upload progress callbacks for AjaxRequest --- wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js index f329ac1db2..917c5d6986 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js @@ -50,6 +50,8 @@ define(['Core', 'Language', 'Dom/ChangeListener', 'Dom/Util', 'Ui/Dialog', 'Wolt failure: null, finalize: null, success: null, + progress: null, + uploadProgress: null, callbackObject: null }, options); @@ -68,6 +70,8 @@ define(['Core', 'Language', 'Dom/ChangeListener', 'Dom/Util', 'Ui/Dialog', 'Wolt if (typeof this._options.callbackObject._ajaxFailure === 'function') this._options.failure = this._options.callbackObject._ajaxFailure.bind(this._options.callbackObject); if (typeof this._options.callbackObject._ajaxFinalize === 'function') this._options.finalize = this._options.callbackObject._ajaxFinalize.bind(this._options.callbackObject); if (typeof this._options.callbackObject._ajaxSuccess === 'function') this._options.success = this._options.callbackObject._ajaxSuccess.bind(this._options.callbackObject); + if (typeof this._options.callbackObject._ajaxProgress === 'function') this._options.progress = this._options.callbackObject._ajaxProgress.bind(this._options.callbackObject); + if (typeof this._options.callbackObject._ajaxUploadProgress === 'function') this._options.uploadProgress = this._options.callbackObject._ajaxUploadProgress.bind(this._options.callbackObject); } if (_didInit === false) { @@ -124,6 +128,13 @@ define(['Core', 'Language', 'Dom/ChangeListener', 'Dom/Util', 'Ui/Dialog', 'Wolt self._failure(this, options); }; + if (this._options.progress) { + this._xhr.onprogress = this._options.progress; + } + if (this._options.uploadProgress) { + this._xhr.upload.onprogress = this._options.uploadProgress; + } + if (this._options.type === 'POST') { var data = this._options.data; if (typeof data === 'object') { -- 2.20.1