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

View File

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