Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1509 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 1509 Revision 1551
Zeile 1... Zeile 1...
1
/*
1
/*
2
 * jQuery Iframe Transport Plugin 1.2.2
2
 * jQuery Iframe Transport Plugin
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
 *
8
 * Licensed under the MIT license:
8
 * Licensed under the MIT license:
9
 * http://creativecommons.org/licenses/MIT/
9
 * https://opensource.org/licenses/MIT
10
 */
10
 */
Zeile 11... Zeile -...
11
 
-
 
12
/*jslint unparam: true */
11
 
Zeile 130... Zeile 98...
130
                        form.remove();
98
                if (!response.length || !response[0].firstChild) {
-
 
99
                  throw new Error();
-
 
100
                }
131
                    }
101
              } catch (e) {
-
 
102
                response = undefined;
-
 
103
              }
-
 
104
              // The complete callback returns the
-
 
105
              // iframe content document as response object:
-
 
106
              completeCallback(200, 'success', { iframe: response });
-
 
107
              // Fix for IE endless progress bar activity bug
132
                }
108
              // (happens on form submits to iframe targets):
133
            };
109
              $('<iframe src="' + initialIframeSrc + '"></iframe>').appendTo(
134
        }
-
 
-
 
110
                form
135
    });
111
              );
136
 
112
              window.setTimeout(function () {
-
 
113
                // Removing the form in a setTimeout call
-
 
114
                // allows Chrome's developer tools to display
-
 
115
                // the response result
137
    // The iframe transport returns the iframe content document as response.
116
                form.remove();
138
    // The following adds converters from iframe to text, json, html, and script:
117
              }, 0);
-
 
118
            });
-
 
119
            form
139
    $.ajaxSetup({
120
              .prop('target', iframe.prop('name'))
-
 
121
              .prop('action', options.url)
-
 
122
              .prop('method', options.type);
-
 
123
            if (options.formData) {
-
 
124
              $.each(options.formData, function (index, field) {
140
        converters: {
125
                $('<input type="hidden"/>')
-
 
126
                  .prop('name', field.name)
-
 
127
                  .val(field.value)
141
            'iframe text': function (iframe) {
128
                  .appendTo(form);
-
 
129
              });
142
                return iframe.text();
130
            }
143
            },
131
            if (
-
 
132
              options.fileInput &&
144
            'iframe json': function (iframe) {
133
              options.fileInput.length &&
-
 
134
              options.type === 'POST'
-
 
135
            ) {
145
                return $.parseJSON(iframe.text());
136
              fileInputClones = options.fileInput.clone();
146
            },
137
              // Insert a clone for each file input field:
147
            'iframe html': function (iframe) {
138
              options.fileInput.after(function (index) {
-
 
139
                return fileInputClones[index];
148
                return iframe.find('body').html();
140
              });
-
 
141
              if (options.paramName) {
-
 
142
                options.fileInput.each(function (index) {
-
 
143
                  $(this).prop('name', paramNames[index] || options.paramName);
-
 
144
                });
-
 
145
              }
-
 
146
              // Appending the file input fields to the hidden form
-
 
147
              // removes them from their original location:
-
 
148
              form
-
 
149
                .append(options.fileInput)
149
            },
150
                .prop('enctype', 'multipart/form-data')
-
 
151
                // enctype must be set as encoding for IE:
-
 
152
                .prop('encoding', 'multipart/form-data');
150
            'iframe script': function (iframe) {
153
              // Remove the HTML5 form attribute from the input(s):
-
 
154
              options.fileInput.removeAttr('form');
-
 
155
            }
-
 
156
            window.setTimeout(function () {
-
 
157
              // Submitting the form in a setTimeout call fixes an issue with
-
 
158
              // Safari 13 not triggering the iframe load event after resetting
-
 
159
              // the load event handler, see also:
-
 
160
              // https://github.com/blueimp/jQuery-File-Upload/issues/3633
-
 
161
              form.submit();
-
 
162
              // Insert the file input fields at their original location
-
 
163
              // by replacing the clones with the originals:
-
 
164
              if (fileInputClones && fileInputClones.length) {
-
 
165
                options.fileInput.each(function (index, input) {
-
 
166
                  var clone = $(fileInputClones[index]);
-
 
167
                  // Restore the original name and form properties:
-
 
168
                  $(input)
-
 
169
                    .prop('name', clone.prop('name'))
-
 
170
                    .attr('form', clone.attr('form'));
-
 
171
                  clone.replaceWith(input);
-
 
172
                });
-
 
173
              }
-
 
174
            }, 0);
-
 
175
          });
-
 
176
          form.append(iframe).appendTo(document.body);
-
 
177
        },
-
 
178
        abort: function () {
-
 
179
          if (iframe) {
-
 
180
            // javascript:false as iframe src aborts the request
-
 
181
            // and prevents warning popups on HTTPS in IE6.
-
 
182
            iframe.off('load').prop('src', initialIframeSrc);
-
 
183
          }
-
 
184
          if (form) {
151
                return $.globalEval(iframe.text());
185
            form.remove();
152
            }
-
 
153
        }
-
 
154
    });
-
 
155
 
186
          }
-
 
187
        }
-
 
188
      };
-
 
189
    }
-
 
190
  });
-
 
191
 
-
 
192
  // The iframe transport returns the iframe content document as response.
-
 
193
  // The following adds converters from iframe to text, json, html, xml
-
 
194
  // and script.
-
 
195
  // Please note that the Content-Type for JSON responses has to be text/plain
-
 
196
  // or text/html, if the browser doesn't include application/json in the
-
 
197
  // Accept header, else IE will show a download dialog.
-
 
198
  // The Content-Type for XML responses on the other hand has to be always
-
 
199
  // application/xml or text/xml, so IE properly parses the XML response.
-
 
200
  // See also
-
 
201
  // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
-
 
202
  $.ajaxSetup({
-
 
203
    converters: {
-
 
204
      'iframe text': function (iframe) {
-
 
205
        return iframe && $(iframe[0].body).text();
-
 
206
      },
-
 
207
      'iframe json': function (iframe) {
-
 
208
        return iframe && jsonAPI[jsonParse]($(iframe[0].body).text());
-
 
209
      },
-
 
210
      'iframe html': function (iframe) {
-
 
211
        return iframe && $(iframe[0].body).html();
-
 
212
      },
-
 
213
      'iframe xml': function (iframe) {
-
 
214
        var xmlDoc = iframe && iframe[0];
-
 
215
        return xmlDoc && $.isXMLDoc(xmlDoc)
-
 
216
          ? xmlDoc
-
 
217
          : $.parseXML(
-
 
218
              (xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) ||
-
 
219
                $(xmlDoc.body).html()
-
 
220
            );
-
 
221
      },
-
 
222
      'iframe script': function (iframe) {
-
 
223
        return iframe && $.globalEval($(iframe[0].body).text());
-
 
224
      }
-
 
225
    }
-
 
226
  });