vuejs-rails 0.12.12 → 1.0.4

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: e4c4e90150cc78b28107cae522db80ea8d371c8a
4
- data.tar.gz: 420db11d9c8f74335a8df30ca9eefba7cc43287f
3
+ metadata.gz: 652e1bf18c147ff425bb80bcf926d99fec92fe19
4
+ data.tar.gz: 8ecc9c6186aca2d9dfacae834e76f1d3b2389c05
5
5
  SHA512:
6
- metadata.gz: e734a62438bfa6bdb33afcf6a04f32bf7a51926ed2aa68ec5667495f380735b09c975241c2e930238ac3c59374cc7b64859e99749cc2e30681c0b7299dc7ee65
7
- data.tar.gz: 801cfc5a213196f467c9d7a66a20c7cc4e701d2c48b0364584978001bf1ca97f450affbe9d5bab1925a4ba51dd76719e6933a5aa0788c8fb3d3bf971593bd452
6
+ metadata.gz: 1a7861fd6bc86684780a13058974cf1477067a7094d2a73ca56ac3442fade37889e9d89ab2d0d205a3aa4af12dfdd99f127b6fb2ffb90c75e7edb840582c7ae8
7
+ data.tar.gz: a3236a3e9f553c3ac41ab4ca347d7fe9cf4f7b51ea96c5ed78b65d635e54005ca2c68f276a68d8aa4db1ffb1174b32da1f9298eb5a6d11d6aa356defdf52639a
data/Readme.md CHANGED
@@ -13,6 +13,8 @@ Have in your Gemfile:
13
13
  And, have in your application.js manifest:
14
14
 
15
15
  //= require vue
16
+ //= require vue-router (optional)
17
+ //= require vue-resource (optional)
16
18
 
17
19
  ## Contributing
18
20
 
@@ -1,5 +1,5 @@
1
1
  module Vue
2
2
  module Rails
3
- VERSION = "0.12.12"
3
+ VERSION = '1.0.4'
4
4
  end
5
5
  end
@@ -0,0 +1,968 @@
1
+ /**
2
+ * vue-resource v0.1.16
3
+ * https://github.com/vuejs/vue-resource
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ (function webpackUniversalModuleDefinition(root, factory) {
8
+ if(typeof exports === 'object' && typeof module === 'object')
9
+ module.exports = factory();
10
+ else if(typeof define === 'function' && define.amd)
11
+ define(factory);
12
+ else if(typeof exports === 'object')
13
+ exports["VueResource"] = factory();
14
+ else
15
+ root["VueResource"] = factory();
16
+ })(this, function() {
17
+ return /******/ (function(modules) { // webpackBootstrap
18
+ /******/ // The module cache
19
+ /******/ var installedModules = {};
20
+
21
+ /******/ // The require function
22
+ /******/ function __webpack_require__(moduleId) {
23
+
24
+ /******/ // Check if module is in cache
25
+ /******/ if(installedModules[moduleId])
26
+ /******/ return installedModules[moduleId].exports;
27
+
28
+ /******/ // Create a new module (and put it into the cache)
29
+ /******/ var module = installedModules[moduleId] = {
30
+ /******/ exports: {},
31
+ /******/ id: moduleId,
32
+ /******/ loaded: false
33
+ /******/ };
34
+
35
+ /******/ // Execute the module function
36
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
37
+
38
+ /******/ // Flag the module as loaded
39
+ /******/ module.loaded = true;
40
+
41
+ /******/ // Return the exports of the module
42
+ /******/ return module.exports;
43
+ /******/ }
44
+
45
+
46
+ /******/ // expose the modules object (__webpack_modules__)
47
+ /******/ __webpack_require__.m = modules;
48
+
49
+ /******/ // expose the module cache
50
+ /******/ __webpack_require__.c = installedModules;
51
+
52
+ /******/ // __webpack_public_path__
53
+ /******/ __webpack_require__.p = "";
54
+
55
+ /******/ // Load entry module and return exports
56
+ /******/ return __webpack_require__(0);
57
+ /******/ })
58
+ /************************************************************************/
59
+ /******/ ([
60
+ /* 0 */
61
+ /***/ function(module, exports, __webpack_require__) {
62
+
63
+ /**
64
+ * Install plugin.
65
+ */
66
+
67
+ function install(Vue) {
68
+
69
+ var _ = __webpack_require__(1)(Vue);
70
+
71
+ Vue.url = __webpack_require__(2)(_);
72
+ Vue.http = __webpack_require__(3)(_);
73
+ Vue.resource = __webpack_require__(7)(_);
74
+
75
+ Object.defineProperties(Vue.prototype, {
76
+
77
+ $url: {
78
+ get: function () {
79
+ return this._url || (this._url = _.options(Vue.url, this, this.$options.url));
80
+ }
81
+ },
82
+
83
+ $http: {
84
+ get: function () {
85
+ return this._http || (this._http = _.options(Vue.http, this, this.$options.http));
86
+ }
87
+ },
88
+
89
+ $resource: {
90
+ get: function () {
91
+ return Vue.resource.bind(this);
92
+ }
93
+ }
94
+
95
+ });
96
+ }
97
+
98
+ if (window.Vue) {
99
+ Vue.use(install);
100
+ }
101
+
102
+ module.exports = install;
103
+
104
+ /***/ },
105
+ /* 1 */
106
+ /***/ function(module, exports) {
107
+
108
+ /**
109
+ * Utility functions.
110
+ */
111
+
112
+ module.exports = function (Vue) {
113
+
114
+ var _ = Vue.util.extend({}, Vue.util);
115
+
116
+ _.isString = function (value) {
117
+ return typeof value === 'string';
118
+ };
119
+
120
+ _.isFunction = function (value) {
121
+ return typeof value === 'function';
122
+ };
123
+
124
+ _.options = function (fn, obj, options) {
125
+
126
+ options = options || {};
127
+
128
+ if (_.isFunction(options)) {
129
+ options = options.call(obj);
130
+ }
131
+
132
+ return _.extend(fn.bind({vm: obj, options: options}), fn, {options: options});
133
+ };
134
+
135
+ _.each = function (obj, iterator) {
136
+
137
+ var i, key;
138
+
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
+ }
150
+
151
+ return obj;
152
+ };
153
+
154
+ _.extend = function (target) {
155
+
156
+ var array = [], args = array.slice.call(arguments, 1), deep;
157
+
158
+ if (typeof target == 'boolean') {
159
+ deep = target;
160
+ target = args.shift();
161
+ }
162
+
163
+ args.forEach(function (arg) {
164
+ extend(target, arg, deep);
165
+ });
166
+
167
+ return target;
168
+ };
169
+
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
+ }
183
+ }
184
+ }
185
+
186
+ return _;
187
+ };
188
+
189
+
190
+ /***/ },
191
+ /* 2 */
192
+ /***/ function(module, exports) {
193
+
194
+ /**
195
+ * Service for URL templating.
196
+ */
197
+
198
+ var ie = document.documentMode;
199
+ var el = document.createElement('a');
200
+
201
+ module.exports = function (_) {
202
+
203
+ function Url(url, params) {
204
+
205
+ var urlParams = {}, queryParams = {}, options = url, query;
206
+
207
+ if (!_.isPlainObject(options)) {
208
+ options = {url: url, params: params};
209
+ }
210
+
211
+ options = _.extend(true, {},
212
+ Url.options, this.options, options
213
+ );
214
+
215
+ url = options.url.replace(/(\/?):([a-z]\w*)/gi, function (match, slash, name) {
216
+
217
+ if (options.params[name]) {
218
+ urlParams[name] = true;
219
+ return slash + encodeUriSegment(options.params[name]);
220
+ }
221
+
222
+ return '';
223
+ });
224
+
225
+ if (_.isString(options.root) && !url.match(/^(https?:)?\//)) {
226
+ url = options.root + '/' + url;
227
+ }
228
+
229
+ _.each(options.params, function (value, key) {
230
+ if (!urlParams[key]) {
231
+ queryParams[key] = value;
232
+ }
233
+ });
234
+
235
+ query = Url.params(queryParams);
236
+
237
+ if (query) {
238
+ url += (url.indexOf('?') == -1 ? '?' : '&') + query;
239
+ }
240
+
241
+ return url;
242
+ }
243
+
244
+ /**
245
+ * Url options.
246
+ */
247
+
248
+ Url.options = {
249
+ url: '',
250
+ root: null,
251
+ params: {}
252
+ };
253
+
254
+ /**
255
+ * Encodes a Url parameter string.
256
+ *
257
+ * @param {Object} obj
258
+ */
259
+
260
+ Url.params = function (obj) {
261
+
262
+ var params = [];
263
+
264
+ params.add = function (key, value) {
265
+
266
+ if (_.isFunction (value)) {
267
+ value = value();
268
+ }
269
+
270
+ if (value === null) {
271
+ value = '';
272
+ }
273
+
274
+ this.push(encodeUriSegment(key) + '=' + encodeUriSegment(value));
275
+ };
276
+
277
+ serialize(params, obj);
278
+
279
+ return params.join('&');
280
+ };
281
+
282
+ /**
283
+ * Parse a URL and return its components.
284
+ *
285
+ * @param {String} url
286
+ */
287
+
288
+ Url.parse = function (url) {
289
+
290
+ if (ie) {
291
+ el.href = url;
292
+ url = el.href;
293
+ }
294
+
295
+ el.href = url;
296
+
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
+ };
308
+
309
+ function serialize(params, obj, scope) {
310
+
311
+ var array = _.isArray(obj), plain = _.isPlainObject(obj), hash;
312
+
313
+ _.each(obj, function (value, key) {
314
+
315
+ hash = _.isObject(value) || _.isArray(value);
316
+
317
+ if (scope) {
318
+ key = scope + '[' + (plain || hash ? key : '') + ']';
319
+ }
320
+
321
+ if (!scope && array) {
322
+ params.add(value.name, value.value);
323
+ } else if (hash) {
324
+ serialize(params, value, key);
325
+ } else {
326
+ params.add(key, value);
327
+ }
328
+ });
329
+ }
330
+
331
+ function encodeUriSegment(value) {
332
+
333
+ return encodeUriQuery(value, true).
334
+ replace(/%26/gi, '&').
335
+ replace(/%3D/gi, '=').
336
+ replace(/%2B/gi, '+');
337
+ }
338
+
339
+ function encodeUriQuery(value, spaces) {
340
+
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' : '+'));
347
+ }
348
+
349
+ return _.url = Url;
350
+ };
351
+
352
+
353
+ /***/ },
354
+ /* 3 */
355
+ /***/ function(module, exports, __webpack_require__) {
356
+
357
+ /**
358
+ * Service for sending network requests.
359
+ */
360
+
361
+ var xhr = __webpack_require__(4);
362
+ var jsonp = __webpack_require__(6);
363
+ var Promise = __webpack_require__(5);
364
+
365
+ module.exports = function (_) {
366
+
367
+ var originUrl = _.url.parse(location.href);
368
+ var jsonType = {'Content-Type': 'application/json;charset=utf-8'};
369
+
370
+ function Http(url, options) {
371
+
372
+ var promise;
373
+
374
+ if (_.isPlainObject(url)) {
375
+ options = url;
376
+ url = '';
377
+ }
378
+
379
+ options = _.extend({url: url}, options);
380
+ options = _.extend(true, {},
381
+ Http.options, this.options, options
382
+ );
383
+
384
+ if (options.crossOrigin === null) {
385
+ options.crossOrigin = crossOrigin(options.url);
386
+ }
387
+
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
+ );
394
+
395
+ if (_.isPlainObject(options.data) && /^(GET|JSONP)$/i.test(options.method)) {
396
+ _.extend(options.params, options.data);
397
+ delete options.data;
398
+ }
399
+
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
+ }
404
+
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
+ }
409
+
410
+ if (_.isObject(options.data) && /FormData/i.test(options.data.toString())) {
411
+ delete options.headers['Content-Type'];
412
+ }
413
+
414
+ if (_.isPlainObject(options.data)) {
415
+ options.data = JSON.stringify(options.data);
416
+ }
417
+
418
+ promise = (options.method == 'JSONP' ? jsonp : xhr).call(this.vm, _, options);
419
+ promise = extendPromise(promise.then(transformResponse, transformResponse), this.vm);
420
+
421
+ if (options.success) {
422
+ promise = promise.success(options.success);
423
+ }
424
+
425
+ if (options.error) {
426
+ promise = promise.error(options.error);
427
+ }
428
+
429
+ return promise;
430
+ }
431
+
432
+ function extendPromise(promise, vm) {
433
+
434
+ promise.success = function (fn) {
435
+
436
+ return extendPromise(promise.then(function (response) {
437
+ return fn.call(vm, response.data, response.status, response) || response;
438
+ }), vm);
439
+
440
+ };
441
+
442
+ promise.error = function (fn) {
443
+
444
+ return extendPromise(promise.then(undefined, function (response) {
445
+ return fn.call(vm, response.data, response.status, response) || response;
446
+ }), vm);
447
+
448
+ };
449
+
450
+ promise.always = function (fn) {
451
+
452
+ var cb = function (response) {
453
+ return fn.call(vm, response.data, response.status, response) || response;
454
+ };
455
+
456
+ return extendPromise(promise.then(cb, cb), vm);
457
+ };
458
+
459
+ return promise;
460
+ }
461
+
462
+ function transformResponse(response) {
463
+
464
+ try {
465
+ response.data = JSON.parse(response.responseText);
466
+ } catch (e) {
467
+ response.data = response.responseText;
468
+ }
469
+
470
+ return response.ok ? response : Promise.reject(response);
471
+ }
472
+
473
+ function crossOrigin(url) {
474
+
475
+ var requestUrl = _.url.parse(url);
476
+
477
+ return (requestUrl.protocol !== originUrl.protocol || requestUrl.host !== originUrl.host);
478
+ }
479
+
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
+ };
491
+
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'}
499
+ };
500
+
501
+ ['get', 'put', 'post', 'patch', 'delete', 'jsonp'].forEach(function (method) {
502
+
503
+ Http[method] = function (url, data, success, options) {
504
+
505
+ if (_.isFunction(data)) {
506
+ options = success;
507
+ success = data;
508
+ data = undefined;
509
+ }
510
+
511
+ return this(url, _.extend({method: method, data: data, success: success}, options));
512
+ };
513
+ });
514
+
515
+ return _.http = Http;
516
+ };
517
+
518
+
519
+ /***/ },
520
+ /* 4 */
521
+ /***/ function(module, exports, __webpack_require__) {
522
+
523
+ /**
524
+ * XMLHttp request.
525
+ */
526
+
527
+ var Promise = __webpack_require__(5);
528
+ var XDomain = window.XDomainRequest;
529
+
530
+ module.exports = function (_, options) {
531
+
532
+ var request = new XMLHttpRequest(), promise;
533
+
534
+ if (XDomain && options.crossOrigin) {
535
+ request = new XDomainRequest(); options.headers = {};
536
+ }
537
+
538
+ if (_.isPlainObject(options.xhr)) {
539
+ _.extend(request, options.xhr);
540
+ }
541
+
542
+ if (_.isFunction(options.beforeSend)) {
543
+ options.beforeSend.call(this, request, options);
544
+ }
545
+
546
+ promise = new Promise(function (resolve, reject) {
547
+
548
+ request.open(options.method, _.url(options), true);
549
+
550
+ _.each(options.headers, function (value, header) {
551
+ request.setRequestHeader(header, value);
552
+ });
553
+
554
+ var handler = function (event) {
555
+
556
+ request.ok = event.type === 'load';
557
+
558
+ if (request.ok && request.status) {
559
+ request.ok = request.status >= 200 && request.status < 300;
560
+ }
561
+
562
+ (request.ok ? resolve : reject)(request);
563
+ };
564
+
565
+ request.onload = handler;
566
+ request.onabort = handler;
567
+ request.onerror = handler;
568
+
569
+ request.send(options.data);
570
+ });
571
+
572
+ return promise;
573
+ };
574
+
575
+
576
+ /***/ },
577
+ /* 5 */
578
+ /***/ function(module, exports) {
579
+
580
+ /**
581
+ * Promises/A+ polyfill v1.1.0 (https://github.com/bramstein/promis)
582
+ */
583
+
584
+ var RESOLVED = 0;
585
+ var REJECTED = 1;
586
+ var PENDING = 2;
587
+
588
+ function Promise(executor) {
589
+
590
+ this.state = PENDING;
591
+ this.value = undefined;
592
+ this.deferred = [];
593
+
594
+ var promise = this;
595
+
596
+ try {
597
+ executor(function (x) {
598
+ promise.resolve(x);
599
+ }, function (r) {
600
+ promise.reject(r);
601
+ });
602
+ } catch (e) {
603
+ promise.reject(e);
604
+ }
605
+ }
606
+
607
+ Promise.reject = function (r) {
608
+ return new Promise(function (resolve, reject) {
609
+ reject(r);
610
+ });
611
+ };
612
+
613
+ Promise.resolve = function (x) {
614
+ return new Promise(function (resolve, reject) {
615
+ resolve(x);
616
+ });
617
+ };
618
+
619
+ Promise.all = function all(iterable) {
620
+ return new Promise(function (resolve, reject) {
621
+ var count = 0,
622
+ result = [];
623
+
624
+ if (iterable.length === 0) {
625
+ resolve(result);
626
+ }
627
+
628
+ function resolver(i) {
629
+ return function (x) {
630
+ result[i] = x;
631
+ count += 1;
632
+
633
+ if (count === iterable.length) {
634
+ resolve(result);
635
+ }
636
+ };
637
+ }
638
+
639
+ for (var i = 0; i < iterable.length; i += 1) {
640
+ iterable[i].then(resolver(i), reject);
641
+ }
642
+ });
643
+ };
644
+
645
+ Promise.race = function race(iterable) {
646
+ return new Promise(function (resolve, reject) {
647
+ for (var i = 0; i < iterable.length; i += 1) {
648
+ iterable[i].then(resolve, reject);
649
+ }
650
+ });
651
+ };
652
+
653
+ var p = Promise.prototype;
654
+
655
+ p.resolve = function resolve(x) {
656
+ var promise = this;
657
+
658
+ if (promise.state === PENDING) {
659
+ if (x === promise) {
660
+ throw new TypeError('Promise settled with itself.');
661
+ }
662
+
663
+ var called = false;
664
+
665
+ try {
666
+ var then = x && x['then'];
667
+
668
+ if (x !== null && typeof x === 'object' && typeof then === 'function') {
669
+ then.call(x, function (x) {
670
+ if (!called) {
671
+ promise.resolve(x);
672
+ }
673
+ called = true;
674
+
675
+ }, function (r) {
676
+ if (!called) {
677
+ promise.reject(r);
678
+ }
679
+ called = true;
680
+ });
681
+ return;
682
+ }
683
+ } catch (e) {
684
+ if (!called) {
685
+ promise.reject(e);
686
+ }
687
+ return;
688
+ }
689
+ promise.state = RESOLVED;
690
+ promise.value = x;
691
+ promise.notify();
692
+ }
693
+ };
694
+
695
+ p.reject = function reject(reason) {
696
+ var promise = this;
697
+
698
+ if (promise.state === PENDING) {
699
+ if (reason === promise) {
700
+ throw new TypeError('Promise settled with itself.');
701
+ }
702
+
703
+ promise.state = REJECTED;
704
+ promise.value = reason;
705
+ promise.notify();
706
+ }
707
+ };
708
+
709
+ p.notify = function notify() {
710
+ var promise = this;
711
+
712
+ async(function () {
713
+ if (promise.state !== PENDING) {
714
+ while (promise.deferred.length) {
715
+ var deferred = promise.deferred.shift(),
716
+ onResolved = deferred[0],
717
+ onRejected = deferred[1],
718
+ resolve = deferred[2],
719
+ reject = deferred[3];
720
+
721
+ try {
722
+ if (promise.state === RESOLVED) {
723
+ if (typeof onResolved === 'function') {
724
+ resolve(onResolved.call(undefined, promise.value));
725
+ } else {
726
+ resolve(promise.value);
727
+ }
728
+ } else if (promise.state === REJECTED) {
729
+ if (typeof onRejected === 'function') {
730
+ resolve(onRejected.call(undefined, promise.value));
731
+ } else {
732
+ reject(promise.value);
733
+ }
734
+ }
735
+ } catch (e) {
736
+ reject(e);
737
+ }
738
+ }
739
+ }
740
+ });
741
+ };
742
+
743
+ p.catch = function (onRejected) {
744
+ return this.then(undefined, onRejected);
745
+ };
746
+
747
+ p.then = function then(onResolved, onRejected) {
748
+ var promise = this;
749
+
750
+ return new Promise(function (resolve, reject) {
751
+ promise.deferred.push([onResolved, onRejected, resolve, reject]);
752
+ promise.notify();
753
+ });
754
+ };
755
+
756
+ var queue = [];
757
+ var async = function (callback) {
758
+ queue.push(callback);
759
+
760
+ if (queue.length === 1) {
761
+ async.async();
762
+ }
763
+ };
764
+
765
+ async.run = function () {
766
+ while (queue.length) {
767
+ queue[0]();
768
+ queue.shift();
769
+ }
770
+ };
771
+
772
+ if (window.MutationObserver) {
773
+ var el = document.createElement('div');
774
+ var mo = new MutationObserver(async.run);
775
+
776
+ mo.observe(el, {
777
+ attributes: true
778
+ });
779
+
780
+ async.async = function () {
781
+ el.setAttribute("x", 0);
782
+ };
783
+ } else {
784
+ async.async = function () {
785
+ setTimeout(async.run);
786
+ };
787
+ }
788
+
789
+ module.exports = window.Promise || Promise;
790
+
791
+
792
+ /***/ },
793
+ /* 6 */
794
+ /***/ function(module, exports, __webpack_require__) {
795
+
796
+ /**
797
+ * JSONP request.
798
+ */
799
+
800
+ var Promise = __webpack_require__(5);
801
+
802
+ module.exports = function (_, options) {
803
+
804
+ var callback = '_jsonp' + Math.random().toString(36).substr(2), response = {}, script, body;
805
+
806
+ options.params[options.jsonp] = callback;
807
+
808
+ if (_.isFunction(options.beforeSend)) {
809
+ options.beforeSend.call(this, {}, options);
810
+ }
811
+
812
+ return new Promise(function (resolve, reject) {
813
+
814
+ script = document.createElement('script');
815
+ script.src = _.url(options);
816
+ script.type = 'text/javascript';
817
+ script.async = true;
818
+
819
+ window[callback] = function (data) {
820
+ body = data;
821
+ };
822
+
823
+ var handler = function (event) {
824
+
825
+ delete window[callback];
826
+ document.body.removeChild(script);
827
+
828
+ if (event.type === 'load' && !body) {
829
+ event.type = 'error';
830
+ }
831
+
832
+ response.ok = event.type !== 'error';
833
+ response.status = response.ok ? 200 : 404;
834
+ response.responseText = body ? body : event.type;
835
+
836
+ (response.ok ? resolve : reject)(response);
837
+ };
838
+
839
+ script.onload = handler;
840
+ script.onerror = handler;
841
+
842
+ document.body.appendChild(script);
843
+ });
844
+
845
+ };
846
+
847
+
848
+ /***/ },
849
+ /* 7 */
850
+ /***/ function(module, exports) {
851
+
852
+ /**
853
+ * Service for interacting with RESTful services.
854
+ */
855
+
856
+ module.exports = function (_) {
857
+
858
+ function Resource(url, params, actions) {
859
+
860
+ var self = this, resource = {};
861
+
862
+ actions = _.extend({},
863
+ Resource.actions,
864
+ actions
865
+ );
866
+
867
+ _.each(actions, function (action, name) {
868
+
869
+ action = _.extend(true, {url: url, params: params || {}}, action);
870
+
871
+ resource[name] = function () {
872
+ return (self.$http || _.http)(opts(action, arguments));
873
+ };
874
+ });
875
+
876
+ return resource;
877
+ }
878
+
879
+ function opts(action, args) {
880
+
881
+ var options = _.extend({}, action), params = {}, data, success, error;
882
+
883
+ switch (args.length) {
884
+
885
+ case 4:
886
+
887
+ error = args[3];
888
+ success = args[2];
889
+
890
+ case 3:
891
+ case 2:
892
+
893
+ if (_.isFunction(args[1])) {
894
+
895
+ if (_.isFunction(args[0])) {
896
+
897
+ success = args[0];
898
+ error = args[1];
899
+
900
+ break;
901
+ }
902
+
903
+ success = args[1];
904
+ error = args[2];
905
+
906
+ } else {
907
+
908
+ params = args[0];
909
+ data = args[1];
910
+ success = args[2];
911
+
912
+ break;
913
+ }
914
+
915
+ case 1:
916
+
917
+ if (_.isFunction(args[0])) {
918
+ success = args[0];
919
+ } else if (/^(POST|PUT|PATCH)$/i.test(options.method)) {
920
+ data = args[0];
921
+ } else {
922
+ params = args[0];
923
+ }
924
+
925
+ break;
926
+
927
+ case 0:
928
+
929
+ break;
930
+
931
+ default:
932
+
933
+ throw 'Expected up to 4 arguments [params, data, success, error], got ' + args.length + ' arguments';
934
+ }
935
+
936
+ options.data = data;
937
+ options.params = _.extend({}, options.params, params);
938
+
939
+ if (success) {
940
+ options.success = success;
941
+ }
942
+
943
+ if (error) {
944
+ options.error = error;
945
+ }
946
+
947
+ return options;
948
+ }
949
+
950
+ Resource.actions = {
951
+
952
+ get: {method: 'GET'},
953
+ save: {method: 'POST'},
954
+ query: {method: 'GET'},
955
+ update: {method: 'PUT'},
956
+ remove: {method: 'DELETE'},
957
+ delete: {method: 'DELETE'}
958
+
959
+ };
960
+
961
+ return _.resource = Resource;
962
+ };
963
+
964
+
965
+ /***/ }
966
+ /******/ ])
967
+ });
968
+ ;