mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-22 22:34:53 -04:00
UI Cleanup - Updated Form and Handlebars subtree.
This commit is contained in:
@@ -1,83 +1,79 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'handlebars',
|
||||
'System/StatusModel',
|
||||
'underscore'
|
||||
], function (Handlebars, StatusModel, _) {
|
||||
Handlebars.registerHelper('poster', function () {
|
||||
var Handlebars = require('handlebars');
|
||||
var StatusModel = require('../../System/StatusModel');
|
||||
var _ = require('underscore');
|
||||
|
||||
var placeholder = StatusModel.get('urlBase') + '/Content/Images/poster-dark.png';
|
||||
var poster = _.where(this.images, {coverType: 'poster'});
|
||||
Handlebars.registerHelper('poster', function() {
|
||||
|
||||
if (poster[0]) {
|
||||
if (!poster[0].url.match(/^https?:\/\//)) {
|
||||
return new Handlebars.SafeString('<img class="series-poster" {0}>'.format(Handlebars.helpers.defaultImg.call(null, poster[0].url, 250)));
|
||||
} else {
|
||||
return new Handlebars.SafeString('<img class="series-poster" {0}>'.format(Handlebars.helpers.defaultImg.call(null, poster[0].url)));
|
||||
}
|
||||
}
|
||||
var placeholder = StatusModel.get('urlBase') + '/Content/Images/poster-dark.png';
|
||||
var poster = _.where(this.images, { coverType : 'poster' });
|
||||
|
||||
return new Handlebars.SafeString('<img class="series-poster placeholder-image" src="{0}">'.format(placeholder));
|
||||
});
|
||||
if (poster[0]) {
|
||||
if (!poster[0].url.match(/^https?:\/\//)) {
|
||||
return new Handlebars.SafeString('<img class="series-poster" {0}>'.format(Handlebars.helpers.defaultImg.call(null, poster[0].url, 250)));
|
||||
} else {
|
||||
return new Handlebars.SafeString('<img class="series-poster" {0}>'.format(Handlebars.helpers.defaultImg.call(null, poster[0].url)));
|
||||
}
|
||||
}
|
||||
|
||||
Handlebars.registerHelper('traktUrl', function () {
|
||||
return 'http://trakt.tv/show/' + this.titleSlug;
|
||||
});
|
||||
return new Handlebars.SafeString('<img class="series-poster placeholder-image" src="{0}">'.format(placeholder));
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('imdbUrl', function () {
|
||||
return 'http://imdb.com/title/' + this.imdbId;
|
||||
});
|
||||
Handlebars.registerHelper('traktUrl', function() {
|
||||
return 'http://trakt.tv/show/' + this.titleSlug;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('tvdbUrl', function () {
|
||||
return 'http://www.thetvdb.com/?tab=series&id=' + this.tvdbId;
|
||||
});
|
||||
Handlebars.registerHelper('imdbUrl', function() {
|
||||
return 'http://imdb.com/title/' + this.imdbId;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('tvRageUrl', function () {
|
||||
return 'http://www.tvrage.com/shows/id-' + this.tvRageId;
|
||||
});
|
||||
Handlebars.registerHelper('tvdbUrl', function() {
|
||||
return 'http://www.thetvdb.com/?tab=series&id=' + this.tvdbId;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('route', function () {
|
||||
return StatusModel.get('urlBase') + '/series/' + this.titleSlug;
|
||||
});
|
||||
Handlebars.registerHelper('tvRageUrl', function() {
|
||||
return 'http://www.tvrage.com/shows/id-' + this.tvRageId;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('percentOfEpisodes', function () {
|
||||
var episodeCount = this.episodeCount;
|
||||
var episodeFileCount = this.episodeFileCount;
|
||||
Handlebars.registerHelper('route', function() {
|
||||
return StatusModel.get('urlBase') + '/series/' + this.titleSlug;
|
||||
});
|
||||
|
||||
var percent = 100;
|
||||
Handlebars.registerHelper('percentOfEpisodes', function() {
|
||||
var episodeCount = this.episodeCount;
|
||||
var episodeFileCount = this.episodeFileCount;
|
||||
|
||||
if (episodeCount > 0) {
|
||||
percent = episodeFileCount / episodeCount * 100;
|
||||
}
|
||||
var percent = 100;
|
||||
|
||||
return percent;
|
||||
});
|
||||
if (episodeCount > 0) {
|
||||
percent = episodeFileCount / episodeCount * 100;
|
||||
}
|
||||
|
||||
Handlebars.registerHelper('seasonCountHelper', function () {
|
||||
var seasonCount = this.seasonCount;
|
||||
var continuing = this.status === 'continuing';
|
||||
return percent;
|
||||
});
|
||||
|
||||
if (continuing) {
|
||||
return new Handlebars.SafeString('<span class="label label-info">Season {0}</span>'.format(seasonCount));
|
||||
}
|
||||
Handlebars.registerHelper('seasonCountHelper', function() {
|
||||
var seasonCount = this.seasonCount;
|
||||
var continuing = this.status === 'continuing';
|
||||
|
||||
if (seasonCount === 1) {
|
||||
return new Handlebars.SafeString('<span class="label label-info">{0} Season</span>'.format(seasonCount));
|
||||
}
|
||||
if (continuing) {
|
||||
return new Handlebars.SafeString('<span class="label label-info">Season {0}</span>'.format(seasonCount));
|
||||
}
|
||||
|
||||
return new Handlebars.SafeString('<span class="label label-info">{0} Seasons</span>'.format(seasonCount));
|
||||
});
|
||||
if (seasonCount === 1) {
|
||||
return new Handlebars.SafeString('<span class="label label-info">{0} Season</span>'.format(seasonCount));
|
||||
}
|
||||
|
||||
Handlebars.registerHelper('titleWithYear', function () {
|
||||
if (this.title.endsWith(' ({0})'.format(this.year))) {
|
||||
return this.title;
|
||||
}
|
||||
return new Handlebars.SafeString('<span class="label label-info">{0} Seasons</span>'.format(seasonCount));
|
||||
});
|
||||
|
||||
if (!this.year) {
|
||||
return this.title;
|
||||
}
|
||||
Handlebars.registerHelper('titleWithYear', function() {
|
||||
if (this.title.endsWith(' ({0})'.format(this.year))) {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
return new Handlebars.SafeString('{0} <span class="year">({1})</span>'.format(this.title, this.year));
|
||||
});
|
||||
});
|
||||
if (!this.year) {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
return new Handlebars.SafeString('{0} <span class="year">({1})</span>'.format(this.title, this.year));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user