diff options
| author | Horus3 | 2014-12-01 02:09:10 +0100 |
|---|---|---|
| committer | Horus3 | 2014-12-01 02:09:10 +0100 |
| commit | b435ec462e0f39457e14d81750f07781db97cb91 (patch) | |
| tree | 6923f685c0ca9d6fef80d3496c02e12318e68fdc /uploaded/js/cors/jquery.xdr-transport.js | |
| parent | 33affa31742f0bc9d735349763f639087ea4e7ff (diff) | |
| download | tools.iamfabulous.de-b435ec462e0f39457e14d81750f07781db97cb91.tar.gz | |
File Uploaded added
Diffstat (limited to 'uploaded/js/cors/jquery.xdr-transport.js')
| -rw-r--r-- | uploaded/js/cors/jquery.xdr-transport.js | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/uploaded/js/cors/jquery.xdr-transport.js b/uploaded/js/cors/jquery.xdr-transport.js new file mode 100644 index 0000000..0044cc2 --- /dev/null +++ b/uploaded/js/cors/jquery.xdr-transport.js @@ -0,0 +1,86 @@ +/* + * jQuery XDomainRequest Transport Plugin 1.1.3 + * https://github.com/blueimp/jQuery-File-Upload + * + * Copyright 2011, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/MIT + * + * Based on Julian Aubourg's ajaxHooks xdr.js: + * https://github.com/jaubourg/ajaxHooks/ + */ + +/* global define, window, XDomainRequest */ + +(function (factory) { + 'use strict'; + if (typeof define === 'function' && define.amd) { + // Register as an anonymous AMD module: + define(['jquery'], factory); + } else { + // Browser globals: + factory(window.jQuery); + } +}(function ($) { + 'use strict'; + if (window.XDomainRequest && !$.support.cors) { + $.ajaxTransport(function (s) { + if (s.crossDomain && s.async) { + if (s.timeout) { + s.xdrTimeout = s.timeout; + delete s.timeout; + } + var xdr; + return { + send: function (headers, completeCallback) { + var addParamChar = /\?/.test(s.url) ? '&' : '?'; + function callback(status, statusText, responses, responseHeaders) { + xdr.onload = xdr.onerror = xdr.ontimeout = $.noop; + xdr = null; + completeCallback(status, statusText, responses, responseHeaders); + } + xdr = new XDomainRequest(); + // XDomainRequest only supports GET and POST: + if (s.type === 'DELETE') { + s.url = s.url + addParamChar + '_method=DELETE'; + s.type = 'POST'; + } else if (s.type === 'PUT') { + s.url = s.url + addParamChar + '_method=PUT'; + s.type = 'POST'; + } else if (s.type === 'PATCH') { + s.url = s.url + addParamChar + '_method=PATCH'; + s.type = 'POST'; + } + xdr.open(s.type, s.url); + xdr.onload = function () { + callback( + 200, + 'OK', + {text: xdr.responseText}, + 'Content-Type: ' + xdr.contentType + ); + }; + xdr.onerror = function () { + callback(404, 'Not Found'); + }; + if (s.xdrTimeout) { + xdr.ontimeout = function () { + callback(0, 'timeout'); + }; + xdr.timeout = s.xdrTimeout; + } + xdr.send((s.hasContent && s.data) || null); + }, + abort: function () { + if (xdr) { + xdr.onerror = $.noop(); + xdr.abort(); + } + } + }; + } + }); + } +})); |
