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;
|
|
|
|
}
|
|
|
|
|
2016-08-07 11:46:11 -07:00
|
|
|
function getProgressHtml(pct, options) {
|
2016-05-28 11:03:38 -07:00
|
|
|
|
2016-08-07 11:46:11 -07: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 11:03:38 -07:00
|
|
|
}
|
|
|
|
|
2016-08-07 11:46:11 -07:00
|
|
|
function getProgressBarHtml(item, options) {
|
2016-05-28 11:03:38 -07:00
|
|
|
|
|
|
|
if (enableProgressIndicator(item)) {
|
|
|
|
if (item.Type == "Recording" && item.CompletionPercentage) {
|
|
|
|
|
2016-08-07 11:46:11 -07:00
|
|
|
return getProgressHtml(item.CompletionPercentage, options);
|
2016-05-28 11:03:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var userData = item.UserData;
|
|
|
|
if (userData) {
|
|
|
|
var pct = userData.PlayedPercentage;
|
|
|
|
|
|
|
|
if (pct && pct < 100) {
|
|
|
|
|
2016-08-07 11:46:11 -07:00
|
|
|
return getProgressHtml(pct, options);
|
2016-05-28 11:03:38 -07: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 13:14:39 -07:00
|
|
|
return '<div class="playedIndicator indicator"><i class="md-icon indicatorIcon"></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) {
|
2016-08-02 23:38:19 -07:00
|
|
|
|
2016-05-28 11:03:38 -07:00
|
|
|
if (item.SeriesTimerId) {
|
2016-08-04 16:48:54 -07:00
|
|
|
return '<i class="md-icon timerIndicator indicatorIcon">fiber_smart_record</i>';
|
2016-05-28 11:03:38 -07:00
|
|
|
}
|
|
|
|
if (item.TimerId) {
|
2016-08-04 16:48:54 -07:00
|
|
|
return '<i class="md-icon timerIndicator indicatorIcon">fiber_manual_record</i>';
|
2016-05-28 11:03:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2016-08-02 23:38:19 -07:00
|
|
|
function getSyncIndicator(item) {
|
|
|
|
|
|
|
|
if (item.SyncPercent == 100) {
|
2016-08-03 13:14:39 -07:00
|
|
|
return '<div class="syncIndicator indicator fullSyncIndicator"><i class="md-icon indicatorIcon fullSyncIndicatorIcon">offline_pin</i></div>';
|
2016-08-02 23:38:19 -07:00
|
|
|
} else if (item.SyncPercent != null) {
|
2016-08-03 13:14:39 -07:00
|
|
|
return '<div class="syncIndicator indicator emptySyncIndicator"><i class="md-icon indicatorIcon">file_download</i></div>';
|
2016-08-02 23:38:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2016-05-28 11:03:38 -07:00
|
|
|
return {
|
|
|
|
getProgressBarHtml: getProgressBarHtml,
|
|
|
|
getPlayedIndicatorHtml: getPlayedIndicator,
|
|
|
|
getChildCountIndicatorHtml: getChildCountIndicatorHtml,
|
|
|
|
enableProgressIndicator: enableProgressIndicator,
|
|
|
|
getTimerIndicator: getTimerIndicator,
|
2016-08-02 23:38:19 -07:00
|
|
|
enablePlayedIndicator: enablePlayedIndicator,
|
|
|
|
getSyncIndicator: getSyncIndicator
|
2016-05-28 11:03:38 -07:00
|
|
|
};
|
|
|
|
});
|