2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-05-15 01:17:24 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
define(
|
|
|
|
[
|
2013-07-17 06:23:44 +00:00
|
|
|
'backgrid',
|
|
|
|
'moment'
|
|
|
|
], function (Backgrid, Moment) {
|
2013-06-24 23:41:59 +00:00
|
|
|
return Backgrid.Cell.extend({
|
2013-05-15 01:17:24 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
className: 'episode-status-cell',
|
2013-05-20 21:42:20 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
render: function () {
|
|
|
|
this.$el.empty();
|
2013-05-20 21:05:48 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
if (this.model) {
|
2013-05-20 21:05:48 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
var icon;
|
2013-07-05 20:26:50 +00:00
|
|
|
var tooltip;
|
2013-05-20 21:05:48 +00:00
|
|
|
|
2013-07-26 05:19:50 +00:00
|
|
|
var hasAired = Moment(this.model.get('airDateUtc')).isBefore(Moment());
|
2013-07-17 03:25:42 +00:00
|
|
|
var hasFile = this.model.get('hasFile');
|
2013-07-16 23:54:45 +00:00
|
|
|
|
2013-07-17 03:25:42 +00:00
|
|
|
if (hasFile) {
|
2013-07-19 15:41:08 +00:00
|
|
|
var quality = this.model.get('episodeFile').quality;
|
|
|
|
|
|
|
|
if (quality.proper) {
|
|
|
|
this.$el.html('<span class="badge badge-info" title="Episode downloaded [PROPER]">{0}</span>'.format(quality.quality.name));
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
this.$el.html('<span class="badge badge-inverse" title="Episode downloaded">{0}</span>'.format(quality.quality.name));
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2013-05-20 21:06:01 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-07-26 05:19:50 +00:00
|
|
|
if (!this.model.get('airDateUtc')) {
|
2013-07-18 05:02:19 +00:00
|
|
|
icon = 'icon-question-sign';
|
|
|
|
tooltip = 'TBA';
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (hasAired) {
|
2013-06-24 23:41:59 +00:00
|
|
|
icon = 'icon-warning-sign';
|
2013-07-05 20:26:50 +00:00
|
|
|
tooltip = 'Episode missing from disk';
|
2013-06-24 23:41:59 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
icon = 'icon-time';
|
2013-07-05 20:26:50 +00:00
|
|
|
tooltip = 'Episode has not aired';
|
2013-06-24 23:41:59 +00:00
|
|
|
}
|
2013-05-20 21:06:01 +00:00
|
|
|
}
|
2013-07-18 05:52:13 +00:00
|
|
|
|
2013-07-05 20:26:50 +00:00
|
|
|
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
|
2013-05-20 21:06:01 +00:00
|
|
|
}
|
2013-05-20 21:05:48 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
return this;
|
2013-05-20 21:05:48 +00:00
|
|
|
}
|
2013-06-24 23:41:59 +00:00
|
|
|
});
|
2013-05-15 01:17:24 +00:00
|
|
|
});
|