From: Alexander Ebert Date: Sat, 30 May 2015 19:20:07 +0000 (+0200) Subject: Improved API of `Ajax/Request` X-Git-Tag: 3.0.0_Beta_1~2299 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b99935c87b9157f5e701e5e3ee6301e8dc0a3c1a;p=GitHub%2FWoltLab%2FWCF.git Improved API of `Ajax/Request` --- diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js index 7b12064bed..cfd81ba508 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js @@ -154,11 +154,6 @@ define(['Core', 'Language', 'DOM/ChangeListener', 'DOM/Util', 'UI/Dialog', 'Wolt /** * Sets a specific option. * - * Do not call this method, it exists for compatibility with WCF.Action.Proxy - * and will be removed at some point without further notice. - * - * @deprecated 2.2 - * * @param {string} key option name * @param {*} value option value */ @@ -166,6 +161,20 @@ define(['Core', 'Language', 'DOM/ChangeListener', 'DOM/Util', 'UI/Dialog', 'Wolt this._options[key] = value; }, + /** + * Returns an option by key or undefined. + * + * @param {string} key option name + * @return {(*|null)} option value or null + */ + getOption: function(key) { + if (this._options.hasOwnProperty(key)) { + return this._options[key]; + } + + return null; + }, + /** * Sets request data while honoring pinned data from setup callback. * @@ -198,18 +207,18 @@ define(['Core', 'Language', 'DOM/ChangeListener', 'DOM/Util', 'UI/Dialog', 'Wolt } catch (e) { // invalid JSON - this._failure(xhr); + this._failure(xhr, options); return; } // trim HTML before processing, see http://jquery.com/upgrade-guide/1.9/#jquery-htmlstring-versus-jquery-selectorstring - if (data.returnValues !== undefined && data.returnValues.template !== undefined) { + if (data.returnValues && data.returnValues.template !== undefined) { data.returnValues.template = data.returnValues.template.trim(); } } - options.success(data, xhr.responseText, xhr); + options.success(data, xhr.responseText, xhr, options.data); } this._finalize(options); @@ -239,7 +248,7 @@ define(['Core', 'Language', 'DOM/ChangeListener', 'DOM/Util', 'UI/Dialog', 'Wolt var showError = true; if (typeof options.failure === 'function') { - showError = options.failure(data, xhr); + showError = options.failure(data, xhr.responseText, xhr, options.data); } if (options.ignoreError !== true && showError !== false) {