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