comparison OrthancExplorer/libs/jquery-file-upload/js/jquery.iframe-transport.js @ 3066:5713952f60c0 update-jquery

upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
author am@osimis.io
date Wed, 26 Dec 2018 16:58:21 +0100
parents 4bc019d2f969
children
comparison
equal deleted inserted replaced
3065:b89a4288d605 3066:5713952f60c0
1 /* 1 /*
2 * jQuery Iframe Transport Plugin 1.4 2 * jQuery Iframe Transport Plugin 1.7
3 * https://github.com/blueimp/jQuery-File-Upload 3 * https://github.com/blueimp/jQuery-File-Upload
4 * 4 *
5 * Copyright 2011, Sebastian Tschan 5 * Copyright 2011, Sebastian Tschan
6 * https://blueimp.net 6 * https://blueimp.net
7 * 7 *
34 // can be a string or an array of strings. 34 // can be a string or an array of strings.
35 // options.formData: an array of objects with name and value properties, 35 // options.formData: an array of objects with name and value properties,
36 // equivalent to the return data of .serializeArray(), e.g.: 36 // equivalent to the return data of .serializeArray(), e.g.:
37 // [{name: 'a', value: 1}, {name: 'b', value: 2}] 37 // [{name: 'a', value: 1}, {name: 'b', value: 2}]
38 $.ajaxTransport('iframe', function (options) { 38 $.ajaxTransport('iframe', function (options) {
39 if (options.async && (options.type === 'POST' || options.type === 'GET')) { 39 if (options.async) {
40 var form, 40 var form,
41 iframe; 41 iframe,
42 addParamChar;
42 return { 43 return {
43 send: function (_, completeCallback) { 44 send: function (_, completeCallback) {
44 form = $('<form style="display:none;"></form>'); 45 form = $('<form style="display:none;"></form>');
46 form.attr('accept-charset', options.formAcceptCharset);
47 addParamChar = /\?/.test(options.url) ? '&' : '?';
48 // XDomainRequest only supports GET and POST:
49 if (options.type === 'DELETE') {
50 options.url = options.url + addParamChar + '_method=DELETE';
51 options.type = 'POST';
52 } else if (options.type === 'PUT') {
53 options.url = options.url + addParamChar + '_method=PUT';
54 options.type = 'POST';
55 } else if (options.type === 'PATCH') {
56 options.url = options.url + addParamChar + '_method=PATCH';
57 options.type = 'POST';
58 }
45 // javascript:false as initial iframe src 59 // javascript:false as initial iframe src
46 // prevents warning popups on HTTPS in IE6. 60 // prevents warning popups on HTTPS in IE6.
47 // IE versions below IE8 cannot set the name property of 61 // IE versions below IE8 cannot set the name property of
48 // elements that have already been added to the DOM, 62 // elements that have already been added to the DOM,
49 // so we set the name along with the iframe HTML markup: 63 // so we set the name along with the iframe HTML markup:
64 counter += 1;
50 iframe = $( 65 iframe = $(
51 '<iframe src="javascript:false;" name="iframe-transport-' + 66 '<iframe src="javascript:false;" name="iframe-transport-' +
52 (counter += 1) + '"></iframe>' 67 counter + '"></iframe>'
53 ).bind('load', function () { 68 ).bind('load', function () {
54 var fileInputClones, 69 var fileInputClones,
55 paramNames = $.isArray(options.paramName) ? 70 paramNames = $.isArray(options.paramName) ?
56 options.paramName : [options.paramName]; 71 options.paramName : [options.paramName];
57 iframe 72 iframe
80 ); 95 );
81 // Fix for IE endless progress bar activity bug 96 // Fix for IE endless progress bar activity bug
82 // (happens on form submits to iframe targets): 97 // (happens on form submits to iframe targets):
83 $('<iframe src="javascript:false;"></iframe>') 98 $('<iframe src="javascript:false;"></iframe>')
84 .appendTo(form); 99 .appendTo(form);
85 form.remove(); 100 window.setTimeout(function () {
101 // Removing the form in a setTimeout call
102 // allows Chrome's developer tools to display
103 // the response result
104 form.remove();
105 }, 0);
86 }); 106 });
87 form 107 form
88 .prop('target', iframe.prop('name')) 108 .prop('target', iframe.prop('name'))
89 .prop('action', options.url) 109 .prop('action', options.url)
90 .prop('method', options.type); 110 .prop('method', options.type);
148 }; 168 };
149 } 169 }
150 }); 170 });
151 171
152 // The iframe transport returns the iframe content document as response. 172 // The iframe transport returns the iframe content document as response.
153 // The following adds converters from iframe to text, json, html, and script: 173 // The following adds converters from iframe to text, json, html, xml
174 // and script.
175 // Please note that the Content-Type for JSON responses has to be text/plain
176 // or text/html, if the browser doesn't include application/json in the
177 // Accept header, else IE will show a download dialog.
178 // The Content-Type for XML responses on the other hand has to be always
179 // application/xml or text/xml, so IE properly parses the XML response.
180 // See also
181 // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
154 $.ajaxSetup({ 182 $.ajaxSetup({
155 converters: { 183 converters: {
156 'iframe text': function (iframe) { 184 'iframe text': function (iframe) {
157 return $(iframe[0].body).text(); 185 return iframe && $(iframe[0].body).text();
158 }, 186 },
159 'iframe json': function (iframe) { 187 'iframe json': function (iframe) {
160 return $.parseJSON($(iframe[0].body).text()); 188 return iframe && $.parseJSON($(iframe[0].body).text());
161 }, 189 },
162 'iframe html': function (iframe) { 190 'iframe html': function (iframe) {
163 return $(iframe[0].body).html(); 191 return iframe && $(iframe[0].body).html();
192 },
193 'iframe xml': function (iframe) {
194 var xmlDoc = iframe && iframe[0];
195 return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc :
196 $.parseXML((xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) ||
197 $(xmlDoc.body).html());
164 }, 198 },
165 'iframe script': function (iframe) { 199 'iframe script': function (iframe) {
166 return $.globalEval($(iframe[0].body).text()); 200 return iframe && $.globalEval($(iframe[0].body).text());
167 } 201 }
168 } 202 }
169 }); 203 });
170 204
171 })); 205 }));