define(['css!./indicators.css', 'material-icons'], function () {
function enableProgressIndicator(item) {
if (item.MediaType == 'Video') {
if (item.Type != 'TvChannel') {
return true;
}
}
return false;
}
function getProgressHtml(pct, options) {
var containerClass = 'itemProgressBar';
if (options) {
if (options.containerClass) {
containerClass += ' ' + options.containerClass;
}
}
return '
';
}
function getProgressBarHtml(item, options) {
if (enableProgressIndicator(item)) {
if (item.Type == "Recording" && item.CompletionPercentage) {
return getProgressHtml(item.CompletionPercentage, options);
}
var userData = options ? (options.userData || item.UserData) : item.UserData;
if (userData) {
var pct = userData.PlayedPercentage;
if (pct && pct < 100) {
return getProgressHtml(pct, options);
}
}
}
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 '' + userData.UnplayedItemCount + '
';
}
if (userData.PlayedPercentage && userData.PlayedPercentage >= 100 || (userData.Played)) {
return '
';
}
}
return '';
}
function getCountIndicatorHtml(count) {
return '' + count + '
';
}
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) {
return 'fiber_smart_record';
}
if (item.TimerId) {
return 'fiber_manual_record';
}
return '';
}
function getSyncIndicator(item) {
if (item.SyncPercent == 100) {
return 'file_download
';
} else if (item.SyncPercent != null) {
return 'file_download
';
}
return '';
}
return {
getProgressBarHtml: getProgressBarHtml,
getPlayedIndicatorHtml: getPlayedIndicator,
getChildCountIndicatorHtml: getChildCountIndicatorHtml,
enableProgressIndicator: enableProgressIndicator,
getTimerIndicator: getTimerIndicator,
enablePlayedIndicator: enablePlayedIndicator,
getSyncIndicator: getSyncIndicator
};
});