1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/indicators/indicators.js

150 lines
4.2 KiB
JavaScript
Raw Normal View History

2016-06-10 02:54:03 -04:00
define(['css!./indicators.css', 'material-icons'], function () {
2016-05-28 14:03:38 -04:00
function enableProgressIndicator(item) {
if (item.MediaType == 'Video') {
if (item.Type != 'TvChannel') {
return true;
}
}
return false;
}
2016-08-07 14:46:11 -04:00
function getProgressHtml(pct, options) {
2016-05-28 14:03:38 -04:00
2016-08-07 14:46:11 -04:00
var containerClass = 'itemProgressBar';
if (options) {
if (options.containerClass) {
containerClass += ' ' + options.containerClass;
}
}
return '<div class="' + containerClass + '"><div class="itemProgressBarForeground" style="width:' + pct + '%;"></div></div>';
2016-05-28 14:03:38 -04:00
}
2016-08-07 14:46:11 -04:00
function getProgressBarHtml(item, options) {
2016-05-28 14:03:38 -04:00
if (enableProgressIndicator(item)) {
if (item.Type == "Recording" && item.CompletionPercentage) {
2016-08-07 14:46:11 -04:00
return getProgressHtml(item.CompletionPercentage, options);
2016-05-28 14:03:38 -04:00
}
2016-08-30 00:33:24 -04:00
var userData = options ? (options.userData || item.UserData) : item.UserData;
2016-05-28 14:03:38 -04:00
if (userData) {
var pct = userData.PlayedPercentage;
if (pct && pct < 100) {
2016-08-07 14:46:11 -04:00
return getProgressHtml(pct, options);
2016-05-28 14:03:38 -04:00
}
}
}
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-03 16:14:39 -04:00
return '<div class="playedIndicator indicator"><i class="md-icon indicatorIcon">&#xE5CA;</i></div>';
2016-05-28 14:03:38 -04: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) {
2016-08-03 02:38:19 -04:00
2016-10-04 01:15:39 -04:00
var status;
if (item.Type == 'SeriesTimer') {
return '<i class="md-icon timerIndicator indicatorIcon">&#xE062;</i>';
}
else if (item.TimerId) {
status = item.TimerStatus;
}
else if (item.Type == 'Timer') {
status = item.Status;
}
else {
return '';
}
if (item.SeriesTimerId) {
if (status != 'Cancelled' && status != 'Aborted') {
2016-09-22 02:57:31 -04:00
return '<i class="md-icon timerIndicator indicatorIcon">&#xE062;</i>';
}
2016-10-04 01:15:39 -04:00
return '<i class="md-icon timerIndicator timerIndicator-inactive indicatorIcon">&#xE062;</i>';
2016-05-28 14:03:38 -04:00
}
2016-10-04 01:15:39 -04:00
return '<i class="md-icon timerIndicator indicatorIcon">&#xE061;</i>';
2016-05-28 14:03:38 -04:00
}
2016-08-03 02:38:19 -04:00
function getSyncIndicator(item) {
if (item.SyncPercent == 100) {
2016-08-17 01:29:05 -04:00
return '<div class="syncIndicator indicator fullSyncIndicator"><i class="md-icon indicatorIcon">file_download</i></div>';
2016-08-03 02:38:19 -04:00
} else if (item.SyncPercent != null) {
2016-08-03 16:14:39 -04:00
return '<div class="syncIndicator indicator emptySyncIndicator"><i class="md-icon indicatorIcon">file_download</i></div>';
2016-08-03 02:38:19 -04:00
}
return '';
}
2016-05-28 14:03:38 -04:00
return {
getProgressBarHtml: getProgressBarHtml,
getPlayedIndicatorHtml: getPlayedIndicator,
getChildCountIndicatorHtml: getChildCountIndicatorHtml,
enableProgressIndicator: enableProgressIndicator,
getTimerIndicator: getTimerIndicator,
2016-08-03 02:38:19 -04:00
enablePlayedIndicator: enablePlayedIndicator,
getSyncIndicator: getSyncIndicator
2016-05-28 14:03:38 -04:00
};
});