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