annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /*
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
2 * jQuery Iframe Transport Plugin 1.7
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * https://github.com/blueimp/jQuery-File-Upload
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright 2011, Sebastian Tschan
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * https://blueimp.net
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * Licensed under the MIT license:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * http://www.opensource.org/licenses/MIT
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 /*jslint unparam: true, nomen: true */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 /*global define, window, document */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 (function (factory) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 'use strict';
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 if (typeof define === 'function' && define.amd) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 // Register as an anonymous AMD module:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 define(['jquery'], factory);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 } else {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 // Browser globals:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 factory(window.jQuery);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 }(function ($) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 'use strict';
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 // Helper variable to create unique names for the transport iframes:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 var counter = 0;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 // The iframe transport accepts three additional options:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 // options.fileInput: a jQuery collection of file input fields
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 // options.paramName: the parameter name for the file form data,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 // overrides the name property of the file input field(s),
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 // can be a string or an array of strings.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 // options.formData: an array of objects with name and value properties,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 // equivalent to the return data of .serializeArray(), e.g.:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 // [{name: 'a', value: 1}, {name: 'b', value: 2}]
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 $.ajaxTransport('iframe', function (options) {
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
39 if (options.async) {
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 var form,
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
41 iframe,
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
42 addParamChar;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 return {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 send: function (_, completeCallback) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 form = $('<form style="display:none;"></form>');
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
46 form.attr('accept-charset', options.formAcceptCharset);
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
47 addParamChar = /\?/.test(options.url) ? '&' : '?';
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
48 // XDomainRequest only supports GET and POST:
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
49 if (options.type === 'DELETE') {
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
50 options.url = options.url + addParamChar + '_method=DELETE';
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
51 options.type = 'POST';
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
52 } else if (options.type === 'PUT') {
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
53 options.url = options.url + addParamChar + '_method=PUT';
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
54 options.type = 'POST';
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
55 } else if (options.type === 'PATCH') {
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
56 options.url = options.url + addParamChar + '_method=PATCH';
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
57 options.type = 'POST';
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
58 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 // javascript:false as initial iframe src
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 // prevents warning popups on HTTPS in IE6.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 // IE versions below IE8 cannot set the name property of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 // elements that have already been added to the DOM,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 // so we set the name along with the iframe HTML markup:
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
64 counter += 1;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 iframe = $(
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 '<iframe src="javascript:false;" name="iframe-transport-' +
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
67 counter + '"></iframe>'
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 ).bind('load', function () {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 var fileInputClones,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 paramNames = $.isArray(options.paramName) ?
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 options.paramName : [options.paramName];
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 iframe
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 .unbind('load')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 .bind('load', function () {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 var response;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 // Wrap in a try/catch block to catch exceptions thrown
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 // when trying to access cross-domain iframe contents:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 try {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 response = iframe.contents();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 // Google Chrome and Firefox do not throw an
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 // exception when calling iframe.contents() on
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 // cross-domain requests, so we unify the response:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 if (!response.length || !response[0].firstChild) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 throw new Error();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 } catch (e) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 response = undefined;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 // The complete callback returns the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 // iframe content document as response object:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 completeCallback(
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 200,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 'success',
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {'iframe': response}
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 );
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 // Fix for IE endless progress bar activity bug
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 // (happens on form submits to iframe targets):
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 $('<iframe src="javascript:false;"></iframe>')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 .appendTo(form);
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
100 window.setTimeout(function () {
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
101 // Removing the form in a setTimeout call
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
102 // allows Chrome's developer tools to display
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
103 // the response result
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
104 form.remove();
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
105 }, 0);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 form
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 .prop('target', iframe.prop('name'))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 .prop('action', options.url)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 .prop('method', options.type);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 if (options.formData) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 $.each(options.formData, function (index, field) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 $('<input type="hidden"/>')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 .prop('name', field.name)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 .val(field.value)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 .appendTo(form);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 if (options.fileInput && options.fileInput.length &&
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 options.type === 'POST') {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 fileInputClones = options.fileInput.clone();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 // Insert a clone for each file input field:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 options.fileInput.after(function (index) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 return fileInputClones[index];
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 if (options.paramName) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 options.fileInput.each(function (index) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 $(this).prop(
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 'name',
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 paramNames[index] || options.paramName
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 );
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 // Appending the file input fields to the hidden form
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 // removes them from their original location:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 form
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 .append(options.fileInput)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 .prop('enctype', 'multipart/form-data')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 // enctype must be set as encoding for IE:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 .prop('encoding', 'multipart/form-data');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 form.submit();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 // Insert the file input fields at their original location
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 // by replacing the clones with the originals:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 if (fileInputClones && fileInputClones.length) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 options.fileInput.each(function (index, input) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 var clone = $(fileInputClones[index]);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 $(input).prop('name', clone.prop('name'));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 clone.replaceWith(input);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 form.append(iframe).appendTo(document.body);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 },
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 abort: function () {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 if (iframe) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 // javascript:false as iframe src aborts the request
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 // and prevents warning popups on HTTPS in IE6.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 // concat is used to avoid the "Script URL" JSLint error:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 iframe
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 .unbind('load')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 .prop('src', 'javascript'.concat(':false;'));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 if (form) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 form.remove();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 // The iframe transport returns the iframe content document as response.
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
173 // The following adds converters from iframe to text, json, html, xml
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
174 // and script.
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
175 // Please note that the Content-Type for JSON responses has to be text/plain
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
176 // or text/html, if the browser doesn't include application/json in the
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
177 // Accept header, else IE will show a download dialog.
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
178 // The Content-Type for XML responses on the other hand has to be always
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
179 // application/xml or text/xml, so IE properly parses the XML response.
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
180 // See also
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
181 // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 $.ajaxSetup({
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 converters: {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 'iframe text': function (iframe) {
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
185 return iframe && $(iframe[0].body).text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 },
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 'iframe json': function (iframe) {
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
188 return iframe && $.parseJSON($(iframe[0].body).text());
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 },
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 'iframe html': function (iframe) {
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
191 return iframe && $(iframe[0].body).html();
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
192 },
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
193 'iframe xml': function (iframe) {
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
194 var xmlDoc = iframe && iframe[0];
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
195 return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc :
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
196 $.parseXML((xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) ||
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
197 $(xmlDoc.body).html());
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 },
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 'iframe script': function (iframe) {
3066
5713952f60c0 upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
am@osimis.io
parents: 57
diff changeset
200 return iframe && $.globalEval($(iframe[0].body).text());
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 }));