From cb9a53d24dd48e663beb0678b717d43847be79f8 Mon Sep 17 00:00:00 2001 From: Anon Ray Date: Sun, 6 Oct 2013 18:53:06 +0530 Subject: [PATCH] Fix each Mouchak type having all attributes Each Mouchak type was inheriting attribute of all other Mouchak types. Fix that. It had to with the underscore _.extend method. I did not know it copied the resultant object to the first argument to it. Which was causing the BaseType itself to have all the attributes of all models. --- mouchak/static/js/models.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mouchak/static/js/models.js b/mouchak/static/js/models.js index 244dbcd..36dae73 100644 --- a/mouchak/static/js/models.js +++ b/mouchak/static/js/models.js @@ -11,48 +11,48 @@ }); var Text = BaseType.extend({ - defaults: _.extend(BaseType.prototype.defaults, { + defaults: _.extend({ data: "", - }), + }, BaseType.prototype.defaults), initialize: function() { BaseType.prototype.initialize.call(this, arguments); } }); var Table = BaseType.extend({ - defaults: _.extend(BaseType.prototype.defaults, { + defaults: _.extend({ data : { th: [], tr:[] } - }), + }, BaseType.prototype.defaults), initialize: function() { BaseType.prototype.initialize.call(this, arguments); } }); var Image = BaseType.extend({ - defaults: _.extend(BaseType.prototype.defaults, { + defaults: _.extend({ src: "" - }), + }, BaseType.prototype.defaults), initialize:function() { BaseType.prototype.initialize.call(this, arguments); } }); var Video = BaseType.extend({ - defaults: _.extend(BaseType.prototype.defaults, { + defaults: _.extend({ src: "" - }), + }, BaseType.prototype.defaults), initialize:function() { BaseType.prototype.initialize.call(this, arguments); } }); var RSS = BaseType.extend({ - defaults: _.extend(BaseType.prototype.defaults, { + defaults: _.extend({ src: "" - }), + }, BaseType.prototype.defaults), initialize:function() { BaseType.prototype.initialize.call(this, arguments); } @@ -60,10 +60,10 @@ // Map model var Map = BaseType.extend({ - defaults: _.extend(BaseType.prototype.defaults, { + defaults: _.extend({ tileLayer:"", shp: "" - }), + }, BaseType.prototype.defaults), initialize: function(){ BaseType.prototype.initialize.call(this, arguments); } @@ -74,11 +74,11 @@ // Also the website can be styled by using external CSS files, // which can also be loaded via this plugin model. var Plugin = BaseType.extend({ - defaults: _.extend(BaseType.prototype.defaults, { + defaults: _.extend({ src: "", data: {}, callback: "" - }), + }, BaseType.prototype.defaults), initialize: function() { BaseType.prototype.initialize.call(this, arguments); -- 1.7.10.4