2013-06-22 08:24:24 +02:00
|
|
|
'use strict';
|
2013-05-15 03:17:24 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'backgrid'
|
|
|
|
], function (Backgrid) {
|
|
|
|
return Backgrid.Cell.extend({
|
2013-05-15 03:17:24 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
className: 'episode-status-cell',
|
2013-05-20 23:42:20 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
render: function () {
|
|
|
|
this.$el.empty();
|
2013-05-20 23:05:48 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
if (this.model) {
|
2013-05-20 23:05:48 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
var icon;
|
2013-07-05 22:26:50 +02:00
|
|
|
var tooltip;
|
2013-05-20 23:05:48 +02:00
|
|
|
|
2013-07-17 01:54:45 +02:00
|
|
|
var hasAired = Date.create(this.model.get('airDate')).isBefore(Date.create());
|
2013-07-17 05:25:42 +02:00
|
|
|
var hasFile = this.model.get('hasFile');
|
2013-07-17 01:54:45 +02:00
|
|
|
|
2013-07-17 05:25:42 +02:00
|
|
|
if (hasFile) {
|
2013-06-25 01:41:59 +02:00
|
|
|
icon = 'icon-ok';
|
2013-07-05 22:26:50 +02:00
|
|
|
tooltip = 'Episode downloaded';
|
2013-05-20 23:06:01 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-07-17 05:25:42 +02:00
|
|
|
if (hasAired) {
|
2013-06-25 01:41:59 +02:00
|
|
|
icon = 'icon-warning-sign';
|
2013-07-05 22:26:50 +02:00
|
|
|
tooltip = 'Episode missing from disk';
|
2013-06-25 01:41:59 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
icon = 'icon-time';
|
2013-07-05 22:26:50 +02:00
|
|
|
tooltip = 'Episode has not aired';
|
2013-06-25 01:41:59 +02:00
|
|
|
}
|
2013-05-20 23:06:01 +02:00
|
|
|
}
|
2013-06-25 01:41:59 +02:00
|
|
|
|
2013-07-05 22:26:50 +02:00
|
|
|
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
|
2013-05-20 23:06:01 +02:00
|
|
|
}
|
2013-05-20 23:05:48 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
return this;
|
2013-05-20 23:05:48 +02:00
|
|
|
}
|
2013-06-25 01:41:59 +02:00
|
|
|
});
|
2013-05-15 03:17:24 +02:00
|
|
|
});
|