vendor/assets/javascripts/vue-resource.js in vuejs-1.0.24 vs vendor/assets/javascripts/vue-resource.js in vuejs-1.0.25
- old
+ new
@@ -1,7 +1,7 @@
/**
- * vue-resource v0.7.0
+ * vue-resource v0.7.2
* https://github.com/vuejs/vue-resource
* Released under the MIT License.
*/
(function webpackUniversalModuleDefinition(root, factory) {
@@ -62,12 +62,16 @@
/**
* Install plugin.
*/
- function install(Vue) {
+ function plugin(Vue) {
+ if (plugin.installed) {
+ return;
+ }
+
var _ = __webpack_require__(1);
_.config = Vue.config;
_.warning = Vue.util.warn;
_.nextTick = Vue.util.nextTick;
@@ -78,54 +82,59 @@
Vue.Promise = __webpack_require__(10);
Object.defineProperties(Vue.prototype, {
$url: {
- get: function () {
+ get: function get() {
return _.options(Vue.url, this, this.$options.url);
}
},
$http: {
- get: function () {
+ get: function get() {
return _.options(Vue.http, this, this.$options.http);
}
},
$resource: {
- get: function () {
+ get: function get() {
return Vue.resource.bind(this);
}
},
$promise: {
- get: function () {
+ get: function get() {
+ var _this = this;
+
return function (executor) {
- return new Vue.Promise(executor, this);
- }.bind(this);
+ return new Vue.Promise(executor, _this);
+ };
}
}
});
}
- if (window.Vue) {
- Vue.use(install);
+ if (typeof window !== 'undefined' && window.Vue) {
+ window.Vue.use(plugin);
}
- module.exports = install;
+ module.exports = plugin;
-
/***/ },
/* 1 */
/***/ function(module, exports) {
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
+
/**
* Utility functions.
*/
- var _ = exports, array = [], console = window.console;
+ var _ = exports,
+ array = [],
+ console = window.console;
_.warn = function (msg) {
if (console && _.warning && (!_.config.silent || _.config.debug)) {
console.warn('[VueResource warn]: ' + msg);
}
@@ -154,11 +163,11 @@
_.isFunction = function (val) {
return typeof val === 'function';
};
_.isObject = function (obj) {
- return obj !== null && typeof obj === 'object';
+ return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
};
_.isPlainObject = function (obj) {
return _.isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
};
@@ -169,11 +178,11 @@
if (_.isFunction(options)) {
options = options.call(obj);
}
- return _.merge(fn.bind({$vm: obj, $options: options}), fn, {$options: options});
+ return _.merge(fn.bind({ $vm: obj, $options: options }), fn, { $options: options });
};
_.each = function (obj, iterator) {
var i, key;
@@ -240,11 +249,10 @@
target[key] = source[key];
}
}
}
-
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -255,14 +263,15 @@
var ie = document.documentMode;
var el = document.createElement('a');
function Url(url, params) {
- var options = url, transform;
+ var options = url,
+ transform;
if (_.isString(url)) {
- options = {url: url, params: params};
+ options = { url: url, params: params };
}
options = _.merge({}, Url.options, this.$options, options);
Url.transforms.forEach(function (handler) {
@@ -284,26 +293,22 @@
/**
* Url transforms.
*/
- Url.transforms = [
- __webpack_require__(3),
- __webpack_require__(5),
- __webpack_require__(6),
- __webpack_require__(7)
- ];
+ Url.transforms = [__webpack_require__(3), __webpack_require__(5), __webpack_require__(6), __webpack_require__(7)];
/**
* Encodes a Url parameter string.
*
* @param {Object} obj
*/
Url.params = function (obj) {
- var params = [], escape = encodeURIComponent;
+ var params = [],
+ escape = encodeURIComponent;
params.add = function (key, value) {
if (_.isFunction(value)) {
value = value();
@@ -354,11 +359,13 @@
};
}
function serialize(params, obj, scope) {
- var array = _.isArray(obj), plain = _.isPlainObject(obj), hash;
+ var array = _.isArray(obj),
+ plain = _.isPlainObject(obj),
+ hash;
_.each(obj, function (value, key) {
hash = _.isObject(value) || _.isArray(value);
@@ -376,11 +383,10 @@
});
}
module.exports = _.url = Url;
-
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -389,50 +395,53 @@
var UrlTemplate = __webpack_require__(4);
module.exports = function (options) {
- var variables = [], url = UrlTemplate.expand(options.url, options.params, variables);
+ var variables = [],
+ url = UrlTemplate.expand(options.url, options.params, variables);
variables.forEach(function (key) {
delete options.params[key];
});
return url;
};
-
/***/ },
/* 4 */
/***/ function(module, exports) {
/**
* URL Template v2.0.6 (https://github.com/bramstein/url-template)
*/
exports.expand = function (url, params, variables) {
- var tmpl = this.parse(url), expanded = tmpl.expand(params);
+ var tmpl = this.parse(url),
+ expanded = tmpl.expand(params);
if (variables) {
variables.push.apply(variables, tmpl.vars);
}
return expanded;
};
exports.parse = function (template) {
- var operators = ['+', '#', '.', '/', ';', '?', '&'], variables = [];
+ var operators = ['+', '#', '.', '/', ';', '?', '&'],
+ variables = [];
return {
vars: variables,
- expand: function (context) {
+ expand: function expand(context) {
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
if (expression) {
- var operator = null, values = [];
+ var operator = null,
+ values = [];
if (operators.indexOf(expression.charAt(0)) !== -1) {
operator = expression.charAt(0);
expression = expression.substr(1);
}
@@ -455,22 +464,22 @@
return (values.length !== 0 ? operator : '') + values.join(separator);
} else {
return values.join(',');
}
-
} else {
return exports.encodeReserved(literal);
}
});
}
};
};
exports.getValues = function (context, operator, key, modifier) {
- var value = context[key], result = [];
+ var value = context[key],
+ result = [];
if (this.isDefined(value) && value !== '') {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
value = value.toString();
@@ -536,11 +545,11 @@
return operator === ';' || operator === '&' || operator === '?';
};
exports.encodeValue = function (operator, value, key) {
- value = (operator === '+' || operator === '#') ? this.encodeReserved(value) : encodeURIComponent(value);
+ value = operator === '+' || operator === '#' ? this.encodeReserved(value) : encodeURIComponent(value);
if (key) {
return encodeURIComponent(key) + '=' + value;
} else {
return value;
@@ -554,11 +563,10 @@
}
return part;
}).join('');
};
-
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -567,11 +575,12 @@
var _ = __webpack_require__(1);
module.exports = function (options, next) {
- var variables = [], url = next(options);
+ var variables = [],
+ url = next(options);
url = url.replace(/(\/?):([a-z]\w*)/gi, function (match, slash, name) {
_.warn('The `:' + name + '` parameter syntax has been deprecated. Use the `{' + name + '}` syntax instead.');
@@ -590,27 +599,18 @@
return url;
};
function encodeUriSegment(value) {
- return encodeUriQuery(value, true).
- replace(/%26/gi, '&').
- replace(/%3D/gi, '=').
- replace(/%2B/gi, '+');
+ return encodeUriQuery(value, true).replace(/%26/gi, '&').replace(/%3D/gi, '=').replace(/%2B/gi, '+');
}
function encodeUriQuery(value, spaces) {
- return encodeURIComponent(value).
- replace(/%40/gi, '@').
- replace(/%3A/gi, ':').
- replace(/%24/g, '$').
- replace(/%2C/gi, ',').
- replace(/%20/g, (spaces ? '%20' : '+'));
+ return encodeURIComponent(value).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, spaces ? '%20' : '+');
}
-
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -619,13 +619,15 @@
var _ = __webpack_require__(1);
module.exports = function (options, next) {
- var urlParams = Object.keys(_.url.options.params), query = {}, url = next(options);
+ var urlParams = Object.keys(_.url.options.params),
+ query = {},
+ url = next(options);
- _.each(options.params, function (value, key) {
+ _.each(options.params, function (value, key) {
if (urlParams.indexOf(key) === -1) {
query[key] = value;
}
});
@@ -636,11 +638,10 @@
}
return url;
};
-
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -658,11 +659,10 @@
}
return url;
};
-
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -671,26 +671,28 @@
var _ = __webpack_require__(1);
var Client = __webpack_require__(9);
var Promise = __webpack_require__(10);
var interceptor = __webpack_require__(13);
- var jsonType = {'Content-Type': 'application/json'};
+ var jsonType = { 'Content-Type': 'application/json' };
function Http(url, options) {
+ var _this = this;
- var client = Client, request, promise;
+ var client = Client,
+ request,
+ promise;
Http.interceptors.forEach(function (handler) {
- client = interceptor(handler, this.$vm)(client);
- }, this);
+ client = interceptor(handler, _this.$vm)(client);
+ });
- options = _.isObject(url) ? url : _.extend({url: url}, options);
+ options = _.isObject(url) ? url : _.extend({ url: url }, options);
request = _.merge({}, Http.options, this.$options, options);
promise = client(request).bind(this.$vm).then(function (response) {
return response.ok ? response : Promise.reject(response);
-
}, function (response) {
if (response instanceof Error) {
_.error(response);
}
@@ -722,27 +724,19 @@
emulateHTTP: false,
emulateJSON: false,
timeout: 0
};
- Http.interceptors = [
- __webpack_require__(14),
- __webpack_require__(15),
- __webpack_require__(16),
- __webpack_require__(18),
- __webpack_require__(19),
- __webpack_require__(20),
- __webpack_require__(21)
- ];
+ Http.interceptors = [__webpack_require__(14), __webpack_require__(15), __webpack_require__(16), __webpack_require__(18), __webpack_require__(19), __webpack_require__(20), __webpack_require__(21)];
Http.headers = {
put: jsonType,
post: jsonType,
patch: jsonType,
delete: jsonType,
- common: {'Accept': 'application/json, text/plain, */*'},
- custom: {'X-Requested-With': 'XMLHttpRequest'}
+ common: { 'Accept': 'application/json, text/plain, */*' },
+ custom: { 'X-Requested-With': 'XMLHttpRequest' }
};
['get', 'put', 'post', 'patch', 'delete', 'jsonp'].forEach(function (method) {
Http[method] = function (url, data, success, options) {
@@ -756,17 +750,16 @@
if (_.isObject(success)) {
options = success;
success = undefined;
}
- return this(url, _.extend({method: method, data: data, success: success}, options));
+ return this(url, _.extend({ method: method, data: data, success: success }, options));
};
});
module.exports = _.http = Http;
-
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -793,23 +786,24 @@
return headers[_.toLower(name)];
}
return headers;
};
-
}
response.ok = response.status >= 200 && response.status < 300;
return response;
});
-
};
function parseHeaders(str) {
- var headers = {}, value, name, i;
+ var headers = {},
+ value,
+ name,
+ i;
if (_.isString(str)) {
_.each(str.split('\n'), function (row) {
i = row.indexOf(':');
@@ -821,23 +815,20 @@
if (_.isArray(headers[name])) {
headers[name].push(value);
} else {
headers[name] = [headers[name], value];
}
-
} else {
headers[name] = value;
}
-
});
}
return headers;
}
-
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -908,17 +899,16 @@
};
p.finally = function (callback) {
return this.then(function (value) {
- callback.call(this);
- return value;
- }, function (reason) {
- callback.call(this);
- return PromiseObj.reject(reason);
- }
- );
+ callback.call(this);
+ return value;
+ }, function (reason) {
+ callback.call(this);
+ return PromiseObj.reject(reason);
+ });
};
p.success = function (callback) {
_.warn('The `success` method has been deprecated. Use the `then` method instead.');
@@ -939,33 +929,34 @@
p.always = function (callback) {
_.warn('The `always` method has been deprecated. Use the `finally` method instead.');
- var cb = function (response) {
+ var cb = function cb(response) {
return callback.call(this, response.data, response.status, response) || response;
};
return this.then(cb, cb);
};
module.exports = Promise;
-
/***/ },
/* 11 */
/***/ function(module, exports, __webpack_require__) {
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
+
/**
* Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis)
*/
var _ = __webpack_require__(1);
var RESOLVED = 0;
var REJECTED = 1;
- var PENDING = 2;
+ var PENDING = 2;
function Promise(executor) {
this.state = PENDING;
this.value = undefined;
@@ -996,11 +987,12 @@
});
};
Promise.all = function all(iterable) {
return new Promise(function (resolve, reject) {
- var count = 0, result = [];
+ var count = 0,
+ result = [];
if (iterable.length === 0) {
resolve(result);
}
@@ -1042,17 +1034,16 @@
var called = false;
try {
var then = x && x['then'];
- if (x !== null && typeof x === 'object' && typeof then === 'function') {
+ if (x !== null && (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && typeof then === 'function') {
then.call(x, function (x) {
if (!called) {
promise.resolve(x);
}
called = true;
-
}, function (r) {
if (!called) {
promise.reject(r);
}
called = true;
@@ -1133,11 +1124,10 @@
return this.then(undefined, onRejected);
};
module.exports = Promise;
-
/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1148,19 +1138,21 @@
var Promise = __webpack_require__(10);
module.exports = function (request) {
return new Promise(function (resolve) {
- var xhr = new XMLHttpRequest(), response = {request: request}, handler;
+ var xhr = new XMLHttpRequest(),
+ response = { request: request },
+ handler;
request.cancel = function () {
xhr.abort();
};
xhr.open(request.method, _.url(request), true);
- handler = function (event) {
+ handler = function handler(event) {
response.data = xhr.responseText;
response.status = xhr.status;
response.statusText = xhr.statusText;
response.headers = xhr.getAllResponseHeaders();
@@ -1189,11 +1181,10 @@
xhr.send(request.data);
});
};
-
/***/ },
/* 13 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1240,11 +1231,10 @@
}
return promise.then(fulfilled, rejected);
}
-
/***/ },
/* 14 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1253,22 +1243,21 @@
var _ = __webpack_require__(1);
module.exports = {
- request: function (request) {
+ request: function request(_request) {
- if (_.isFunction(request.beforeSend)) {
- request.beforeSend.call(this, request);
+ if (_.isFunction(_request.beforeSend)) {
+ _request.beforeSend.call(this, _request);
}
- return request;
+ return _request;
}
};
-
/***/ },
/* 15 */
/***/ function(module, exports) {
/**
@@ -1279,32 +1268,31 @@
var timeout;
return {
- request: function (request) {
+ request: function request(_request) {
- if (request.timeout) {
+ if (_request.timeout) {
timeout = setTimeout(function () {
- request.cancel();
- }, request.timeout);
+ _request.cancel();
+ }, _request.timeout);
}
- return request;
+ return _request;
},
- response: function (response) {
+ response: function response(_response) {
clearTimeout(timeout);
- return response;
+ return _response;
}
};
};
-
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1313,22 +1301,21 @@
var jsonpClient = __webpack_require__(17);
module.exports = {
- request: function (request) {
+ request: function request(_request) {
- if (request.method == 'JSONP') {
- request.client = jsonpClient;
+ if (_request.method == 'JSONP') {
+ _request.client = jsonpClient;
}
- return request;
+ return _request;
}
};
-
/***/ },
/* 17 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1339,15 +1326,18 @@
var Promise = __webpack_require__(10);
module.exports = function (request) {
return new Promise(function (resolve) {
- var callback = '_jsonp' + Math.random().toString(36).substr(2), response = {request: request, data: null}, handler, script;
+ var callback = '_jsonp' + Math.random().toString(36).substr(2),
+ response = { request: request, data: null },
+ handler,
+ script;
request.params[request.jsonp] = callback;
request.cancel = function () {
- handler({type: 'cancel'});
+ handler({ type: 'cancel' });
};
script = document.createElement('script');
script.src = _.url(request);
script.type = 'text/javascript';
@@ -1355,11 +1345,11 @@
window[callback] = function (data) {
response.data = data;
};
- handler = function (event) {
+ handler = function handler(event) {
if (event.type === 'load' && response.data !== null) {
response.status = 200;
} else if (event.type === 'error') {
response.status = 404;
@@ -1378,34 +1368,32 @@
document.body.appendChild(script);
});
};
-
/***/ },
/* 18 */
/***/ function(module, exports) {
/**
* HTTP method override Interceptor.
*/
module.exports = {
- request: function (request) {
+ request: function request(_request) {
- if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) {
- request.headers['X-HTTP-Method-Override'] = request.method;
- request.method = 'POST';
+ if (_request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(_request.method)) {
+ _request.headers['X-HTTP-Method-Override'] = _request.method;
+ _request.method = 'POST';
}
- return request;
+ return _request;
}
};
-
/***/ },
/* 19 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1414,40 +1402,39 @@
var _ = __webpack_require__(1);
module.exports = {
- request: function (request) {
+ request: function request(_request) {
- if (request.emulateJSON && _.isPlainObject(request.data)) {
- request.headers['Content-Type'] = 'application/x-www-form-urlencoded';
- request.data = _.url.params(request.data);
+ if (_request.emulateJSON && _.isPlainObject(_request.data)) {
+ _request.headers['Content-Type'] = 'application/x-www-form-urlencoded';
+ _request.data = _.url.params(_request.data);
}
- if (_.isObject(request.data) && /FormData/i.test(request.data.toString())) {
- delete request.headers['Content-Type'];
+ if (_.isObject(_request.data) && /FormData/i.test(_request.data.toString())) {
+ delete _request.headers['Content-Type'];
}
- if (_.isPlainObject(request.data)) {
- request.data = JSON.stringify(request.data);
+ if (_.isPlainObject(_request.data)) {
+ _request.data = JSON.stringify(_request.data);
}
- return request;
+ return _request;
},
- response: function (response) {
+ response: function response(_response) {
try {
- response.data = JSON.parse(response.data);
+ _response.data = JSON.parse(_response.data);
} catch (e) {}
- return response;
+ return _response;
}
};
-
/***/ },
/* 20 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1456,30 +1443,25 @@
var _ = __webpack_require__(1);
module.exports = {
- request: function (request) {
+ request: function request(_request) {
- request.method = request.method.toUpperCase();
- request.headers = _.extend({}, _.http.headers.common,
- !request.crossOrigin ? _.http.headers.custom : {},
- _.http.headers[request.method.toLowerCase()],
- request.headers
- );
+ _request.method = _request.method.toUpperCase();
+ _request.headers = _.extend({}, _.http.headers.common, !_request.crossOrigin ? _.http.headers.custom : {}, _.http.headers[_request.method.toLowerCase()], _request.headers);
- if (_.isPlainObject(request.data) && /^(GET|JSONP)$/i.test(request.method)) {
- _.extend(request.params, request.data);
- delete request.data;
+ if (_.isPlainObject(_request.data) && /^(GET|JSONP)$/i.test(_request.method)) {
+ _.extend(_request.params, _request.data);
+ delete _request.data;
}
- return request;
+ return _request;
}
};
-
/***/ },
/* 21 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1491,38 +1473,37 @@
var xhrCors = 'withCredentials' in new XMLHttpRequest();
var originUrl = _.url.parse(location.href);
module.exports = {
- request: function (request) {
+ request: function request(_request) {
- if (request.crossOrigin === null) {
- request.crossOrigin = crossOrigin(request);
+ if (_request.crossOrigin === null) {
+ _request.crossOrigin = crossOrigin(_request);
}
- if (request.crossOrigin) {
+ if (_request.crossOrigin) {
if (!xhrCors) {
- request.client = xdrClient;
+ _request.client = xdrClient;
}
- request.emulateHTTP = false;
+ _request.emulateHTTP = false;
}
- return request;
+ return _request;
}
};
function crossOrigin(request) {
var requestUrl = _.url.parse(_.url(request));
- return (requestUrl.protocol !== originUrl.protocol || requestUrl.host !== originUrl.host);
+ return requestUrl.protocol !== originUrl.protocol || requestUrl.host !== originUrl.host;
}
-
/***/ },
/* 22 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1533,19 +1514,21 @@
var Promise = __webpack_require__(10);
module.exports = function (request) {
return new Promise(function (resolve) {
- var xdr = new XDomainRequest(), response = {request: request}, handler;
+ var xdr = new XDomainRequest(),
+ response = { request: request },
+ handler;
request.cancel = function () {
xdr.abort();
};
xdr.open(request.method, _.url(request), true);
- handler = function (event) {
+ handler = function handler(event) {
response.data = xdr.responseText;
response.status = xdr.status;
response.statusText = xdr.statusText;
@@ -1561,11 +1544,10 @@
xdr.send(request.data);
});
};
-
/***/ },
/* 23 */
/***/ function(module, exports, __webpack_require__) {
/**
@@ -1574,20 +1556,18 @@
var _ = __webpack_require__(1);
function Resource(url, params, actions, options) {
- var self = this, resource = {};
+ var self = this,
+ resource = {};
- actions = _.extend({},
- Resource.actions,
- actions
- );
+ actions = _.extend({}, Resource.actions, actions);
_.each(actions, function (action, name) {
- action = _.merge({url: url, params: params || {}}, options, action);
+ action = _.merge({ url: url, params: params || {} }, options, action);
resource[name] = function () {
return (self.$http || _.http)(opts(action, arguments));
};
});
@@ -1595,11 +1575,15 @@
return resource;
}
function opts(action, args) {
- var options = _.extend({}, action), params = {}, data, success, error;
+ var options = _.extend({}, action),
+ params = {},
+ data,
+ success,
+ error;
switch (args.length) {
case 4:
@@ -1619,11 +1603,10 @@
break;
}
success = args[1];
error = args[2];
-
} else {
params = args[0];
data = args[1];
success = args[2];
@@ -1666,20 +1649,19 @@
return options;
}
Resource.actions = {
- get: {method: 'GET'},
- save: {method: 'POST'},
- query: {method: 'GET'},
- update: {method: 'PUT'},
- remove: {method: 'DELETE'},
- delete: {method: 'DELETE'}
+ get: { method: 'GET' },
+ save: { method: 'POST' },
+ query: { method: 'GET' },
+ update: { method: 'PUT' },
+ remove: { method: 'DELETE' },
+ delete: { method: 'DELETE' }
};
module.exports = _.resource = Resource;
-
/***/ }
/******/ ])
});
;
\ No newline at end of file