diff options
| author | Cezar Berea | 2012-11-25 17:10:37 +0200 | 
|---|---|---|
| committer | Pawel Kozlowski | 2012-11-30 22:47:25 +0100 | 
| commit | c12f525df4c45de206f5949ea8c54e081417c83c (patch) | |
| tree | 6807990279e1f614468a90a970b212051cc5148f /src | |
| parent | e7ba83069117b4ed6ebf383c30c73224632d569a (diff) | |
| download | angular.js-c12f525df4c45de206f5949ea8c54e081417c83c.tar.bz2 | |
refactor($resource): fix indentation and move a method definition
Moved Resource.bind out of the actions forEach
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngResource/resource.js | 92 | 
1 files changed, 46 insertions, 46 deletions
| diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index 5e58737e..4f468d42 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -6,7 +6,7 @@   * @description   */ - /** +/**   * @ngdoc object   * @name ngResource.$resource   * @requires $http @@ -224,46 +224,46 @@ angular.module('ngResource', ['ng']).            return $parse(path)(obj);          }; -  /** -   * We need our custom mehtod because encodeURIComponent is too aggressive and doesn't follow -   * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path -   * segments: -   *    segment       = *pchar -   *    pchar         = unreserved / pct-encoded / sub-delims / ":" / "@" -   *    pct-encoded   = "%" HEXDIG HEXDIG -   *    unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~" -   *    sub-delims    = "!" / "$" / "&" / "'" / "(" / ")" -   *                     / "*" / "+" / "," / ";" / "=" -   */ -  function encodeUriSegment(val) { -    return encodeUriQuery(val, true). -      replace(/%26/gi, '&'). -      replace(/%3D/gi, '='). -      replace(/%2B/gi, '+'); -  } - - -  /** -   * This method is intended for encoding *key* or *value* parts of query component. We need a custom -   * method becuase encodeURIComponent is too agressive and encodes stuff that doesn't have to be -   * encoded per http://tools.ietf.org/html/rfc3986: -   *    query       = *( pchar / "/" / "?" ) -   *    pchar         = unreserved / pct-encoded / sub-delims / ":" / "@" -   *    unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~" -   *    pct-encoded   = "%" HEXDIG HEXDIG -   *    sub-delims    = "!" / "$" / "&" / "'" / "(" / ")" -   *                     / "*" / "+" / "," / ";" / "=" -   */ -  function encodeUriQuery(val, pctEncodeSpaces) { -    return encodeURIComponent(val). -      replace(/%40/gi, '@'). -      replace(/%3A/gi, ':'). -      replace(/%24/g, '$'). -      replace(/%2C/gi, ','). -      replace((pctEncodeSpaces ? null : /%20/g), '+'); -  } - -  function Route(template, defaults) { +    /** +     * We need our custom mehtod because encodeURIComponent is too aggressive and doesn't follow +     * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path +     * segments: +     *    segment       = *pchar +     *    pchar         = unreserved / pct-encoded / sub-delims / ":" / "@" +     *    pct-encoded   = "%" HEXDIG HEXDIG +     *    unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~" +     *    sub-delims    = "!" / "$" / "&" / "'" / "(" / ")" +     *                     / "*" / "+" / "," / ";" / "=" +     */ +    function encodeUriSegment(val) { +      return encodeUriQuery(val, true). +        replace(/%26/gi, '&'). +        replace(/%3D/gi, '='). +        replace(/%2B/gi, '+'); +    } + + +    /** +     * This method is intended for encoding *key* or *value* parts of query component. We need a custom +     * method becuase encodeURIComponent is too agressive and encodes stuff that doesn't have to be +     * encoded per http://tools.ietf.org/html/rfc3986: +     *    query       = *( pchar / "/" / "?" ) +     *    pchar         = unreserved / pct-encoded / sub-delims / ":" / "@" +     *    unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~" +     *    pct-encoded   = "%" HEXDIG HEXDIG +     *    sub-delims    = "!" / "$" / "&" / "'" / "(" / ")" +     *                     / "*" / "+" / "," / ";" / "=" +     */ +    function encodeUriQuery(val, pctEncodeSpaces) { +      return encodeURIComponent(val). +        replace(/%40/gi, '@'). +        replace(/%3A/gi, ':'). +        replace(/%24/g, '$'). +        replace(/%2C/gi, ','). +        replace((pctEncodeSpaces ? null : /%20/g), '+'); +    } + +    function Route(template, defaults) {        this.template = template = template + '#';        this.defaults = defaults || {};        var urlParams = this.urlParams = {}; @@ -390,11 +390,6 @@ angular.module('ngResource', ['ng']).          }; -        Resource.bind = function(additionalParamDefaults){ -          return ResourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions); -        }; - -          Resource.prototype['$' + name] = function(a1, a2, a3) {            var params = extractParams(this),                success = noop, @@ -420,6 +415,11 @@ angular.module('ngResource', ['ng']).            Resource[name].call(this, params, data, success, error);          };        }); + +      Resource.bind = function(additionalParamDefaults){ +        return ResourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions); +      }; +        return Resource;      } | 
