loader.js (icingaweb2-2.11.3) | : | loader.js (icingaweb2-2.11.4) | ||
---|---|---|---|---|
skipping to change at line 132 | skipping to change at line 132 | |||
name: $button.attr('name'), | name: $button.attr('name'), | |||
value: $button.attr('value') | value: $button.attr('value') | |||
}); | }); | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
// Disable all form controls to prevent resubmission except for our search input | // Disable all form controls to prevent resubmission except for our search input | |||
// Note that disabled form inputs will not be enabled via JavaScript again | // Note that disabled form inputs will not be enabled via JavaScript again | |||
if (! $form.is('[role="search"]') && $target.attr('id') === $form.cl | if (! $autoSubmittedBy | |||
osest('.container').attr('id')) { | && ! $form.is('[role="search"]') | |||
$form.find('input:not(:disabled)').prop('disabled', true); | && $target.attr('id') === $form.closest('.container').attr('id') | |||
) { | ||||
$form.find('input[type=submit],button[type=submit],button:not([t | ||||
ype])').prop('disabled', true); | ||||
} | } | |||
// Show a spinner depending on how the form is being submitted | // Show a spinner depending on how the form is being submitted | |||
if ($autoSubmittedBy && $autoSubmittedBy.siblings('.spinner').length ) { | if ($autoSubmittedBy && $autoSubmittedBy.siblings('.spinner').length ) { | |||
$autoSubmittedBy.siblings('.spinner').first().addClass('active') ; | $autoSubmittedBy.siblings('.spinner').first().addClass('active') ; | |||
} else if ($button.length && $button.is('button') && $button.hasClas s('animated')) { | } else if ($button.length && $button.is('button') && $button.hasClas s('animated')) { | |||
$button.addClass('active'); | $button.addClass('active'); | |||
} else if ($button.length && $button.attr('data-progress-label')) { | } else if ($button.length && $button.attr('data-progress-label')) { | |||
var isInput = $button.is('input'); | var isInput = $button.is('input'); | |||
if (isInput) { | if (isInput) { | |||
skipping to change at line 184 | skipping to change at line 187 | |||
var $progressElement = $('#' + $form.attr('data-progress-element ')); | var $progressElement = $('#' + $form.attr('data-progress-element ')); | |||
if ($progressElement.length) { | if ($progressElement.length) { | |||
if ($progressElement.hasClass('spinner')) { | if ($progressElement.hasClass('spinner')) { | |||
$('i', $progressElement).addClass('active'); | $('i', $progressElement).addClass('active'); | |||
} else { | } else { | |||
$('i.spinner', $progressElement).addClass('active'); | $('i.spinner', $progressElement).addClass('active'); | |||
} | } | |||
} | } | |||
} | } | |||
var req = this.loadUrl(url, $target, data, method); | var extraHeaders = {}; | |||
if ($autoSubmittedBy && ($autoSubmittedBy.attr('name') || $autoSubmi | ||||
ttedBy.attr('id'))) { | ||||
extraHeaders['X-Icinga-AutoSubmittedBy'] = $autoSubmittedBy.attr | ||||
('name') || $autoSubmittedBy.attr('id'); | ||||
} | ||||
var req = this.loadUrl(url, $target, data, method, undefined, undefi | ||||
ned, undefined, extraHeaders); | ||||
req.forceFocus = $autoSubmittedBy ? $autoSubmittedBy : $button.lengt h ? $button : null; | req.forceFocus = $autoSubmittedBy ? $autoSubmittedBy : $button.lengt h ? $button : null; | |||
req.autosubmit = !! $autoSubmittedBy; | req.autosubmit = !! $autoSubmittedBy; | |||
req.addToHistory = method === 'GET'; | req.addToHistory = method === 'GET'; | |||
req.progressTimer = progressTimer; | req.progressTimer = progressTimer; | |||
if ($autoSubmittedBy) { | if ($autoSubmittedBy) { | |||
if ($autoSubmittedBy.closest('.controls').length) { | if ($autoSubmittedBy.closest('.controls').length) { | |||
$('.content', req.$target).addClass('impact'); | $('.content', req.$target).addClass('impact'); | |||
} else { | } else { | |||
req.$target.addClass('impact'); | req.$target.addClass('impact'); | |||
skipping to change at line 211 | skipping to change at line 219 | |||
/** | /** | |||
* Load the given URL to the given target | * Load the given URL to the given target | |||
* | * | |||
* @param {string} url URL to be loaded | * @param {string} url URL to be loaded | |||
* @param {object} target Target jQuery element | * @param {object} target Target jQuery element | |||
* @param {object} data Optional parameters, usually for POS T requests | * @param {object} data Optional parameters, usually for POS T requests | |||
* @param {string} method HTTP method, default is 'GET' | * @param {string} method HTTP method, default is 'GET' | |||
* @param {string} action How to handle the response ('replace ' or 'append'), default is 'replace' | * @param {string} action How to handle the response ('replace ' or 'append'), default is 'replace' | |||
* @param {boolean} autorefresh Whether the cause is a autorefresh o r not | * @param {boolean} autorefresh Whether the cause is a autorefresh o r not | |||
* @param {object} progressTimer A timer to be stopped when the reque st is done | * @param {object} progressTimer A timer to be stopped when the reque st is done | |||
* @param {object} extraHeaders Extra header entries | ||||
*/ | */ | |||
loadUrl: function (url, $target, data, method, action, autorefresh, prog ressTimer) { | loadUrl: function (url, $target, data, method, action, autorefresh, prog ressTimer, extraHeaders) { | |||
var id = null; | var id = null; | |||
// Default method is GET | // Default method is GET | |||
if ('undefined' === typeof method) { | if ('undefined' === typeof method) { | |||
method = 'GET'; | method = 'GET'; | |||
} | } | |||
if ('undefined' === typeof action) { | if ('undefined' === typeof action) { | |||
action = 'replace'; | action = 'replace'; | |||
} | } | |||
if ('undefined' === typeof autorefresh) { | if ('undefined' === typeof autorefresh) { | |||
skipping to change at line 280 | skipping to change at line 289 | |||
var windowId = this.icinga.ui.getWindowId(); | var windowId = this.icinga.ui.getWindowId(); | |||
var containerId = this.icinga.ui.getUniqueContainerId($target); | var containerId = this.icinga.ui.getUniqueContainerId($target); | |||
if (containerId) { | if (containerId) { | |||
windowId = windowId + '_' + containerId; | windowId = windowId + '_' + containerId; | |||
} | } | |||
headers['X-Icinga-WindowId'] = windowId; | headers['X-Icinga-WindowId'] = windowId; | |||
} else { | } else { | |||
headers['X-Icinga-WindowId'] = 'undefined'; | headers['X-Icinga-WindowId'] = 'undefined'; | |||
} | } | |||
if (typeof extraHeaders !== 'undefined') { | ||||
headers = $.extend(headers, extraHeaders); | ||||
} | ||||
// This is jQuery's default content type | // This is jQuery's default content type | |||
var contentType = 'application/x-www-form-urlencoded; charset=UTF-8' ; | var contentType = 'application/x-www-form-urlencoded; charset=UTF-8' ; | |||
var isFormData = typeof window.FormData !== 'undefined' && data inst anceof window.FormData; | var isFormData = typeof window.FormData !== 'undefined' && data inst anceof window.FormData; | |||
if (isFormData) { | if (isFormData) { | |||
// Setting false is mandatory as the form's data | // Setting false is mandatory as the form's data | |||
// won't be recognized by the server otherwise | // won't be recognized by the server otherwise | |||
contentType = false; | contentType = false; | |||
} | } | |||
End of changes. 5 change blocks. | ||||
5 lines changed or deleted | 21 lines changed or added |