-
Notifications
You must be signed in to change notification settings - Fork 1
/
angular-resource.min.js
12 lines (12 loc) · 3.03 KB
/
angular-resource.min.js
1
2
3
4
5
6
7
8
9
10
11
12
/*
AngularJS v1.2.1
(c) 2010-2012 Google, Inc. http://angularjs.org
License: MIT
*/
(function(H,f,z){'use strict';var v=f.$$minErr("$resource"),A=/^(\.[a-zA-Z_$][0-9a-zA-Z_$]*)+$/;f.module("ngResource",["ng"]).factory("$resource",["$http","$q",function(D,E){function n(f,h){this.template=f;this.defaults=h||{};this.urlParams={}}function w(m,h,k){function r(d,c){var e={};c=x({},h,c);s(c,function(a,c){u(a)&&(a=a());var g;if(a&&a.charAt&&"@"==a.charAt(0)){g=d;var b=a.substr(1);if(null==b||""===b||"hasOwnProperty"===b||!A.test("."+b))throw v("badmember",b);for(var b=b.split("."),f=0,h=
b.length;f<h&&g!==z;f++){var q=b[f];g=null!==g?g[q]:z}}else g=a;e[c]=g});return e}function e(b){return b.resource}function b(b){B(b||{},this)}var F=new n(m);k=x({},G,k);s(k,function(d,c){var h=/^(POST|PUT|PATCH)$/i.test(d.method);b[c]=function(a,c,g,m){var p={},t,q,k;switch(arguments.length){case 4:k=m,q=g;case 3:case 2:if(u(c)){if(u(a)){q=a;k=c;break}q=c;k=g}else{p=a;t=c;q=g;break}case 1:u(a)?q=a:h?t=a:p=a;break;case 0:break;default:throw v("badargs",arguments.length);}var n=t instanceof b,l=n?t:
d.isArray?[]:new b(t),y={},w=d.interceptor&&d.interceptor.response||e,A=d.interceptor&&d.interceptor.responseError||z;s(d,function(b,a){"params"!=a&&("isArray"!=a&&"interceptor"!=a)&&(y[a]=B(b))});h&&(y.data=t);F.setUrlParams(y,x({},r(t,d.params||{}),p),d.url);p=D(y).then(function(a){var c=a.data,g=l.$promise;if(c){if(f.isArray(c)!==!!d.isArray)throw v("badcfg",d.isArray?"array":"object",f.isArray(c)?"array":"object");d.isArray?(l.length=0,s(c,function(a){l.push(new b(a))})):(B(c,l),l.$promise=g)}l.$resolved=
!0;a.resource=l;return a},function(a){l.$resolved=!0;(k||C)(a);return E.reject(a)});p=p.then(function(a){var c=w(a);(q||C)(c,a.headers);return c},A);return n?p:(l.$promise=p,l.$resolved=!1,l)};b.prototype["$"+c]=function(a,d,g){u(a)&&(g=d,d=a,a={});a=b[c](a,this,d,g);return a.$promise||a}});b.bind=function(b){return w(m,x({},h,b),k)};return b}var G={get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}},C=f.noop,s=f.forEach,x=f.extend,
B=f.copy,u=f.isFunction;n.prototype={setUrlParams:function(m,h,k){var r=this,e=k||r.template,b,n,d=r.urlParams={};s(e.split(/\W/),function(c){if("hasOwnProperty"===c)throw v("badname");!/^\d+$/.test(c)&&(c&&RegExp("(^|[^\\\\]):"+c+"(\\W|$)").test(e))&&(d[c]=!0)});e=e.replace(/\\:/g,":");h=h||{};s(r.urlParams,function(c,d){b=h.hasOwnProperty(d)?h[d]:r.defaults[d];f.isDefined(b)&&null!==b?(n=encodeURIComponent(b).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,
"%20").replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+"),e=e.replace(RegExp(":"+d+"(\\W|$)","g"),n+"$1")):e=e.replace(RegExp("(/?):"+d+"(\\W|$)","g"),function(a,c,b){return"/"==b.charAt(0)?b:c+b})});e=e.replace(/\/+$/,"");e=e.replace(/\/\.(?=\w+($|\?))/,".");m.url=e.replace(/\/\\\./,"/.");s(h,function(b,d){r.urlParams[d]||(m.params=m.params||{},m.params[d]=b)})}};return w}])})(window,window.angular);
//# sourceMappingURL=angular-resource.min.js.map