/*! * vue-resource v1.3.5 * https://github.com/pagekit/vue-resource * Released under the MIT License. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueResource=e()}(this,function(){"use strict";function t(t){this.state=$,this.value=void 0,this.deferred=[];var e=this;try{t(function(t){e.resolve(t)},function(t){e.reject(t)})}catch(t){e.reject(t)}}function e(t,e){t instanceof Promise?this.promise=t:this.promise=new Promise(t.bind(e)),this.context=e}function n(t){return t?t.replace(/^\s*|\s*$/g,""):""}function o(t){return t?t.toLowerCase():""}function r(t){return"string"==typeof t}function i(t){return"function"==typeof t}function s(t){return null!==t&&"object"==typeof t}function u(t){return s(t)&&Object.getPrototypeOf(t)==Object.prototype}function a(t,n,o){var r=e.resolve(t);return arguments.length<2?r:r.then(n,o)}function c(t,e,n){return n=n||{},i(n)&&(n=n.call(e)),p(t.bind({$vm:e,$options:n}),t,{$options:n})}function f(t,e){var n,o;if(H(t))for(n=0;n=200&&s<300,this.status=s||0,this.statusText=u||"",this.headers=new M(i),this.body=t,r(t)?this.bodyText=t:function(t){return"undefined"!=typeof Blob&&t instanceof Blob}(t)&&(this.bodyBlob=t,function(t){return 0===t.type.indexOf("text")||-1!==t.type.indexOf("json")}(t)&&(this.bodyText=function(t){return new e(function(e){var n=new FileReader;n.readAsText(t),n.onload=function(){e(n.result)}})}(t)))};N.prototype.blob=function(){return a(this.bodyBlob)},N.prototype.text=function(){return a(this.bodyText)},N.prototype.json=function(){return a(this.text(),function(t){return JSON.parse(t)})},Object.defineProperty(N.prototype,"data",{get:function(){return this.body},set:function(t){this.body=t}});var D=function(t){this.body=null,this.params={},L(this,t,{method:function(t){return t?t.toUpperCase():""}(t.method||"GET")}),this.headers instanceof M||(this.headers=new M(this.headers))};D.prototype.getUrl=function(){return b(this)},D.prototype.getBody=function(){return this.body},D.prototype.respondWith=function(t,e){return new N(t,L(e||{},{url:this.getUrl()}))};var J={"Content-Type":"application/json;charset=utf-8"};return O.options={},O.headers={put:J,post:J,patch:J,delete:J,common:{Accept:"application/json, text/plain, */*"},custom:{}},O.interceptor={before:function(t,e){i(t.before)&&t.before.call(this,t),e()},method:function(t,e){t.emulateHTTP&&/^(PUT|PATCH|DELETE)$/i.test(t.method)&&(t.headers.set("X-HTTP-Method-Override",t.method),t.method="POST"),e()},jsonp:function(t,e){"JSONP"==t.method&&(t.client=T),e()},json:function(t,e){var n=t.headers.get("Content-Type")||"";s(t.body)&&0===n.indexOf("application/json")&&(t.body=JSON.stringify(t.body)),e(function(t){return t.bodyText?a(t.text(),function(e){if(0===(n=t.headers.get("Content-Type")||"").indexOf("application/json")||function(t){var e=t.match(/^\s*(\[|\{)/);return e&&{"[":/]\s*$/,"{":/}\s*$/}[e[1]].test(t)}(e))try{t.body=JSON.parse(e)}catch(e){t.body=null}else t.body=e;return t}):t})},form:function(t,e){!function(t){return"undefined"!=typeof FormData&&t instanceof FormData}(t.body)?s(t.body)&&t.emulateJSON&&(t.body=b.params(t.body),t.headers.set("Content-Type","application/x-www-form-urlencoded")):t.headers.delete("Content-Type"),e()},header:function(t,e){f(L({},O.headers.common,t.crossOrigin?{}:O.headers.custom,O.headers[o(t.method)]),function(e,n){t.headers.has(n)||t.headers.set(n,e)}),e()},cors:function(t,e){if(q){var n=b.parse(location.href),o=b.parse(t.getUrl());o.protocol===n.protocol&&o.host===n.host||(t.crossOrigin=!0,t.emulateHTTP=!1,B||(t.client=w))}e()}},O.interceptors=["before","method","jsonp","json","form","header","cors"],["get","delete","head","jsonp"].forEach(function(t){O[t]=function(e,n){return this(L(n||{},{url:e,method:t}))}}),["post","put","patch"].forEach(function(t){O[t]=function(e,n,o){return this(L(o||{},{url:e,method:t,body:n}))}}),P.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},update:{method:"PUT"},remove:{method:"DELETE"},delete:{method:"DELETE"}},"undefined"!=typeof window&&window.Vue&&window.Vue.use(C),C});