diff options
| author | Misko Hevery | 2010-04-01 14:10:28 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-04-01 14:10:28 -0700 |
| commit | 85f13d602e31424b2e2d18172872f14a24c31135 (patch) | |
| tree | 8389ab1a0dfd6b8717a1f0dc70a738deaca146c2 /src/moveToAngularCom | |
| parent | 11a6431f8926c557f3c58408dacc98466e76cde1 (diff) | |
| download | angular.js-85f13d602e31424b2e2d18172872f14a24c31135.tar.bz2 | |
work on $location and autobind
Diffstat (limited to 'src/moveToAngularCom')
| -rw-r--r-- | src/moveToAngularCom/Model.js | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/src/moveToAngularCom/Model.js b/src/moveToAngularCom/Model.js deleted file mode 100644 index b09efd0e..00000000 --- a/src/moveToAngularCom/Model.js +++ /dev/null @@ -1,65 +0,0 @@ -// Single $ is special and does not get searched -// Double $$ is special an is client only (does not get sent to server) - -function Model(entity, initial) { - this['$$entity'] = entity; - this['$loadFrom'](initial||{}); - this['$entity'] = entity['title']; - this['$migrate'](); -}; - -Model.copyDirectFields = function(src, dst) { - if (src === dst || !src || !dst) return; - var isDataField = function(src, dst, field) { - return (field.substring(0,2) !== '$$') && - (typeof src[field] !== 'function') && - (typeof dst[field] !== 'function'); - }; - for (var field in dst) { - if (isDataField(src, dst, field)) - delete dst[field]; - } - for (field in src) { - if (isDataField(src, dst, field)) - dst[field] = src[field]; - } -}; - -extend(Model.prototype, { - '$migrate': function() { - merge(this['$$entity']['defaults'], this); - return this; - }, - - '$merge': function(other) { - merge(other, this); - return this; - }, - - '$save': function(callback) { - this['$$entity'].datastore.save(this, callback === true ? undefined : callback); - if (callback === true) this['$$entity'].datastore.flush(); - return this; - }, - - '$delete': function(callback) { - this['$$entity'].datastore.remove(this, callback === true ? undefined : callback); - if (callback === true) this['$$entity'].datastore.flush(); - return this; - }, - - '$loadById': function(id, callback) { - this['$$entity'].datastore.load(this, id, callback); - return this; - }, - - '$loadFrom': function(other) { - Model.copyDirectFields(other, this); - return this; - }, - - '$saveTo': function(other) { - Model.copyDirectFields(this, other); - return this; - } -});
\ No newline at end of file |
