2013-06-22 08:24:24 +02:00
|
|
|
'use strict';
|
2013-06-25 01:41:59 +02:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'backbone',
|
2013-07-17 08:23:44 +02:00
|
|
|
'moment',
|
2013-06-25 01:41:59 +02:00
|
|
|
'Series/SeriesModel'
|
2013-07-17 08:23:44 +02:00
|
|
|
], function (Backbone, Moment, SeriesModel) {
|
2013-06-25 01:41:59 +02:00
|
|
|
return Backbone.Model.extend({
|
|
|
|
|
2013-07-17 02:41:04 +02:00
|
|
|
initialize: function () {
|
|
|
|
if (this.has('series')) {
|
2013-07-24 07:28:06 +02:00
|
|
|
var start = Moment(this.get('airDateUtc'));
|
2013-07-17 02:41:04 +02:00
|
|
|
var runtime = this.get('series').get('runtime');
|
2013-05-01 03:54:15 +02:00
|
|
|
|
2013-07-17 08:23:44 +02:00
|
|
|
this.set('end', start.add('minutes', runtime));
|
2013-06-25 01:41:59 +02:00
|
|
|
}
|
2013-05-20 23:06:01 +02:00
|
|
|
},
|
2013-03-02 20:13:23 +01:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
parse: function (model) {
|
|
|
|
model.series = new SeriesModel(model.series);
|
|
|
|
|
|
|
|
return model;
|
|
|
|
},
|
2013-06-09 22:51:32 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
toJSON: function () {
|
|
|
|
var json = _.clone(this.attributes);
|
2013-06-09 22:51:32 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
if (this.has('series')) {
|
|
|
|
json.series = this.get('series').toJSON();
|
2013-06-10 07:27:20 +02:00
|
|
|
}
|
2013-06-25 01:41:59 +02:00
|
|
|
return json;
|
|
|
|
},
|
2013-06-10 04:10:15 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
defaults: {
|
|
|
|
seasonNumber: 0,
|
2013-06-29 02:35:21 +02:00
|
|
|
status : 0
|
2013-06-25 01:41:59 +02:00
|
|
|
}
|
|
|
|
});
|
2013-03-02 20:13:23 +01:00
|
|
|
});
|