Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Documentation updated for v0.3.1

  • Loading branch information...
commit 932514db981667b8e38441217739a4362692a55a 1 parent eeeaa44
dhruvaray authored
View
2  LICENSE.txt
@@ -1,4 +1,4 @@
-copyright (c) 2012 Dhruva Ray, Jaynti Kanani, Persistent Systems Ltd.
+copyright (c) 2013 Dhruva Ray, Jaynti Kanani, Persistent Systems Ltd.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
View
6 README.md
@@ -22,8 +22,8 @@ It was originally born out of a need to provide a simpler and speedier implement
## <a name="download"/>Download
-* [Production version - 0.3.0](http://dhruvaray.github.com/backbone-associations/backbone-associations-min.js) (1.6KB packed and gzipped)
-* [Development version - 0.3.0](http://dhruvaray.github.com/backbone-associations/backbone-associations.js)
+* [Production version - 0.3.1](http://dhruvaray.github.com/backbone-associations/backbone-associations-min.js) (_1.7KB packed and gzipped_)
+* [Development version - 0.3.1](http://dhruvaray.github.com/backbone-associations/backbone-associations.js)
## <a name="installation"/>Installation
@@ -529,7 +529,7 @@ emp.on('change:works_for', function () {
![Performance](http://dhruvaray.github.com/backbone-associations/docs/img/speed.png)
-Each operation comprises of n (10, 15, 20, 25, 30) inserts. The chart above compares the performance (time and operations/sec) of the two implementations. (backbone-associations v0.3.0 v/s backbone-relational v0.7.0)
+Each operation comprises of n (10, 15, 20, 25, 30) inserts. The chart above compares the performance (time and operations/sec) of the two implementations. (backbone-associations v0.3.1 v/s backbone-relational v0.7.0)
Run tests on your machine configuration instantly [here](http://dhruvaray.github.com/backbone-associations/test/speed-comparison.html)
View
18 backbone-associations-min.js
@@ -1,9 +1,9 @@
-(function(){var e,g,i,o,n;"undefined"!==typeof require?(e=require("underscore"),g=require("backbone"),exports=module.exports=g):(e=window._,g=window.Backbone);i=g.Model.prototype;o="change add remove reset destroy sync error sort request".split(" ");g.Many="Many";g.One="One";n=g.AssociatedModel=g.Model.extend({relations:void 0,_proxyCalls:void 0,set:function(b,a,c){var d,f,h;if(e.isObject(b)||b==null){d=b;c=a}else{d={};d[b]=a}c||(c={});if(!d)return this;if(c.unset)for(h in d)d[h]=void 0;this.relations&&
-e.each(this.relations,function(a){var b=a.key,h=a.relatedModel,k=a.collectionType,l,m;if(d[b]){l=e.result(d,b);h&&e.isString(h)&&(h=eval(h));k&&e.isString(k)&&(k=eval(k));m=a.options?e.extend({},a.options,c):c;if(a.type===g.Many){if(k&&!k.prototype instanceof g.Collection)throw Error("collectionType must inherit from Backbone.Collection");if(l instanceof g.Collection)i.set.call(this,b,l,m);else if(this.attributes[b])this.attributes[b].reset(l,m);else{a=k?new k:this._createCollection(h);a.add(l,m);
-i.set.call(this,b,a,m)}}else if(a.type===g.One&&h){a=l instanceof n?l:new h(l);i.set.call(this,b,a,m)}if(!this.attributes[b]._proxyCallback){this.attributes[b]._proxyCallback=function(){var a=arguments,c=a[0].split(":"),d=c[0],f=a[1],h=-1,i=this.attributes[b]._proxyCalls,j;if(e.contains(o,d)){c&&e.size(c)>1&&(j=c[1]);this.attributes[b]instanceof g.Collection&&"change"===d&&(h=e.indexOf(this.attributes[b].models,f));j=b+(h!==-1?"["+h+"]":"")+(j?"."+j:"");a[0]=d+":"+j;if(i){if(c=e.find(i,function(a,
-b){return j.indexOf(b,j.length-b.length)!==-1}))return this}else i=this.attributes[b]._proxyCalls={};i[j]=true}this.trigger.apply(this,a);j&&i&&delete i[j];return this};this.attributes[b].on("all",this.attributes[b]._proxyCallback,this)}!f&&(f=[]);e.indexOf(f,b)===-1&&f.push(b)}},this);if(f){b={};for(h in d)e.indexOf(f,h)===-1&&(b[h]=d[h])}else b=d;return i.set.call(this,b,c)},_createCollection:function(b){var a=b;e.isString(a)&&(a=eval(a));if(a&&a.prototype instanceof n){b=new g.Collection;b.model=
-a}else throw Error("type must inherit from Backbone.AssociatedModel");return b},hasChanged:function(b){var a,c,d;if(!this.visitedHC){this.visitedHC=true;a=i.hasChanged.apply(this,arguments);if(!a&&this.relations)for(d=0;d<this.relations.length;++d){c=this.relations[d];if(c=this.attributes[c.key]){if(c instanceof g.Collection){c=c.filter(function(a){return a.hasChanged()===true});e.size(c)>0&&(a=true)}else a=c.hasChanged&&c.hasChanged();if(a)break}}delete this.visitedHC}return!!a},changedAttributes:function(b){var a,
-c,d,f;if(!this.visited){this.visited=true;a=i.changedAttributes.apply(this,arguments);if(this.relations)for(f=0;f<this.relations.length;++f){c=this.relations[f];if(d=this.attributes[c.key])if(d instanceof g.Collection){d=e.filter(d.map(function(a){return a.changedAttributes()}),function(a){return!!a});e.size(d)>0&&(a[c.key]=d)}else d instanceof n&&d.hasChanged()&&(a[c.key]=d.toJSON())}delete this.visited}return!a?false:a},previousAttributes:function(){var b,a,c,d;if(!this.visited){this.visited=true;
-b=i.previousAttributes.apply(this,arguments);this.relations&&e.each(this.relations,function(f){a=this.attributes[f.key];d=(c=b[f.key])?c.toJSON():void 0;c&&c==a?a instanceof n?b[f.key]=a.previousAttributes():a instanceof g.Collection&&(b[f.key]=a.map(function(a){return a.previousAttributes()})):c&&(b[f.key]=d)},this);delete this.visited}return b},previous:function(b){return this.previousAttributes()[b]},toJSON:function(b){var a,c;if(!this.visited){this.visited=true;a=i.toJSON.apply(this,arguments);
-this.relations&&e.each(this.relations,function(d){var f=this.attributes[d.key];if(f){c=f.toJSON(b);a[d.key]=e.isArray(c)?e.compact(c):c}},this);delete this.visited}return a},clone:function(){var b,a;if(!this.visited){this.visited=true;b=i.clone.apply(this,arguments);this.relations&&e.each(this.relations,function(c){if(this.attributes[c.key]){var d=b.attributes[c.key];if(d instanceof g.Collection){a=c.collectionType?new c.collectionType:this._createCollection(c.relatedModel);d.each(function(b){(b=
-b.clone())&&a.add(b)});b.attributes[c.key]=a}else d instanceof g.Model&&(b.attributes[c.key]=d.clone())}},this);delete this.visited}return b}})})();
+(function(){var f,h,q,l,m,r,n;"undefined"!==typeof require?(f=require("underscore"),h=require("backbone"),exports=module.exports=h):(f=window._,h=window.Backbone);q=h.Model;l=h.Collection;m=q.prototype;r="change add remove reset destroy sync error sort request".split(" ");h.Many="Many";h.One="One";n=h.AssociatedModel=q.extend({relations:void 0,_proxyCalls:void 0,get:function(b){return this.getAttr.apply(this,arguments)},set:function(b,a,c){var d,e,g;if(f.isObject(b)||b==null){d=b;c=a}else{d={};d[b]=
+a}c||(c={});if(!d)return this;if(c.unset)for(g in d)d[g]=void 0;this.relations&&f.each(this.relations,function(a){var b=a.key,g=a.relatedModel,k=a.collectionType,i,p;if(d[b]){i=f.result(d,b);g&&f.isString(g)&&(g=eval(g));k&&f.isString(k)&&(k=eval(k));p=a.options?f.extend({},a.options,c):c;if(a.type===h.Many){if(k&&!k.prototype instanceof l)throw Error("collectionType must inherit from Backbone.Collection");if(i instanceof l)m.set.call(this,b,i,p);else if(this.attributes[b])this.attributes[b].reset(i,
+p);else{a=k?new k:this._createCollection(g);a.add(i,p);m.set.call(this,b,a,p)}}else if(a.type===h.One&&g){a=i instanceof n?i:new g(i);m.set.call(this,b,a,p)}if((i=this.attributes[b])&&!i._proxyCallback){i._proxyCallback=function(){return this._bubbleEvent.call(this,b,arguments)};i.on("all",i._proxyCallback,this)}!e&&(e=[]);f.indexOf(e,b)===-1&&e.push(b)}},this);if(e){b={};for(g in d)f.indexOf(e,g)===-1&&(b[g]=d[g])}else b=d;return m.set.call(this,b,c)},_bubbleEvent:function(b,a){var c=a[0].split(":"),
+d=c[0],e=a[1],g=-1,h=this.attributes[b],o=h._proxyCalls,j;if(f.contains(r,d)){f.size(c)>1&&(j=c[1]);if(h instanceof l&&"change"===d&&e){var k=s(j),i=f.initial(k);(c=h.find(function(a){var b=a.get(k);return e===!(b instanceof n||b instanceof l)?a.get(i):b}))&&(g=h.indexOf(c))}j=b+(g!==-1?"["+g+"]":"")+(j?"."+j:"");a[0]=d+":"+j;if(o){if(d=f.find(o,function(a,b){return j.indexOf(b,j.length-b.length)!==-1}))return this}else o=h._proxyCalls={};o[j]=true}this.trigger.apply(this,a);j&&o&&delete o[j];return this},
+_createCollection:function(b){var a=b;f.isString(a)&&(a=eval(a));if(a&&a.prototype instanceof n){b=new l;b.model=a}else throw Error("type must inherit from Backbone.AssociatedModel");return b},hasChanged:function(b){var a,c,d;if(!this.visitedHC){this.visitedHC=true;a=m.hasChanged.apply(this,arguments);if(!a&&this.relations)for(d=0;d<this.relations.length;++d){c=this.relations[d];if(c=this.attributes[c.key]){if(c instanceof l){c=c.filter(function(a){return a.hasChanged()===true});f.size(c)>0&&(a=true)}else a=
+c.hasChanged&&c.hasChanged();if(a)break}}delete this.visitedHC}return!!a},changedAttributes:function(b){var a,c,d,e;if(!this.visited){this.visited=true;a=m.changedAttributes.apply(this,arguments);if(this.relations)for(e=0;e<this.relations.length;++e){c=this.relations[e];if(d=this.attributes[c.key])if(d instanceof l){d=f.filter(d.map(function(a){return a.changedAttributes()}),function(a){return!!a});f.size(d)>0&&(a[c.key]=d)}else d instanceof n&&d.hasChanged()&&(a[c.key]=d.toJSON())}delete this.visited}return!a?
+false:a},previousAttributes:function(){var b,a,c,d;if(!this.visited){this.visited=true;b=m.previousAttributes.apply(this,arguments);this.relations&&f.each(this.relations,function(e){a=this.attributes[e.key];d=(c=b[e.key])?c.toJSON():void 0;c&&c==a?a instanceof n?b[e.key]=a.previousAttributes():a instanceof l&&(b[e.key]=a.map(function(a){return a.previousAttributes()})):c&&(b[e.key]=d)},this);delete this.visited}return b},previous:function(b){return this.previousAttributes()[b]},toJSON:function(b){var a,
+c;if(!this.visited){this.visited=true;a=m.toJSON.apply(this,arguments);this.relations&&f.each(this.relations,function(d){var e=this.attributes[d.key];if(e){c=e.toJSON(b);a[d.key]=f.isArray(c)?f.compact(c):c}},this);delete this.visited}return a},clone:function(){return new this.constructor(this.toJSON())},getAttr:function(b,a){var c=this,d=s(b),e,g;a||(a=function(a,b){return a instanceof l&&f.isNumber(b)?a.at(b):a.attributes[b]});for(g=0;g<d.length;g++){e=d[g];if(!c)break;c=a.call(this,c,e,d)}return c}});
+var s=function(b,a,c){if(f.isString(b)){a||(a=function(a){return a.match(/^\d+$/)?parseInt(a,10):a});return f.map(b.match(/[^\.\[\]]+/g)||[],a,c)}return b||[]}})();
View
4 backbone-associations.js
@@ -1,7 +1,7 @@
//
-// Backbone-associations.js 0.3.0
+// Backbone-associations.js 0.3.1
//
-// (c) 2012 Dhruva Ray, Jaynti Kanani
+// (c) 2013 Dhruva Ray, Jaynti Kanani
// Backbone-associations may be freely distributed under the MIT license;
// see the accompanying LICENSE.txt.
// Depends on [Backbone](https://github.com/documentcloud/backbone) and [Underscore](https://github.com/documentcloud/underscore/) as well.
View
1,335 docs/backbone-associations.html
210 additions, 1,125 deletions not shown
View
2  docs/cd-example.tex
@@ -1,7 +1,7 @@
\documentclass[landscape]{article}
\usepackage{tikz-uml}
-
+\pagestyle{empty
\begin{document}
\begin{tikzpicture}
View
BIN  docs/img/cd-example.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  docs/img/speed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  package.json
@@ -8,5 +8,5 @@
},
"lib":".",
"main":"backbone-associations.js",
- "version":"0.3.0"
+ "version":"0.3.1"
}
Please sign in to comment.
Something went wrong with that request. Please try again.