mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
js: Drop iframe-upload fallback for IE
This commit is contained in:
parent
97d5b39662
commit
5cf71c9bbd
@ -322,33 +322,6 @@
|
|||||||
url = icinga.utils.addUrlParams(url, dataObj);
|
url = icinga.utils.addUrlParams(url, dataObj);
|
||||||
} else {
|
} else {
|
||||||
if (encoding === 'multipart/form-data') {
|
if (encoding === 'multipart/form-data') {
|
||||||
if (typeof window.FormData === 'undefined') {
|
|
||||||
icinga.loader.submitFormToIframe($form, url, $target);
|
|
||||||
|
|
||||||
// Disable all form controls to prevent resubmission as early as possible.
|
|
||||||
// (This relies on native form submission, so using setTimeout is the only possible solution)
|
|
||||||
setTimeout(function () {
|
|
||||||
if ($target.attr('id') == $form.closest('.container').attr('id')) {
|
|
||||||
$form.find(':input:not(:disabled)').prop('disabled', true);
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
if (autosubmit) {
|
|
||||||
if ($button.length) {
|
|
||||||
// We're autosubmitting the form so the button has not been clicked, however,
|
|
||||||
// to be really safe, we're disabling the button explicitly, just in case..
|
|
||||||
$button.prop('disabled', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$form[0].submit(); // This should actually not trigger the onSubmit event, let's hope that this is true for all browsers..
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data = new window.FormData($form[0]);
|
data = new window.FormData($form[0]);
|
||||||
} else {
|
} else {
|
||||||
data = $form.serializeArray();
|
data = $form.serializeArray();
|
||||||
@ -370,7 +343,7 @@
|
|||||||
|
|
||||||
// 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 ($target.attr('id') == $form.closest('.container').attr('id')) {
|
if ($target.attr('id') === $form.closest('.container').attr('id')) {
|
||||||
$form.find(':input:not(#search):not(:disabled)').prop('disabled', true);
|
$form.find(':input:not(#search):not(:disabled)').prop('disabled', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,41 +163,6 @@
|
|||||||
return req;
|
return req;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Mimic XHR form submission by using an iframe
|
|
||||||
*
|
|
||||||
* @param {object} $form The form being submitted
|
|
||||||
* @param {string} action The form's action URL
|
|
||||||
* @param {object} $target The target container
|
|
||||||
*/
|
|
||||||
submitFormToIframe: function ($form, action, $target) {
|
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
$form.prop('action', _this.icinga.utils.addUrlParams(action, {
|
|
||||||
'_frameUpload': true
|
|
||||||
}));
|
|
||||||
$form.prop('target', 'fileupload-frame-target');
|
|
||||||
$('#fileupload-frame-target').on('load', function (event) {
|
|
||||||
var $frame = $(event.target);
|
|
||||||
var $contents = $frame.contents();
|
|
||||||
|
|
||||||
var $redirectMeta = $contents.find('meta[name="redirectUrl"]');
|
|
||||||
if ($redirectMeta.length) {
|
|
||||||
_this.redirectToUrl($redirectMeta.attr('content'), $target);
|
|
||||||
} else {
|
|
||||||
// Fetch the frame's new content and paste it into the target
|
|
||||||
_this.renderContentToContainer(
|
|
||||||
$contents.find('body').html(),
|
|
||||||
$target,
|
|
||||||
'replace'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$frame.prop('src', 'about:blank'); // Clear the frame's dom
|
|
||||||
$frame.off('load'); // Unbind the event as it's set on demand
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an URL relative to the Icinga base Url, still unused
|
* Create an URL relative to the Icinga base Url, still unused
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user