2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-06-24 23:41:59 +00:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'marionette',
|
|
|
|
'Series/Details/SeasonLayout'
|
|
|
|
], function (Marionette, SeasonLayout) {
|
|
|
|
return Marionette.CollectionView.extend({
|
2013-06-01 19:31:39 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
itemView: SeasonLayout,
|
2013-06-01 19:31:39 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
initialize: function (options) {
|
2013-06-01 19:31:39 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
if (!options.episodeCollection) {
|
|
|
|
throw 'episodeCollection is needed';
|
|
|
|
}
|
2013-06-01 19:31:39 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
this.episodeCollection = options.episodeCollection;
|
2013-06-29 00:35:21 +00:00
|
|
|
this.series = options.series;
|
2013-06-24 23:41:59 +00:00
|
|
|
},
|
2013-06-01 19:31:39 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
itemViewOptions: function () {
|
|
|
|
return {
|
2013-06-29 00:35:21 +00:00
|
|
|
episodeCollection: this.episodeCollection,
|
|
|
|
series : this.series
|
2013-06-24 23:41:59 +00:00
|
|
|
};
|
2013-08-10 18:38:01 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onEpisodeGrabbed: function (message) {
|
|
|
|
if (message.episode.series.id != this.episodeCollection.seriesId) {
|
|
|
|
return;
|
|
|
|
}
|
2013-06-01 19:31:39 +00:00
|
|
|
|
2013-08-10 18:38:01 +00:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
_.each(message.episode.episodes, function (episode){
|
2013-08-22 03:24:50 +00:00
|
|
|
var ep = self.episodeCollection.get(episode.id);
|
2013-08-10 18:38:01 +00:00
|
|
|
ep.set('downloading', true);
|
|
|
|
console.debug(episode.title);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render();
|
|
|
|
}
|
2013-06-24 23:41:59 +00:00
|
|
|
});
|
2013-06-01 19:31:39 +00:00
|
|
|
});
|