mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
69 lines
2.6 KiB
JavaScript
69 lines
2.6 KiB
JavaScript
'use strict';
|
|
|
|
define(
|
|
[
|
|
'marionette',
|
|
'Cells/NzbDroneCell',
|
|
'reqres',
|
|
'Series/SeriesCollection'
|
|
], function (Marionette, NzbDroneCell, reqres, SeriesCollection) {
|
|
return NzbDroneCell.extend({
|
|
|
|
className: 'episode-number-cell',
|
|
template : 'Series/Details/EpisodeNumberCellTemplate',
|
|
|
|
render: function () {
|
|
|
|
this.$el.empty();
|
|
this.$el.html(this.model.get('episodeNumber'));
|
|
|
|
var series = SeriesCollection.get(this.model.get('seriesId'));
|
|
|
|
if (series.get('seriesType') === 'anime' && this.model.has('absoluteEpisodeNumber')) {
|
|
this.$el.html('{0} ({1})'.format(this.model.get('episodeNumber'), this.model.get('absoluteEpisodeNumber')));
|
|
}
|
|
|
|
var alternateTitles = [];
|
|
|
|
if (reqres.hasHandler(reqres.Requests.GetAlternateNameBySeasonNumber)) {
|
|
|
|
if (this.model.get('sceneSeasonNumber') > 0) {
|
|
alternateTitles = reqres.request(reqres.Requests.GetAlternateNameBySeasonNumber,
|
|
this.model.get('seriesId'),
|
|
this.model.get('sceneSeasonNumber'));
|
|
}
|
|
|
|
if (alternateTitles.length === 0) {
|
|
alternateTitles = reqres.request(reqres.Requests.GetAlternateNameBySeasonNumber,
|
|
this.model.get('seriesId'),
|
|
this.model.get('seasonNumber'));
|
|
}
|
|
}
|
|
|
|
if (this.model.get('sceneSeasonNumber') > 0 ||
|
|
this.model.get('sceneEpisodeNumber') > 0 ||
|
|
this.model.has('sceneAbsoluteEpisodeNumber') ||
|
|
alternateTitles.length > 0)
|
|
{
|
|
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
|
|
|
var json = this.model.toJSON();
|
|
json.alternateTitles = alternateTitles;
|
|
|
|
var html = this.templateFunction(json);
|
|
|
|
this.$el.popover({
|
|
content : html,
|
|
html : true,
|
|
trigger : 'hover',
|
|
title : 'Scene Information',
|
|
placement: 'right',
|
|
container: this.$el
|
|
});
|
|
}
|
|
|
|
this.delegateEvents();
|
|
return this;
|
|
}
|
|
});
|
|
});
|