{"version":3,"sources":["jquery.iframe-transport.js"],"names":["factory","define","amd","window","jQuery","$","counter","ajaxTransport","options","form","iframe","async","type","send","_","completeCallback","bind","fileInputClones","paramNames","isArray","paramName","unbind","response","contents","length","firstChild","Error","e","undefined","appendTo","remove","prop","url","formData","each","index","field","name","val","value","fileInput","clone","after","this","append","submit","input","replaceWith","document","body","abort","concat","ajaxSetup","converters","iframe text","text","iframe json","parseJSON","iframe html","html","iframe script","globalEval"],"mappings":"CAcC,SAAUA,GACP,aACsB,mBAAXC,QAAyBA,OAAOC,IAEvCD,OAAO,CAAC,UAAWD,GAGnBA,EAAQG,OAAOC,QAPvB,CASG,SAAUC,GACT,aAGA,IAAIC,EAAU,EAUdD,EAAEE,cAAc,SAAU,SAAUC,GAE5B,IAAIC,EACAC,EAFR,GAAIF,EAAQG,QAA2B,SAAjBH,EAAQI,MAAoC,QAAjBJ,EAAQI,MAGrD,MAAO,CACHC,KAAM,SAAUC,EAAGC,GACfN,EAAOJ,EAAE,uCAMTK,EAASL,EACL,2DACKC,GAAW,GAAK,eACvBU,KAAK,OAAQ,WACX,IAAIC,EACAC,EAAab,EAAEc,QAAQX,EAAQY,WACvBZ,EAAQY,UAAY,CAACZ,EAAQY,WACzCV,EACKW,OAAO,QACPL,KAAK,OAAQ,WACV,IAAIM,EAGJ,IAKI,KAJAA,EAAWZ,EAAOa,YAIJC,SAAWF,EAAS,GAAGG,WACjC,MAAM,IAAIC,MAEhB,MAAOC,GACLL,OAAWM,EAIfb,EACI,IACA,UACA,CAAEL,OAAUY,IAIhBjB,EAAE,6CACGwB,SAASpB,GACdA,EAAKqB,WAEbrB,EACKsB,KAAK,SAAUrB,EAAOqB,KAAK,SAC3BA,KAAK,SAAUvB,EAAQwB,KACvBD,KAAK,SAAUvB,EAAQI,MACxBJ,EAAQyB,UACR5B,EAAE6B,KAAK1B,EAAQyB,SAAU,SAAUE,EAAOC,GACtC/B,EAAE,0BACG0B,KAAK,OAAQK,EAAMC,MACnBC,IAAIF,EAAMG,OACVV,SAASpB,KAGlBD,EAAQgC,WAAahC,EAAQgC,UAAUhB,QAClB,SAAjBhB,EAAQI,OACZK,EAAkBT,EAAQgC,UAAUC,QAEpCjC,EAAQgC,UAAUE,MAAM,SAAUP,GAC9B,OAAOlB,EAAgBkB,KAEvB3B,EAAQY,WACRZ,EAAQgC,UAAUN,KAAK,SAAUC,GAC7B9B,EAAEsC,MAAMZ,KACJ,OACAb,EAAWiB,IAAU3B,EAAQY,aAMzCX,EACKmC,OAAOpC,EAAQgC,WACfT,KAAK,UAAW,uBAEhBA,KAAK,WAAY,wBAE1BtB,EAAKoC,SAGD5B,GAAmBA,EAAgBO,QACnChB,EAAQgC,UAAUN,KAAK,SAAUC,EAAOW,GACpC,IAAIL,EAAQpC,EAAEY,EAAgBkB,IAC9B9B,EAAEyC,GAAOf,KAAK,OAAQU,EAAMV,KAAK,SACjCU,EAAMM,YAAYD,OAI9BrC,EAAKmC,OAAOlC,GAAQmB,SAASmB,SAASC,OAE1CC,MAAO,WACCxC,GAIAA,EACKW,OAAO,QACPU,KAAK,MAAO,aAAaoB,OAAO,YAErC1C,GACAA,EAAKqB,aASzBzB,EAAE+C,UAAU,CACRC,WAAY,CACRC,cAAe,SAAU5C,GACrB,OAAOL,EAAEK,EAAO,GAAGuC,MAAMM,QAE7BC,cAAe,SAAU9C,GACrB,OAAOL,EAAEoD,UAAUpD,EAAEK,EAAO,GAAGuC,MAAMM,SAEzCG,cAAe,SAAUhD,GACrB,OAAOL,EAAEK,EAAO,GAAGuC,MAAMU,QAE7BC,gBAAiB,SAAUlD,GACvB,OAAOL,EAAEwD,WAAWxD,EAAEK,EAAO,GAAGuC,MAAMM","file":"jquery.iframe-transport.js","sourcesContent":["/*\r\n* jQuery Iframe Transport Plugin 1.4\r\n* https://github.com/blueimp/jQuery-File-Upload\r\n*\r\n* Copyright 2011, Sebastian Tschan\r\n* https://blueimp.net\r\n*\r\n* Licensed under the MIT license:\r\n* http://www.opensource.org/licenses/MIT\r\n*/\r\n\r\n/*jslint unparam: true, nomen: true */\r\n/*global define, window, document */\r\n\r\n(function (factory) {\r\n 'use strict';\r\n if (typeof define === 'function' && define.amd) {\r\n // Register as an anonymous AMD module:\r\n define(['jquery'], factory);\r\n } else {\r\n // Browser globals:\r\n factory(window.jQuery);\r\n }\r\n} (function ($) {\r\n 'use strict';\r\n\r\n // Helper variable to create unique names for the transport iframes:\r\n var counter = 0;\r\n\r\n // The iframe transport accepts three additional options:\r\n // options.fileInput: a jQuery collection of file input fields\r\n // options.paramName: the parameter name for the file form data,\r\n // overrides the name property of the file input field(s),\r\n // can be a string or an array of strings.\r\n // options.formData: an array of objects with name and value properties,\r\n // equivalent to the return data of .serializeArray(), e.g.:\r\n // [{name: 'a', value: 1}, {name: 'b', value: 2}]\r\n $.ajaxTransport('iframe', function (options) {\r\n if (options.async && (options.type === 'POST' || options.type === 'GET')) {\r\n var form,\r\n iframe;\r\n return {\r\n send: function (_, completeCallback) {\r\n form = $('
');\r\n // javascript:false as initial iframe src\r\n // prevents warning popups on HTTPS in IE6.\r\n // IE versions below IE8 cannot set the name property of\r\n // elements that have already been added to the DOM,\r\n // so we set the name along with the iframe HTML markup:\r\n iframe = $(\r\n ''\r\n ).bind('load', function () {\r\n var fileInputClones,\r\n paramNames = $.isArray(options.paramName) ?\r\n options.paramName : [options.paramName];\r\n iframe\r\n .unbind('load')\r\n .bind('load', function () {\r\n var response;\r\n // Wrap in a try/catch block to catch exceptions thrown\r\n // when trying to access cross-domain iframe contents:\r\n try {\r\n response = iframe.contents();\r\n // Google Chrome and Firefox do not throw an\r\n // exception when calling iframe.contents() on\r\n // cross-domain requests, so we unify the response:\r\n if (!response.length || !response[0].firstChild) {\r\n throw new Error();\r\n }\r\n } catch (e) {\r\n response = undefined;\r\n }\r\n // The complete callback returns the\r\n // iframe content document as response object:\r\n completeCallback(\r\n 200,\r\n 'success',\r\n { 'iframe': response }\r\n );\r\n // Fix for IE endless progress bar activity bug\r\n // (happens on form submits to iframe targets):\r\n $('')\r\n .appendTo(form);\r\n form.remove();\r\n });\r\n form\r\n .prop('target', iframe.prop('name'))\r\n .prop('action', options.url)\r\n .prop('method', options.type);\r\n if (options.formData) {\r\n $.each(options.formData, function (index, field) {\r\n $('')\r\n .prop('name', field.name)\r\n .val(field.value)\r\n .appendTo(form);\r\n });\r\n }\r\n if (options.fileInput && options.fileInput.length &&\r\n options.type === 'POST') {\r\n fileInputClones = options.fileInput.clone();\r\n // Insert a clone for each file input field:\r\n options.fileInput.after(function (index) {\r\n return fileInputClones[index];\r\n });\r\n if (options.paramName) {\r\n options.fileInput.each(function (index) {\r\n $(this).prop(\r\n 'name',\r\n paramNames[index] || options.paramName\r\n );\r\n });\r\n }\r\n // Appending the file input fields to the hidden form\r\n // removes them from their original location:\r\n form\r\n .append(options.fileInput)\r\n .prop('enctype', 'multipart/form-data')\r\n // enctype must be set as encoding for IE:\r\n .prop('encoding', 'multipart/form-data');\r\n }\r\n form.submit();\r\n // Insert the file input fields at their original location\r\n // by replacing the clones with the originals:\r\n if (fileInputClones && fileInputClones.length) {\r\n options.fileInput.each(function (index, input) {\r\n var clone = $(fileInputClones[index]);\r\n $(input).prop('name', clone.prop('name'));\r\n clone.replaceWith(input);\r\n });\r\n }\r\n });\r\n form.append(iframe).appendTo(document.body);\r\n },\r\n abort: function () {\r\n if (iframe) {\r\n // javascript:false as iframe src aborts the request\r\n // and prevents warning popups on HTTPS in IE6.\r\n // concat is used to avoid the \"Script URL\" JSLint error:\r\n iframe\r\n .unbind('load')\r\n .prop('src', 'javascript'.concat(':false;'));\r\n }\r\n if (form) {\r\n form.remove();\r\n }\r\n }\r\n };\r\n }\r\n });\r\n\r\n // The iframe transport returns the iframe content document as response.\r\n // The following adds converters from iframe to text, json, html, and script:\r\n $.ajaxSetup({\r\n converters: {\r\n 'iframe text': function (iframe) {\r\n return $(iframe[0].body).text();\r\n },\r\n 'iframe json': function (iframe) {\r\n return $.parseJSON($(iframe[0].body).text());\r\n },\r\n 'iframe html': function (iframe) {\r\n return $(iframe[0].body).html();\r\n },\r\n 'iframe script': function (iframe) {\r\n return $.globalEval($(iframe[0].body).text());\r\n }\r\n }\r\n });\r\n\r\n}));\r\n"]}