jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/indicators/indicators.js

111 lines
3.0 KiB
JavaScript
Raw Normal View History

2016-06-09 23:54:03 -07:00
define(['css!./indicators.css', 'material-icons'], function () {
2016-05-28 11:03:38 -07:00
function enableProgressIndicator(item) {
if (item.MediaType == 'Video') {
if (item.Type != 'TvChannel') {
return true;
}
}
return false;
}
function getProgressHtml(pct) {
return '<div class="itemProgressBar"><div class="itemProgressBarForeground" style="width:' + pct + '%;"></div></div>';
}
function getProgressBarHtml(item) {
if (enableProgressIndicator(item)) {
if (item.Type == "Recording" && item.CompletionPercentage) {
return getProgressHtml(item.CompletionPercentage);
}
var userData = item.UserData;
if (userData) {
var pct = userData.PlayedPercentage;
if (pct && pct < 100) {
return getProgressHtml(pct);
}
}
}
return '';
}
function enablePlayedIndicator(item) {
if (item.Type == "Series" || item.Type == "Season" || item.Type == "BoxSet" || item.MediaType == "Video" || item.MediaType == "Game" || item.MediaType == "Book") {
if (item.Type != 'TvChannel') {
return true;
}
}
return false;
}
function getPlayedIndicator(item) {
if (enablePlayedIndicator(item)) {
var userData = item.UserData || {};
if (userData.UnplayedItemCount) {
return '<div class="countIndicator indicator">' + userData.UnplayedItemCount + '</div>';
}
if (userData.PlayedPercentage && userData.PlayedPercentage >= 100 || (userData.Played)) {
2016-08-01 22:55:52 -07:00
return '<div class="playedIndicator indicator"><i class="md-icon playedIndicatorIcon">&#xE5CA;</i></div>';
2016-05-28 11:03:38 -07:00
}
}
return '';
}
function getCountIndicatorHtml(count) {
return '<div class="countIndicator indicator">' + count + '</div>';
}
function getChildCountIndicatorHtml(item, options) {
var minCount = 0;
if (options) {
minCount = options.minCount || minCount;
}
if (item.ChildCount && item.ChildCount > minCount) {
return getCountIndicatorHtml(item.ChildCount);
}
return '';
}
function getTimerIndicator(item) {
if (item.SeriesTimerId) {
2016-06-09 23:54:03 -07:00
return '<i class="md-icon timerIndicator indicator">fiber_smart_record</i>';
2016-05-28 11:03:38 -07:00
}
if (item.TimerId) {
2016-06-09 23:54:03 -07:00
return '<i class="md-icon timerIndicator indicator">fiber_manual_record</i>';
2016-05-28 11:03:38 -07:00
}
return '';
}
return {
getProgressBarHtml: getProgressBarHtml,
getPlayedIndicatorHtml: getPlayedIndicator,
getChildCountIndicatorHtml: getChildCountIndicatorHtml,
enableProgressIndicator: enableProgressIndicator,
getTimerIndicator: getTimerIndicator,
enablePlayedIndicator: enablePlayedIndicator
};
});