1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-07-17 01:32:30 +02:00
Files
Sonarr/UI/Mixins/jquery.ajax.js

32 lines
858 B
JavaScript
Raw Normal View History

2013-02-22 00:56:46 -05:00
//try to add ajax data as query string to DELETE calls.
2013-06-21 23:24:24 -07:00
'use strict';
2013-06-20 22:35:56 -07:00
define(function () {
2013-02-15 15:38:53 -08:00
2013-06-20 22:35:56 -07:00
return function () {
2013-02-15 15:38:53 -08:00
2013-06-20 22:35:56 -07:00
var original = this.ajax;
this.ajax = function () {
2013-02-15 15:38:53 -08:00
2013-06-20 22:35:56 -07:00
var xhr = arguments[0];
2013-02-15 15:38:53 -08:00
2013-06-20 22:35:56 -07:00
//check if ajax call was made with data option
if (xhr && xhr.data && xhr.type === 'DELETE') {
2013-09-11 14:38:35 -07:00
if (!xhr.url.contains('?')) {
2013-06-20 22:35:56 -07:00
xhr.url = xhr.url + '?' + $.param(xhr.data);
}
else {
xhr.url = xhr.url + '&' + $.param(xhr.data);
}
delete xhr.data;
2013-02-15 15:38:53 -08:00
}
2013-09-20 00:31:02 -07:00
if (xhr) {
2013-09-20 15:19:48 -07:00
xhr.headers = xhr.headers || {};
xhr.headers['Authorization'] = window.NzbDrone.ApiKey;
2013-09-20 00:31:02 -07:00
}
2013-02-15 15:38:53 -08:00
2013-06-20 22:35:56 -07:00
return original.apply(this, arguments);
};
2013-02-15 15:38:53 -08:00
};
});