interval-braining-ui-asset-pack 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asset_pack/engine.rb +5 -2
  3. data/lib/asset_pack/version.rb +1 -1
  4. data/vendor/assets/bower_components/angular/angular.js +23377 -0
  5. data/vendor/assets/bower_components/angular-animate/angular-animate.js +1729 -0
  6. data/vendor/assets/bower_components/angular-growl-notifications/dist/growl-notifications.js +241 -0
  7. data/vendor/assets/bower_components/angular-input-match/dist/angular-input-match.js +39 -0
  8. data/vendor/assets/bower_components/angular-messages/angular-messages.js +400 -0
  9. data/vendor/assets/bower_components/angular-mocks/angular-mocks.js +2228 -0
  10. data/vendor/assets/bower_components/angular-resource/angular-resource.js +660 -0
  11. data/vendor/assets/bower_components/angular-sanitize/angular-sanitize.js +640 -0
  12. data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.js +3223 -0
  13. data/vendor/assets/bower_components/angular-ui-router-breadcrumbs/dist/angular-ui-router-breadcrumbs.js +82 -0
  14. data/vendor/assets/bower_components/angular-ui-router-helpers/dist/angular-ui-router-helpers.js +52 -0
  15. data/vendor/assets/bower_components/angular-ui-router-hooks-before-state/dist/angular-ui-router-hooks-before-state.js +56 -0
  16. data/vendor/assets/bower_components/angular-validate-in-set/dist/angular-validate-in-set.js +77 -0
  17. data/vendor/assets/bower_components/animate.css/animate.css +3125 -0
  18. data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap.css +5785 -0
  19. data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
  20. data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +229 -0
  21. data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  22. data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
  23. data/vendor/assets/bower_components/bootstrap/dist/js/bootstrap.js +1951 -0
  24. data/vendor/assets/bower_components/cardigan/dist/cardigan.css +37 -0
  25. data/vendor/assets/bower_components/cardigan/dist/cardigan.js +239 -0
  26. data/vendor/assets/bower_components/font-awesome-bower/css/font-awesome.css +1338 -0
  27. data/vendor/assets/bower_components/font-awesome-bower/fonts/FontAwesome.otf +0 -0
  28. data/vendor/assets/bower_components/font-awesome-bower/fonts/fontawesome-webfont.eot +0 -0
  29. data/vendor/assets/bower_components/font-awesome-bower/fonts/fontawesome-webfont.svg +414 -0
  30. data/vendor/assets/bower_components/font-awesome-bower/fonts/fontawesome-webfont.ttf +0 -0
  31. data/vendor/assets/bower_components/font-awesome-bower/fonts/fontawesome-webfont.woff +0 -0
  32. data/vendor/assets/bower_components/jquery/dist/jquery.js +9190 -0
  33. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.css +10 -0
  34. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.eot +0 -0
  35. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.svg +1831 -0
  36. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.ttf +0 -0
  37. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.woff +0 -0
  38. metadata +36 -2
@@ -0,0 +1,660 @@
1
+ /**
2
+ * @license AngularJS v1.3.0-build.2991+sha.9025113
3
+ * (c) 2010-2014 Google, Inc. http://angularjs.org
4
+ * License: MIT
5
+ */
6
+ (function(window, angular, undefined) {'use strict';
7
+
8
+ var $resourceMinErr = angular.$$minErr('$resource');
9
+
10
+ // Helper functions and regex to lookup a dotted path on an object
11
+ // stopping at undefined/null. The path must be composed of ASCII
12
+ // identifiers (just like $parse)
13
+ var MEMBER_NAME_REGEX = /^(\.[a-zA-Z_$][0-9a-zA-Z_$]*)+$/;
14
+
15
+ function isValidDottedPath(path) {
16
+ return (path != null && path !== '' && path !== 'hasOwnProperty' &&
17
+ MEMBER_NAME_REGEX.test('.' + path));
18
+ }
19
+
20
+ function lookupDottedPath(obj, path) {
21
+ if (!isValidDottedPath(path)) {
22
+ throw $resourceMinErr('badmember', 'Dotted member path "@{0}" is invalid.', path);
23
+ }
24
+ var keys = path.split('.');
25
+ for (var i = 0, ii = keys.length; i < ii && obj !== undefined; i++) {
26
+ var key = keys[i];
27
+ obj = (obj !== null) ? obj[key] : undefined;
28
+ }
29
+ return obj;
30
+ }
31
+
32
+ /**
33
+ * Create a shallow copy of an object and clear other fields from the destination
34
+ */
35
+ function shallowClearAndCopy(src, dst) {
36
+ dst = dst || {};
37
+
38
+ angular.forEach(dst, function(value, key){
39
+ delete dst[key];
40
+ });
41
+
42
+ for (var key in src) {
43
+ if (src.hasOwnProperty(key) && !(key.charAt(0) === '$' && key.charAt(1) === '$')) {
44
+ dst[key] = src[key];
45
+ }
46
+ }
47
+
48
+ return dst;
49
+ }
50
+
51
+ /**
52
+ * @ngdoc module
53
+ * @name ngResource
54
+ * @description
55
+ *
56
+ * # ngResource
57
+ *
58
+ * The `ngResource` module provides interaction support with RESTful services
59
+ * via the $resource service.
60
+ *
61
+ *
62
+ * <div doc-module-components="ngResource"></div>
63
+ *
64
+ * See {@link ngResource.$resource `$resource`} for usage.
65
+ */
66
+
67
+ /**
68
+ * @ngdoc service
69
+ * @name $resource
70
+ * @requires $http
71
+ *
72
+ * @description
73
+ * A factory which creates a resource object that lets you interact with
74
+ * [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer) server-side data sources.
75
+ *
76
+ * The returned resource object has action methods which provide high-level behaviors without
77
+ * the need to interact with the low level {@link ng.$http $http} service.
78
+ *
79
+ * Requires the {@link ngResource `ngResource`} module to be installed.
80
+ *
81
+ * By default, trailing slashes will be stripped from the calculated URLs,
82
+ * which can pose problems with server backends that do not expect that
83
+ * behavior. This can be disabled by configuring the `$resourceProvider` like
84
+ * this:
85
+ *
86
+ * ```js
87
+ app.config(['$resourceProvider', function ($resourceProvider) {
88
+ // Don't strip trailing slashes from calculated URLs
89
+ $resourceProvider.defaults.stripTrailingSlashes = false;
90
+ }]);
91
+ * ```
92
+ *
93
+ * @param {string} url A parametrized URL template with parameters prefixed by `:` as in
94
+ * `/user/:username`. If you are using a URL with a port number (e.g.
95
+ * `http://example.com:8080/api`), it will be respected.
96
+ *
97
+ * If you are using a url with a suffix, just add the suffix, like this:
98
+ * `$resource('http://example.com/resource.json')` or `$resource('http://example.com/:id.json')`
99
+ * or even `$resource('http://example.com/resource/:resource_id.:format')`
100
+ * If the parameter before the suffix is empty, :resource_id in this case, then the `/.` will be
101
+ * collapsed down to a single `.`. If you need this sequence to appear and not collapse then you
102
+ * can escape it with `/\.`.
103
+ *
104
+ * @param {Object=} paramDefaults Default values for `url` parameters. These can be overridden in
105
+ * `actions` methods. If any of the parameter value is a function, it will be executed every time
106
+ * when a param value needs to be obtained for a request (unless the param was overridden).
107
+ *
108
+ * Each key value in the parameter object is first bound to url template if present and then any
109
+ * excess keys are appended to the url search query after the `?`.
110
+ *
111
+ * Given a template `/path/:verb` and parameter `{verb:'greet', salutation:'Hello'}` results in
112
+ * URL `/path/greet?salutation=Hello`.
113
+ *
114
+ * If the parameter value is prefixed with `@` then the value of that parameter will be taken
115
+ * from the corresponding key on the data object (useful for non-GET operations).
116
+ *
117
+ * @param {Object.<Object>=} actions Hash with declaration of custom action that should extend
118
+ * the default set of resource actions. The declaration should be created in the format of {@link
119
+ * ng.$http#usage_parameters $http.config}:
120
+ *
121
+ * {action1: {method:?, params:?, isArray:?, headers:?, ...},
122
+ * action2: {method:?, params:?, isArray:?, headers:?, ...},
123
+ * ...}
124
+ *
125
+ * Where:
126
+ *
127
+ * - **`action`** – {string} – The name of action. This name becomes the name of the method on
128
+ * your resource object.
129
+ * - **`method`** – {string} – Case insensitive HTTP method (e.g. `GET`, `POST`, `PUT`,
130
+ * `DELETE`, `JSONP`, etc).
131
+ * - **`params`** – {Object=} – Optional set of pre-bound parameters for this action. If any of
132
+ * the parameter value is a function, it will be executed every time when a param value needs to
133
+ * be obtained for a request (unless the param was overridden).
134
+ * - **`url`** – {string} – action specific `url` override. The url templating is supported just
135
+ * like for the resource-level urls.
136
+ * - **`isArray`** – {boolean=} – If true then the returned object for this action is an array,
137
+ * see `returns` section.
138
+ * - **`transformRequest`** –
139
+ * `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
140
+ * transform function or an array of such functions. The transform function takes the http
141
+ * request body and headers and returns its transformed (typically serialized) version.
142
+ * - **`transformResponse`** –
143
+ * `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
144
+ * transform function or an array of such functions. The transform function takes the http
145
+ * response body and headers and returns its transformed (typically deserialized) version.
146
+ * - **`cache`** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the
147
+ * GET request, otherwise if a cache instance built with
148
+ * {@link ng.$cacheFactory $cacheFactory}, this cache will be used for
149
+ * caching.
150
+ * - **`timeout`** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise} that
151
+ * should abort the request when resolved.
152
+ * - **`withCredentials`** - `{boolean}` - whether to set the `withCredentials` flag on the
153
+ * XHR object. See
154
+ * [requests with credentials](https://developer.mozilla.org/en/http_access_control#section_5)
155
+ * for more information.
156
+ * - **`responseType`** - `{string}` - see
157
+ * [requestType](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#responseType).
158
+ * - **`interceptor`** - `{Object=}` - The interceptor object has two optional methods -
159
+ * `response` and `responseError`. Both `response` and `responseError` interceptors get called
160
+ * with `http response` object. See {@link ng.$http $http interceptors}.
161
+ *
162
+ * @param {Object} options Hash with custom settings that should extend the
163
+ * default `$resourceProvider` behavior. The only supported option is
164
+ *
165
+ * Where:
166
+ *
167
+ * - **`stripTrailingSlashes`** – {boolean} – If true then the trailing
168
+ * slashes from any calculated URL will be stripped. (Defaults to true.)
169
+ *
170
+ * @returns {Object} A resource "class" object with methods for the default set of resource actions
171
+ * optionally extended with custom `actions`. The default set contains these actions:
172
+ * ```js
173
+ * { 'get': {method:'GET'},
174
+ * 'save': {method:'POST'},
175
+ * 'query': {method:'GET', isArray:true},
176
+ * 'remove': {method:'DELETE'},
177
+ * 'delete': {method:'DELETE'} };
178
+ * ```
179
+ *
180
+ * Calling these methods invoke an {@link ng.$http} with the specified http method,
181
+ * destination and parameters. When the data is returned from the server then the object is an
182
+ * instance of the resource class. The actions `save`, `remove` and `delete` are available on it
183
+ * as methods with the `$` prefix. This allows you to easily perform CRUD operations (create,
184
+ * read, update, delete) on server-side data like this:
185
+ * ```js
186
+ * var User = $resource('/user/:userId', {userId:'@id'});
187
+ * var user = User.get({userId:123}, function() {
188
+ * user.abc = true;
189
+ * user.$save();
190
+ * });
191
+ * ```
192
+ *
193
+ * It is important to realize that invoking a $resource object method immediately returns an
194
+ * empty reference (object or array depending on `isArray`). Once the data is returned from the
195
+ * server the existing reference is populated with the actual data. This is a useful trick since
196
+ * usually the resource is assigned to a model which is then rendered by the view. Having an empty
197
+ * object results in no rendering, once the data arrives from the server then the object is
198
+ * populated with the data and the view automatically re-renders itself showing the new data. This
199
+ * means that in most cases one never has to write a callback function for the action methods.
200
+ *
201
+ * The action methods on the class object or instance object can be invoked with the following
202
+ * parameters:
203
+ *
204
+ * - HTTP GET "class" actions: `Resource.action([parameters], [success], [error])`
205
+ * - non-GET "class" actions: `Resource.action([parameters], postData, [success], [error])`
206
+ * - non-GET instance actions: `instance.$action([parameters], [success], [error])`
207
+ *
208
+ * Success callback is called with (value, responseHeaders) arguments. Error callback is called
209
+ * with (httpResponse) argument.
210
+ *
211
+ * Class actions return empty instance (with additional properties below).
212
+ * Instance actions return promise of the action.
213
+ *
214
+ * The Resource instances and collection have these additional properties:
215
+ *
216
+ * - `$promise`: the {@link ng.$q promise} of the original server interaction that created this
217
+ * instance or collection.
218
+ *
219
+ * On success, the promise is resolved with the same resource instance or collection object,
220
+ * updated with data from server. This makes it easy to use in
221
+ * {@link ngRoute.$routeProvider resolve section of $routeProvider.when()} to defer view
222
+ * rendering until the resource(s) are loaded.
223
+ *
224
+ * On failure, the promise is resolved with the {@link ng.$http http response} object, without
225
+ * the `resource` property.
226
+ *
227
+ * If an interceptor object was provided, the promise will instead be resolved with the value
228
+ * returned by the interceptor.
229
+ *
230
+ * - `$resolved`: `true` after first server interaction is completed (either with success or
231
+ * rejection), `false` before that. Knowing if the Resource has been resolved is useful in
232
+ * data-binding.
233
+ *
234
+ * @example
235
+ *
236
+ * # Credit card resource
237
+ *
238
+ * ```js
239
+ // Define CreditCard class
240
+ var CreditCard = $resource('/user/:userId/card/:cardId',
241
+ {userId:123, cardId:'@id'}, {
242
+ charge: {method:'POST', params:{charge:true}}
243
+ });
244
+
245
+ // We can retrieve a collection from the server
246
+ var cards = CreditCard.query(function() {
247
+ // GET: /user/123/card
248
+ // server returns: [ {id:456, number:'1234', name:'Smith'} ];
249
+
250
+ var card = cards[0];
251
+ // each item is an instance of CreditCard
252
+ expect(card instanceof CreditCard).toEqual(true);
253
+ card.name = "J. Smith";
254
+ // non GET methods are mapped onto the instances
255
+ card.$save();
256
+ // POST: /user/123/card/456 {id:456, number:'1234', name:'J. Smith'}
257
+ // server returns: {id:456, number:'1234', name: 'J. Smith'};
258
+
259
+ // our custom method is mapped as well.
260
+ card.$charge({amount:9.99});
261
+ // POST: /user/123/card/456?amount=9.99&charge=true {id:456, number:'1234', name:'J. Smith'}
262
+ });
263
+
264
+ // we can create an instance as well
265
+ var newCard = new CreditCard({number:'0123'});
266
+ newCard.name = "Mike Smith";
267
+ newCard.$save();
268
+ // POST: /user/123/card {number:'0123', name:'Mike Smith'}
269
+ // server returns: {id:789, number:'0123', name: 'Mike Smith'};
270
+ expect(newCard.id).toEqual(789);
271
+ * ```
272
+ *
273
+ * The object returned from this function execution is a resource "class" which has "static" method
274
+ * for each action in the definition.
275
+ *
276
+ * Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and
277
+ * `headers`.
278
+ * When the data is returned from the server then the object is an instance of the resource type and
279
+ * all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD
280
+ * operations (create, read, update, delete) on server-side data.
281
+
282
+ ```js
283
+ var User = $resource('/user/:userId', {userId:'@id'});
284
+ User.get({userId:123}, function(user) {
285
+ user.abc = true;
286
+ user.$save();
287
+ });
288
+ ```
289
+ *
290
+ * It's worth noting that the success callback for `get`, `query` and other methods gets passed
291
+ * in the response that came from the server as well as $http header getter function, so one
292
+ * could rewrite the above example and get access to http headers as:
293
+ *
294
+ ```js
295
+ var User = $resource('/user/:userId', {userId:'@id'});
296
+ User.get({userId:123}, function(u, getResponseHeaders){
297
+ u.abc = true;
298
+ u.$save(function(u, putResponseHeaders) {
299
+ //u => saved user object
300
+ //putResponseHeaders => $http header getter
301
+ });
302
+ });
303
+ ```
304
+ *
305
+ * You can also access the raw `$http` promise via the `$promise` property on the object returned
306
+ *
307
+ ```
308
+ var User = $resource('/user/:userId', {userId:'@id'});
309
+ User.get({userId:123})
310
+ .$promise.then(function(user) {
311
+ $scope.user = user;
312
+ });
313
+ ```
314
+
315
+ * # Creating a custom 'PUT' request
316
+ * In this example we create a custom method on our resource to make a PUT request
317
+ * ```js
318
+ * var app = angular.module('app', ['ngResource', 'ngRoute']);
319
+ *
320
+ * // Some APIs expect a PUT request in the format URL/object/ID
321
+ * // Here we are creating an 'update' method
322
+ * app.factory('Notes', ['$resource', function($resource) {
323
+ * return $resource('/notes/:id', null,
324
+ * {
325
+ * 'update': { method:'PUT' }
326
+ * });
327
+ * }]);
328
+ *
329
+ * // In our controller we get the ID from the URL using ngRoute and $routeParams
330
+ * // We pass in $routeParams and our Notes factory along with $scope
331
+ * app.controller('NotesCtrl', ['$scope', '$routeParams', 'Notes',
332
+ function($scope, $routeParams, Notes) {
333
+ * // First get a note object from the factory
334
+ * var note = Notes.get({ id:$routeParams.id });
335
+ * $id = note.id;
336
+ *
337
+ * // Now call update passing in the ID first then the object you are updating
338
+ * Notes.update({ id:$id }, note);
339
+ *
340
+ * // This will PUT /notes/ID with the note object in the request payload
341
+ * }]);
342
+ * ```
343
+ */
344
+ angular.module('ngResource', ['ng']).
345
+ provider('$resource', function () {
346
+ var provider = this;
347
+
348
+ this.defaults = {
349
+ // Strip slashes by default
350
+ stripTrailingSlashes: true,
351
+
352
+ // Default actions configuration
353
+ actions: {
354
+ 'get': {method: 'GET'},
355
+ 'save': {method: 'POST'},
356
+ 'query': {method: 'GET', isArray: true},
357
+ 'remove': {method: 'DELETE'},
358
+ 'delete': {method: 'DELETE'}
359
+ }
360
+ };
361
+
362
+ this.$get = ['$http', '$q', function ($http, $q) {
363
+
364
+ var noop = angular.noop,
365
+ forEach = angular.forEach,
366
+ extend = angular.extend,
367
+ copy = angular.copy,
368
+ isFunction = angular.isFunction;
369
+
370
+ /**
371
+ * We need our custom method because encodeURIComponent is too aggressive and doesn't follow
372
+ * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set
373
+ * (pchar) allowed in path segments:
374
+ * segment = *pchar
375
+ * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
376
+ * pct-encoded = "%" HEXDIG HEXDIG
377
+ * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
378
+ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
379
+ * / "*" / "+" / "," / ";" / "="
380
+ */
381
+ function encodeUriSegment(val) {
382
+ return encodeUriQuery(val, true).
383
+ replace(/%26/gi, '&').
384
+ replace(/%3D/gi, '=').
385
+ replace(/%2B/gi, '+');
386
+ }
387
+
388
+
389
+ /**
390
+ * This method is intended for encoding *key* or *value* parts of query component. We need a
391
+ * custom method because encodeURIComponent is too aggressive and encodes stuff that doesn't
392
+ * have to be encoded per http://tools.ietf.org/html/rfc3986:
393
+ * query = *( pchar / "/" / "?" )
394
+ * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
395
+ * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
396
+ * pct-encoded = "%" HEXDIG HEXDIG
397
+ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
398
+ * / "*" / "+" / "," / ";" / "="
399
+ */
400
+ function encodeUriQuery(val, pctEncodeSpaces) {
401
+ return encodeURIComponent(val).
402
+ replace(/%40/gi, '@').
403
+ replace(/%3A/gi, ':').
404
+ replace(/%24/g, '$').
405
+ replace(/%2C/gi, ',').
406
+ replace(/%20/g, (pctEncodeSpaces ? '%20' : '+'));
407
+ }
408
+
409
+ function Route(template, defaults) {
410
+ this.template = template;
411
+ this.defaults = extend({}, provider.defaults, defaults);
412
+ this.urlParams = {};
413
+ }
414
+
415
+ Route.prototype = {
416
+ setUrlParams: function (config, params, actionUrl) {
417
+ var self = this,
418
+ url = actionUrl || self.template,
419
+ val,
420
+ encodedVal;
421
+
422
+ var urlParams = self.urlParams = {};
423
+ forEach(url.split(/\W/), function (param) {
424
+ if (param === 'hasOwnProperty') {
425
+ throw $resourceMinErr('badname', "hasOwnProperty is not a valid parameter name.");
426
+ }
427
+ if (!(new RegExp("^\\d+$").test(param)) && param &&
428
+ (new RegExp("(^|[^\\\\]):" + param + "(\\W|$)").test(url))) {
429
+ urlParams[param] = true;
430
+ }
431
+ });
432
+ url = url.replace(/\\:/g, ':');
433
+
434
+ params = params || {};
435
+ forEach(self.urlParams, function (_, urlParam) {
436
+ val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam];
437
+ if (angular.isDefined(val) && val !== null) {
438
+ encodedVal = encodeUriSegment(val);
439
+ url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function (match, p1) {
440
+ return encodedVal + p1;
441
+ });
442
+ } else {
443
+ url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W|$)", "g"), function (match,
444
+ leadingSlashes, tail) {
445
+ if (tail.charAt(0) == '/') {
446
+ return tail;
447
+ } else {
448
+ return leadingSlashes + tail;
449
+ }
450
+ });
451
+ }
452
+ });
453
+
454
+ // strip trailing slashes and set the url (unless this behavior is specifically disabled)
455
+ if (self.defaults.stripTrailingSlashes) {
456
+ url = url.replace(/\/+$/, '') || '/';
457
+ }
458
+
459
+ // then replace collapse `/.` if found in the last URL path segment before the query
460
+ // E.g. `http://url.com/id./format?q=x` becomes `http://url.com/id.format?q=x`
461
+ url = url.replace(/\/\.(?=\w+($|\?))/, '.');
462
+ // replace escaped `/\.` with `/.`
463
+ config.url = url.replace(/\/\\\./, '/.');
464
+
465
+
466
+ // set params - delegate param encoding to $http
467
+ forEach(params, function (value, key) {
468
+ if (!self.urlParams[key]) {
469
+ config.params = config.params || {};
470
+ config.params[key] = value;
471
+ }
472
+ });
473
+ }
474
+ };
475
+
476
+
477
+ function resourceFactory(url, paramDefaults, actions, options) {
478
+ var route = new Route(url, options);
479
+
480
+ actions = extend({}, provider.defaults.actions, actions);
481
+
482
+ function extractParams(data, actionParams) {
483
+ var ids = {};
484
+ actionParams = extend({}, paramDefaults, actionParams);
485
+ forEach(actionParams, function (value, key) {
486
+ if (isFunction(value)) { value = value(); }
487
+ ids[key] = value && value.charAt && value.charAt(0) == '@' ?
488
+ lookupDottedPath(data, value.substr(1)) : value;
489
+ });
490
+ return ids;
491
+ }
492
+
493
+ function defaultResponseInterceptor(response) {
494
+ return response.resource;
495
+ }
496
+
497
+ function Resource(value) {
498
+ shallowClearAndCopy(value || {}, this);
499
+ }
500
+
501
+ Resource.prototype.toJSON = function () {
502
+ var data = extend({}, this);
503
+ delete data.$promise;
504
+ delete data.$resolved;
505
+ return data;
506
+ };
507
+
508
+ forEach(actions, function (action, name) {
509
+ var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method);
510
+
511
+ Resource[name] = function (a1, a2, a3, a4) {
512
+ var params = {}, data, success, error;
513
+
514
+ /* jshint -W086 */ /* (purposefully fall through case statements) */
515
+ switch (arguments.length) {
516
+ case 4:
517
+ error = a4;
518
+ success = a3;
519
+ //fallthrough
520
+ case 3:
521
+ case 2:
522
+ if (isFunction(a2)) {
523
+ if (isFunction(a1)) {
524
+ success = a1;
525
+ error = a2;
526
+ break;
527
+ }
528
+
529
+ success = a2;
530
+ error = a3;
531
+ //fallthrough
532
+ } else {
533
+ params = a1;
534
+ data = a2;
535
+ success = a3;
536
+ break;
537
+ }
538
+ case 1:
539
+ if (isFunction(a1)) success = a1;
540
+ else if (hasBody) data = a1;
541
+ else params = a1;
542
+ break;
543
+ case 0: break;
544
+ default:
545
+ throw $resourceMinErr('badargs',
546
+ "Expected up to 4 arguments [params, data, success, error], got {0} arguments",
547
+ arguments.length);
548
+ }
549
+ /* jshint +W086 */ /* (purposefully fall through case statements) */
550
+
551
+ var isInstanceCall = this instanceof Resource;
552
+ var value = isInstanceCall ? data : (action.isArray ? [] : new Resource(data));
553
+ var httpConfig = {};
554
+ var responseInterceptor = action.interceptor && action.interceptor.response ||
555
+ defaultResponseInterceptor;
556
+ var responseErrorInterceptor = action.interceptor && action.interceptor.responseError ||
557
+ undefined;
558
+
559
+ forEach(action, function (value, key) {
560
+ if (key != 'params' && key != 'isArray' && key != 'interceptor') {
561
+ httpConfig[key] = copy(value);
562
+ }
563
+ });
564
+
565
+ if (hasBody) httpConfig.data = data;
566
+ route.setUrlParams(httpConfig,
567
+ extend({}, extractParams(data, action.params || {}), params),
568
+ action.url);
569
+
570
+ var promise = $http(httpConfig).then(function (response) {
571
+ var data = response.data,
572
+ promise = value.$promise;
573
+
574
+ if (data) {
575
+ // Need to convert action.isArray to boolean in case it is undefined
576
+ // jshint -W018
577
+ if (angular.isArray(data) !== (!!action.isArray)) {
578
+ throw $resourceMinErr('badcfg',
579
+ 'Error in resource configuration. Expected ' +
580
+ 'response to contain an {0} but got an {1}',
581
+ action.isArray ? 'array' : 'object',
582
+ angular.isArray(data) ? 'array' : 'object');
583
+ }
584
+ // jshint +W018
585
+ if (action.isArray) {
586
+ value.length = 0;
587
+ forEach(data, function (item) {
588
+ if (typeof item === "object") {
589
+ value.push(new Resource(item));
590
+ } else {
591
+ // Valid JSON values may be string literals, and these should not be converted
592
+ // into objects. These items will not have access to the Resource prototype
593
+ // methods, but unfortunately there
594
+ value.push(item);
595
+ }
596
+ });
597
+ } else {
598
+ shallowClearAndCopy(data, value);
599
+ value.$promise = promise;
600
+ }
601
+ }
602
+
603
+ value.$resolved = true;
604
+
605
+ response.resource = value;
606
+
607
+ return response;
608
+ }, function (response) {
609
+ value.$resolved = true;
610
+
611
+ (error || noop)(response);
612
+
613
+ return $q.reject(response);
614
+ });
615
+
616
+ promise = promise.then(
617
+ function (response) {
618
+ var value = responseInterceptor(response);
619
+ (success || noop)(value, response.headers);
620
+ return value;
621
+ },
622
+ responseErrorInterceptor);
623
+
624
+ if (!isInstanceCall) {
625
+ // we are creating instance / collection
626
+ // - set the initial promise
627
+ // - return the instance / collection
628
+ value.$promise = promise;
629
+ value.$resolved = false;
630
+
631
+ return value;
632
+ }
633
+
634
+ // instance call
635
+ return promise;
636
+ };
637
+
638
+
639
+ Resource.prototype['$' + name] = function (params, success, error) {
640
+ if (isFunction(params)) {
641
+ error = success; success = params; params = {};
642
+ }
643
+ var result = Resource[name].call(this, params, this, success, error);
644
+ return result.$promise || result;
645
+ };
646
+ });
647
+
648
+ Resource.bind = function (additionalParamDefaults) {
649
+ return resourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions);
650
+ };
651
+
652
+ return Resource;
653
+ }
654
+
655
+ return resourceFactory;
656
+ }];
657
+ });
658
+
659
+
660
+ })(window, window.angular);