Commit cb9a53d24dd48e663beb0678b717d43847be79f8

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.
  • Diff rendering mode:
  • inline
  • side by side

mouchak/static/js/models.js

11 });11 });
1212
13 var Text = BaseType.extend({13 var Text = BaseType.extend({
14 defaults: _.extend(BaseType.prototype.defaults, {
14 defaults: _.extend({
15 data: "",15 data: "",
16 }),
16 }, BaseType.prototype.defaults),
17 initialize: function() {17 initialize: function() {
18 BaseType.prototype.initialize.call(this, arguments);18 BaseType.prototype.initialize.call(this, arguments);
19 }19 }
20 });20 });
2121
22 var Table = BaseType.extend({22 var Table = BaseType.extend({
23 defaults: _.extend(BaseType.prototype.defaults, {
23 defaults: _.extend({
24 data : {24 data : {
25 th: [],25 th: [],
26 tr:[]26 tr:[]
27 }27 }
28 }),
28 }, BaseType.prototype.defaults),
29 initialize: function() {29 initialize: function() {
30 BaseType.prototype.initialize.call(this, arguments);30 BaseType.prototype.initialize.call(this, arguments);
31 }31 }
32 });32 });
3333
34 var Image = BaseType.extend({34 var Image = BaseType.extend({
35 defaults: _.extend(BaseType.prototype.defaults, {
35 defaults: _.extend({
36 src: ""36 src: ""
37 }),
37 }, BaseType.prototype.defaults),
38 initialize:function() {38 initialize:function() {
39 BaseType.prototype.initialize.call(this, arguments);39 BaseType.prototype.initialize.call(this, arguments);
40 }40 }
41 });41 });
4242
43 var Video = BaseType.extend({43 var Video = BaseType.extend({
44 defaults: _.extend(BaseType.prototype.defaults, {
44 defaults: _.extend({
45 src: ""45 src: ""
46 }),
46 }, BaseType.prototype.defaults),
47 initialize:function() {47 initialize:function() {
48 BaseType.prototype.initialize.call(this, arguments);48 BaseType.prototype.initialize.call(this, arguments);
49 }49 }
50 });50 });
5151
52 var RSS = BaseType.extend({52 var RSS = BaseType.extend({
53 defaults: _.extend(BaseType.prototype.defaults, {
53 defaults: _.extend({
54 src: ""54 src: ""
55 }),
55 }, BaseType.prototype.defaults),
56 initialize:function() {56 initialize:function() {
57 BaseType.prototype.initialize.call(this, arguments);57 BaseType.prototype.initialize.call(this, arguments);
58 }58 }
6060
61 // Map model61 // Map model
62 var Map = BaseType.extend({62 var Map = BaseType.extend({
63 defaults: _.extend(BaseType.prototype.defaults, {
63 defaults: _.extend({
64 tileLayer:"",64 tileLayer:"",
65 shp: ""65 shp: ""
66 }),
66 }, BaseType.prototype.defaults),
67 initialize: function(){67 initialize: function(){
68 BaseType.prototype.initialize.call(this, arguments);68 BaseType.prototype.initialize.call(this, arguments);
69 }69 }
74 // Also the website can be styled by using external CSS files,74 // Also the website can be styled by using external CSS files,
75 // which can also be loaded via this plugin model.75 // which can also be loaded via this plugin model.
76 var Plugin = BaseType.extend({76 var Plugin = BaseType.extend({
77 defaults: _.extend(BaseType.prototype.defaults, {
77 defaults: _.extend({
78 src: "",78 src: "",
79 data: {},79 data: {},
80 callback: ""80 callback: ""
81 }),
81 }, BaseType.prototype.defaults),
82 initialize: function() {82 initialize: function() {
83 BaseType.prototype.initialize.call(this, arguments);83 BaseType.prototype.initialize.call(this, arguments);
8484