From: Matthias Schmidt Date: Wed, 23 Sep 2015 16:09:47 +0000 (+0200) Subject: Add progress and upload progress callbacks for AjaxRequest X-Git-Tag: 3.0.0_Beta_1~2122 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=500102c20767d48e7a40949ec9a5aab12ea1efdf;p=GitHub%2FWoltLab%2FWCF.git Add progress and upload progress callbacks for AjaxRequest --- 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') {