Skip to content

Instantly share code, notes, and snippets.

@inklesspen
Created August 2, 2011 06:01
Show Gist options
  • Select an option

  • Save inklesspen/1119662 to your computer and use it in GitHub Desktop.

Select an option

Save inklesspen/1119662 to your computer and use it in GitHub Desktop.
leeuwenhoek.models.Scene = Backbone.Model.extend({
defaults: {
'question': 'What?',
'setting': 'Where, when, and who?',
'answer': 'What?',
'tone': 'light'
}
});
leeuwenhoek.models.SceneList = Backbone.Collection.extend({
model: leeuwenhoek.models.Scene
});
leeuwenhoek.models.Event = Backbone.Model.extend({
defaults: {
'description': 'Describe Me',
'tone': 'light'
},
initialize: function(attrs, opts) {
this.set({'scenes': new leeuwenhoek.models.SceneList(attrs.scenes)});
},
toJSON: function() {
var json = Backbone.Model.prototype.toJSON.call(this);
json['scenes'] = json['scenes'].toJSON();
return json;
}
});
leeuwenhoek.models.EventList = Backbone.Collection.extend({
model: leeuwenhoek.models.Event
});
leeuwenhoek.models.Period = Backbone.Model.extend({
defaults: {
"description": "Describe Me",
"tone": "light",
"comment": ""
},
initialize: function(attrs, opts) {
this.set({'events': new leeuwenhoek.models.EventList(attrs.events)});
},
toJSON: function() {
var json = Backbone.Model.prototype.toJSON.call(this);
json['events'] = json['events'].toJSON();
return json;
}
});
leeuwenhoek.models.PeriodList = Backbone.Collection.extend({
model: leeuwenhoek.models.Period
});
leeuwenhoek.models.History = Backbone.Model.extend({
defaults: {
'bigPicture': 'Stuff happens'
},
initialize: function(attrs, opts) {
this.set({'periods': new leeuwenhoek.models.PeriodList(attrs.periods)});
},
toJSON: function() {
var json = Backbone.Model.prototype.toJSON.call(this);
json['periods'] = json['periods'].toJSON();
return json;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment