-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathparse-angular.js
1 lines (1 loc) · 2.41 KB
/
parse-angular.js
1
!function(t,e){var r=t.angular;if(r!==e){var n=r.module("parse-angular",[]);n.run(["$q","$window",function(t,e){if(!r.isUndefined(e.Parse)&&r.isObject(e.Parse)){var n=e.Parse,o={Object:{prototype:["save","fetch","destroy"],"static":["saveAll","destroyAll"]},Collection:{prototype:["fetch"],"static":[]},Query:{prototype:["find","first","count","get"],"static":[]},Cloud:{prototype:[],"static":["run"]},User:{prototype:["signUp"],"static":["requestPasswordReset","logIn"]},FacebookUtils:{prototype:[],"static":["logIn","link","unlink"]},Config:{prototype:[],"static":["get"]}};for(var i in o){var s=i,a=o[i],c=a.prototype,p=a["static"];c.forEach(function(e){var r=n[s].prototype[e];n[s].prototype[e]=function(){return r.apply(this,arguments).then(function(e){var r=t.defer();return r.resolve(e),r.promise},function(e){var r=t.defer();return r.reject(e),r.promise})}}),p.forEach(function(e){var r=n[s][e];n[s][e]=function(){return r.apply(this,arguments).then(function(e){var r=t.defer();return r.resolve(e),r.promise},function(e){var r=t.defer();return r.reject(e),r.promise})}})}}}]),r.module("parse-angular.enhance",["parse-angular"]).run(["$q","$window",function(t,e){if(!r.isUndefined(e.Parse)&&r.isObject(e.Parse)){var n=e.Parse;n.Object.getClass=function(t){return n.Object._classMap[t]};var o=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},i=n.Object.extend;n.Object.extend=function(t){var e=i.apply(this,arguments);if(n._.isObject(t)&&n._.isArray(t.attrs)){var r=t.attrs;n._.each(r,function(t){var r=o(t);e.prototype["get"+r]||(e.prototype["get"+r]=function(){return this.get(t)}),e.prototype["set"+r]||(e.prototype["set"+r]=function(e){return this.set(t,e),this});var n=Object.getOwnPropertyDescriptor(e.prototype,t);n||(e.prototype.__defineGetter__(t,function(){return this.get(t)}),e.prototype.__defineSetter__(t,function(e){return this.set(t,e)}))})}return e},n.Collection._classMap={};var s=n.Collection.extend;n.Collection.extend=function(t){var e=s.apply(this,arguments);return t&&t.className&&(n.Collection._classMap[t.className]=e),e},n.Collection.getClass=function(t){return n.Collection._classMap[t]},n.Collection.prototype=r.extend(n.Collection.prototype,{loadMore:function(t){if(!r.isUndefined(this.query)){var e=-1==this.query._limit?100:this.query._limit,n=this.query._skip;n+=e,this.query.skip(n);var o=this;return this.query.find().then(function(r){return t&&t.add===!1||o.add(r),r.length<e&&(o.hasMoreToLoad=!1),r})}}})}}])}}(this);