vuejs-rails 1.0.4 → 1.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 652e1bf18c147ff425bb80bcf926d99fec92fe19
4
- data.tar.gz: 8ecc9c6186aca2d9dfacae834e76f1d3b2389c05
3
+ metadata.gz: e174ae583339c6007caf8ffdf834c9ad8610dbce
4
+ data.tar.gz: 4f23d0e8167cf6100179dfab9a27d70bb70fb53d
5
5
  SHA512:
6
- metadata.gz: 1a7861fd6bc86684780a13058974cf1477067a7094d2a73ca56ac3442fade37889e9d89ab2d0d205a3aa4af12dfdd99f127b6fb2ffb90c75e7edb840582c7ae8
7
- data.tar.gz: a3236a3e9f553c3ac41ab4ca347d7fe9cf4f7b51ea96c5ed78b65d635e54005ca2c68f276a68d8aa4db1ffb1174b32da1f9298eb5a6d11d6aa356defdf52639a
6
+ metadata.gz: 5e5e62bb2ebe40a7e79e92e9973cd3d40316d82bac922a1d443ea3eb4d81cc2e5f15013f29cef8c1a316a03112d20d9130307affb91369d9361fc6c760bde6da
7
+ data.tar.gz: a326fa7b3db116e0a0e66478e04972836b92971184579a1683d2c231b3bbc45cb32ff0299eeda2f1c0733997ecee67ccdcfbe818975aa59195f6e951e7db24ff
@@ -1,5 +1,5 @@
1
1
  module Vue
2
2
  module Rails
3
- VERSION = '1.0.4'
3
+ VERSION = '1.0.16'
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue-resource v0.1.16
2
+ * vue-resource v0.7.0
3
3
  * https://github.com/vuejs/vue-resource
4
4
  * Released under the MIT License.
5
5
  */
@@ -8,7 +8,7 @@
8
8
  if(typeof exports === 'object' && typeof module === 'object')
9
9
  module.exports = factory();
10
10
  else if(typeof define === 'function' && define.amd)
11
- define(factory);
11
+ define([], factory);
12
12
  else if(typeof exports === 'object')
13
13
  exports["VueResource"] = factory();
14
14
  else
@@ -66,23 +66,28 @@ return /******/ (function(modules) { // webpackBootstrap
66
66
 
67
67
  function install(Vue) {
68
68
 
69
- var _ = __webpack_require__(1)(Vue);
69
+ var _ = __webpack_require__(1);
70
70
 
71
- Vue.url = __webpack_require__(2)(_);
72
- Vue.http = __webpack_require__(3)(_);
73
- Vue.resource = __webpack_require__(7)(_);
71
+ _.config = Vue.config;
72
+ _.warning = Vue.util.warn;
73
+ _.nextTick = Vue.util.nextTick;
74
+
75
+ Vue.url = __webpack_require__(2);
76
+ Vue.http = __webpack_require__(8);
77
+ Vue.resource = __webpack_require__(23);
78
+ Vue.Promise = __webpack_require__(10);
74
79
 
75
80
  Object.defineProperties(Vue.prototype, {
76
81
 
77
82
  $url: {
78
83
  get: function () {
79
- return this._url || (this._url = _.options(Vue.url, this, this.$options.url));
84
+ return _.options(Vue.url, this, this.$options.url);
80
85
  }
81
86
  },
82
87
 
83
88
  $http: {
84
89
  get: function () {
85
- return this._http || (this._http = _.options(Vue.http, this, this.$options.http));
90
+ return _.options(Vue.http, this, this.$options.http);
86
91
  }
87
92
  },
88
93
 
@@ -90,6 +95,14 @@ return /******/ (function(modules) { // webpackBootstrap
90
95
  get: function () {
91
96
  return Vue.resource.bind(this);
92
97
  }
98
+ },
99
+
100
+ $promise: {
101
+ get: function () {
102
+ return function (executor) {
103
+ return new Vue.Promise(executor, this);
104
+ }.bind(this);
105
+ }
93
106
  }
94
107
 
95
108
  });
@@ -101,6 +114,7 @@ return /******/ (function(modules) { // webpackBootstrap
101
114
 
102
115
  module.exports = install;
103
116
 
117
+
104
118
  /***/ },
105
119
  /* 1 */
106
120
  /***/ function(module, exports) {
@@ -109,478 +123,844 @@ return /******/ (function(modules) { // webpackBootstrap
109
123
  * Utility functions.
110
124
  */
111
125
 
112
- module.exports = function (Vue) {
126
+ var _ = exports, array = [], console = window.console;
113
127
 
114
- var _ = Vue.util.extend({}, Vue.util);
128
+ _.warn = function (msg) {
129
+ if (console && _.warning && (!_.config.silent || _.config.debug)) {
130
+ console.warn('[VueResource warn]: ' + msg);
131
+ }
132
+ };
115
133
 
116
- _.isString = function (value) {
117
- return typeof value === 'string';
118
- };
134
+ _.error = function (msg) {
135
+ if (console) {
136
+ console.error(msg);
137
+ }
138
+ };
119
139
 
120
- _.isFunction = function (value) {
121
- return typeof value === 'function';
122
- };
140
+ _.trim = function (str) {
141
+ return str.replace(/^\s*|\s*$/g, '');
142
+ };
123
143
 
124
- _.options = function (fn, obj, options) {
144
+ _.toLower = function (str) {
145
+ return str ? str.toLowerCase() : '';
146
+ };
125
147
 
126
- options = options || {};
148
+ _.isArray = Array.isArray;
127
149
 
128
- if (_.isFunction(options)) {
129
- options = options.call(obj);
130
- }
150
+ _.isString = function (val) {
151
+ return typeof val === 'string';
152
+ };
131
153
 
132
- return _.extend(fn.bind({vm: obj, options: options}), fn, {options: options});
133
- };
154
+ _.isFunction = function (val) {
155
+ return typeof val === 'function';
156
+ };
134
157
 
135
- _.each = function (obj, iterator) {
158
+ _.isObject = function (obj) {
159
+ return obj !== null && typeof obj === 'object';
160
+ };
136
161
 
137
- var i, key;
162
+ _.isPlainObject = function (obj) {
163
+ return _.isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
164
+ };
138
165
 
139
- if (typeof obj.length == 'number') {
140
- for (i = 0; i < obj.length; i++) {
141
- iterator.call(obj[i], obj[i], i);
142
- }
143
- } else if (_.isObject(obj)) {
144
- for (key in obj) {
145
- if (obj.hasOwnProperty(key)) {
146
- iterator.call(obj[key], obj[key], key);
147
- }
148
- }
149
- }
166
+ _.options = function (fn, obj, options) {
150
167
 
151
- return obj;
152
- };
168
+ options = options || {};
153
169
 
154
- _.extend = function (target) {
170
+ if (_.isFunction(options)) {
171
+ options = options.call(obj);
172
+ }
173
+
174
+ return _.merge(fn.bind({$vm: obj, $options: options}), fn, {$options: options});
175
+ };
155
176
 
156
- var array = [], args = array.slice.call(arguments, 1), deep;
177
+ _.each = function (obj, iterator) {
157
178
 
158
- if (typeof target == 'boolean') {
159
- deep = target;
160
- target = args.shift();
179
+ var i, key;
180
+
181
+ if (typeof obj.length == 'number') {
182
+ for (i = 0; i < obj.length; i++) {
183
+ iterator.call(obj[i], obj[i], i);
161
184
  }
185
+ } else if (_.isObject(obj)) {
186
+ for (key in obj) {
187
+ if (obj.hasOwnProperty(key)) {
188
+ iterator.call(obj[key], obj[key], key);
189
+ }
190
+ }
191
+ }
162
192
 
163
- args.forEach(function (arg) {
164
- extend(target, arg, deep);
165
- });
193
+ return obj;
194
+ };
166
195
 
167
- return target;
168
- };
196
+ _.defaults = function (target, source) {
169
197
 
170
- function extend(target, source, deep) {
171
- for (var key in source) {
172
- if (deep && (_.isPlainObject(source[key]) || _.isArray(source[key]))) {
173
- if (_.isPlainObject(source[key]) && !_.isPlainObject(target[key])) {
174
- target[key] = {};
175
- }
176
- if (_.isArray(source[key]) && !_.isArray(target[key])) {
177
- target[key] = [];
178
- }
179
- extend(target[key], source[key], deep);
180
- } else if (source[key] !== undefined) {
181
- target[key] = source[key];
182
- }
198
+ for (var key in source) {
199
+ if (target[key] === undefined) {
200
+ target[key] = source[key];
183
201
  }
184
202
  }
185
203
 
186
- return _;
204
+ return target;
205
+ };
206
+
207
+ _.extend = function (target) {
208
+
209
+ var args = array.slice.call(arguments, 1);
210
+
211
+ args.forEach(function (arg) {
212
+ merge(target, arg);
213
+ });
214
+
215
+ return target;
216
+ };
217
+
218
+ _.merge = function (target) {
219
+
220
+ var args = array.slice.call(arguments, 1);
221
+
222
+ args.forEach(function (arg) {
223
+ merge(target, arg, true);
224
+ });
225
+
226
+ return target;
187
227
  };
188
228
 
229
+ function merge(target, source, deep) {
230
+ for (var key in source) {
231
+ if (deep && (_.isPlainObject(source[key]) || _.isArray(source[key]))) {
232
+ if (_.isPlainObject(source[key]) && !_.isPlainObject(target[key])) {
233
+ target[key] = {};
234
+ }
235
+ if (_.isArray(source[key]) && !_.isArray(target[key])) {
236
+ target[key] = [];
237
+ }
238
+ merge(target[key], source[key], deep);
239
+ } else if (source[key] !== undefined) {
240
+ target[key] = source[key];
241
+ }
242
+ }
243
+ }
244
+
189
245
 
190
246
  /***/ },
191
247
  /* 2 */
192
- /***/ function(module, exports) {
248
+ /***/ function(module, exports, __webpack_require__) {
193
249
 
194
250
  /**
195
251
  * Service for URL templating.
196
252
  */
197
253
 
254
+ var _ = __webpack_require__(1);
198
255
  var ie = document.documentMode;
199
256
  var el = document.createElement('a');
200
257
 
201
- module.exports = function (_) {
258
+ function Url(url, params) {
202
259
 
203
- function Url(url, params) {
260
+ var options = url, transform;
204
261
 
205
- var urlParams = {}, queryParams = {}, options = url, query;
262
+ if (_.isString(url)) {
263
+ options = {url: url, params: params};
264
+ }
206
265
 
207
- if (!_.isPlainObject(options)) {
208
- options = {url: url, params: params};
209
- }
266
+ options = _.merge({}, Url.options, this.$options, options);
210
267
 
211
- options = _.extend(true, {},
212
- Url.options, this.options, options
213
- );
268
+ Url.transforms.forEach(function (handler) {
269
+ transform = factory(handler, transform, this.$vm);
270
+ }, this);
214
271
 
215
- url = options.url.replace(/(\/?):([a-z]\w*)/gi, function (match, slash, name) {
272
+ return transform(options);
273
+ };
216
274
 
217
- if (options.params[name]) {
218
- urlParams[name] = true;
219
- return slash + encodeUriSegment(options.params[name]);
220
- }
275
+ /**
276
+ * Url options.
277
+ */
221
278
 
222
- return '';
223
- });
279
+ Url.options = {
280
+ url: '',
281
+ root: null,
282
+ params: {}
283
+ };
224
284
 
225
- if (_.isString(options.root) && !url.match(/^(https?:)?\//)) {
226
- url = options.root + '/' + url;
227
- }
285
+ /**
286
+ * Url transforms.
287
+ */
228
288
 
229
- _.each(options.params, function (value, key) {
230
- if (!urlParams[key]) {
231
- queryParams[key] = value;
232
- }
233
- });
289
+ Url.transforms = [
290
+ __webpack_require__(3),
291
+ __webpack_require__(5),
292
+ __webpack_require__(6),
293
+ __webpack_require__(7)
294
+ ];
295
+
296
+ /**
297
+ * Encodes a Url parameter string.
298
+ *
299
+ * @param {Object} obj
300
+ */
301
+
302
+ Url.params = function (obj) {
303
+
304
+ var params = [], escape = encodeURIComponent;
305
+
306
+ params.add = function (key, value) {
234
307
 
235
- query = Url.params(queryParams);
308
+ if (_.isFunction(value)) {
309
+ value = value();
310
+ }
236
311
 
237
- if (query) {
238
- url += (url.indexOf('?') == -1 ? '?' : '&') + query;
312
+ if (value === null) {
313
+ value = '';
239
314
  }
240
315
 
241
- return url;
316
+ this.push(escape(key) + '=' + escape(value));
317
+ };
318
+
319
+ serialize(params, obj);
320
+
321
+ return params.join('&').replace(/%20/g, '+');
322
+ };
323
+
324
+ /**
325
+ * Parse a URL and return its components.
326
+ *
327
+ * @param {String} url
328
+ */
329
+
330
+ Url.parse = function (url) {
331
+
332
+ if (ie) {
333
+ el.href = url;
334
+ url = el.href;
242
335
  }
243
336
 
244
- /**
245
- * Url options.
246
- */
337
+ el.href = url;
338
+
339
+ return {
340
+ href: el.href,
341
+ protocol: el.protocol ? el.protocol.replace(/:$/, '') : '',
342
+ port: el.port,
343
+ host: el.host,
344
+ hostname: el.hostname,
345
+ pathname: el.pathname.charAt(0) === '/' ? el.pathname : '/' + el.pathname,
346
+ search: el.search ? el.search.replace(/^\?/, '') : '',
347
+ hash: el.hash ? el.hash.replace(/^#/, '') : ''
348
+ };
349
+ };
247
350
 
248
- Url.options = {
249
- url: '',
250
- root: null,
251
- params: {}
351
+ function factory(handler, next, vm) {
352
+ return function (options) {
353
+ return handler.call(vm, options, next);
252
354
  };
355
+ }
253
356
 
254
- /**
255
- * Encodes a Url parameter string.
256
- *
257
- * @param {Object} obj
258
- */
357
+ function serialize(params, obj, scope) {
259
358
 
260
- Url.params = function (obj) {
359
+ var array = _.isArray(obj), plain = _.isPlainObject(obj), hash;
261
360
 
262
- var params = [];
361
+ _.each(obj, function (value, key) {
263
362
 
264
- params.add = function (key, value) {
363
+ hash = _.isObject(value) || _.isArray(value);
265
364
 
266
- if (_.isFunction (value)) {
267
- value = value();
268
- }
365
+ if (scope) {
366
+ key = scope + '[' + (plain || hash ? key : '') + ']';
367
+ }
269
368
 
270
- if (value === null) {
271
- value = '';
272
- }
369
+ if (!scope && array) {
370
+ params.add(value.name, value.value);
371
+ } else if (hash) {
372
+ serialize(params, value, key);
373
+ } else {
374
+ params.add(key, value);
375
+ }
376
+ });
377
+ }
273
378
 
274
- this.push(encodeUriSegment(key) + '=' + encodeUriSegment(value));
275
- };
379
+ module.exports = _.url = Url;
276
380
 
277
- serialize(params, obj);
278
381
 
279
- return params.join('&');
280
- };
382
+ /***/ },
383
+ /* 3 */
384
+ /***/ function(module, exports, __webpack_require__) {
281
385
 
282
- /**
283
- * Parse a URL and return its components.
284
- *
285
- * @param {String} url
286
- */
386
+ /**
387
+ * URL Template (RFC 6570) Transform.
388
+ */
287
389
 
288
- Url.parse = function (url) {
390
+ var UrlTemplate = __webpack_require__(4);
289
391
 
290
- if (ie) {
291
- el.href = url;
292
- url = el.href;
293
- }
392
+ module.exports = function (options) {
294
393
 
295
- el.href = url;
394
+ var variables = [], url = UrlTemplate.expand(options.url, options.params, variables);
296
395
 
297
- return {
298
- href: el.href,
299
- protocol: el.protocol ? el.protocol.replace(/:$/, '') : '',
300
- port: el.port,
301
- host: el.host,
302
- hostname: el.hostname,
303
- pathname: el.pathname.charAt(0) === '/' ? el.pathname : '/' + el.pathname,
304
- search: el.search ? el.search.replace(/^\?/, '') : '',
305
- hash: el.hash ? el.hash.replace(/^#/, '') : ''
306
- };
307
- };
396
+ variables.forEach(function (key) {
397
+ delete options.params[key];
398
+ });
399
+
400
+ return url;
401
+ };
402
+
403
+
404
+ /***/ },
405
+ /* 4 */
406
+ /***/ function(module, exports) {
308
407
 
309
- function serialize(params, obj, scope) {
408
+ /**
409
+ * URL Template v2.0.6 (https://github.com/bramstein/url-template)
410
+ */
411
+
412
+ exports.expand = function (url, params, variables) {
413
+
414
+ var tmpl = this.parse(url), expanded = tmpl.expand(params);
415
+
416
+ if (variables) {
417
+ variables.push.apply(variables, tmpl.vars);
418
+ }
419
+
420
+ return expanded;
421
+ };
422
+
423
+ exports.parse = function (template) {
424
+
425
+ var operators = ['+', '#', '.', '/', ';', '?', '&'], variables = [];
310
426
 
311
- var array = _.isArray(obj), plain = _.isPlainObject(obj), hash;
427
+ return {
428
+ vars: variables,
429
+ expand: function (context) {
430
+ return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
431
+ if (expression) {
312
432
 
313
- _.each(obj, function (value, key) {
433
+ var operator = null, values = [];
314
434
 
315
- hash = _.isObject(value) || _.isArray(value);
435
+ if (operators.indexOf(expression.charAt(0)) !== -1) {
436
+ operator = expression.charAt(0);
437
+ expression = expression.substr(1);
438
+ }
439
+
440
+ expression.split(/,/g).forEach(function (variable) {
441
+ var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
442
+ values.push.apply(values, exports.getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
443
+ variables.push(tmp[1]);
444
+ });
445
+
446
+ if (operator && operator !== '+') {
447
+
448
+ var separator = ',';
449
+
450
+ if (operator === '?') {
451
+ separator = '&';
452
+ } else if (operator !== '#') {
453
+ separator = operator;
454
+ }
455
+
456
+ return (values.length !== 0 ? operator : '') + values.join(separator);
457
+ } else {
458
+ return values.join(',');
459
+ }
316
460
 
317
- if (scope) {
318
- key = scope + '[' + (plain || hash ? key : '') + ']';
461
+ } else {
462
+ return exports.encodeReserved(literal);
463
+ }
464
+ });
465
+ }
466
+ };
467
+ };
468
+
469
+ exports.getValues = function (context, operator, key, modifier) {
470
+
471
+ var value = context[key], result = [];
472
+
473
+ if (this.isDefined(value) && value !== '') {
474
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
475
+ value = value.toString();
476
+
477
+ if (modifier && modifier !== '*') {
478
+ value = value.substring(0, parseInt(modifier, 10));
319
479
  }
320
480
 
321
- if (!scope && array) {
322
- params.add(value.name, value.value);
323
- } else if (hash) {
324
- serialize(params, value, key);
481
+ result.push(this.encodeValue(operator, value, this.isKeyOperator(operator) ? key : null));
482
+ } else {
483
+ if (modifier === '*') {
484
+ if (Array.isArray(value)) {
485
+ value.filter(this.isDefined).forEach(function (value) {
486
+ result.push(this.encodeValue(operator, value, this.isKeyOperator(operator) ? key : null));
487
+ }, this);
488
+ } else {
489
+ Object.keys(value).forEach(function (k) {
490
+ if (this.isDefined(value[k])) {
491
+ result.push(this.encodeValue(operator, value[k], k));
492
+ }
493
+ }, this);
494
+ }
325
495
  } else {
326
- params.add(key, value);
496
+ var tmp = [];
497
+
498
+ if (Array.isArray(value)) {
499
+ value.filter(this.isDefined).forEach(function (value) {
500
+ tmp.push(this.encodeValue(operator, value));
501
+ }, this);
502
+ } else {
503
+ Object.keys(value).forEach(function (k) {
504
+ if (this.isDefined(value[k])) {
505
+ tmp.push(encodeURIComponent(k));
506
+ tmp.push(this.encodeValue(operator, value[k].toString()));
507
+ }
508
+ }, this);
509
+ }
510
+
511
+ if (this.isKeyOperator(operator)) {
512
+ result.push(encodeURIComponent(key) + '=' + tmp.join(','));
513
+ } else if (tmp.length !== 0) {
514
+ result.push(tmp.join(','));
515
+ }
327
516
  }
328
- });
517
+ }
518
+ } else {
519
+ if (operator === ';') {
520
+ result.push(encodeURIComponent(key));
521
+ } else if (value === '' && (operator === '&' || operator === '?')) {
522
+ result.push(encodeURIComponent(key) + '=');
523
+ } else if (value === '') {
524
+ result.push('');
525
+ }
329
526
  }
330
527
 
331
- function encodeUriSegment(value) {
528
+ return result;
529
+ };
332
530
 
333
- return encodeUriQuery(value, true).
334
- replace(/%26/gi, '&').
335
- replace(/%3D/gi, '=').
336
- replace(/%2B/gi, '+');
337
- }
531
+ exports.isDefined = function (value) {
532
+ return value !== undefined && value !== null;
533
+ };
534
+
535
+ exports.isKeyOperator = function (operator) {
536
+ return operator === ';' || operator === '&' || operator === '?';
537
+ };
338
538
 
339
- function encodeUriQuery(value, spaces) {
539
+ exports.encodeValue = function (operator, value, key) {
340
540
 
341
- return encodeURIComponent(value).
342
- replace(/%40/gi, '@').
343
- replace(/%3A/gi, ':').
344
- replace(/%24/g, '$').
345
- replace(/%2C/gi, ',').
346
- replace(/%20/g, (spaces ? '%20' : '+'));
541
+ value = (operator === '+' || operator === '#') ? this.encodeReserved(value) : encodeURIComponent(value);
542
+
543
+ if (key) {
544
+ return encodeURIComponent(key) + '=' + value;
545
+ } else {
546
+ return value;
347
547
  }
548
+ };
348
549
 
349
- return _.url = Url;
550
+ exports.encodeReserved = function (str) {
551
+ return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) {
552
+ if (!/%[0-9A-Fa-f]/.test(part)) {
553
+ part = encodeURI(part);
554
+ }
555
+ return part;
556
+ }).join('');
350
557
  };
351
558
 
352
559
 
353
560
  /***/ },
354
- /* 3 */
561
+ /* 5 */
355
562
  /***/ function(module, exports, __webpack_require__) {
356
563
 
357
564
  /**
358
- * Service for sending network requests.
565
+ * Legacy Transform.
359
566
  */
360
567
 
361
- var xhr = __webpack_require__(4);
362
- var jsonp = __webpack_require__(6);
363
- var Promise = __webpack_require__(5);
568
+ var _ = __webpack_require__(1);
364
569
 
365
- module.exports = function (_) {
570
+ module.exports = function (options, next) {
366
571
 
367
- var originUrl = _.url.parse(location.href);
368
- var jsonType = {'Content-Type': 'application/json;charset=utf-8'};
572
+ var variables = [], url = next(options);
369
573
 
370
- function Http(url, options) {
574
+ url = url.replace(/(\/?):([a-z]\w*)/gi, function (match, slash, name) {
371
575
 
372
- var promise;
576
+ _.warn('The `:' + name + '` parameter syntax has been deprecated. Use the `{' + name + '}` syntax instead.');
373
577
 
374
- if (_.isPlainObject(url)) {
375
- options = url;
376
- url = '';
578
+ if (options.params[name]) {
579
+ variables.push(name);
580
+ return slash + encodeUriSegment(options.params[name]);
377
581
  }
378
582
 
379
- options = _.extend({url: url}, options);
380
- options = _.extend(true, {},
381
- Http.options, this.options, options
382
- );
583
+ return '';
584
+ });
383
585
 
384
- if (options.crossOrigin === null) {
385
- options.crossOrigin = crossOrigin(options.url);
386
- }
586
+ variables.forEach(function (key) {
587
+ delete options.params[key];
588
+ });
387
589
 
388
- options.method = options.method.toUpperCase();
389
- options.headers = _.extend({}, Http.headers.common,
390
- !options.crossOrigin ? Http.headers.custom : {},
391
- Http.headers[options.method.toLowerCase()],
392
- options.headers
393
- );
590
+ return url;
591
+ };
394
592
 
395
- if (_.isPlainObject(options.data) && /^(GET|JSONP)$/i.test(options.method)) {
396
- _.extend(options.params, options.data);
397
- delete options.data;
398
- }
593
+ function encodeUriSegment(value) {
399
594
 
400
- if (options.emulateHTTP && !options.crossOrigin && /^(PUT|PATCH|DELETE)$/i.test(options.method)) {
401
- options.headers['X-HTTP-Method-Override'] = options.method;
402
- options.method = 'POST';
403
- }
595
+ return encodeUriQuery(value, true).
596
+ replace(/%26/gi, '&').
597
+ replace(/%3D/gi, '=').
598
+ replace(/%2B/gi, '+');
599
+ }
404
600
 
405
- if (options.emulateJSON && _.isPlainObject(options.data)) {
406
- options.headers['Content-Type'] = 'application/x-www-form-urlencoded';
407
- options.data = _.url.params(options.data);
408
- }
601
+ function encodeUriQuery(value, spaces) {
409
602
 
410
- if (_.isObject(options.data) && /FormData/i.test(options.data.toString())) {
411
- delete options.headers['Content-Type'];
412
- }
603
+ return encodeURIComponent(value).
604
+ replace(/%40/gi, '@').
605
+ replace(/%3A/gi, ':').
606
+ replace(/%24/g, '$').
607
+ replace(/%2C/gi, ',').
608
+ replace(/%20/g, (spaces ? '%20' : '+'));
609
+ }
413
610
 
414
- if (_.isPlainObject(options.data)) {
415
- options.data = JSON.stringify(options.data);
416
- }
417
611
 
418
- promise = (options.method == 'JSONP' ? jsonp : xhr).call(this.vm, _, options);
419
- promise = extendPromise(promise.then(transformResponse, transformResponse), this.vm);
612
+ /***/ },
613
+ /* 6 */
614
+ /***/ function(module, exports, __webpack_require__) {
420
615
 
421
- if (options.success) {
422
- promise = promise.success(options.success);
423
- }
616
+ /**
617
+ * Query Parameter Transform.
618
+ */
424
619
 
425
- if (options.error) {
426
- promise = promise.error(options.error);
620
+ var _ = __webpack_require__(1);
621
+
622
+ module.exports = function (options, next) {
623
+
624
+ var urlParams = Object.keys(_.url.options.params), query = {}, url = next(options);
625
+
626
+ _.each(options.params, function (value, key) {
627
+ if (urlParams.indexOf(key) === -1) {
628
+ query[key] = value;
427
629
  }
630
+ });
428
631
 
429
- return promise;
632
+ query = _.url.params(query);
633
+
634
+ if (query) {
635
+ url += (url.indexOf('?') == -1 ? '?' : '&') + query;
430
636
  }
431
637
 
432
- function extendPromise(promise, vm) {
638
+ return url;
639
+ };
640
+
641
+
642
+ /***/ },
643
+ /* 7 */
644
+ /***/ function(module, exports, __webpack_require__) {
433
645
 
434
- promise.success = function (fn) {
646
+ /**
647
+ * Root Prefix Transform.
648
+ */
435
649
 
436
- return extendPromise(promise.then(function (response) {
437
- return fn.call(vm, response.data, response.status, response) || response;
438
- }), vm);
650
+ var _ = __webpack_require__(1);
439
651
 
440
- };
652
+ module.exports = function (options, next) {
441
653
 
442
- promise.error = function (fn) {
654
+ var url = next(options);
443
655
 
444
- return extendPromise(promise.then(undefined, function (response) {
445
- return fn.call(vm, response.data, response.status, response) || response;
446
- }), vm);
656
+ if (_.isString(options.root) && !url.match(/^(https?:)?\//)) {
657
+ url = options.root + '/' + url;
658
+ }
447
659
 
448
- };
660
+ return url;
661
+ };
449
662
 
450
- promise.always = function (fn) {
451
663
 
452
- var cb = function (response) {
453
- return fn.call(vm, response.data, response.status, response) || response;
454
- };
664
+ /***/ },
665
+ /* 8 */
666
+ /***/ function(module, exports, __webpack_require__) {
455
667
 
456
- return extendPromise(promise.then(cb, cb), vm);
457
- };
668
+ /**
669
+ * Service for sending network requests.
670
+ */
458
671
 
459
- return promise;
460
- }
672
+ var _ = __webpack_require__(1);
673
+ var Client = __webpack_require__(9);
674
+ var Promise = __webpack_require__(10);
675
+ var interceptor = __webpack_require__(13);
676
+ var jsonType = {'Content-Type': 'application/json'};
461
677
 
462
- function transformResponse(response) {
678
+ function Http(url, options) {
463
679
 
464
- try {
465
- response.data = JSON.parse(response.responseText);
466
- } catch (e) {
467
- response.data = response.responseText;
468
- }
680
+ var client = Client, request, promise;
681
+
682
+ Http.interceptors.forEach(function (handler) {
683
+ client = interceptor(handler, this.$vm)(client);
684
+ }, this);
685
+
686
+ options = _.isObject(url) ? url : _.extend({url: url}, options);
687
+ request = _.merge({}, Http.options, this.$options, options);
688
+ promise = client(request).bind(this.$vm).then(function (response) {
469
689
 
470
690
  return response.ok ? response : Promise.reject(response);
471
- }
472
691
 
473
- function crossOrigin(url) {
692
+ }, function (response) {
693
+
694
+ if (response instanceof Error) {
695
+ _.error(response);
696
+ }
474
697
 
475
- var requestUrl = _.url.parse(url);
698
+ return Promise.reject(response);
699
+ });
476
700
 
477
- return (requestUrl.protocol !== originUrl.protocol || requestUrl.host !== originUrl.host);
701
+ if (request.success) {
702
+ promise.success(request.success);
478
703
  }
479
704
 
480
- Http.options = {
481
- method: 'get',
482
- params: {},
483
- data: '',
484
- xhr: null,
485
- jsonp: 'callback',
486
- beforeSend: null,
487
- crossOrigin: null,
488
- emulateHTTP: false,
489
- emulateJSON: false
490
- };
705
+ if (request.error) {
706
+ promise.error(request.error);
707
+ }
708
+
709
+ return promise;
710
+ }
711
+
712
+ Http.options = {
713
+ method: 'get',
714
+ data: '',
715
+ params: {},
716
+ headers: {},
717
+ xhr: null,
718
+ upload: null,
719
+ jsonp: 'callback',
720
+ beforeSend: null,
721
+ crossOrigin: null,
722
+ emulateHTTP: false,
723
+ emulateJSON: false,
724
+ timeout: 0
725
+ };
726
+
727
+ Http.interceptors = [
728
+ __webpack_require__(14),
729
+ __webpack_require__(15),
730
+ __webpack_require__(16),
731
+ __webpack_require__(18),
732
+ __webpack_require__(19),
733
+ __webpack_require__(20),
734
+ __webpack_require__(21)
735
+ ];
736
+
737
+ Http.headers = {
738
+ put: jsonType,
739
+ post: jsonType,
740
+ patch: jsonType,
741
+ delete: jsonType,
742
+ common: {'Accept': 'application/json, text/plain, */*'},
743
+ custom: {'X-Requested-With': 'XMLHttpRequest'}
744
+ };
745
+
746
+ ['get', 'put', 'post', 'patch', 'delete', 'jsonp'].forEach(function (method) {
747
+
748
+ Http[method] = function (url, data, success, options) {
749
+
750
+ if (_.isFunction(data)) {
751
+ options = success;
752
+ success = data;
753
+ data = undefined;
754
+ }
755
+
756
+ if (_.isObject(success)) {
757
+ options = success;
758
+ success = undefined;
759
+ }
491
760
 
492
- Http.headers = {
493
- put: jsonType,
494
- post: jsonType,
495
- patch: jsonType,
496
- delete: jsonType,
497
- common: {'Accept': 'application/json, text/plain, */*'},
498
- custom: {'X-Requested-With': 'XMLHttpRequest'}
761
+ return this(url, _.extend({method: method, data: data, success: success}, options));
499
762
  };
763
+ });
500
764
 
501
- ['get', 'put', 'post', 'patch', 'delete', 'jsonp'].forEach(function (method) {
765
+ module.exports = _.http = Http;
502
766
 
503
- Http[method] = function (url, data, success, options) {
504
767
 
505
- if (_.isFunction(data)) {
506
- options = success;
507
- success = data;
508
- data = undefined;
509
- }
768
+ /***/ },
769
+ /* 9 */
770
+ /***/ function(module, exports, __webpack_require__) {
510
771
 
511
- return this(url, _.extend({method: method, data: data, success: success}, options));
512
- };
772
+ /**
773
+ * Base client.
774
+ */
775
+
776
+ var _ = __webpack_require__(1);
777
+ var Promise = __webpack_require__(10);
778
+ var xhrClient = __webpack_require__(12);
779
+
780
+ module.exports = function (request) {
781
+
782
+ var response = (request.client || xhrClient)(request);
783
+
784
+ return Promise.resolve(response).then(function (response) {
785
+
786
+ if (response.headers) {
787
+
788
+ var headers = parseHeaders(response.headers);
789
+
790
+ response.headers = function (name) {
791
+
792
+ if (name) {
793
+ return headers[_.toLower(name)];
794
+ }
795
+
796
+ return headers;
797
+ };
798
+
799
+ }
800
+
801
+ response.ok = response.status >= 200 && response.status < 300;
802
+
803
+ return response;
513
804
  });
514
805
 
515
- return _.http = Http;
516
806
  };
517
807
 
808
+ function parseHeaders(str) {
809
+
810
+ var headers = {}, value, name, i;
811
+
812
+ if (_.isString(str)) {
813
+ _.each(str.split('\n'), function (row) {
814
+
815
+ i = row.indexOf(':');
816
+ name = _.trim(_.toLower(row.slice(0, i)));
817
+ value = _.trim(row.slice(i + 1));
818
+
819
+ if (headers[name]) {
820
+
821
+ if (_.isArray(headers[name])) {
822
+ headers[name].push(value);
823
+ } else {
824
+ headers[name] = [headers[name], value];
825
+ }
826
+
827
+ } else {
828
+
829
+ headers[name] = value;
830
+ }
831
+
832
+ });
833
+ }
834
+
835
+ return headers;
836
+ }
837
+
518
838
 
519
839
  /***/ },
520
- /* 4 */
840
+ /* 10 */
521
841
  /***/ function(module, exports, __webpack_require__) {
522
842
 
523
843
  /**
524
- * XMLHttp request.
844
+ * Promise adapter.
525
845
  */
526
846
 
527
- var Promise = __webpack_require__(5);
528
- var XDomain = window.XDomainRequest;
847
+ var _ = __webpack_require__(1);
848
+ var PromiseObj = window.Promise || __webpack_require__(11);
849
+
850
+ function Promise(executor, context) {
851
+
852
+ if (executor instanceof PromiseObj) {
853
+ this.promise = executor;
854
+ } else {
855
+ this.promise = new PromiseObj(executor.bind(context));
856
+ }
857
+
858
+ this.context = context;
859
+ }
860
+
861
+ Promise.all = function (iterable, context) {
862
+ return new Promise(PromiseObj.all(iterable), context);
863
+ };
864
+
865
+ Promise.resolve = function (value, context) {
866
+ return new Promise(PromiseObj.resolve(value), context);
867
+ };
868
+
869
+ Promise.reject = function (reason, context) {
870
+ return new Promise(PromiseObj.reject(reason), context);
871
+ };
872
+
873
+ Promise.race = function (iterable, context) {
874
+ return new Promise(PromiseObj.race(iterable), context);
875
+ };
529
876
 
530
- module.exports = function (_, options) {
877
+ var p = Promise.prototype;
531
878
 
532
- var request = new XMLHttpRequest(), promise;
879
+ p.bind = function (context) {
880
+ this.context = context;
881
+ return this;
882
+ };
533
883
 
534
- if (XDomain && options.crossOrigin) {
535
- request = new XDomainRequest(); options.headers = {};
884
+ p.then = function (fulfilled, rejected) {
885
+
886
+ if (fulfilled && fulfilled.bind && this.context) {
887
+ fulfilled = fulfilled.bind(this.context);
536
888
  }
537
889
 
538
- if (_.isPlainObject(options.xhr)) {
539
- _.extend(request, options.xhr);
890
+ if (rejected && rejected.bind && this.context) {
891
+ rejected = rejected.bind(this.context);
540
892
  }
541
893
 
542
- if (_.isFunction(options.beforeSend)) {
543
- options.beforeSend.call(this, request, options);
894
+ this.promise = this.promise.then(fulfilled, rejected);
895
+
896
+ return this;
897
+ };
898
+
899
+ p.catch = function (rejected) {
900
+
901
+ if (rejected && rejected.bind && this.context) {
902
+ rejected = rejected.bind(this.context);
544
903
  }
545
904
 
546
- promise = new Promise(function (resolve, reject) {
905
+ this.promise = this.promise.catch(rejected);
547
906
 
548
- request.open(options.method, _.url(options), true);
907
+ return this;
908
+ };
549
909
 
550
- _.each(options.headers, function (value, header) {
551
- request.setRequestHeader(header, value);
552
- });
910
+ p.finally = function (callback) {
553
911
 
554
- var handler = function (event) {
912
+ return this.then(function (value) {
913
+ callback.call(this);
914
+ return value;
915
+ }, function (reason) {
916
+ callback.call(this);
917
+ return PromiseObj.reject(reason);
918
+ }
919
+ );
920
+ };
555
921
 
556
- request.ok = event.type === 'load';
922
+ p.success = function (callback) {
557
923
 
558
- if (request.ok && request.status) {
559
- request.ok = request.status >= 200 && request.status < 300;
560
- }
924
+ _.warn('The `success` method has been deprecated. Use the `then` method instead.');
561
925
 
562
- (request.ok ? resolve : reject)(request);
563
- };
926
+ return this.then(function (response) {
927
+ return callback.call(this, response.data, response.status, response) || response;
928
+ });
929
+ };
930
+
931
+ p.error = function (callback) {
564
932
 
565
- request.onload = handler;
566
- request.onabort = handler;
567
- request.onerror = handler;
933
+ _.warn('The `error` method has been deprecated. Use the `catch` method instead.');
568
934
 
569
- request.send(options.data);
935
+ return this.catch(function (response) {
936
+ return callback.call(this, response.data, response.status, response) || response;
570
937
  });
938
+ };
571
939
 
572
- return promise;
940
+ p.always = function (callback) {
941
+
942
+ _.warn('The `always` method has been deprecated. Use the `finally` method instead.');
943
+
944
+ var cb = function (response) {
945
+ return callback.call(this, response.data, response.status, response) || response;
946
+ };
947
+
948
+ return this.then(cb, cb);
573
949
  };
574
950
 
951
+ module.exports = Promise;
952
+
575
953
 
576
954
  /***/ },
577
- /* 5 */
578
- /***/ function(module, exports) {
955
+ /* 11 */
956
+ /***/ function(module, exports, __webpack_require__) {
579
957
 
580
958
  /**
581
- * Promises/A+ polyfill v1.1.0 (https://github.com/bramstein/promis)
959
+ * Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis)
582
960
  */
583
961
 
962
+ var _ = __webpack_require__(1);
963
+
584
964
  var RESOLVED = 0;
585
965
  var REJECTED = 1;
586
966
  var PENDING = 2;
@@ -618,8 +998,7 @@ return /******/ (function(modules) { // webpackBootstrap
618
998
 
619
999
  Promise.all = function all(iterable) {
620
1000
  return new Promise(function (resolve, reject) {
621
- var count = 0,
622
- result = [];
1001
+ var count = 0, result = [];
623
1002
 
624
1003
  if (iterable.length === 0) {
625
1004
  resolve(result);
@@ -637,7 +1016,7 @@ return /******/ (function(modules) { // webpackBootstrap
637
1016
  }
638
1017
 
639
1018
  for (var i = 0; i < iterable.length; i += 1) {
640
- iterable[i].then(resolver(i), reject);
1019
+ Promise.resolve(iterable[i]).then(resolver(i), reject);
641
1020
  }
642
1021
  });
643
1022
  };
@@ -645,7 +1024,7 @@ return /******/ (function(modules) { // webpackBootstrap
645
1024
  Promise.race = function race(iterable) {
646
1025
  return new Promise(function (resolve, reject) {
647
1026
  for (var i = 0; i < iterable.length; i += 1) {
648
- iterable[i].then(resolve, reject);
1027
+ Promise.resolve(iterable[i]).then(resolve, reject);
649
1028
  }
650
1029
  });
651
1030
  };
@@ -686,6 +1065,7 @@ return /******/ (function(modules) { // webpackBootstrap
686
1065
  }
687
1066
  return;
688
1067
  }
1068
+
689
1069
  promise.state = RESOLVED;
690
1070
  promise.value = x;
691
1071
  promise.notify();
@@ -709,7 +1089,7 @@ return /******/ (function(modules) { // webpackBootstrap
709
1089
  p.notify = function notify() {
710
1090
  var promise = this;
711
1091
 
712
- async(function () {
1092
+ _.nextTick(function () {
713
1093
  if (promise.state !== PENDING) {
714
1094
  while (promise.deferred.length) {
715
1095
  var deferred = promise.deferred.shift(),
@@ -740,10 +1120,6 @@ return /******/ (function(modules) { // webpackBootstrap
740
1120
  });
741
1121
  };
742
1122
 
743
- p.catch = function (onRejected) {
744
- return this.then(undefined, onRejected);
745
- };
746
-
747
1123
  p.then = function then(onResolved, onRejected) {
748
1124
  var promise = this;
749
1125
 
@@ -753,87 +1129,248 @@ return /******/ (function(modules) { // webpackBootstrap
753
1129
  });
754
1130
  };
755
1131
 
756
- var queue = [];
757
- var async = function (callback) {
758
- queue.push(callback);
759
-
760
- if (queue.length === 1) {
761
- async.async();
762
- }
1132
+ p.catch = function (onRejected) {
1133
+ return this.then(undefined, onRejected);
763
1134
  };
764
1135
 
765
- async.run = function () {
766
- while (queue.length) {
767
- queue[0]();
768
- queue.shift();
769
- }
770
- };
1136
+ module.exports = Promise;
1137
+
1138
+
1139
+ /***/ },
1140
+ /* 12 */
1141
+ /***/ function(module, exports, __webpack_require__) {
1142
+
1143
+ /**
1144
+ * XMLHttp client.
1145
+ */
1146
+
1147
+ var _ = __webpack_require__(1);
1148
+ var Promise = __webpack_require__(10);
1149
+
1150
+ module.exports = function (request) {
1151
+ return new Promise(function (resolve) {
1152
+
1153
+ var xhr = new XMLHttpRequest(), response = {request: request}, handler;
1154
+
1155
+ request.cancel = function () {
1156
+ xhr.abort();
1157
+ };
1158
+
1159
+ xhr.open(request.method, _.url(request), true);
1160
+
1161
+ handler = function (event) {
1162
+
1163
+ response.data = xhr.responseText;
1164
+ response.status = xhr.status;
1165
+ response.statusText = xhr.statusText;
1166
+ response.headers = xhr.getAllResponseHeaders();
1167
+
1168
+ resolve(response);
1169
+ };
771
1170
 
772
- if (window.MutationObserver) {
773
- var el = document.createElement('div');
774
- var mo = new MutationObserver(async.run);
1171
+ xhr.timeout = 0;
1172
+ xhr.onload = handler;
1173
+ xhr.onabort = handler;
1174
+ xhr.onerror = handler;
1175
+ xhr.ontimeout = function () {};
1176
+ xhr.onprogress = function () {};
775
1177
 
776
- mo.observe(el, {
777
- attributes: true
1178
+ if (_.isPlainObject(request.xhr)) {
1179
+ _.extend(xhr, request.xhr);
1180
+ }
1181
+
1182
+ if (_.isPlainObject(request.upload)) {
1183
+ _.extend(xhr.upload, request.upload);
1184
+ }
1185
+
1186
+ _.each(request.headers || {}, function (value, header) {
1187
+ xhr.setRequestHeader(header, value);
1188
+ });
1189
+
1190
+ xhr.send(request.data);
778
1191
  });
1192
+ };
779
1193
 
780
- async.async = function () {
781
- el.setAttribute("x", 0);
782
- };
783
- } else {
784
- async.async = function () {
785
- setTimeout(async.run);
1194
+
1195
+ /***/ },
1196
+ /* 13 */
1197
+ /***/ function(module, exports, __webpack_require__) {
1198
+
1199
+ /**
1200
+ * Interceptor factory.
1201
+ */
1202
+
1203
+ var _ = __webpack_require__(1);
1204
+ var Promise = __webpack_require__(10);
1205
+
1206
+ module.exports = function (handler, vm) {
1207
+
1208
+ return function (client) {
1209
+
1210
+ if (_.isFunction(handler)) {
1211
+ handler = handler.call(vm, Promise);
1212
+ }
1213
+
1214
+ return function (request) {
1215
+
1216
+ if (_.isFunction(handler.request)) {
1217
+ request = handler.request.call(vm, request);
1218
+ }
1219
+
1220
+ return when(request, function (request) {
1221
+ return when(client(request), function (response) {
1222
+
1223
+ if (_.isFunction(handler.response)) {
1224
+ response = handler.response.call(vm, response);
1225
+ }
1226
+
1227
+ return response;
1228
+ });
1229
+ });
1230
+ };
786
1231
  };
1232
+ };
1233
+
1234
+ function when(value, fulfilled, rejected) {
1235
+
1236
+ var promise = Promise.resolve(value);
1237
+
1238
+ if (arguments.length < 2) {
1239
+ return promise;
1240
+ }
1241
+
1242
+ return promise.then(fulfilled, rejected);
787
1243
  }
788
1244
 
789
- module.exports = window.Promise || Promise;
1245
+
1246
+ /***/ },
1247
+ /* 14 */
1248
+ /***/ function(module, exports, __webpack_require__) {
1249
+
1250
+ /**
1251
+ * Before Interceptor.
1252
+ */
1253
+
1254
+ var _ = __webpack_require__(1);
1255
+
1256
+ module.exports = {
1257
+
1258
+ request: function (request) {
1259
+
1260
+ if (_.isFunction(request.beforeSend)) {
1261
+ request.beforeSend.call(this, request);
1262
+ }
1263
+
1264
+ return request;
1265
+ }
1266
+
1267
+ };
790
1268
 
791
1269
 
792
1270
  /***/ },
793
- /* 6 */
1271
+ /* 15 */
1272
+ /***/ function(module, exports) {
1273
+
1274
+ /**
1275
+ * Timeout Interceptor.
1276
+ */
1277
+
1278
+ module.exports = function () {
1279
+
1280
+ var timeout;
1281
+
1282
+ return {
1283
+
1284
+ request: function (request) {
1285
+
1286
+ if (request.timeout) {
1287
+ timeout = setTimeout(function () {
1288
+ request.cancel();
1289
+ }, request.timeout);
1290
+ }
1291
+
1292
+ return request;
1293
+ },
1294
+
1295
+ response: function (response) {
1296
+
1297
+ clearTimeout(timeout);
1298
+
1299
+ return response;
1300
+ }
1301
+
1302
+ };
1303
+ };
1304
+
1305
+
1306
+ /***/ },
1307
+ /* 16 */
794
1308
  /***/ function(module, exports, __webpack_require__) {
795
1309
 
796
1310
  /**
797
- * JSONP request.
1311
+ * JSONP Interceptor.
798
1312
  */
799
1313
 
800
- var Promise = __webpack_require__(5);
1314
+ var jsonpClient = __webpack_require__(17);
801
1315
 
802
- module.exports = function (_, options) {
1316
+ module.exports = {
803
1317
 
804
- var callback = '_jsonp' + Math.random().toString(36).substr(2), response = {}, script, body;
1318
+ request: function (request) {
805
1319
 
806
- options.params[options.jsonp] = callback;
1320
+ if (request.method == 'JSONP') {
1321
+ request.client = jsonpClient;
1322
+ }
807
1323
 
808
- if (_.isFunction(options.beforeSend)) {
809
- options.beforeSend.call(this, {}, options);
1324
+ return request;
810
1325
  }
811
1326
 
812
- return new Promise(function (resolve, reject) {
1327
+ };
1328
+
1329
+
1330
+ /***/ },
1331
+ /* 17 */
1332
+ /***/ function(module, exports, __webpack_require__) {
1333
+
1334
+ /**
1335
+ * JSONP client.
1336
+ */
1337
+
1338
+ var _ = __webpack_require__(1);
1339
+ var Promise = __webpack_require__(10);
1340
+
1341
+ module.exports = function (request) {
1342
+ return new Promise(function (resolve) {
1343
+
1344
+ var callback = '_jsonp' + Math.random().toString(36).substr(2), response = {request: request, data: null}, handler, script;
1345
+
1346
+ request.params[request.jsonp] = callback;
1347
+ request.cancel = function () {
1348
+ handler({type: 'cancel'});
1349
+ };
813
1350
 
814
1351
  script = document.createElement('script');
815
- script.src = _.url(options);
1352
+ script.src = _.url(request);
816
1353
  script.type = 'text/javascript';
817
1354
  script.async = true;
818
1355
 
819
1356
  window[callback] = function (data) {
820
- body = data;
1357
+ response.data = data;
821
1358
  };
822
1359
 
823
- var handler = function (event) {
1360
+ handler = function (event) {
824
1361
 
825
- delete window[callback];
826
- document.body.removeChild(script);
827
-
828
- if (event.type === 'load' && !body) {
829
- event.type = 'error';
1362
+ if (event.type === 'load' && response.data !== null) {
1363
+ response.status = 200;
1364
+ } else if (event.type === 'error') {
1365
+ response.status = 404;
1366
+ } else {
1367
+ response.status = 0;
830
1368
  }
831
1369
 
832
- response.ok = event.type !== 'error';
833
- response.status = response.ok ? 200 : 404;
834
- response.responseText = body ? body : event.type;
1370
+ resolve(response);
835
1371
 
836
- (response.ok ? resolve : reject)(response);
1372
+ delete window[callback];
1373
+ document.body.removeChild(script);
837
1374
  };
838
1375
 
839
1376
  script.onload = handler;
@@ -841,128 +1378,309 @@ return /******/ (function(modules) { // webpackBootstrap
841
1378
 
842
1379
  document.body.appendChild(script);
843
1380
  });
844
-
845
1381
  };
846
1382
 
847
1383
 
848
1384
  /***/ },
849
- /* 7 */
1385
+ /* 18 */
850
1386
  /***/ function(module, exports) {
851
1387
 
852
1388
  /**
853
- * Service for interacting with RESTful services.
1389
+ * HTTP method override Interceptor.
1390
+ */
1391
+
1392
+ module.exports = {
1393
+
1394
+ request: function (request) {
1395
+
1396
+ if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) {
1397
+ request.headers['X-HTTP-Method-Override'] = request.method;
1398
+ request.method = 'POST';
1399
+ }
1400
+
1401
+ return request;
1402
+ }
1403
+
1404
+ };
1405
+
1406
+
1407
+ /***/ },
1408
+ /* 19 */
1409
+ /***/ function(module, exports, __webpack_require__) {
1410
+
1411
+ /**
1412
+ * Mime Interceptor.
1413
+ */
1414
+
1415
+ var _ = __webpack_require__(1);
1416
+
1417
+ module.exports = {
1418
+
1419
+ request: function (request) {
1420
+
1421
+ if (request.emulateJSON && _.isPlainObject(request.data)) {
1422
+ request.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1423
+ request.data = _.url.params(request.data);
1424
+ }
1425
+
1426
+ if (_.isObject(request.data) && /FormData/i.test(request.data.toString())) {
1427
+ delete request.headers['Content-Type'];
1428
+ }
1429
+
1430
+ if (_.isPlainObject(request.data)) {
1431
+ request.data = JSON.stringify(request.data);
1432
+ }
1433
+
1434
+ return request;
1435
+ },
1436
+
1437
+ response: function (response) {
1438
+
1439
+ try {
1440
+ response.data = JSON.parse(response.data);
1441
+ } catch (e) {}
1442
+
1443
+ return response;
1444
+ }
1445
+
1446
+ };
1447
+
1448
+
1449
+ /***/ },
1450
+ /* 20 */
1451
+ /***/ function(module, exports, __webpack_require__) {
1452
+
1453
+ /**
1454
+ * Header Interceptor.
854
1455
  */
855
1456
 
856
- module.exports = function (_) {
1457
+ var _ = __webpack_require__(1);
857
1458
 
858
- function Resource(url, params, actions) {
1459
+ module.exports = {
859
1460
 
860
- var self = this, resource = {};
1461
+ request: function (request) {
861
1462
 
862
- actions = _.extend({},
863
- Resource.actions,
864
- actions
1463
+ request.method = request.method.toUpperCase();
1464
+ request.headers = _.extend({}, _.http.headers.common,
1465
+ !request.crossOrigin ? _.http.headers.custom : {},
1466
+ _.http.headers[request.method.toLowerCase()],
1467
+ request.headers
865
1468
  );
866
1469
 
867
- _.each(actions, function (action, name) {
1470
+ if (_.isPlainObject(request.data) && /^(GET|JSONP)$/i.test(request.method)) {
1471
+ _.extend(request.params, request.data);
1472
+ delete request.data;
1473
+ }
868
1474
 
869
- action = _.extend(true, {url: url, params: params || {}}, action);
1475
+ return request;
1476
+ }
870
1477
 
871
- resource[name] = function () {
872
- return (self.$http || _.http)(opts(action, arguments));
873
- };
874
- });
1478
+ };
1479
+
1480
+
1481
+ /***/ },
1482
+ /* 21 */
1483
+ /***/ function(module, exports, __webpack_require__) {
1484
+
1485
+ /**
1486
+ * CORS Interceptor.
1487
+ */
1488
+
1489
+ var _ = __webpack_require__(1);
1490
+ var xdrClient = __webpack_require__(22);
1491
+ var xhrCors = 'withCredentials' in new XMLHttpRequest();
1492
+ var originUrl = _.url.parse(location.href);
1493
+
1494
+ module.exports = {
1495
+
1496
+ request: function (request) {
1497
+
1498
+ if (request.crossOrigin === null) {
1499
+ request.crossOrigin = crossOrigin(request);
1500
+ }
1501
+
1502
+ if (request.crossOrigin) {
1503
+
1504
+ if (!xhrCors) {
1505
+ request.client = xdrClient;
1506
+ }
875
1507
 
876
- return resource;
1508
+ request.emulateHTTP = false;
1509
+ }
1510
+
1511
+ return request;
877
1512
  }
878
1513
 
879
- function opts(action, args) {
1514
+ };
1515
+
1516
+ function crossOrigin(request) {
880
1517
 
881
- var options = _.extend({}, action), params = {}, data, success, error;
1518
+ var requestUrl = _.url.parse(_.url(request));
882
1519
 
883
- switch (args.length) {
1520
+ return (requestUrl.protocol !== originUrl.protocol || requestUrl.host !== originUrl.host);
1521
+ }
884
1522
 
885
- case 4:
886
1523
 
887
- error = args[3];
888
- success = args[2];
1524
+ /***/ },
1525
+ /* 22 */
1526
+ /***/ function(module, exports, __webpack_require__) {
889
1527
 
890
- case 3:
891
- case 2:
1528
+ /**
1529
+ * XDomain client (Internet Explorer).
1530
+ */
892
1531
 
893
- if (_.isFunction(args[1])) {
1532
+ var _ = __webpack_require__(1);
1533
+ var Promise = __webpack_require__(10);
894
1534
 
895
- if (_.isFunction(args[0])) {
1535
+ module.exports = function (request) {
1536
+ return new Promise(function (resolve) {
896
1537
 
897
- success = args[0];
898
- error = args[1];
1538
+ var xdr = new XDomainRequest(), response = {request: request}, handler;
899
1539
 
900
- break;
901
- }
1540
+ request.cancel = function () {
1541
+ xdr.abort();
1542
+ };
902
1543
 
903
- success = args[1];
904
- error = args[2];
1544
+ xdr.open(request.method, _.url(request), true);
905
1545
 
906
- } else {
1546
+ handler = function (event) {
907
1547
 
908
- params = args[0];
909
- data = args[1];
910
- success = args[2];
1548
+ response.data = xdr.responseText;
1549
+ response.status = xdr.status;
1550
+ response.statusText = xdr.statusText;
911
1551
 
912
- break;
913
- }
1552
+ resolve(response);
1553
+ };
1554
+
1555
+ xdr.timeout = 0;
1556
+ xdr.onload = handler;
1557
+ xdr.onabort = handler;
1558
+ xdr.onerror = handler;
1559
+ xdr.ontimeout = function () {};
1560
+ xdr.onprogress = function () {};
1561
+
1562
+ xdr.send(request.data);
1563
+ });
1564
+ };
1565
+
1566
+
1567
+ /***/ },
1568
+ /* 23 */
1569
+ /***/ function(module, exports, __webpack_require__) {
1570
+
1571
+ /**
1572
+ * Service for interacting with RESTful services.
1573
+ */
1574
+
1575
+ var _ = __webpack_require__(1);
1576
+
1577
+ function Resource(url, params, actions, options) {
1578
+
1579
+ var self = this, resource = {};
1580
+
1581
+ actions = _.extend({},
1582
+ Resource.actions,
1583
+ actions
1584
+ );
1585
+
1586
+ _.each(actions, function (action, name) {
1587
+
1588
+ action = _.merge({url: url, params: params || {}}, options, action);
1589
+
1590
+ resource[name] = function () {
1591
+ return (self.$http || _.http)(opts(action, arguments));
1592
+ };
1593
+ });
1594
+
1595
+ return resource;
1596
+ }
1597
+
1598
+ function opts(action, args) {
1599
+
1600
+ var options = _.extend({}, action), params = {}, data, success, error;
1601
+
1602
+ switch (args.length) {
1603
+
1604
+ case 4:
1605
+
1606
+ error = args[3];
1607
+ success = args[2];
914
1608
 
915
- case 1:
1609
+ case 3:
1610
+ case 2:
1611
+
1612
+ if (_.isFunction(args[1])) {
916
1613
 
917
1614
  if (_.isFunction(args[0])) {
1615
+
918
1616
  success = args[0];
919
- } else if (/^(POST|PUT|PATCH)$/i.test(options.method)) {
920
- data = args[0];
921
- } else {
922
- params = args[0];
1617
+ error = args[1];
1618
+
1619
+ break;
923
1620
  }
924
1621
 
925
- break;
1622
+ success = args[1];
1623
+ error = args[2];
1624
+
1625
+ } else {
926
1626
 
927
- case 0:
1627
+ params = args[0];
1628
+ data = args[1];
1629
+ success = args[2];
928
1630
 
929
1631
  break;
1632
+ }
930
1633
 
931
- default:
1634
+ case 1:
932
1635
 
933
- throw 'Expected up to 4 arguments [params, data, success, error], got ' + args.length + ' arguments';
934
- }
1636
+ if (_.isFunction(args[0])) {
1637
+ success = args[0];
1638
+ } else if (/^(POST|PUT|PATCH)$/i.test(options.method)) {
1639
+ data = args[0];
1640
+ } else {
1641
+ params = args[0];
1642
+ }
935
1643
 
936
- options.data = data;
937
- options.params = _.extend({}, options.params, params);
1644
+ break;
938
1645
 
939
- if (success) {
940
- options.success = success;
941
- }
1646
+ case 0:
942
1647
 
943
- if (error) {
944
- options.error = error;
945
- }
1648
+ break;
1649
+
1650
+ default:
946
1651
 
947
- return options;
1652
+ throw 'Expected up to 4 arguments [params, data, success, error], got ' + args.length + ' arguments';
948
1653
  }
949
1654
 
950
- Resource.actions = {
1655
+ options.data = data;
1656
+ options.params = _.extend({}, options.params, params);
951
1657
 
952
- get: {method: 'GET'},
953
- save: {method: 'POST'},
954
- query: {method: 'GET'},
955
- update: {method: 'PUT'},
956
- remove: {method: 'DELETE'},
957
- delete: {method: 'DELETE'}
1658
+ if (success) {
1659
+ options.success = success;
1660
+ }
958
1661
 
959
- };
1662
+ if (error) {
1663
+ options.error = error;
1664
+ }
1665
+
1666
+ return options;
1667
+ }
1668
+
1669
+ Resource.actions = {
1670
+
1671
+ get: {method: 'GET'},
1672
+ save: {method: 'POST'},
1673
+ query: {method: 'GET'},
1674
+ update: {method: 'PUT'},
1675
+ remove: {method: 'DELETE'},
1676
+ delete: {method: 'DELETE'}
960
1677
 
961
- return _.resource = Resource;
962
1678
  };
963
1679
 
1680
+ module.exports = _.resource = Resource;
1681
+
964
1682
 
965
1683
  /***/ }
966
1684
  /******/ ])
967
1685
  });
968
- ;
1686
+ ;