Removed mutators from EpisodeModel

This commit is contained in:
Mark McDowall 2013-07-16 17:41:04 -07:00
commit e164df217d
8 changed files with 95 additions and 70 deletions

View file

@ -14,4 +14,33 @@ define(
return new Handlebars.SafeString(result);
});
Handlebars.registerHelper('Day', function (input) {
if (!input) {
return '';
}
return Date.create(input).format('{dd}');
});
Handlebars.registerHelper('Month', function (input) {
if (!input) {
return '';
}
return Date.create(input).format('{Mon}');
});
Handlebars.registerHelper('StartTime', function (input) {
if (!input) {
return '';
}
var date = Date.create(input);
if (date.format('{mm}') === '00') {
return date.format('{h}{tt}');
}
return date.format('{h}.{mm}{tt}');
});
});

View file

@ -4,15 +4,38 @@ define(
'handlebars',
'Shared/FormatHelpers'
], function (Handlebars, FormatHelpers) {
Handlebars.registerHelper('episodeNumberHelper', function () {
Handlebars.registerHelper('EpisodeNumber', function () {
if (this.series.seriesType === 'daily') {
return FormatHelpers.DateHelper(this.airDate);
}
else {
return '{0}x{1}'.format(this.seasonNumber, this.paddedEpisodeNumber);
return '{0}x{1}'.format(this.seasonNumber, this.episodeNumber.pad(2));
}
});
Handlebars.registerHelper('StatusLevel', function () {
var hasFile = this.hasFile;
var currentTime = Date.create();
var start = Date.create(this.airDate);
var end = Date.create(this.end);
if (currentTime.isBetween(start, end)) {
return 'warning';
}
if (start.isBefore(currentTime) && !hasFile) {
return 'danger';
}
if (hasFile) {
return 'success';
}
return 'primary';
});
});

View file

@ -7,4 +7,8 @@ define(
Handlebars.registerHelper('Bytes', function (size) {
return new Handlebars.SafeString(FormatHelpers.Bytes(size));
});
Handlebars.registerHelper('Pad2', function (input) {
return input.pad(2);
});
});

View file

@ -11,7 +11,7 @@ define(
var profile = QualityProfileCollection.get(profileId);
if (profile) {
return new Handlebars.SafeString('<span class="label quality-profile-lable">' + profile.get("name") + '</span>');
return new Handlebars.SafeString('<span class="label quality-profile-label">' + profile.get("name") + '</span>');
}
return undefined;