aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js')
-rw-r--r--vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js66
1 files changed, 30 insertions, 36 deletions
diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js b/vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js
index 3e3b9a93b..b56690bea 100644
--- a/vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js
+++ b/vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js
@@ -11,7 +11,7 @@
/* global define, require */
-(function (factory) {
+(function(factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
@@ -23,7 +23,7 @@
// Browser globals:
factory(window.jQuery);
}
-})(function ($) {
+})(function($) {
'use strict';
// Helper variable to create unique names for the transport iframes:
@@ -46,7 +46,7 @@
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
// options.initialIframeSrc: the URL of the initial iframe src,
// by default set to "javascript:false;"
- $.ajaxTransport('iframe', function (options) {
+ $.ajaxTransport('iframe', function(options) {
if (options.async) {
// javascript:false as initial iframe src
// prevents warning popups on HTTPS in IE6:
@@ -56,7 +56,7 @@
iframe,
addParamChar;
return {
- send: function (_, completeCallback) {
+ send: function(_, completeCallback) {
form = $('<form style="display:none;"></form>');
form.attr('accept-charset', options.formAcceptCharset);
addParamChar = /\?/.test(options.url) ? '&' : '?';
@@ -81,12 +81,12 @@
'" name="iframe-transport-' +
counter +
'"></iframe>'
- ).on('load', function () {
+ ).bind('load', function() {
var fileInputClones,
paramNames = $.isArray(options.paramName)
? options.paramName
: [options.paramName];
- iframe.off('load').on('load', function () {
+ iframe.unbind('load').bind('load', function() {
var response;
// Wrap in a try/catch block to catch exceptions thrown
// when trying to access cross-domain iframe contents:
@@ -109,7 +109,7 @@
$('<iframe src="' + initialIframeSrc + '"></iframe>').appendTo(
form
);
- window.setTimeout(function () {
+ window.setTimeout(function() {
// Removing the form in a setTimeout call
// allows Chrome's developer tools to display
// the response result
@@ -121,7 +121,7 @@
.prop('action', options.url)
.prop('method', options.type);
if (options.formData) {
- $.each(options.formData, function (index, field) {
+ $.each(options.formData, function(index, field) {
$('<input type="hidden"/>')
.prop('name', field.name)
.val(field.value)
@@ -135,11 +135,11 @@
) {
fileInputClones = options.fileInput.clone();
// Insert a clone for each file input field:
- options.fileInput.after(function (index) {
+ options.fileInput.after(function(index) {
return fileInputClones[index];
});
if (options.paramName) {
- options.fileInput.each(function (index) {
+ options.fileInput.each(function(index) {
$(this).prop('name', paramNames[index] || options.paramName);
});
}
@@ -153,33 +153,27 @@
// Remove the HTML5 form attribute from the input(s):
options.fileInput.removeAttr('form');
}
- window.setTimeout(function () {
- // Submitting the form in a setTimeout call fixes an issue with
- // Safari 13 not triggering the iframe load event after resetting
- // the load event handler, see also:
- // https://github.com/blueimp/jQuery-File-Upload/issues/3633
- form.submit();
- // Insert the file input fields at their original location
- // by replacing the clones with the originals:
- if (fileInputClones && fileInputClones.length) {
- options.fileInput.each(function (index, input) {
- var clone = $(fileInputClones[index]);
- // Restore the original name and form properties:
- $(input)
- .prop('name', clone.prop('name'))
- .attr('form', clone.attr('form'));
- clone.replaceWith(input);
- });
- }
- }, 0);
+ form.submit();
+ // Insert the file input fields at their original location
+ // by replacing the clones with the originals:
+ if (fileInputClones && fileInputClones.length) {
+ options.fileInput.each(function(index, input) {
+ var clone = $(fileInputClones[index]);
+ // Restore the original name and form properties:
+ $(input)
+ .prop('name', clone.prop('name'))
+ .attr('form', clone.attr('form'));
+ clone.replaceWith(input);
+ });
+ }
});
form.append(iframe).appendTo(document.body);
},
- abort: function () {
+ abort: function() {
if (iframe) {
// javascript:false as iframe src aborts the request
// and prevents warning popups on HTTPS in IE6.
- iframe.off('load').prop('src', initialIframeSrc);
+ iframe.unbind('load').prop('src', initialIframeSrc);
}
if (form) {
form.remove();
@@ -201,16 +195,16 @@
// https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
$.ajaxSetup({
converters: {
- 'iframe text': function (iframe) {
+ 'iframe text': function(iframe) {
return iframe && $(iframe[0].body).text();
},
- 'iframe json': function (iframe) {
+ 'iframe json': function(iframe) {
return iframe && jsonAPI[jsonParse]($(iframe[0].body).text());
},
- 'iframe html': function (iframe) {
+ 'iframe html': function(iframe) {
return iframe && $(iframe[0].body).html();
},
- 'iframe xml': function (iframe) {
+ 'iframe xml': function(iframe) {
var xmlDoc = iframe && iframe[0];
return xmlDoc && $.isXMLDoc(xmlDoc)
? xmlDoc
@@ -219,7 +213,7 @@
$(xmlDoc.body).html()
);
},
- 'iframe script': function (iframe) {
+ 'iframe script': function(iframe) {
return iframe && $.globalEval($(iframe[0].body).text());
}
}