From 5cf71c9bbdfe5212a7339af119bece2c5fa1cc9c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 11 Jul 2019 11:14:08 +0200 Subject: [PATCH] js: Drop iframe-upload fallback for IE --- public/js/icinga/events.js | 29 +---------------------------- public/js/icinga/loader.js | 35 ----------------------------------- 2 files changed, 1 insertion(+), 63 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 3c4f3b9d5..5678b66e4 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -322,33 +322,6 @@ url = icinga.utils.addUrlParams(url, dataObj); } else { 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]); } else { data = $form.serializeArray(); @@ -370,7 +343,7 @@ // Disable all form controls to prevent resubmission except for our search input // 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); } diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 38f3c442c..d48f871fd 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -163,41 +163,6 @@ 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 *