diff options
Diffstat (limited to 'xstatic/pkg/angular/data/angular-resource.js')
-rw-r--r-- | xstatic/pkg/angular/data/angular-resource.js | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/xstatic/pkg/angular/data/angular-resource.js b/xstatic/pkg/angular/data/angular-resource.js index 27dc6dc..4cde1b7 100644 --- a/xstatic/pkg/angular/data/angular-resource.js +++ b/xstatic/pkg/angular/data/angular-resource.js @@ -1,6 +1,6 @@ /** - * @license AngularJS v1.3.18 - * (c) 2010-2014 Google, Inc. http://angularjs.org + * @license AngularJS v1.4.10 + * (c) 2010-2015 Google, Inc. http://angularjs.org * License: MIT */ (function(window, angular, undefined) {'use strict'; @@ -10,7 +10,7 @@ var $resourceMinErr = angular.$$minErr('$resource'); // Helper functions and regex to lookup a dotted path on an object // stopping at undefined/null. The path must be composed of ASCII // identifiers (just like $parse) -var MEMBER_NAME_REGEX = /^(\.[a-zA-Z_$][0-9a-zA-Z_$]*)+$/; +var MEMBER_NAME_REGEX = /^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/; function isValidDottedPath(path) { return (path != null && path !== '' && path !== 'hasOwnProperty' && @@ -22,7 +22,7 @@ function lookupDottedPath(obj, path) { throw $resourceMinErr('badmember', 'Dotted member path "@{0}" is invalid.', path); } var keys = path.split('.'); - for (var i = 0, ii = keys.length; i < ii && obj !== undefined; i++) { + for (var i = 0, ii = keys.length; i < ii && angular.isDefined(obj); i++) { var key = keys[i]; obj = (obj !== null) ? obj[key] : undefined; } @@ -90,7 +90,7 @@ function shallowClearAndCopy(src, dst) { }]); * ``` * - * @param {string} url A parametrized URL template with parameters prefixed by `:` as in + * @param {string} url A parameterized URL template with parameters prefixed by `:` as in * `/user/:username`. If you are using a URL with a port number (e.g. * `http://example.com:8080/api`), it will be respected. * @@ -102,7 +102,7 @@ function shallowClearAndCopy(src, dst) { * can escape it with `/\.`. * * @param {Object=} paramDefaults Default values for `url` parameters. These can be overridden in - * `actions` methods. If any of the parameter value is a function, it will be executed every time + * `actions` methods. If a parameter value is a function, it will be executed every time * when a param value needs to be obtained for a request (unless the param was overridden). * * Each key value in the parameter object is first bound to url template if present and then any @@ -155,8 +155,11 @@ function shallowClearAndCopy(src, dst) { * GET request, otherwise if a cache instance built with * {@link ng.$cacheFactory $cacheFactory}, this cache will be used for * caching. - * - **`timeout`** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise} that - * should abort the request when resolved. + * - **`timeout`** – `{number}` – timeout in milliseconds.<br /> + * **Note:** In contrast to {@link ng.$http#usage $http.config}, {@link ng.$q promises} are + * **not** supported in $resource, because the same value would be used for multiple requests. + * If you need support for cancellable $resource actions, you should upgrade to version 1.5 or + * higher. * - **`withCredentials`** - `{boolean}` - whether to set the `withCredentials` flag on the * XHR object. See * [requests with credentials](https://developer.mozilla.org/en/http_access_control#section_5) @@ -214,7 +217,8 @@ function shallowClearAndCopy(src, dst) { * - non-GET instance actions: `instance.$action([parameters], [success], [error])` * * - * Success callback is called with (value, responseHeaders) arguments. Error callback is called + * Success callback is called with (value, responseHeaders) arguments, where the value is + * the populated resource instance or collection object. The error callback is called * with (httpResponse) argument. * * Class actions return empty instance (with additional properties below). @@ -230,7 +234,7 @@ function shallowClearAndCopy(src, dst) { * {@link ngRoute.$routeProvider resolve section of $routeProvider.when()} to defer view * rendering until the resource(s) are loaded. * - * On failure, the promise is resolved with the {@link ng.$http http response} object, without + * On failure, the promise is rejected with the {@link ng.$http http response} object, without * the `resource` property. * * If an interceptor object was provided, the promise will instead be resolved with the value @@ -352,6 +356,7 @@ function shallowClearAndCopy(src, dst) { */ angular.module('ngResource', ['ng']). provider('$resource', function() { + var PROTOCOL_AND_DOMAIN_REGEX = /^https?:\/\/[^\/]*/; var provider = this; this.defaults = { @@ -368,7 +373,7 @@ angular.module('ngResource', ['ng']). } }; - this.$get = ['$http', '$q', function($http, $q) { + this.$get = ['$http', '$log', '$q', function($http, $log, $q) { var noop = angular.noop, forEach = angular.forEach, @@ -426,7 +431,8 @@ angular.module('ngResource', ['ng']). var self = this, url = actionUrl || self.template, val, - encodedVal; + encodedVal, + protocolAndDomain = ''; var urlParams = self.urlParams = {}; forEach(url.split(/\W/), function(param) { @@ -439,6 +445,10 @@ angular.module('ngResource', ['ng']). } }); url = url.replace(/\\:/g, ':'); + url = url.replace(PROTOCOL_AND_DOMAIN_REGEX, function(match) { + protocolAndDomain = match; + return ''; + }); params = params || {}; forEach(self.urlParams, function(_, urlParam) { @@ -469,7 +479,7 @@ angular.module('ngResource', ['ng']). // E.g. `http://url.com/id./format?q=x` becomes `http://url.com/id.format?q=x` url = url.replace(/\/\.(?=\w+($|\?))/, '.'); // replace escaped `/\.` with `/.` - config.url = url.replace(/\/\\\./, '/.'); + config.url = protocolAndDomain + url.replace(/\/\\\./, '/.'); // set params - delegate param encoding to $http @@ -566,8 +576,24 @@ angular.module('ngResource', ['ng']). undefined; forEach(action, function(value, key) { - if (key != 'params' && key != 'isArray' && key != 'interceptor') { - httpConfig[key] = copy(value); + switch (key) { + default: + httpConfig[key] = copy(value); + break; + case 'params': + case 'isArray': + case 'interceptor': + break; + case 'timeout': + if (value && !angular.isNumber(value)) { + $log.debug('ngResource:\n' + + ' Only numeric values are allowed as `timeout`.\n' + + ' Promises are not supported in $resource, because the same value would ' + + 'be used for multiple requests.\n' + + ' If you need support for cancellable $resource actions, you should ' + + 'upgrade to version 1.5 or higher.'); + } + break; } }); @@ -586,8 +612,8 @@ angular.module('ngResource', ['ng']). if (angular.isArray(data) !== (!!action.isArray)) { throw $resourceMinErr('badcfg', 'Error in resource configuration for action `{0}`. Expected response to ' + - 'contain an {1} but got an {2}', name, action.isArray ? 'array' : 'object', - angular.isArray(data) ? 'array' : 'object'); + 'contain an {1} but got an {2} (Request: {3} {4})', name, action.isArray ? 'array' : 'object', + angular.isArray(data) ? 'array' : 'object', httpConfig.method, httpConfig.url); } // jshint +W018 if (action.isArray) { |