vendor/assets/javascripts/vue-resource.js in vuejs-1.0.25 vs vendor/assets/javascripts/vue-resource.js in vuejs-1.0.26
- old
+ new
@@ -1,1668 +1,1382 @@
-/**
- * vue-resource v0.7.2
+/*!
+ * vue-resource v0.7.4
* https://github.com/vuejs/vue-resource
* Released under the MIT License.
*/
-(function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define([], factory);
- else if(typeof exports === 'object')
- exports["VueResource"] = factory();
- else
- root["VueResource"] = factory();
-})(this, function() {
-return /******/ (function(modules) { // webpackBootstrap
-/******/ // The module cache
-/******/ var installedModules = {};
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global.VueResource = factory());
+}(this, function () { 'use strict';
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
+ 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;
+ };
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId])
-/******/ return installedModules[moduleId].exports;
+ /**
+ * Utility functions.
+ */
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ exports: {},
-/******/ id: moduleId,
-/******/ loaded: false
-/******/ };
+ var util = {};
+ var config = {};
+ var array = [];
+ var console = window.console;
+ function Util (Vue) {
+ util = Vue.util;
+ config = Vue.config;
+ }
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+ var isArray = Array.isArray;
-/******/ // Flag the module as loaded
-/******/ module.loaded = true;
+ function warn(msg) {
+ if (console && util.warn && (!config.silent || config.debug)) {
+ console.warn('[VueResource warn]: ' + msg);
+ }
+ }
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
+ function error(msg) {
+ if (console) {
+ console.error(msg);
+ }
+ }
+ function nextTick(cb, ctx) {
+ return util.nextTick(cb, ctx);
+ }
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
+ function trim(str) {
+ return str.replace(/^\s*|\s*$/g, '');
+ }
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
+ function toLower(str) {
+ return str ? str.toLowerCase() : '';
+ }
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "";
+ function isString(val) {
+ return typeof val === 'string';
+ }
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(0);
-/******/ })
-/************************************************************************/
-/******/ ([
-/* 0 */
-/***/ function(module, exports, __webpack_require__) {
+ function isFunction(val) {
+ return typeof val === 'function';
+ }
- /**
- * Install plugin.
- */
+ function isObject(obj) {
+ return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
+ }
- function plugin(Vue) {
+ function isPlainObject(obj) {
+ return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
+ }
- if (plugin.installed) {
- return;
- }
+ function options(fn, obj, opts) {
- var _ = __webpack_require__(1);
+ opts = opts || {};
- _.config = Vue.config;
- _.warning = Vue.util.warn;
- _.nextTick = Vue.util.nextTick;
+ if (isFunction(opts)) {
+ opts = opts.call(obj);
+ }
- Vue.url = __webpack_require__(2);
- Vue.http = __webpack_require__(8);
- Vue.resource = __webpack_require__(23);
- Vue.Promise = __webpack_require__(10);
+ return merge(fn.bind({ $vm: obj, $options: opts }), fn, { $options: opts });
+ }
- Object.defineProperties(Vue.prototype, {
+ function each(obj, iterator) {
- $url: {
- get: function get() {
- return _.options(Vue.url, this, this.$options.url);
- }
- },
+ var i, key;
- $http: {
- get: function get() {
- return _.options(Vue.http, this, this.$options.http);
- }
- },
+ if (typeof obj.length == 'number') {
+ for (i = 0; i < obj.length; i++) {
+ iterator.call(obj[i], obj[i], i);
+ }
+ } else if (isObject(obj)) {
+ for (key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ iterator.call(obj[key], obj[key], key);
+ }
+ }
+ }
- $resource: {
- get: function get() {
- return Vue.resource.bind(this);
- }
- },
+ return obj;
+ }
- $promise: {
- get: function get() {
- var _this = this;
+ function extend(target) {
- return function (executor) {
- return new Vue.Promise(executor, _this);
- };
- }
- }
+ var args = array.slice.call(arguments, 1);
- });
- }
+ args.forEach(function (arg) {
+ _merge(target, arg);
+ });
- if (typeof window !== 'undefined' && window.Vue) {
- window.Vue.use(plugin);
- }
+ return target;
+ }
- module.exports = plugin;
+ function merge(target) {
-/***/ },
-/* 1 */
-/***/ function(module, exports) {
+ var args = array.slice.call(arguments, 1);
- 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; };
+ args.forEach(function (arg) {
+ _merge(target, arg, true);
+ });
- /**
- * Utility functions.
- */
+ return target;
+ }
- var _ = exports,
- array = [],
- console = window.console;
+ function _merge(target, source, deep) {
+ for (var key in source) {
+ if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
+ if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
+ target[key] = {};
+ }
+ if (isArray(source[key]) && !isArray(target[key])) {
+ target[key] = [];
+ }
+ _merge(target[key], source[key], deep);
+ } else if (source[key] !== undefined) {
+ target[key] = source[key];
+ }
+ }
+ }
- _.warn = function (msg) {
- if (console && _.warning && (!_.config.silent || _.config.debug)) {
- console.warn('[VueResource warn]: ' + msg);
- }
- };
+ function root (options, next) {
- _.error = function (msg) {
- if (console) {
- console.error(msg);
- }
- };
+ var url = next(options);
- _.trim = function (str) {
- return str.replace(/^\s*|\s*$/g, '');
- };
+ if (isString(options.root) && !url.match(/^(https?:)?\//)) {
+ url = options.root + '/' + url;
+ }
- _.toLower = function (str) {
- return str ? str.toLowerCase() : '';
- };
+ return url;
+ }
- _.isArray = Array.isArray;
+ function query (options, next) {
- _.isString = function (val) {
- return typeof val === 'string';
- };
+ var urlParams = Object.keys(Url.options.params),
+ query = {},
+ url = next(options);
- _.isFunction = function (val) {
- return typeof val === 'function';
- };
+ each(options.params, function (value, key) {
+ if (urlParams.indexOf(key) === -1) {
+ query[key] = value;
+ }
+ });
- _.isObject = function (obj) {
- return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
- };
+ query = Url.params(query);
- _.isPlainObject = function (obj) {
- return _.isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
- };
+ if (query) {
+ url += (url.indexOf('?') == -1 ? '?' : '&') + query;
+ }
- _.options = function (fn, obj, options) {
+ return url;
+ }
- options = options || {};
+ function legacy (options, next) {
- if (_.isFunction(options)) {
- options = options.call(obj);
- }
+ var variables = [],
+ url = next(options);
- return _.merge(fn.bind({ $vm: obj, $options: options }), fn, { $options: options });
- };
+ url = url.replace(/(\/?):([a-z]\w*)/gi, function (match, slash, name) {
- _.each = function (obj, iterator) {
+ warn('The `:' + name + '` parameter syntax has been deprecated. Use the `{' + name + '}` syntax instead.');
- var i, key;
+ if (options.params[name]) {
+ variables.push(name);
+ return slash + encodeUriSegment(options.params[name]);
+ }
- if (typeof obj.length == 'number') {
- for (i = 0; i < obj.length; i++) {
- iterator.call(obj[i], obj[i], i);
- }
- } else if (_.isObject(obj)) {
- for (key in obj) {
- if (obj.hasOwnProperty(key)) {
- iterator.call(obj[key], obj[key], key);
- }
- }
- }
+ return '';
+ });
- return obj;
- };
+ variables.forEach(function (key) {
+ delete options.params[key];
+ });
- _.defaults = function (target, source) {
+ return url;
+ }
- for (var key in source) {
- if (target[key] === undefined) {
- target[key] = source[key];
- }
- }
+ function encodeUriSegment(value) {
- return target;
- };
+ return encodeUriQuery(value, true).replace(/%26/gi, '&').replace(/%3D/gi, '=').replace(/%2B/gi, '+');
+ }
- _.extend = function (target) {
+ function encodeUriQuery(value, spaces) {
- var args = array.slice.call(arguments, 1);
+ return encodeURIComponent(value).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, spaces ? '%20' : '+');
+ }
- args.forEach(function (arg) {
- merge(target, arg);
- });
+ /**
+ * URL Template v2.0.6 (https://github.com/bramstein/url-template)
+ */
- return target;
- };
+ function expand(url, params, variables) {
- _.merge = function (target) {
+ var tmpl = parse(url),
+ expanded = tmpl.expand(params);
- var args = array.slice.call(arguments, 1);
+ if (variables) {
+ variables.push.apply(variables, tmpl.vars);
+ }
- args.forEach(function (arg) {
- merge(target, arg, true);
- });
+ return expanded;
+ }
- return target;
- };
+ function parse(template) {
- function merge(target, source, deep) {
- for (var key in source) {
- if (deep && (_.isPlainObject(source[key]) || _.isArray(source[key]))) {
- if (_.isPlainObject(source[key]) && !_.isPlainObject(target[key])) {
- target[key] = {};
- }
- if (_.isArray(source[key]) && !_.isArray(target[key])) {
- target[key] = [];
- }
- merge(target[key], source[key], deep);
- } else if (source[key] !== undefined) {
- target[key] = source[key];
- }
- }
- }
+ var operators = ['+', '#', '.', '/', ';', '?', '&'],
+ variables = [];
-/***/ },
-/* 2 */
-/***/ function(module, exports, __webpack_require__) {
+ return {
+ vars: variables,
+ expand: function expand(context) {
+ return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
+ if (expression) {
- /**
- * Service for URL templating.
- */
+ var operator = null,
+ values = [];
- var _ = __webpack_require__(1);
- var ie = document.documentMode;
- var el = document.createElement('a');
+ if (operators.indexOf(expression.charAt(0)) !== -1) {
+ operator = expression.charAt(0);
+ expression = expression.substr(1);
+ }
- function Url(url, params) {
+ expression.split(/,/g).forEach(function (variable) {
+ var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
+ values.push.apply(values, getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
+ variables.push(tmp[1]);
+ });
- var options = url,
- transform;
+ if (operator && operator !== '+') {
- if (_.isString(url)) {
- options = { url: url, params: params };
- }
+ var separator = ',';
- options = _.merge({}, Url.options, this.$options, options);
+ if (operator === '?') {
+ separator = '&';
+ } else if (operator !== '#') {
+ separator = operator;
+ }
- Url.transforms.forEach(function (handler) {
- transform = factory(handler, transform, this.$vm);
- }, this);
+ return (values.length !== 0 ? operator : '') + values.join(separator);
+ } else {
+ return values.join(',');
+ }
+ } else {
+ return encodeReserved(literal);
+ }
+ });
+ }
+ };
+ }
- return transform(options);
- };
+ function getValues(context, operator, key, modifier) {
- /**
- * Url options.
- */
+ var value = context[key],
+ result = [];
- Url.options = {
- url: '',
- root: null,
- params: {}
- };
+ if (isDefined(value) && value !== '') {
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
+ value = value.toString();
- /**
- * Url transforms.
- */
+ if (modifier && modifier !== '*') {
+ value = value.substring(0, parseInt(modifier, 10));
+ }
- Url.transforms = [__webpack_require__(3), __webpack_require__(5), __webpack_require__(6), __webpack_require__(7)];
+ result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null));
+ } else {
+ if (modifier === '*') {
+ if (Array.isArray(value)) {
+ value.filter(isDefined).forEach(function (value) {
+ result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null));
+ });
+ } else {
+ Object.keys(value).forEach(function (k) {
+ if (isDefined(value[k])) {
+ result.push(encodeValue(operator, value[k], k));
+ }
+ });
+ }
+ } else {
+ var tmp = [];
- /**
- * Encodes a Url parameter string.
- *
- * @param {Object} obj
- */
+ if (Array.isArray(value)) {
+ value.filter(isDefined).forEach(function (value) {
+ tmp.push(encodeValue(operator, value));
+ });
+ } else {
+ Object.keys(value).forEach(function (k) {
+ if (isDefined(value[k])) {
+ tmp.push(encodeURIComponent(k));
+ tmp.push(encodeValue(operator, value[k].toString()));
+ }
+ });
+ }
- Url.params = function (obj) {
+ if (isKeyOperator(operator)) {
+ result.push(encodeURIComponent(key) + '=' + tmp.join(','));
+ } else if (tmp.length !== 0) {
+ result.push(tmp.join(','));
+ }
+ }
+ }
+ } else {
+ if (operator === ';') {
+ result.push(encodeURIComponent(key));
+ } else if (value === '' && (operator === '&' || operator === '?')) {
+ result.push(encodeURIComponent(key) + '=');
+ } else if (value === '') {
+ result.push('');
+ }
+ }
- var params = [],
- escape = encodeURIComponent;
+ return result;
+ }
- params.add = function (key, value) {
+ function isDefined(value) {
+ return value !== undefined && value !== null;
+ }
- if (_.isFunction(value)) {
- value = value();
- }
+ function isKeyOperator(operator) {
+ return operator === ';' || operator === '&' || operator === '?';
+ }
- if (value === null) {
- value = '';
- }
+ function encodeValue(operator, value, key) {
- this.push(escape(key) + '=' + escape(value));
- };
+ value = operator === '+' || operator === '#' ? encodeReserved(value) : encodeURIComponent(value);
- serialize(params, obj);
+ if (key) {
+ return encodeURIComponent(key) + '=' + value;
+ } else {
+ return value;
+ }
+ }
- return params.join('&').replace(/%20/g, '+');
- };
+ function encodeReserved(str) {
+ return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) {
+ if (!/%[0-9A-Fa-f]/.test(part)) {
+ part = encodeURI(part);
+ }
+ return part;
+ }).join('');
+ }
- /**
- * Parse a URL and return its components.
- *
- * @param {String} url
- */
+ function template (options) {
- Url.parse = function (url) {
+ var variables = [],
+ url = expand(options.url, options.params, variables);
- if (ie) {
- el.href = url;
- url = el.href;
- }
+ variables.forEach(function (key) {
+ delete options.params[key];
+ });
- el.href = url;
+ return url;
+ }
- return {
- href: el.href,
- protocol: el.protocol ? el.protocol.replace(/:$/, '') : '',
- port: el.port,
- host: el.host,
- hostname: el.hostname,
- pathname: el.pathname.charAt(0) === '/' ? el.pathname : '/' + el.pathname,
- search: el.search ? el.search.replace(/^\?/, '') : '',
- hash: el.hash ? el.hash.replace(/^#/, '') : ''
- };
- };
+ /**
+ * Service for URL templating.
+ */
- function factory(handler, next, vm) {
- return function (options) {
- return handler.call(vm, options, next);
- };
- }
+ var ie = document.documentMode;
+ var el = document.createElement('a');
- function serialize(params, obj, scope) {
+ function Url(url, params) {
- var array = _.isArray(obj),
- plain = _.isPlainObject(obj),
- hash;
+ var self = this || {},
+ options = url,
+ transform;
- _.each(obj, function (value, key) {
+ if (isString(url)) {
+ options = { url: url, params: params };
+ }
- hash = _.isObject(value) || _.isArray(value);
+ options = merge({}, Url.options, self.$options, options);
- if (scope) {
- key = scope + '[' + (plain || hash ? key : '') + ']';
- }
+ Url.transforms.forEach(function (handler) {
+ transform = factory(handler, transform, self.$vm);
+ });
- if (!scope && array) {
- params.add(value.name, value.value);
- } else if (hash) {
- serialize(params, value, key);
- } else {
- params.add(key, value);
- }
- });
- }
+ return transform(options);
+ }
- module.exports = _.url = Url;
+ /**
+ * Url options.
+ */
-/***/ },
-/* 3 */
-/***/ function(module, exports, __webpack_require__) {
+ Url.options = {
+ url: '',
+ root: null,
+ params: {}
+ };
- /**
- * URL Template (RFC 6570) Transform.
- */
+ /**
+ * Url transforms.
+ */
- var UrlTemplate = __webpack_require__(4);
+ Url.transforms = [template, legacy, query, root];
- module.exports = function (options) {
+ /**
+ * Encodes a Url parameter string.
+ *
+ * @param {Object} obj
+ */
- var variables = [],
- url = UrlTemplate.expand(options.url, options.params, variables);
+ Url.params = function (obj) {
- variables.forEach(function (key) {
- delete options.params[key];
- });
+ var params = [],
+ escape = encodeURIComponent;
- return url;
- };
+ params.add = function (key, value) {
-/***/ },
-/* 4 */
-/***/ function(module, exports) {
+ if (isFunction(value)) {
+ value = value();
+ }
- /**
- * URL Template v2.0.6 (https://github.com/bramstein/url-template)
- */
+ if (value === null) {
+ value = '';
+ }
- exports.expand = function (url, params, variables) {
+ this.push(escape(key) + '=' + escape(value));
+ };
- var tmpl = this.parse(url),
- expanded = tmpl.expand(params);
+ serialize(params, obj);
- if (variables) {
- variables.push.apply(variables, tmpl.vars);
- }
+ return params.join('&').replace(/%20/g, '+');
+ };
- return expanded;
- };
+ /**
+ * Parse a URL and return its components.
+ *
+ * @param {String} url
+ */
- exports.parse = function (template) {
+ Url.parse = function (url) {
- var operators = ['+', '#', '.', '/', ';', '?', '&'],
- variables = [];
+ if (ie) {
+ el.href = url;
+ url = el.href;
+ }
- return {
- vars: variables,
- expand: function expand(context) {
- return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
- if (expression) {
+ el.href = url;
- var operator = null,
- values = [];
+ return {
+ href: el.href,
+ protocol: el.protocol ? el.protocol.replace(/:$/, '') : '',
+ port: el.port,
+ host: el.host,
+ hostname: el.hostname,
+ pathname: el.pathname.charAt(0) === '/' ? el.pathname : '/' + el.pathname,
+ search: el.search ? el.search.replace(/^\?/, '') : '',
+ hash: el.hash ? el.hash.replace(/^#/, '') : ''
+ };
+ };
- if (operators.indexOf(expression.charAt(0)) !== -1) {
- operator = expression.charAt(0);
- expression = expression.substr(1);
- }
+ function factory(handler, next, vm) {
+ return function (options) {
+ return handler.call(vm, options, next);
+ };
+ }
- expression.split(/,/g).forEach(function (variable) {
- var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
- values.push.apply(values, exports.getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
- variables.push(tmp[1]);
- });
+ function serialize(params, obj, scope) {
- if (operator && operator !== '+') {
+ var array = isArray(obj),
+ plain = isPlainObject(obj),
+ hash;
- var separator = ',';
+ each(obj, function (value, key) {
- if (operator === '?') {
- separator = '&';
- } else if (operator !== '#') {
- separator = operator;
- }
+ hash = isObject(value) || isArray(value);
- return (values.length !== 0 ? operator : '') + values.join(separator);
- } else {
- return values.join(',');
- }
- } else {
- return exports.encodeReserved(literal);
- }
- });
- }
- };
- };
+ if (scope) {
+ key = scope + '[' + (plain || hash ? key : '') + ']';
+ }
- exports.getValues = function (context, operator, key, modifier) {
+ if (!scope && array) {
+ params.add(value.name, value.value);
+ } else if (hash) {
+ serialize(params, value, key);
+ } else {
+ params.add(key, value);
+ }
+ });
+ }
- var value = context[key],
- result = [];
+ /**
+ * Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis)
+ */
- if (this.isDefined(value) && value !== '') {
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
- value = value.toString();
+ var RESOLVED = 0;
+ var REJECTED = 1;
+ var PENDING = 2;
- if (modifier && modifier !== '*') {
- value = value.substring(0, parseInt(modifier, 10));
- }
+ function Promise$2(executor) {
- result.push(this.encodeValue(operator, value, this.isKeyOperator(operator) ? key : null));
- } else {
- if (modifier === '*') {
- if (Array.isArray(value)) {
- value.filter(this.isDefined).forEach(function (value) {
- result.push(this.encodeValue(operator, value, this.isKeyOperator(operator) ? key : null));
- }, this);
- } else {
- Object.keys(value).forEach(function (k) {
- if (this.isDefined(value[k])) {
- result.push(this.encodeValue(operator, value[k], k));
- }
- }, this);
- }
- } else {
- var tmp = [];
+ this.state = PENDING;
+ this.value = undefined;
+ this.deferred = [];
- if (Array.isArray(value)) {
- value.filter(this.isDefined).forEach(function (value) {
- tmp.push(this.encodeValue(operator, value));
- }, this);
- } else {
- Object.keys(value).forEach(function (k) {
- if (this.isDefined(value[k])) {
- tmp.push(encodeURIComponent(k));
- tmp.push(this.encodeValue(operator, value[k].toString()));
- }
- }, this);
- }
+ var promise = this;
- if (this.isKeyOperator(operator)) {
- result.push(encodeURIComponent(key) + '=' + tmp.join(','));
- } else if (tmp.length !== 0) {
- result.push(tmp.join(','));
- }
- }
- }
- } else {
- if (operator === ';') {
- result.push(encodeURIComponent(key));
- } else if (value === '' && (operator === '&' || operator === '?')) {
- result.push(encodeURIComponent(key) + '=');
- } else if (value === '') {
- result.push('');
- }
- }
+ try {
+ executor(function (x) {
+ promise.resolve(x);
+ }, function (r) {
+ promise.reject(r);
+ });
+ } catch (e) {
+ promise.reject(e);
+ }
+ }
- return result;
- };
+ Promise$2.reject = function (r) {
+ return new Promise$2(function (resolve, reject) {
+ reject(r);
+ });
+ };
- exports.isDefined = function (value) {
- return value !== undefined && value !== null;
- };
+ Promise$2.resolve = function (x) {
+ return new Promise$2(function (resolve, reject) {
+ resolve(x);
+ });
+ };
- exports.isKeyOperator = function (operator) {
- return operator === ';' || operator === '&' || operator === '?';
- };
+ Promise$2.all = function all(iterable) {
+ return new Promise$2(function (resolve, reject) {
+ var count = 0,
+ result = [];
- exports.encodeValue = function (operator, value, key) {
+ if (iterable.length === 0) {
+ resolve(result);
+ }
- value = operator === '+' || operator === '#' ? this.encodeReserved(value) : encodeURIComponent(value);
+ function resolver(i) {
+ return function (x) {
+ result[i] = x;
+ count += 1;
- if (key) {
- return encodeURIComponent(key) + '=' + value;
- } else {
- return value;
- }
- };
+ if (count === iterable.length) {
+ resolve(result);
+ }
+ };
+ }
- exports.encodeReserved = function (str) {
- return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) {
- if (!/%[0-9A-Fa-f]/.test(part)) {
- part = encodeURI(part);
- }
- return part;
- }).join('');
- };
+ for (var i = 0; i < iterable.length; i += 1) {
+ Promise$2.resolve(iterable[i]).then(resolver(i), reject);
+ }
+ });
+ };
-/***/ },
-/* 5 */
-/***/ function(module, exports, __webpack_require__) {
+ Promise$2.race = function race(iterable) {
+ return new Promise$2(function (resolve, reject) {
+ for (var i = 0; i < iterable.length; i += 1) {
+ Promise$2.resolve(iterable[i]).then(resolve, reject);
+ }
+ });
+ };
- /**
- * Legacy Transform.
- */
+ var p$1 = Promise$2.prototype;
- var _ = __webpack_require__(1);
+ p$1.resolve = function resolve(x) {
+ var promise = this;
- module.exports = function (options, next) {
+ if (promise.state === PENDING) {
+ if (x === promise) {
+ throw new TypeError('Promise settled with itself.');
+ }
- var variables = [],
- url = next(options);
+ var called = false;
- url = url.replace(/(\/?):([a-z]\w*)/gi, function (match, slash, name) {
+ try {
+ var then = x && x['then'];
- _.warn('The `:' + name + '` parameter syntax has been deprecated. Use the `{' + name + '}` syntax instead.');
+ 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;
+ });
+ return;
+ }
+ } catch (e) {
+ if (!called) {
+ promise.reject(e);
+ }
+ return;
+ }
- if (options.params[name]) {
- variables.push(name);
- return slash + encodeUriSegment(options.params[name]);
- }
+ promise.state = RESOLVED;
+ promise.value = x;
+ promise.notify();
+ }
+ };
- return '';
- });
+ p$1.reject = function reject(reason) {
+ var promise = this;
- variables.forEach(function (key) {
- delete options.params[key];
- });
+ if (promise.state === PENDING) {
+ if (reason === promise) {
+ throw new TypeError('Promise settled with itself.');
+ }
- return url;
- };
+ promise.state = REJECTED;
+ promise.value = reason;
+ promise.notify();
+ }
+ };
- function encodeUriSegment(value) {
+ p$1.notify = function notify() {
+ var promise = this;
- return encodeUriQuery(value, true).replace(/%26/gi, '&').replace(/%3D/gi, '=').replace(/%2B/gi, '+');
- }
+ nextTick(function () {
+ if (promise.state !== PENDING) {
+ while (promise.deferred.length) {
+ var deferred = promise.deferred.shift(),
+ onResolved = deferred[0],
+ onRejected = deferred[1],
+ resolve = deferred[2],
+ reject = deferred[3];
- function encodeUriQuery(value, spaces) {
+ try {
+ if (promise.state === RESOLVED) {
+ if (typeof onResolved === 'function') {
+ resolve(onResolved.call(undefined, promise.value));
+ } else {
+ resolve(promise.value);
+ }
+ } else if (promise.state === REJECTED) {
+ if (typeof onRejected === 'function') {
+ resolve(onRejected.call(undefined, promise.value));
+ } else {
+ reject(promise.value);
+ }
+ }
+ } catch (e) {
+ reject(e);
+ }
+ }
+ }
+ });
+ };
- return encodeURIComponent(value).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, spaces ? '%20' : '+');
- }
+ p$1.then = function then(onResolved, onRejected) {
+ var promise = this;
-/***/ },
-/* 6 */
-/***/ function(module, exports, __webpack_require__) {
+ return new Promise$2(function (resolve, reject) {
+ promise.deferred.push([onResolved, onRejected, resolve, reject]);
+ promise.notify();
+ });
+ };
- /**
- * Query Parameter Transform.
- */
+ p$1.catch = function (onRejected) {
+ return this.then(undefined, onRejected);
+ };
- var _ = __webpack_require__(1);
+ var PromiseObj = window.Promise || Promise$2;
- module.exports = function (options, next) {
+ function Promise$1(executor, context) {
- var urlParams = Object.keys(_.url.options.params),
- query = {},
- url = next(options);
+ if (executor instanceof PromiseObj) {
+ this.promise = executor;
+ } else {
+ this.promise = new PromiseObj(executor.bind(context));
+ }
- _.each(options.params, function (value, key) {
- if (urlParams.indexOf(key) === -1) {
- query[key] = value;
- }
- });
+ this.context = context;
+ }
- query = _.url.params(query);
+ Promise$1.all = function (iterable, context) {
+ return new Promise$1(PromiseObj.all(iterable), context);
+ };
- if (query) {
- url += (url.indexOf('?') == -1 ? '?' : '&') + query;
- }
+ Promise$1.resolve = function (value, context) {
+ return new Promise$1(PromiseObj.resolve(value), context);
+ };
- return url;
- };
+ Promise$1.reject = function (reason, context) {
+ return new Promise$1(PromiseObj.reject(reason), context);
+ };
-/***/ },
-/* 7 */
-/***/ function(module, exports, __webpack_require__) {
+ Promise$1.race = function (iterable, context) {
+ return new Promise$1(PromiseObj.race(iterable), context);
+ };
- /**
- * Root Prefix Transform.
- */
+ var p = Promise$1.prototype;
- var _ = __webpack_require__(1);
+ p.bind = function (context) {
+ this.context = context;
+ return this;
+ };
- module.exports = function (options, next) {
+ p.then = function (fulfilled, rejected) {
- var url = next(options);
+ if (fulfilled && fulfilled.bind && this.context) {
+ fulfilled = fulfilled.bind(this.context);
+ }
- if (_.isString(options.root) && !url.match(/^(https?:)?\//)) {
- url = options.root + '/' + url;
- }
+ if (rejected && rejected.bind && this.context) {
+ rejected = rejected.bind(this.context);
+ }
- return url;
- };
+ this.promise = this.promise.then(fulfilled, rejected);
-/***/ },
-/* 8 */
-/***/ function(module, exports, __webpack_require__) {
+ return this;
+ };
- /**
- * Service for sending network requests.
- */
+ p.catch = function (rejected) {
- 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' };
+ if (rejected && rejected.bind && this.context) {
+ rejected = rejected.bind(this.context);
+ }
- function Http(url, options) {
- var _this = this;
+ this.promise = this.promise.catch(rejected);
- var client = Client,
- request,
- promise;
+ return this;
+ };
- Http.interceptors.forEach(function (handler) {
- client = interceptor(handler, _this.$vm)(client);
- });
+ p.finally = function (callback) {
- 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 this.then(function (value) {
+ callback.call(this);
+ return value;
+ }, function (reason) {
+ callback.call(this);
+ return PromiseObj.reject(reason);
+ });
+ };
- return response.ok ? response : Promise.reject(response);
- }, function (response) {
+ p.success = function (callback) {
- if (response instanceof Error) {
- _.error(response);
- }
+ warn('The `success` method has been deprecated. Use the `then` method instead.');
- return Promise.reject(response);
- });
+ return this.then(function (response) {
+ return callback.call(this, response.data, response.status, response) || response;
+ });
+ };
- if (request.success) {
- promise.success(request.success);
- }
+ p.error = function (callback) {
- if (request.error) {
- promise.error(request.error);
- }
+ warn('The `error` method has been deprecated. Use the `catch` method instead.');
- return promise;
- }
+ return this.catch(function (response) {
+ return callback.call(this, response.data, response.status, response) || response;
+ });
+ };
- Http.options = {
- method: 'get',
- data: '',
- params: {},
- headers: {},
- xhr: null,
- upload: null,
- jsonp: 'callback',
- beforeSend: null,
- crossOrigin: null,
- emulateHTTP: false,
- emulateJSON: false,
- timeout: 0
- };
+ p.always = function (callback) {
- Http.interceptors = [__webpack_require__(14), __webpack_require__(15), __webpack_require__(16), __webpack_require__(18), __webpack_require__(19), __webpack_require__(20), __webpack_require__(21)];
+ warn('The `always` method has been deprecated. Use the `finally` method instead.');
- Http.headers = {
- put: jsonType,
- post: jsonType,
- patch: jsonType,
- delete: jsonType,
- common: { 'Accept': 'application/json, text/plain, */*' },
- custom: { 'X-Requested-With': 'XMLHttpRequest' }
- };
+ var cb = function cb(response) {
+ return callback.call(this, response.data, response.status, response) || response;
+ };
- ['get', 'put', 'post', 'patch', 'delete', 'jsonp'].forEach(function (method) {
+ return this.then(cb, cb);
+ };
- Http[method] = function (url, data, success, options) {
+ function xdrClient (request) {
+ return new Promise$1(function (resolve) {
- if (_.isFunction(data)) {
- options = success;
- success = data;
- data = undefined;
- }
+ var xdr = new XDomainRequest(),
+ response = { request: request },
+ handler;
- if (_.isObject(success)) {
- options = success;
- success = undefined;
- }
+ request.cancel = function () {
+ xdr.abort();
+ };
- return this(url, _.extend({ method: method, data: data, success: success }, options));
- };
- });
+ xdr.open(request.method, Url(request), true);
- module.exports = _.http = Http;
+ handler = function handler(event) {
-/***/ },
-/* 9 */
-/***/ function(module, exports, __webpack_require__) {
+ response.data = xdr.responseText;
+ response.status = xdr.status;
+ response.statusText = xdr.statusText || '';
- /**
- * Base client.
- */
+ resolve(response);
+ };
- var _ = __webpack_require__(1);
- var Promise = __webpack_require__(10);
- var xhrClient = __webpack_require__(12);
+ xdr.timeout = 0;
+ xdr.onload = handler;
+ xdr.onabort = handler;
+ xdr.onerror = handler;
+ xdr.ontimeout = function () {};
+ xdr.onprogress = function () {};
- module.exports = function (request) {
+ xdr.send(request.data);
+ });
+ }
- var response = (request.client || xhrClient)(request);
+ var originUrl = Url.parse(location.href);
+ var supportCors = 'withCredentials' in new XMLHttpRequest();
- return Promise.resolve(response).then(function (response) {
+ var exports$1 = {
+ request: function request(_request) {
- if (response.headers) {
+ if (_request.crossOrigin === null) {
+ _request.crossOrigin = crossOrigin(_request);
+ }
- var headers = parseHeaders(response.headers);
+ if (_request.crossOrigin) {
- response.headers = function (name) {
+ if (!supportCors) {
+ _request.client = xdrClient;
+ }
- if (name) {
- return headers[_.toLower(name)];
- }
+ _request.emulateHTTP = false;
+ }
- return headers;
- };
- }
+ return _request;
+ }
+ };
- response.ok = response.status >= 200 && response.status < 300;
+ function crossOrigin(request) {
- return response;
- });
- };
+ var requestUrl = Url.parse(Url(request));
- function parseHeaders(str) {
+ return requestUrl.protocol !== originUrl.protocol || requestUrl.host !== originUrl.host;
+ }
- var headers = {},
- value,
- name,
- i;
+ var exports$2 = {
+ request: function request(_request) {
- if (_.isString(str)) {
- _.each(str.split('\n'), function (row) {
+ if (_request.emulateJSON && isPlainObject(_request.data)) {
+ _request.headers['Content-Type'] = 'application/x-www-form-urlencoded';
+ _request.data = Url.params(_request.data);
+ }
- i = row.indexOf(':');
- name = _.trim(_.toLower(row.slice(0, i)));
- value = _.trim(row.slice(i + 1));
+ if (isObject(_request.data) && /FormData/i.test(_request.data.toString())) {
+ delete _request.headers['Content-Type'];
+ }
- if (headers[name]) {
+ if (isPlainObject(_request.data)) {
+ _request.data = JSON.stringify(_request.data);
+ }
- if (_.isArray(headers[name])) {
- headers[name].push(value);
- } else {
- headers[name] = [headers[name], value];
- }
- } else {
+ return _request;
+ },
+ response: function response(_response) {
- headers[name] = value;
- }
- });
- }
+ try {
+ _response.data = JSON.parse(_response.data);
+ } catch (e) {}
- return headers;
- }
+ return _response;
+ }
+ };
-/***/ },
-/* 10 */
-/***/ function(module, exports, __webpack_require__) {
+ function jsonpClient (request) {
+ return new Promise$1(function (resolve) {
- /**
- * Promise adapter.
- */
+ var callback = '_jsonp' + Math.random().toString(36).substr(2),
+ response = { request: request, data: null },
+ handler,
+ script;
- var _ = __webpack_require__(1);
- var PromiseObj = window.Promise || __webpack_require__(11);
+ request.params[request.jsonp] = callback;
+ request.cancel = function () {
+ handler({ type: 'cancel' });
+ };
- function Promise(executor, context) {
+ script = document.createElement('script');
+ script.src = Url(request);
+ script.type = 'text/javascript';
+ script.async = true;
- if (executor instanceof PromiseObj) {
- this.promise = executor;
- } else {
- this.promise = new PromiseObj(executor.bind(context));
- }
+ window[callback] = function (data) {
+ response.data = data;
+ };
- this.context = context;
- }
+ handler = function handler(event) {
- Promise.all = function (iterable, context) {
- return new Promise(PromiseObj.all(iterable), context);
- };
+ if (event.type === 'load' && response.data !== null) {
+ response.status = 200;
+ } else if (event.type === 'error') {
+ response.status = 404;
+ } else {
+ response.status = 0;
+ }
- Promise.resolve = function (value, context) {
- return new Promise(PromiseObj.resolve(value), context);
- };
+ resolve(response);
- Promise.reject = function (reason, context) {
- return new Promise(PromiseObj.reject(reason), context);
- };
+ delete window[callback];
+ document.body.removeChild(script);
+ };
- Promise.race = function (iterable, context) {
- return new Promise(PromiseObj.race(iterable), context);
- };
+ script.onload = handler;
+ script.onerror = handler;
- var p = Promise.prototype;
+ document.body.appendChild(script);
+ });
+ }
- p.bind = function (context) {
- this.context = context;
- return this;
- };
+ var exports$3 = {
+ request: function request(_request) {
- p.then = function (fulfilled, rejected) {
+ if (_request.method == 'JSONP') {
+ _request.client = jsonpClient;
+ }
- if (fulfilled && fulfilled.bind && this.context) {
- fulfilled = fulfilled.bind(this.context);
- }
+ return _request;
+ }
+ };
- if (rejected && rejected.bind && this.context) {
- rejected = rejected.bind(this.context);
- }
+ var exports$4 = {
+ request: function request(_request) {
- this.promise = this.promise.then(fulfilled, rejected);
+ if (isFunction(_request.beforeSend)) {
+ _request.beforeSend.call(this, _request);
+ }
- return this;
- };
+ return _request;
+ }
+ };
- p.catch = function (rejected) {
+ /**
+ * HTTP method override Interceptor.
+ */
- if (rejected && rejected.bind && this.context) {
- rejected = rejected.bind(this.context);
- }
+ var exports$5 = {
+ request: function request(_request) {
- this.promise = this.promise.catch(rejected);
+ if (_request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(_request.method)) {
+ _request.headers['X-HTTP-Method-Override'] = _request.method;
+ _request.method = 'POST';
+ }
- return this;
- };
+ return _request;
+ }
+ };
- p.finally = function (callback) {
+ var exports$6 = {
+ request: function request(_request) {
- return this.then(function (value) {
- callback.call(this);
- return value;
- }, function (reason) {
- callback.call(this);
- return PromiseObj.reject(reason);
- });
- };
+ _request.method = _request.method.toUpperCase();
+ _request.headers = extend({}, Http.headers.common, !_request.crossOrigin ? Http.headers.custom : {}, Http.headers[_request.method.toLowerCase()], _request.headers);
- p.success = function (callback) {
+ if (isPlainObject(_request.data) && /^(GET|JSONP)$/i.test(_request.method)) {
+ extend(_request.params, _request.data);
+ delete _request.data;
+ }
- _.warn('The `success` method has been deprecated. Use the `then` method instead.');
+ return _request;
+ }
+ };
- return this.then(function (response) {
- return callback.call(this, response.data, response.status, response) || response;
- });
- };
+ /**
+ * Timeout Interceptor.
+ */
- p.error = function (callback) {
+ var exports$7 = function exports() {
- _.warn('The `error` method has been deprecated. Use the `catch` method instead.');
+ var timeout;
- return this.catch(function (response) {
- return callback.call(this, response.data, response.status, response) || response;
- });
- };
+ return {
+ request: function request(_request) {
- p.always = function (callback) {
+ if (_request.timeout) {
+ timeout = setTimeout(function () {
+ _request.cancel();
+ }, _request.timeout);
+ }
- _.warn('The `always` method has been deprecated. Use the `finally` method instead.');
+ return _request;
+ },
+ response: function response(_response) {
- var cb = function cb(response) {
- return callback.call(this, response.data, response.status, response) || response;
- };
+ clearTimeout(timeout);
- return this.then(cb, cb);
- };
+ return _response;
+ }
+ };
+ };
- module.exports = Promise;
+ function interceptor (handler, vm) {
-/***/ },
-/* 11 */
-/***/ function(module, exports, __webpack_require__) {
+ return function (client) {
- 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; };
+ if (isFunction(handler)) {
+ handler = handler.call(vm, Promise$1);
+ }
- /**
- * Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis)
- */
+ return function (request) {
- var _ = __webpack_require__(1);
+ if (isFunction(handler.request)) {
+ request = handler.request.call(vm, request);
+ }
- var RESOLVED = 0;
- var REJECTED = 1;
- var PENDING = 2;
+ return when(request, function (request) {
+ return when(client(request), function (response) {
- function Promise(executor) {
+ if (isFunction(handler.response)) {
+ response = handler.response.call(vm, response);
+ }
- this.state = PENDING;
- this.value = undefined;
- this.deferred = [];
+ return response;
+ });
+ });
+ };
+ };
+ }
- var promise = this;
+ function when(value, fulfilled, rejected) {
- try {
- executor(function (x) {
- promise.resolve(x);
- }, function (r) {
- promise.reject(r);
- });
- } catch (e) {
- promise.reject(e);
- }
- }
+ var promise = Promise$1.resolve(value);
- Promise.reject = function (r) {
- return new Promise(function (resolve, reject) {
- reject(r);
- });
- };
+ if (arguments.length < 2) {
+ return promise;
+ }
- Promise.resolve = function (x) {
- return new Promise(function (resolve, reject) {
- resolve(x);
- });
- };
+ return promise.then(fulfilled, rejected);
+ }
- Promise.all = function all(iterable) {
- return new Promise(function (resolve, reject) {
- var count = 0,
- result = [];
+ function xhrClient (request) {
+ return new Promise$1(function (resolve) {
- if (iterable.length === 0) {
- resolve(result);
- }
+ var xhr = new XMLHttpRequest(),
+ response = { request: request },
+ handler;
- function resolver(i) {
- return function (x) {
- result[i] = x;
- count += 1;
+ request.cancel = function () {
+ xhr.abort();
+ };
- if (count === iterable.length) {
- resolve(result);
- }
- };
- }
+ xhr.open(request.method, Url(request), true);
- for (var i = 0; i < iterable.length; i += 1) {
- Promise.resolve(iterable[i]).then(resolver(i), reject);
- }
- });
- };
+ handler = function handler(event) {
- Promise.race = function race(iterable) {
- return new Promise(function (resolve, reject) {
- for (var i = 0; i < iterable.length; i += 1) {
- Promise.resolve(iterable[i]).then(resolve, reject);
- }
- });
- };
+ response.data = 'response' in xhr ? xhr.response : xhr.responseText;
+ response.status = xhr.status === 1223 ? 204 : xhr.status; // IE9 status bug
+ response.statusText = trim(xhr.statusText || '');
+ response.headers = xhr.getAllResponseHeaders();
- var p = Promise.prototype;
+ resolve(response);
+ };
- p.resolve = function resolve(x) {
- var promise = this;
+ xhr.timeout = 0;
+ xhr.onload = handler;
+ xhr.onabort = handler;
+ xhr.onerror = handler;
+ xhr.ontimeout = function () {};
+ xhr.onprogress = function () {};
- if (promise.state === PENDING) {
- if (x === promise) {
- throw new TypeError('Promise settled with itself.');
- }
+ if (isPlainObject(request.xhr)) {
+ extend(xhr, request.xhr);
+ }
- var called = false;
+ if (isPlainObject(request.upload)) {
+ extend(xhr.upload, request.upload);
+ }
- try {
- var then = x && x['then'];
+ each(request.headers || {}, function (value, header) {
+ xhr.setRequestHeader(header, value);
+ });
- 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;
- });
- return;
- }
- } catch (e) {
- if (!called) {
- promise.reject(e);
- }
- return;
- }
+ xhr.send(request.data);
+ });
+ }
- promise.state = RESOLVED;
- promise.value = x;
- promise.notify();
- }
- };
+ function Client (request) {
- p.reject = function reject(reason) {
- var promise = this;
+ var response = (request.client || xhrClient)(request);
- if (promise.state === PENDING) {
- if (reason === promise) {
- throw new TypeError('Promise settled with itself.');
- }
+ return Promise$1.resolve(response).then(function (response) {
- promise.state = REJECTED;
- promise.value = reason;
- promise.notify();
- }
- };
+ if (response.headers) {
- p.notify = function notify() {
- var promise = this;
+ var headers = parseHeaders(response.headers);
- _.nextTick(function () {
- if (promise.state !== PENDING) {
- while (promise.deferred.length) {
- var deferred = promise.deferred.shift(),
- onResolved = deferred[0],
- onRejected = deferred[1],
- resolve = deferred[2],
- reject = deferred[3];
+ response.headers = function (name) {
- try {
- if (promise.state === RESOLVED) {
- if (typeof onResolved === 'function') {
- resolve(onResolved.call(undefined, promise.value));
- } else {
- resolve(promise.value);
- }
- } else if (promise.state === REJECTED) {
- if (typeof onRejected === 'function') {
- resolve(onRejected.call(undefined, promise.value));
- } else {
- reject(promise.value);
- }
- }
- } catch (e) {
- reject(e);
- }
- }
- }
- });
- };
+ if (name) {
+ return headers[toLower(name)];
+ }
- p.then = function then(onResolved, onRejected) {
- var promise = this;
+ return headers;
+ };
+ }
- return new Promise(function (resolve, reject) {
- promise.deferred.push([onResolved, onRejected, resolve, reject]);
- promise.notify();
- });
- };
+ response.ok = response.status >= 200 && response.status < 300;
- p.catch = function (onRejected) {
- return this.then(undefined, onRejected);
- };
+ return response;
+ });
+ }
- module.exports = Promise;
+ function parseHeaders(str) {
-/***/ },
-/* 12 */
-/***/ function(module, exports, __webpack_require__) {
+ var headers = {},
+ value,
+ name,
+ i;
- /**
- * XMLHttp client.
- */
+ if (isString(str)) {
+ each(str.split('\n'), function (row) {
- var _ = __webpack_require__(1);
- var Promise = __webpack_require__(10);
+ i = row.indexOf(':');
+ name = trim(toLower(row.slice(0, i)));
+ value = trim(row.slice(i + 1));
- module.exports = function (request) {
- return new Promise(function (resolve) {
+ if (headers[name]) {
- var xhr = new XMLHttpRequest(),
- response = { request: request },
- handler;
+ if (isArray(headers[name])) {
+ headers[name].push(value);
+ } else {
+ headers[name] = [headers[name], value];
+ }
+ } else {
- request.cancel = function () {
- xhr.abort();
- };
+ headers[name] = value;
+ }
+ });
+ }
- xhr.open(request.method, _.url(request), true);
+ return headers;
+ }
- handler = function handler(event) {
+ /**
+ * Service for sending network requests.
+ */
- response.data = xhr.responseText;
- response.status = xhr.status;
- response.statusText = xhr.statusText;
- response.headers = xhr.getAllResponseHeaders();
+ var jsonType = { 'Content-Type': 'application/json' };
- resolve(response);
- };
+ function Http(url, options) {
- xhr.timeout = 0;
- xhr.onload = handler;
- xhr.onabort = handler;
- xhr.onerror = handler;
- xhr.ontimeout = function () {};
- xhr.onprogress = function () {};
+ var self = this || {},
+ client = Client,
+ request,
+ promise;
- if (_.isPlainObject(request.xhr)) {
- _.extend(xhr, request.xhr);
- }
+ Http.interceptors.forEach(function (handler) {
+ client = interceptor(handler, self.$vm)(client);
+ });
- if (_.isPlainObject(request.upload)) {
- _.extend(xhr.upload, request.upload);
- }
+ options = isObject(url) ? url : extend({ url: url }, options);
+ request = merge({}, Http.options, self.$options, options);
+ promise = client(request).bind(self.$vm).then(function (response) {
- _.each(request.headers || {}, function (value, header) {
- xhr.setRequestHeader(header, value);
- });
+ return response.ok ? response : Promise$1.reject(response);
+ }, function (response) {
- xhr.send(request.data);
- });
- };
+ if (response instanceof Error) {
+ error(response);
+ }
-/***/ },
-/* 13 */
-/***/ function(module, exports, __webpack_require__) {
+ return Promise$1.reject(response);
+ });
- /**
- * Interceptor factory.
- */
+ if (request.success) {
+ promise.success(request.success);
+ }
- var _ = __webpack_require__(1);
- var Promise = __webpack_require__(10);
+ if (request.error) {
+ promise.error(request.error);
+ }
- module.exports = function (handler, vm) {
+ return promise;
+ }
- return function (client) {
+ Http.options = {
+ method: 'get',
+ data: '',
+ params: {},
+ headers: {},
+ xhr: null,
+ upload: null,
+ jsonp: 'callback',
+ beforeSend: null,
+ crossOrigin: null,
+ emulateHTTP: false,
+ emulateJSON: false,
+ timeout: 0
+ };
- if (_.isFunction(handler)) {
- handler = handler.call(vm, Promise);
- }
+ Http.headers = {
+ put: jsonType,
+ post: jsonType,
+ patch: jsonType,
+ delete: jsonType,
+ common: { 'Accept': 'application/json, text/plain, */*' },
+ custom: { 'X-Requested-With': 'XMLHttpRequest' }
+ };
- return function (request) {
+ Http.interceptors = [exports$4, exports$7, exports$3, exports$5, exports$2, exports$6, exports$1];
- if (_.isFunction(handler.request)) {
- request = handler.request.call(vm, request);
- }
+ ['get', 'put', 'post', 'patch', 'delete', 'jsonp'].forEach(function (method) {
- return when(request, function (request) {
- return when(client(request), function (response) {
+ Http[method] = function (url, data, success, options) {
- if (_.isFunction(handler.response)) {
- response = handler.response.call(vm, response);
- }
+ if (isFunction(data)) {
+ options = success;
+ success = data;
+ data = undefined;
+ }
- return response;
- });
- });
- };
- };
- };
+ if (isObject(success)) {
+ options = success;
+ success = undefined;
+ }
- function when(value, fulfilled, rejected) {
+ return this(url, extend({ method: method, data: data, success: success }, options));
+ };
+ });
- var promise = Promise.resolve(value);
+ function Resource(url, params, actions, options) {
- if (arguments.length < 2) {
- return promise;
- }
+ var self = this || {},
+ resource = {};
- return promise.then(fulfilled, rejected);
- }
+ actions = extend({}, Resource.actions, actions);
-/***/ },
-/* 14 */
-/***/ function(module, exports, __webpack_require__) {
+ each(actions, function (action, name) {
- /**
- * Before Interceptor.
- */
+ action = merge({ url: url, params: params || {} }, options, action);
- var _ = __webpack_require__(1);
+ resource[name] = function () {
+ return (self.$http || Http)(opts(action, arguments));
+ };
+ });
- module.exports = {
+ return resource;
+ }
- request: function request(_request) {
+ function opts(action, args) {
- if (_.isFunction(_request.beforeSend)) {
- _request.beforeSend.call(this, _request);
- }
+ var options = extend({}, action),
+ params = {},
+ data,
+ success,
+ error;
- return _request;
- }
+ switch (args.length) {
- };
+ case 4:
-/***/ },
-/* 15 */
-/***/ function(module, exports) {
+ error = args[3];
+ success = args[2];
- /**
- * Timeout Interceptor.
- */
+ case 3:
+ case 2:
- module.exports = function () {
+ if (isFunction(args[1])) {
- var timeout;
+ if (isFunction(args[0])) {
- return {
+ success = args[0];
+ error = args[1];
- request: function request(_request) {
+ break;
+ }
- if (_request.timeout) {
- timeout = setTimeout(function () {
- _request.cancel();
- }, _request.timeout);
- }
+ success = args[1];
+ error = args[2];
+ } else {
- return _request;
- },
+ params = args[0];
+ data = args[1];
+ success = args[2];
- response: function response(_response) {
+ break;
+ }
- clearTimeout(timeout);
+ case 1:
- return _response;
- }
+ if (isFunction(args[0])) {
+ success = args[0];
+ } else if (/^(POST|PUT|PATCH)$/i.test(options.method)) {
+ data = args[0];
+ } else {
+ params = args[0];
+ }
- };
- };
+ break;
-/***/ },
-/* 16 */
-/***/ function(module, exports, __webpack_require__) {
+ case 0:
- /**
- * JSONP Interceptor.
- */
+ break;
- var jsonpClient = __webpack_require__(17);
+ default:
- module.exports = {
+ throw 'Expected up to 4 arguments [params, data, success, error], got ' + args.length + ' arguments';
+ }
- request: function request(_request) {
+ options.data = data;
+ options.params = extend({}, options.params, params);
- if (_request.method == 'JSONP') {
- _request.client = jsonpClient;
- }
+ if (success) {
+ options.success = success;
+ }
- return _request;
- }
+ if (error) {
+ options.error = error;
+ }
- };
+ return options;
+ }
-/***/ },
-/* 17 */
-/***/ function(module, exports, __webpack_require__) {
+ Resource.actions = {
- /**
- * JSONP client.
- */
+ get: { method: 'GET' },
+ save: { method: 'POST' },
+ query: { method: 'GET' },
+ update: { method: 'PUT' },
+ remove: { method: 'DELETE' },
+ delete: { method: 'DELETE' }
- var _ = __webpack_require__(1);
- var Promise = __webpack_require__(10);
+ };
- module.exports = function (request) {
- return new Promise(function (resolve) {
+ function plugin(Vue) {
- var callback = '_jsonp' + Math.random().toString(36).substr(2),
- response = { request: request, data: null },
- handler,
- script;
+ if (plugin.installed) {
+ return;
+ }
- request.params[request.jsonp] = callback;
- request.cancel = function () {
- handler({ type: 'cancel' });
- };
+ Util(Vue);
- script = document.createElement('script');
- script.src = _.url(request);
- script.type = 'text/javascript';
- script.async = true;
+ Vue.url = Url;
+ Vue.http = Http;
+ Vue.resource = Resource;
+ Vue.Promise = Promise$1;
- window[callback] = function (data) {
- response.data = data;
- };
+ Object.defineProperties(Vue.prototype, {
- handler = function handler(event) {
+ $url: {
+ get: function get() {
+ return options(Vue.url, this, this.$options.url);
+ }
+ },
- if (event.type === 'load' && response.data !== null) {
- response.status = 200;
- } else if (event.type === 'error') {
- response.status = 404;
- } else {
- response.status = 0;
- }
+ $http: {
+ get: function get() {
+ return options(Vue.http, this, this.$options.http);
+ }
+ },
- resolve(response);
+ $resource: {
+ get: function get() {
+ return Vue.resource.bind(this);
+ }
+ },
- delete window[callback];
- document.body.removeChild(script);
- };
+ $promise: {
+ get: function get() {
+ var _this = this;
- script.onload = handler;
- script.onerror = handler;
+ return function (executor) {
+ return new Vue.Promise(executor, _this);
+ };
+ }
+ }
- document.body.appendChild(script);
- });
- };
+ });
+ }
-/***/ },
-/* 18 */
-/***/ function(module, exports) {
+ if (typeof window !== 'undefined' && window.Vue) {
+ window.Vue.use(plugin);
+ }
- /**
- * HTTP method override Interceptor.
- */
+ return plugin;
- module.exports = {
-
- 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';
- }
-
- return _request;
- }
-
- };
-
-/***/ },
-/* 19 */
-/***/ function(module, exports, __webpack_require__) {
-
- /**
- * Mime Interceptor.
- */
-
- var _ = __webpack_require__(1);
-
- module.exports = {
-
- 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 (_.isObject(_request.data) && /FormData/i.test(_request.data.toString())) {
- delete _request.headers['Content-Type'];
- }
-
- if (_.isPlainObject(_request.data)) {
- _request.data = JSON.stringify(_request.data);
- }
-
- return _request;
- },
-
- response: function response(_response) {
-
- try {
- _response.data = JSON.parse(_response.data);
- } catch (e) {}
-
- return _response;
- }
-
- };
-
-/***/ },
-/* 20 */
-/***/ function(module, exports, __webpack_require__) {
-
- /**
- * Header Interceptor.
- */
-
- var _ = __webpack_require__(1);
-
- module.exports = {
-
- 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);
-
- if (_.isPlainObject(_request.data) && /^(GET|JSONP)$/i.test(_request.method)) {
- _.extend(_request.params, _request.data);
- delete _request.data;
- }
-
- return _request;
- }
-
- };
-
-/***/ },
-/* 21 */
-/***/ function(module, exports, __webpack_require__) {
-
- /**
- * CORS Interceptor.
- */
-
- var _ = __webpack_require__(1);
- var xdrClient = __webpack_require__(22);
- var xhrCors = 'withCredentials' in new XMLHttpRequest();
- var originUrl = _.url.parse(location.href);
-
- module.exports = {
-
- request: function request(_request) {
-
- if (_request.crossOrigin === null) {
- _request.crossOrigin = crossOrigin(_request);
- }
-
- if (_request.crossOrigin) {
-
- if (!xhrCors) {
- _request.client = xdrClient;
- }
-
- _request.emulateHTTP = false;
- }
-
- return _request;
- }
-
- };
-
- function crossOrigin(request) {
-
- var requestUrl = _.url.parse(_.url(request));
-
- return requestUrl.protocol !== originUrl.protocol || requestUrl.host !== originUrl.host;
- }
-
-/***/ },
-/* 22 */
-/***/ function(module, exports, __webpack_require__) {
-
- /**
- * XDomain client (Internet Explorer).
- */
-
- var _ = __webpack_require__(1);
- var Promise = __webpack_require__(10);
-
- module.exports = function (request) {
- return new Promise(function (resolve) {
-
- var xdr = new XDomainRequest(),
- response = { request: request },
- handler;
-
- request.cancel = function () {
- xdr.abort();
- };
-
- xdr.open(request.method, _.url(request), true);
-
- handler = function handler(event) {
-
- response.data = xdr.responseText;
- response.status = xdr.status;
- response.statusText = xdr.statusText;
-
- resolve(response);
- };
-
- xdr.timeout = 0;
- xdr.onload = handler;
- xdr.onabort = handler;
- xdr.onerror = handler;
- xdr.ontimeout = function () {};
- xdr.onprogress = function () {};
-
- xdr.send(request.data);
- });
- };
-
-/***/ },
-/* 23 */
-/***/ function(module, exports, __webpack_require__) {
-
- /**
- * Service for interacting with RESTful services.
- */
-
- var _ = __webpack_require__(1);
-
- function Resource(url, params, actions, options) {
-
- var self = this,
- resource = {};
-
- actions = _.extend({}, Resource.actions, actions);
-
- _.each(actions, function (action, name) {
-
- action = _.merge({ url: url, params: params || {} }, options, action);
-
- resource[name] = function () {
- return (self.$http || _.http)(opts(action, arguments));
- };
- });
-
- return resource;
- }
-
- function opts(action, args) {
-
- var options = _.extend({}, action),
- params = {},
- data,
- success,
- error;
-
- switch (args.length) {
-
- case 4:
-
- error = args[3];
- success = args[2];
-
- case 3:
- case 2:
-
- if (_.isFunction(args[1])) {
-
- if (_.isFunction(args[0])) {
-
- success = args[0];
- error = args[1];
-
- break;
- }
-
- success = args[1];
- error = args[2];
- } else {
-
- params = args[0];
- data = args[1];
- success = args[2];
-
- break;
- }
-
- case 1:
-
- if (_.isFunction(args[0])) {
- success = args[0];
- } else if (/^(POST|PUT|PATCH)$/i.test(options.method)) {
- data = args[0];
- } else {
- params = args[0];
- }
-
- break;
-
- case 0:
-
- break;
-
- default:
-
- throw 'Expected up to 4 arguments [params, data, success, error], got ' + args.length + ' arguments';
- }
-
- options.data = data;
- options.params = _.extend({}, options.params, params);
-
- if (success) {
- options.success = success;
- }
-
- if (error) {
- options.error = error;
- }
-
- return options;
- }
-
- Resource.actions = {
-
- 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