loader.js: Keep using the promise interface for complete callbacks

This commit is contained in:
Johannes Meyer 2019-07-15 11:29:03 +02:00
parent 5cf71c9bbd
commit 6323a065ea
1 changed files with 11 additions and 3 deletions

View File

@ -135,14 +135,14 @@
headers: headers,
context: _this,
contentType: contentType,
processData: ! isFormData,
complete: this.onComplete
processData: ! isFormData
});
req.$target = $target;
req.url = url;
req.done(this.onResponse);
req.fail(this.onFailure);
req.always(this.onComplete);
req.autorefresh = autorefresh;
req.method = method;
req.action = action;
@ -590,7 +590,15 @@
/**
* Regardless of whether a request succeeded of failed, clean up
*/
onComplete: function (req, textStatus) {
onComplete: function (dataOrReq, textStatus, reqOrError) {
var req;
if (typeof dataOrReq === 'object') {
req = dataOrReq;
} else {
req = reqOrError;
}
// Remove 'impact' class if there was such
if (req.$target.hasClass('impact')) {
req.$target.removeClass('impact');