/*! * DollarJS Ajax Plugin 1.0.0 * Extends window.$ with ajax functionality * Github: https://github.com/seebigs/dollar-js-ajax * Released under the MIT license: https://opensource.org/licenses/MIT */ !function(t,e,r){function n(t,e){function r(i){function s(e){var n=t[i][1][e];if(!n)throw"Missing "+e;return o[n]||r(n)}function a(e,r){var n=t[i][1][e];o[n]=r}if(s.as=e,a.stopAll=function(){n={},o={}},s.cache={mock:a,clear:function(){n={}}},!n[i]){var f=n[i]={exports:{}};t[i][0].call(f.exports,s,f,f.exports,t)}return n[i]?n[i].exports:{}}var n={},o={};r(0)}n([[function(r,n,o){var i={ajax:r("./src/ajax.js"),get:r("./src/get.js"),post:r("./src/post.js"),getJSON:r("./src/getJSON.js"),getScript:r("./src/getScript.js")},s=(void 0!==t?t:e).$||{};if(s.isDollar)for(method in i)i.hasOwnProperty(method)&&(s[method]=i[method]);n.exports=i},{"./src/ajax.js":1,"./src/get.js":5,"./src/post.js":7,"./src/getJSON.js":8,"./src/getScript.js":9}],[function(e,r,n){function o(t,e){var r="object"==typeof e?e:{};"string"==typeof t?r.url=t:r=t,"string"!=typeof r.url&&(r.url=""),r.data=r.data||{},!1===r.cache&&(r.data._=Date.now()),"function"!=typeof r.success&&(r.success=function(){}),"function"!=typeof r.error&&(r.error=function(){}),"function"!=typeof r.complete&&(r.complete=function(){});var n={html:"text/html",json:"application/json",text:"text/plain",xml:"application/xml"},o={method:r.method||r.type||"get"};if("object"==typeof r.headers&&(o.headers=r.headers),"get"===o.method){var a=s(r.data);a.length&&(r.url+=("?"===r.url.slice(-1)?"":"?")+a)}else o.body="object"==typeof r.data?JSON.stringify(r.data):r.data;return i(r.url,o).then(function(t){if(t&&t.ok){"application/json"===(r.dataType?n[r.dataType]:t.headers.get("Content-Type"))?t.json().then(function(e){r.success(e,t),r.complete("success",t)}):t.text().then(function(e){r.success(e,t),r.complete("success",t)})}else r.error(new Error("Request failed")),r.complete("error",t)}).catch(function(t){r.error(t),r.complete("error",{})})}t.Promise=t.Promise||e("promise-polyfill");var i=t.fetch||e("whatwg-fetch").fetch,s=e("./serialize.js");r.exports=o},{"promise-polyfill":2,"whatwg-fetch":3,"./serialize.js":4}],[function(t,e,r){!function(t){function r(){}function n(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(t,this)}function i(t,e){for(;3===t._state;)t=t._value;if(0===t._state)return void t._deferreds.push(e);t._handled=!0,o._immediateFn(function(){var r=1===t._state?e.onFulfilled:e.onRejected;if(null===r)return void(1===t._state?s:a)(e.promise,t._value);var n;try{n=r(t._value)}catch(t){return void a(e.promise,t)}s(e.promise,n)})}function s(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if(e instanceof o)return t._state=3,t._value=e,void f(t);if("function"==typeof r)return void c(n(r,e),t)}t._state=1,t._value=e,f(t)}catch(e){a(t,e)}}function a(t,e){t._state=2,t._value=e,f(t)}function f(t){2===t._state&&0===t._deferreds.length&&o._immediateFn(function(){t._handled||o._unhandledRejectionFn(t._value)});for(var e=0,r=t._deferreds.length;e-1?e:t}function d(t,e){e=e||{};var r=e.body;if(t instanceof d){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new o(t.headers)),this.method=t.method,this.mode=t.mode,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new o(e.headers)),this.method=p(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function l(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e}function y(t){var e=new o;return t.split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}}),e}function m(t,e){e||(e={}),this.type="default",this.status="status"in e?e.status:200,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new o(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var b={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(b.arrayBuffer)var v=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],w=function(t){return t&&DataView.prototype.isPrototypeOf(t)},j=ArrayBuffer.isView||function(t){return t&&v.indexOf(Object.prototype.toString.call(t))>-1};o.prototype.append=function(t,n){t=e(t),n=r(n);var o=this.map[t];this.map[t]=o?o+","+n:n},o.prototype.delete=function(t){delete this.map[e(t)]},o.prototype.get=function(t){return t=e(t),this.has(t)?this.map[t]:null},o.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},o.prototype.set=function(t,n){this.map[e(t)]=r(n)},o.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},o.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),n(t)},o.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),n(t)},o.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),n(t)},b.iterable&&(o.prototype[Symbol.iterator]=o.prototype.entries);var _=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];d.prototype.clone=function(){return new d(this,{body:this._bodyInit})},h.call(d.prototype),h.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new o(this.headers),url:this.url})},m.error=function(){var t=new m(null,{status:0,statusText:""});return t.type="error",t};var g=[301,302,303,307,308];m.redirect=function(t,e){if(-1===g.indexOf(e))throw new RangeError("Invalid status code");return new m(null,{status:e,headers:{location:t}})},t.Headers=o,t.Request=d,t.Response=m,t.fetch=function(t,e){return new Promise(function(r,n){var o=new d(t,e),i=new XMLHttpRequest;i.onload=function(){var t={status:i.status,statusText:i.statusText,headers:y(i.getAllResponseHeaders()||"")};t.url="responseURL"in i?i.responseURL:t.headers.get("X-Request-URL");var e="response"in i?i.response:i.responseText;r(new m(e,t))},i.onerror=function(){n(new TypeError("Network request failed"))},i.ontimeout=function(){n(new TypeError("Network request failed"))},i.open(o.method,o.url,!0),"include"===o.credentials&&(i.withCredentials=!0),"responseType"in i&&b.blob&&(i.responseType="blob"),o.headers.forEach(function(t,e){i.setRequestHeader(e,t)}),i.send(void 0===o._bodyInit?null:o._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)},{}],[function(t,e,r){function n(t){var e=typeof t;if("object"===e){var r=[];for(key in t)t.hasOwnProperty(key)&&r.push(encodeURIComponent(key)+"="+encodeURIComponent(t[key]));return r.join("&")}return"string"===e?t:""}e.exports=n},{}],[function(t,e,r){function n(t,e,r,n){var s=i(t,e,r,n);return s.method="get",o(s)}var o=t("./ajax.js"),i=t("./parseOptions.js");e.exports=n},{"./ajax.js":1,"./parseOptions.js":6}],[function(t,e,r){function n(t,e,r,n){var o={};return"object"==typeof t?o=t:(o.url=t,"object"==typeof e?o.data=e:"function"==typeof e?o.success=e:"string"==typeof e&&(o.dataType=e),"function"==typeof r?o.success=r:"string"==typeof r&&(o.dataType=r),"string"==typeof n&&(o.dataType=n)),o}e.exports=n},{}],[function(t,e,r){function n(t,e,r,n){var s=i(t,e,r,n);return s.method="post",o(s)}var o=t("./ajax.js"),i=t("./parseOptions.js");e.exports=n},{"./ajax.js":1,"./parseOptions.js":6}],[function(t,e,r){function n(t,e,r){var n=i(t,e,r,"json");return o(n)}var o=t("./ajax.js"),i=t("./parseOptions.js");e.exports=n},{"./ajax.js":1,"./parseOptions.js":6}],[function(t,e,n){function o(t,e,n){var o=r,i=o.getElementsByTagName("head")[0]||o.getElementsByTagName("body")[0]||o.documentElement,s=o.createElement("script");return s.async=!0,s.type="text/javascript",s.src=t,"function"==typeof e&&(s.onload=function(){e.call(s)}),"function"==typeof n&&(s.onerror=function(t){n.call(s,t)}),i.appendChild(s)}e.exports=o},{}]])}("undefined"!=typeof global?global:window,window,document);