Fix broken item details menu on TV Shows

This commit is contained in:
Cameron 2020-08-25 15:44:01 +01:00
parent 768fef0f1f
commit b8cf026bad

View File

@ -29,9 +29,7 @@ import 'emby-ratingbutton';
import 'emby-scroller'; import 'emby-scroller';
import 'emby-select'; import 'emby-select';
/* eslint-disable indent */ function getPromise(apiClient, params) {
function getPromise(apiClient, params) {
const id = params.id; const id = params.id;
if (id) { if (id) {
@ -55,9 +53,9 @@ import 'emby-select';
} }
throw new Error('Invalid request'); throw new Error('Invalid request');
} }
function hideAll(page, className, show) { function hideAll(page, className, show) {
for (const elem of page.querySelectorAll('.' + className)) { for (const elem of page.querySelectorAll('.' + className)) {
if (show) { if (show) {
elem.classList.remove('hide'); elem.classList.remove('hide');
@ -65,9 +63,9 @@ import 'emby-select';
elem.classList.add('hide'); elem.classList.add('hide');
} }
} }
} }
function getContextMenuOptions(item, user, button) { function getContextMenuOptions(item, user, button) {
return { return {
item: item, item: item,
open: false, open: false,
@ -83,9 +81,9 @@ import 'emby-select';
user: user, user: user,
share: true share: true
}; };
} }
function getProgramScheduleHtml(items) { function getProgramScheduleHtml(items) {
let html = ''; let html = '';
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-list" data-contextmenu="false">'; html += '<div is="emby-itemscontainer" class="itemsContainer vertical-list" data-contextmenu="false">';
@ -105,9 +103,9 @@ import 'emby-select';
html += '</div>'; html += '</div>';
return html; return html;
} }
function renderSeriesTimerSchedule(page, apiClient, seriesTimerId) { function renderSeriesTimerSchedule(page, apiClient, seriesTimerId) {
apiClient.getLiveTvTimers({ apiClient.getLiveTvTimers({
UserId: apiClient.getCurrentUserId(), UserId: apiClient.getCurrentUserId(),
ImageTypeLimit: 1, ImageTypeLimit: 1,
@ -127,23 +125,23 @@ import 'emby-select';
scheduleTab.innerHTML = html; scheduleTab.innerHTML = html;
imageLoader.lazyChildren(scheduleTab); imageLoader.lazyChildren(scheduleTab);
}); });
} }
function renderTimerEditor(page, item, apiClient, user) { function renderTimerEditor(page, item, apiClient, user) {
if (item.Type !== 'Recording' || !user.Policy.EnableLiveTvManagement || !item.TimerId || item.Status !== 'InProgress') { if (item.Type !== 'Recording' || !user.Policy.EnableLiveTvManagement || !item.TimerId || item.Status !== 'InProgress') {
return void hideAll(page, 'btnCancelTimer'); return void hideAll(page, 'btnCancelTimer');
} }
hideAll(page, 'btnCancelTimer', true); hideAll(page, 'btnCancelTimer', true);
} }
function renderSeriesTimerEditor(page, item, apiClient, user) { function renderSeriesTimerEditor(page, item, apiClient, user) {
if (item.Type !== 'SeriesTimer') { if (item.Type !== 'SeriesTimer') {
return void hideAll(page, 'btnCancelSeriesTimer'); return void hideAll(page, 'btnCancelSeriesTimer');
} }
if (user.Policy.EnableLiveTvManagement) { if (user.Policy.EnableLiveTvManagement) {
import('seriesRecordingEditor').then(({default: seriesRecordingEditor}) => { import('seriesRecordingEditor').then(({ default: seriesRecordingEditor }) => {
seriesRecordingEditor.embed(item, apiClient.serverId(), { seriesRecordingEditor.embed(item, apiClient.serverId(), {
context: page.querySelector('.seriesRecordingEditor') context: page.querySelector('.seriesRecordingEditor')
}); });
@ -156,9 +154,9 @@ import 'emby-select';
page.querySelector('.seriesTimerScheduleSection').classList.add('hide'); page.querySelector('.seriesTimerScheduleSection').classList.add('hide');
return void hideAll(page, 'btnCancelSeriesTimer'); return void hideAll(page, 'btnCancelSeriesTimer');
} }
function renderTrackSelections(page, instance, item, forceReload) { function renderTrackSelections(page, instance, item, forceReload) {
const select = page.querySelector('.selectSource'); const select = page.querySelector('.selectSource');
if (!item.MediaSources || !itemHelper.supportsMediaSourceSelection(item) || playbackManager.getSupportedCommands().indexOf('PlayMediaSource') === -1 || !playbackManager.canPlay(item)) { if (!item.MediaSources || !itemHelper.supportsMediaSourceSelection(item) || playbackManager.getSupportedCommands().indexOf('PlayMediaSource') === -1 || !playbackManager.canPlay(item)) {
@ -195,9 +193,9 @@ import 'emby-select';
renderAudioSelections(page, mediaSources); renderAudioSelections(page, mediaSources);
renderSubtitleSelections(page, mediaSources); renderSubtitleSelections(page, mediaSources);
} }
} }
function renderVideoSelections(page, mediaSources) { function renderVideoSelections(page, mediaSources) {
const mediaSourceId = page.querySelector('.selectSource').value; const mediaSourceId = page.querySelector('.selectSource').value;
const mediaSource = mediaSources.filter(function (m) { const mediaSource = mediaSources.filter(function (m) {
return m.Id === mediaSourceId; return m.Id === mediaSourceId;
@ -232,9 +230,9 @@ import 'emby-select';
} else { } else {
page.querySelector('.selectVideoContainer').classList.add('hide'); page.querySelector('.selectVideoContainer').classList.add('hide');
} }
} }
function renderAudioSelections(page, mediaSources) { function renderAudioSelections(page, mediaSources) {
const mediaSourceId = page.querySelector('.selectSource').value; const mediaSourceId = page.querySelector('.selectSource').value;
const mediaSource = mediaSources.filter(function (m) { const mediaSource = mediaSources.filter(function (m) {
return m.Id === mediaSourceId; return m.Id === mediaSourceId;
@ -261,9 +259,9 @@ import 'emby-select';
} else { } else {
page.querySelector('.selectAudioContainer').classList.add('hide'); page.querySelector('.selectAudioContainer').classList.add('hide');
} }
} }
function renderSubtitleSelections(page, mediaSources) { function renderSubtitleSelections(page, mediaSources) {
const mediaSourceId = page.querySelector('.selectSource').value; const mediaSourceId = page.querySelector('.selectSource').value;
const mediaSource = mediaSources.filter(function (m) { const mediaSource = mediaSources.filter(function (m) {
return m.Id === mediaSourceId; return m.Id === mediaSourceId;
@ -298,9 +296,9 @@ import 'emby-select';
select.innerHTML = ''; select.innerHTML = '';
page.querySelector('.selectSubtitlesContainer').classList.add('hide'); page.querySelector('.selectSubtitlesContainer').classList.add('hide');
} }
} }
function reloadPlayButtons(page, item) { function reloadPlayButtons(page, item) {
let canPlay = false; let canPlay = false;
if (item.Type == 'Program') { if (item.Type == 'Program') {
@ -340,9 +338,9 @@ import 'emby-select';
} }
return canPlay; return canPlay;
} }
function reloadUserDataButtons(page, item) { function reloadUserDataButtons(page, item) {
let i; let i;
let length; let length;
const btnPlaystates = page.querySelectorAll('.btnPlaystate'); const btnPlaystates = page.querySelectorAll('.btnPlaystate');
@ -372,9 +370,9 @@ import 'emby-select';
btnUserRating.setItem(null); btnUserRating.setItem(null);
} }
} }
} }
function getArtistLinksHtml(artists, serverId, context) { function getArtistLinksHtml(artists, serverId, context) {
const html = []; const html = [];
for (const artist of artists) { for (const artist of artists) {
@ -387,15 +385,15 @@ import 'emby-select';
} }
return html.join(' / '); return html.join(' / ');
} }
/** /**
* Renders the item's name block * Renders the item's name block
* @param {Object} item - Item used to render the name. * @param {Object} item - Item used to render the name.
* @param {HTMLDivElement} container - Container to render the information into. * @param {HTMLDivElement} container - Container to render the information into.
* @param {Object} context - Application context. * @param {Object} context - Application context.
*/ */
function renderName(item, container, context) { function renderName(item, container, context) {
let parentRoute; let parentRoute;
const parentNameHtml = []; const parentNameHtml = [];
let parentNameLast = false; let parentNameLast = false;
@ -505,25 +503,25 @@ import 'emby-select';
} else { } else {
container.classList.add('hide'); container.classList.add('hide');
} }
} }
function setTrailerButtonVisibility(page, item) { function setTrailerButtonVisibility(page, item) {
if ((item.LocalTrailerCount || item.RemoteTrailers && item.RemoteTrailers.length) && playbackManager.getSupportedCommands().indexOf('PlayTrailers') !== -1) { if ((item.LocalTrailerCount || item.RemoteTrailers && item.RemoteTrailers.length) && playbackManager.getSupportedCommands().indexOf('PlayTrailers') !== -1) {
hideAll(page, 'btnPlayTrailer', true); hideAll(page, 'btnPlayTrailer', true);
} else { } else {
hideAll(page, 'btnPlayTrailer'); hideAll(page, 'btnPlayTrailer');
} }
} }
function renderBackdrop(item) { function renderBackdrop(item) {
if (dom.getWindowSize().innerWidth >= 1000) { if (dom.getWindowSize().innerWidth >= 1000) {
backdrop.setBackdrops([item]); backdrop.setBackdrops([item]);
} else { } else {
backdrop.clearBackdrop(); backdrop.clearBackdrop();
} }
} }
function renderDetailPageBackdrop(page, item, apiClient) { function renderDetailPageBackdrop(page, item, apiClient) {
let imgUrl; let imgUrl;
let hasbackdrop = false; let hasbackdrop = false;
const itemBackdropElement = page.querySelector('#itemBackdrop'); const itemBackdropElement = page.querySelector('#itemBackdrop');
@ -563,9 +561,9 @@ import 'emby-select';
} }
return hasbackdrop; return hasbackdrop;
} }
function reloadFromItem(instance, page, params, item, user) { function reloadFromItem(instance, page, params, item, user) {
const apiClient = connectionManager.getApiClient(item.ServerId); const apiClient = connectionManager.getApiClient(item.ServerId);
Emby.Page.setTitle(''); Emby.Page.setTitle('');
@ -663,12 +661,12 @@ import 'emby-select';
hideAll(page, 'btnDownload', true); hideAll(page, 'btnDownload', true);
} }
import('autoFocuser').then(({default: autoFocuser}) => { import('autoFocuser').then(({ default: autoFocuser }) => {
autoFocuser.autoFocus(page); autoFocuser.autoFocus(page);
}); });
} }
function logoImageUrl(item, apiClient, options) { function logoImageUrl(item, apiClient, options) {
options = options || {}; options = options || {};
options.type = 'Logo'; options.type = 'Logo';
@ -683,9 +681,9 @@ import 'emby-select';
} }
return null; return null;
} }
function renderLogo(page, item, apiClient) { function renderLogo(page, item, apiClient) {
const detailLogo = page.querySelector('.detailLogo'); const detailLogo = page.querySelector('.detailLogo');
const url = logoImageUrl(item, apiClient, {}); const url = logoImageUrl(item, apiClient, {});
@ -698,14 +696,14 @@ import 'emby-select';
} else { } else {
detailLogo.classList.add('hide'); detailLogo.classList.add('hide');
} }
} }
function showRecordingFields(instance, page, item, user) { function showRecordingFields(instance, page, item, user) {
if (!instance.currentRecordingFields) { if (!instance.currentRecordingFields) {
const recordingFieldsElement = page.querySelector('.recordingFields'); const recordingFieldsElement = page.querySelector('.recordingFields');
if (item.Type == 'Program' && user.Policy.EnableLiveTvManagement) { if (item.Type == 'Program' && user.Policy.EnableLiveTvManagement) {
import('recordingFields').then(({default: recordingFields}) => { import('recordingFields').then(({ default: recordingFields }) => {
instance.currentRecordingFields = new recordingFields({ instance.currentRecordingFields = new recordingFields({
parent: recordingFieldsElement, parent: recordingFieldsElement,
programId: item.Id, programId: item.Id,
@ -718,9 +716,9 @@ import 'emby-select';
recordingFieldsElement.innerHTML = ''; recordingFieldsElement.innerHTML = '';
} }
} }
} }
function renderLinks(page, item) { function renderLinks(page, item) {
const externalLinksElem = page.querySelector('.itemExternalLinks'); const externalLinksElem = page.querySelector('.itemExternalLinks');
const links = []; const links = [];
@ -747,9 +745,9 @@ import 'emby-select';
} else { } else {
externalLinksElem.classList.add('hide'); externalLinksElem.classList.add('hide');
} }
} }
function renderDetailImage(elem, item, imageLoader) { function renderDetailImage(elem, item, imageLoader) {
const itemArray = []; const itemArray = [];
itemArray.push(item); itemArray.push(item);
const cardHtml = cardBuilder.getCardsHtml(itemArray, { const cardHtml = cardBuilder.getCardsHtml(itemArray, {
@ -766,33 +764,33 @@ import 'emby-select';
elem.innerHTML = cardHtml; elem.innerHTML = cardHtml;
imageLoader.lazyChildren(elem); imageLoader.lazyChildren(elem);
} }
function renderImage(page, item) { function renderImage(page, item) {
renderDetailImage( renderDetailImage(
page.querySelector('.detailImageContainer'), page.querySelector('.detailImageContainer'),
item, item,
imageLoader imageLoader
); );
} }
function refreshDetailImageUserData(elem, item) { function refreshDetailImageUserData(elem, item) {
elem.querySelector('.detailImageProgressContainer').innerHTML = indicators.getProgressBarHtml(item); elem.querySelector('.detailImageProgressContainer').innerHTML = indicators.getProgressBarHtml(item);
} }
function refreshImage(page, item) { function refreshImage(page, item) {
refreshDetailImageUserData(page.querySelector('.detailImageContainer'), item); refreshDetailImageUserData(page.querySelector('.detailImageContainer'), item);
} }
function setPeopleHeader(page, item) { function setPeopleHeader(page, item) {
if (item.MediaType == 'Audio' || item.Type == 'MusicAlbum' || item.MediaType == 'Book' || item.MediaType == 'Photo') { if (item.MediaType == 'Audio' || item.Type == 'MusicAlbum' || item.MediaType == 'Book' || item.MediaType == 'Photo') {
page.querySelector('#peopleHeader').innerHTML = globalize.translate('People'); page.querySelector('#peopleHeader').innerHTML = globalize.translate('People');
} else { } else {
page.querySelector('#peopleHeader').innerHTML = globalize.translate('HeaderCastAndCrew'); page.querySelector('#peopleHeader').innerHTML = globalize.translate('HeaderCastAndCrew');
} }
} }
function renderNextUp(page, item, user) { function renderNextUp(page, item, user) {
const section = page.querySelector('.nextUpSection'); const section = page.querySelector('.nextUpSection');
if (item.Type != 'Series') { if (item.Type != 'Series') {
@ -822,9 +820,9 @@ import 'emby-select';
itemsContainer.innerHTML = html; itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer); imageLoader.lazyChildren(itemsContainer);
}); });
} }
function setInitialCollapsibleState(page, item, apiClient, context, user) { function setInitialCollapsibleState(page, item, apiClient, context, user) {
page.querySelector('.collectionItems').innerHTML = ''; page.querySelector('.collectionItems').innerHTML = '';
if (item.Type == 'Playlist') { if (item.Type == 'Playlist') {
@ -873,9 +871,9 @@ import 'emby-select';
} else { } else {
page.querySelector('#musicVideosCollapsible').classList.add('hide'); page.querySelector('#musicVideosCollapsible').classList.add('hide');
} }
} }
function toggleLineClamp(clampTarget, e) { function toggleLineClamp(clampTarget, e) {
const expandButton = e.target; const expandButton = e.target;
const clampClassName = 'detail-clamp-text'; const clampClassName = 'detail-clamp-text';
@ -886,9 +884,9 @@ import 'emby-select';
clampTarget.classList.add(clampClassName); clampTarget.classList.add(clampClassName);
expandButton.innerHTML = globalize.translate('ShowMore'); expandButton.innerHTML = globalize.translate('ShowMore');
} }
} }
function renderOverview(page, item) { function renderOverview(page, item) {
for (const overviewElemnt of page.querySelectorAll('.overview')) { for (const overviewElemnt of page.querySelectorAll('.overview')) {
const overview = item.Overview || ''; const overview = item.Overview || '';
@ -918,9 +916,9 @@ import 'emby-select';
overviewElemnt.classList.add('hide'); overviewElemnt.classList.add('hide');
} }
} }
} }
function renderGenres(page, item, context = inferContext(item)) { function renderGenres(page, item, context = inferContext(item)) {
const genres = item.GenreItems || []; const genres = item.GenreItems || [];
const type = context === 'music' ? 'MusicGenre' : 'Genre'; const type = context === 'music' ? 'MusicGenre' : 'Genre';
@ -946,9 +944,9 @@ import 'emby-select';
} else { } else {
genresGroup.classList.add('hide'); genresGroup.classList.add('hide');
} }
} }
function renderWriter(page, item, context) { function renderWriter(page, item, context) {
const writers = (item.People || []).filter(function (person) { const writers = (item.People || []).filter(function (person) {
return person.Type === 'Writer'; return person.Type === 'Writer';
}); });
@ -975,9 +973,9 @@ import 'emby-select';
} else { } else {
writersGroup.classList.add('hide'); writersGroup.classList.add('hide');
} }
} }
function renderDirector(page, item, context) { function renderDirector(page, item, context) {
const directors = (item.People || []).filter(function (person) { const directors = (item.People || []).filter(function (person) {
return person.Type === 'Director'; return person.Type === 'Director';
}); });
@ -1004,9 +1002,9 @@ import 'emby-select';
} else { } else {
directorsGroup.classList.add('hide'); directorsGroup.classList.add('hide');
} }
} }
function renderMiscInfo(page, item) { function renderMiscInfo(page, item) {
const primaryItemMiscInfo = page.querySelectorAll('.itemMiscInfo-primary'); const primaryItemMiscInfo = page.querySelectorAll('.itemMiscInfo-primary');
for (const miscInfo of primaryItemMiscInfo) { for (const miscInfo of primaryItemMiscInfo) {
@ -1036,9 +1034,9 @@ import 'emby-select';
miscInfo.classList.add('hide'); miscInfo.classList.add('hide');
} }
} }
} }
function renderTagline(page, item) { function renderTagline(page, item) {
const taglineElement = page.querySelector('.tagline'); const taglineElement = page.querySelector('.tagline');
if (item.Taglines && item.Taglines.length) { if (item.Taglines && item.Taglines.length) {
@ -1047,9 +1045,9 @@ import 'emby-select';
} else { } else {
taglineElement.classList.add('hide'); taglineElement.classList.add('hide');
} }
} }
function renderDetails(page, item, apiClient, context, isStatic) { function renderDetails(page, item, apiClient, context, isStatic) {
renderSimilarItems(page, item, context); renderSimilarItems(page, item, context);
renderMoreFromSeason(page, item, apiClient); renderMoreFromSeason(page, item, apiClient);
renderMoreFromArtist(page, item, apiClient); renderMoreFromArtist(page, item, apiClient);
@ -1064,29 +1062,29 @@ import 'emby-select';
renderLinks(page, item); renderLinks(page, item);
renderTags(page, item); renderTags(page, item);
renderSeriesAirTime(page, item, isStatic); renderSeriesAirTime(page, item, isStatic);
} }
function enableScrollX() { function enableScrollX() {
return browser.mobile && screen.availWidth <= 1000; return browser.mobile && screen.availWidth <= 1000;
} }
function getPortraitShape(scrollX) { function getPortraitShape(scrollX) {
if (scrollX == null) { if (scrollX == null) {
scrollX = enableScrollX(); scrollX = enableScrollX();
} }
return scrollX ? 'overflowPortrait' : 'portrait'; return scrollX ? 'overflowPortrait' : 'portrait';
} }
function getSquareShape(scrollX) { function getSquareShape(scrollX) {
if (scrollX == null) { if (scrollX == null) {
scrollX = enableScrollX(); scrollX = enableScrollX();
} }
return scrollX ? 'overflowSquare' : 'square'; return scrollX ? 'overflowSquare' : 'square';
} }
function renderMoreFromSeason(view, item, apiClient) { function renderMoreFromSeason(view, item, apiClient) {
const section = view.querySelector('.moreFromSeasonSection'); const section = view.querySelector('.moreFromSeasonSection');
if (section) { if (section) {
@ -1128,9 +1126,9 @@ import 'emby-select';
} }
}); });
} }
} }
function renderMoreFromArtist(view, item, apiClient) { function renderMoreFromArtist(view, item, apiClient) {
const section = view.querySelector('.moreFromArtistSection'); const section = view.querySelector('.moreFromArtistSection');
if (section) { if (section) {
@ -1187,9 +1185,9 @@ import 'emby-select';
}); });
}); });
} }
} }
function renderSimilarItems(page, item, context) { function renderSimilarItems(page, item, context) {
const similarCollapsible = page.querySelector('#similarCollapsible'); const similarCollapsible = page.querySelector('#similarCollapsible');
if (similarCollapsible) { if (similarCollapsible) {
@ -1235,9 +1233,9 @@ import 'emby-select';
imageLoader.lazyChildren(similarContent); imageLoader.lazyChildren(similarContent);
}); });
} }
} }
function renderSeriesAirTime(page, item, isStatic) { function renderSeriesAirTime(page, item, isStatic) {
const seriesAirTime = page.querySelector('#seriesAirTime'); const seriesAirTime = page.querySelector('#seriesAirTime');
if (item.Type != 'Series') { if (item.Type != 'Series') {
seriesAirTime.classList.add('hide'); seriesAirTime.classList.add('hide');
@ -1276,9 +1274,9 @@ import 'emby-select';
} else { } else {
seriesAirTime.classList.add('hide'); seriesAirTime.classList.add('hide');
} }
} }
function renderTags(page, item) { function renderTags(page, item) {
const itemTags = page.querySelector('.itemTags'); const itemTags = page.querySelector('.itemTags');
const tagElements = []; const tagElements = [];
let tags = item.Tags || []; let tags = item.Tags || [];
@ -1298,9 +1296,9 @@ import 'emby-select';
itemTags.innerHTML = ''; itemTags.innerHTML = '';
itemTags.classList.add('hide'); itemTags.classList.add('hide');
} }
} }
function renderChildren(page, item) { function renderChildren(page, item) {
let fields = 'ItemCounts,PrimaryImageAspectRatio,BasicSyncInfo,CanDelete,MediaSourceCount'; let fields = 'ItemCounts,PrimaryImageAspectRatio,BasicSyncInfo,CanDelete,MediaSourceCount';
const query = { const query = {
ParentId: item.Id, ParentId: item.Id,
@ -1462,21 +1460,21 @@ import 'emby-select';
} else { } else {
page.querySelector('.childrenSectionHeader').classList.remove('hide'); page.querySelector('.childrenSectionHeader').classList.remove('hide');
} }
} }
function renderItemsByName(page, item) { function renderItemsByName(page, item) {
import('scripts/itembynamedetailpage').then(() => { import('scripts/itembynamedetailpage').then(() => {
window.ItemsByName.renderItems(page, item); window.ItemsByName.renderItems(page, item);
}); });
} }
function renderPlaylistItems(page, item) { function renderPlaylistItems(page, item) {
import('scripts/playlistedit').then(() => { import('scripts/playlistedit').then(() => {
PlaylistViewer.render(page, item); PlaylistViewer.render(page, item);
}); });
} }
function renderProgramsForChannel(page, result) { function renderProgramsForChannel(page, result) {
let html = ''; let html = '';
let currentItems = []; let currentItems = [];
let currentStartDate = null; let currentStartDate = null;
@ -1530,9 +1528,9 @@ import 'emby-select';
} }
page.querySelector('.programGuide').innerHTML = html; page.querySelector('.programGuide').innerHTML = html;
} }
function renderChannelGuide(page, apiClient, item) { function renderChannelGuide(page, apiClient, item) {
if (item.Type === 'TvChannel') { if (item.Type === 'TvChannel') {
page.querySelector('.programGuideSection').classList.remove('hide'); page.querySelector('.programGuideSection').classList.remove('hide');
apiClient.getLiveTvPrograms({ apiClient.getLiveTvPrograms({
@ -1548,9 +1546,9 @@ import 'emby-select';
renderProgramsForChannel(page, result); renderProgramsForChannel(page, result);
}); });
} }
} }
function renderSeriesSchedule(page, item) { function renderSeriesSchedule(page, item) {
const apiClient = connectionManager.getApiClient(item.ServerId); const apiClient = connectionManager.getApiClient(item.ServerId);
apiClient.getLiveTvPrograms({ apiClient.getLiveTvPrograms({
UserId: apiClient.getCurrentUserId(), UserId: apiClient.getCurrentUserId(),
@ -1582,9 +1580,9 @@ import 'emby-select';
}); });
loading.hide(); loading.hide();
}); });
} }
function inferContext(item) { function inferContext(item) {
if (item.Type === 'Movie' || item.Type === 'BoxSet') { if (item.Type === 'Movie' || item.Type === 'BoxSet') {
return 'movies'; return 'movies';
} }
@ -1602,9 +1600,9 @@ import 'emby-select';
} }
return null; return null;
} }
function filterItemsByCollectionItemType(items, typeInfo) { function filterItemsByCollectionItemType(items, typeInfo) {
return items.filter(function (item) { return items.filter(function (item) {
if (typeInfo.mediaType) { if (typeInfo.mediaType) {
return item.MediaType == typeInfo.mediaType; return item.MediaType == typeInfo.mediaType;
@ -1612,9 +1610,9 @@ import 'emby-select';
return item.Type == typeInfo.type; return item.Type == typeInfo.type;
}); });
} }
function canPlaySomeItemInCollection(items) { function canPlaySomeItemInCollection(items) {
let i = 0; let i = 0;
for (let length = items.length; i < length; i++) { for (let length = items.length; i < length; i++) {
@ -1624,9 +1622,9 @@ import 'emby-select';
} }
return false; return false;
} }
function renderCollectionItems(page, parentItem, types, items) { function renderCollectionItems(page, parentItem, types, items) {
page.querySelector('.collectionItems').classList.remove('hide'); page.querySelector('.collectionItems').classList.remove('hide');
page.querySelector('.collectionItems').innerHTML = ''; page.querySelector('.collectionItems').innerHTML = '';
@ -1675,12 +1673,12 @@ import 'emby-select';
// HACK: Call autoFocuser again because btnPlay may be hidden, but focused by reloadFromItem // HACK: Call autoFocuser again because btnPlay may be hidden, but focused by reloadFromItem
// FIXME: Sometimes focus does not move until all (?) sections are loaded // FIXME: Sometimes focus does not move until all (?) sections are loaded
import('autoFocuser').then(({default: autoFocuser}) => { import('autoFocuser').then(({ default: autoFocuser }) => {
autoFocuser.autoFocus(page); autoFocuser.autoFocus(page);
}); });
} }
function renderCollectionItemType(page, parentItem, type, items) { function renderCollectionItemType(page, parentItem, type, items) {
let html = ''; let html = '';
html += '<div class="verticalSection">'; html += '<div class="verticalSection">';
html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">'; html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">';
@ -1708,9 +1706,9 @@ import 'emby-select';
const collectionItems = page.querySelector('.collectionItems'); const collectionItems = page.querySelector('.collectionItems');
collectionItems.insertAdjacentHTML('beforeend', html); collectionItems.insertAdjacentHTML('beforeend', html);
imageLoader.lazyChildren(collectionItems); imageLoader.lazyChildren(collectionItems);
} }
function renderMusicVideos(page, item, user) { function renderMusicVideos(page, item, user) {
connectionManager.getApiClient(item.ServerId).getItems(user.Id, { connectionManager.getApiClient(item.ServerId).getItems(user.Id, {
SortBy: 'SortName', SortBy: 'SortName',
SortOrder: 'Ascending', SortOrder: 'Ascending',
@ -1728,9 +1726,9 @@ import 'emby-select';
page.querySelector('#musicVideosCollapsible').classList.add('hide'); page.querySelector('#musicVideosCollapsible').classList.add('hide');
} }
}); });
} }
function renderAdditionalParts(page, item, user) { function renderAdditionalParts(page, item, user) {
connectionManager.getApiClient(item.ServerId).getAdditionalVideoParts(user.Id, item.Id).then(function (result) { connectionManager.getApiClient(item.ServerId).getAdditionalVideoParts(user.Id, item.Id).then(function (result) {
if (result.Items.length) { if (result.Items.length) {
page.querySelector('#additionalPartsCollapsible').classList.remove('hide'); page.querySelector('#additionalPartsCollapsible').classList.remove('hide');
@ -1741,16 +1739,16 @@ import 'emby-select';
page.querySelector('#additionalPartsCollapsible').classList.add('hide'); page.querySelector('#additionalPartsCollapsible').classList.add('hide');
} }
}); });
} }
function renderScenes(page, item) { function renderScenes(page, item) {
let chapters = item.Chapters || []; let chapters = item.Chapters || [];
if (chapters.length && !chapters[0].ImageTag && (chapters = []), chapters.length) { if (chapters.length && !chapters[0].ImageTag && (chapters = []), chapters.length) {
page.querySelector('#scenesCollapsible').classList.remove('hide'); page.querySelector('#scenesCollapsible').classList.remove('hide');
const scenesContent = page.querySelector('#scenesContent'); const scenesContent = page.querySelector('#scenesContent');
import('chaptercardbuilder').then(({default: chaptercardbuilder}) => { import('chaptercardbuilder').then(({ default: chaptercardbuilder }) => {
chaptercardbuilder.buildChapterCards(item, chapters, { chaptercardbuilder.buildChapterCards(item, chapters, {
itemsContainer: scenesContent, itemsContainer: scenesContent,
backdropShape: 'overflowBackdrop', backdropShape: 'overflowBackdrop',
@ -1761,9 +1759,9 @@ import 'emby-select';
} else { } else {
page.querySelector('#scenesCollapsible').classList.add('hide'); page.querySelector('#scenesCollapsible').classList.add('hide');
} }
} }
function getVideosHtml(items) { function getVideosHtml(items) {
return cardBuilder.getCardsHtml({ return cardBuilder.getCardsHtml({
items: items, items: items,
shape: 'autooverflow', shape: 'autooverflow',
@ -1773,17 +1771,17 @@ import 'emby-select';
centerText: true, centerText: true,
showRuntime: true showRuntime: true
}); });
} }
function renderSpecials(page, item, user) { function renderSpecials(page, item, user) {
connectionManager.getApiClient(item.ServerId).getSpecialFeatures(user.Id, item.Id).then(function (specials) { connectionManager.getApiClient(item.ServerId).getSpecialFeatures(user.Id, item.Id).then(function (specials) {
const specialsContent = page.querySelector('#specialsContent'); const specialsContent = page.querySelector('#specialsContent');
specialsContent.innerHTML = getVideosHtml(specials); specialsContent.innerHTML = getVideosHtml(specials);
imageLoader.lazyChildren(specialsContent); imageLoader.lazyChildren(specialsContent);
}); });
} }
function renderCast(page, item) { function renderCast(page, item) {
const people = (item.People || []).filter(function (p) { const people = (item.People || []).filter(function (p) {
return p.Type === 'Actor'; return p.Type === 'Actor';
}); });
@ -1795,7 +1793,7 @@ import 'emby-select';
page.querySelector('#castCollapsible').classList.remove('hide'); page.querySelector('#castCollapsible').classList.remove('hide');
const castContent = page.querySelector('#castContent'); const castContent = page.querySelector('#castContent');
import('peoplecardbuilder').then(({default: peoplecardbuilder}) => { import('peoplecardbuilder').then(({ default: peoplecardbuilder }) => {
peoplecardbuilder.buildPeopleCards(people, { peoplecardbuilder.buildPeopleCards(people, {
itemsContainer: castContent, itemsContainer: castContent,
coverImage: true, coverImage: true,
@ -1804,31 +1802,31 @@ import 'emby-select';
imageBlurhashes: item.ImageBlurHashes imageBlurhashes: item.ImageBlurHashes
}); });
}); });
} }
function itemDetailPage() { function itemDetailPage() {
const self = this; const self = this;
self.setInitialCollapsibleState = setInitialCollapsibleState; self.setInitialCollapsibleState = setInitialCollapsibleState;
self.renderDetails = renderDetails; self.renderDetails = renderDetails;
self.renderCast = renderCast; self.renderCast = renderCast;
} }
function bindAll(view, selector, eventName, fn) { function bindAll(view, selector, eventName, fn) {
const elems = view.querySelectorAll(selector); const elems = view.querySelectorAll(selector);
for (const elem of elems) { for (const elem of elems) {
elem.addEventListener(eventName, fn); elem.addEventListener(eventName, fn);
} }
} }
function onTrackSelectionsSubmit(e) { function onTrackSelectionsSubmit(e) {
e.preventDefault(); e.preventDefault();
return false; return false;
} }
window.ItemDetailPage = new itemDetailPage(); window.ItemDetailPage = new itemDetailPage();
export default function (view, params) { export default function (view, params) {
function reload(instance, page, params) { function reload(instance, page, params) {
loading.show(); loading.show();
@ -1843,7 +1841,7 @@ import 'emby-select';
} }
function splitVersions(instance, page, apiClient, params) { function splitVersions(instance, page, apiClient, params) {
import('confirm').then(({default: confirm}) => { import('confirm').then(({ default: confirm }) => {
confirm('Are you sure you wish to split the media sources into separate items?', 'Split Media Apart').then(function () { confirm('Are you sure you wish to split the media sources into separate items?', 'Split Media Apart').then(function () {
loading.show(); loading.show();
apiClient.ajax({ apiClient.ajax({
@ -1909,7 +1907,7 @@ import 'emby-select';
} }
function onCancelSeriesTimerClick() { function onCancelSeriesTimerClick() {
import('recordingHelper').then(({default: recordingHelper}) => { import('recordingHelper').then(({ default: recordingHelper }) => {
recordingHelper.cancelSeriesTimerWithConfirmation(currentItem.Id, currentItem.ServerId).then(function () { recordingHelper.cancelSeriesTimerWithConfirmation(currentItem.Id, currentItem.ServerId).then(function () {
Dashboard.navigate('livetv.html'); Dashboard.navigate('livetv.html');
}); });
@ -1917,7 +1915,7 @@ import 'emby-select';
} }
function onCancelTimerClick() { function onCancelTimerClick() {
import('recordingHelper').then(({default: recordingHelper}) => { import('recordingHelper').then(({ default: recordingHelper }) => {
recordingHelper.cancelTimer(connectionManager.getApiClient(currentItem.ServerId), currentItem.TimerId).then(function () { recordingHelper.cancelTimer(connectionManager.getApiClient(currentItem.ServerId), currentItem.TimerId).then(function () {
reload(self, view, params); reload(self, view, params);
}); });
@ -1929,7 +1927,7 @@ import 'emby-select';
} }
function onDownloadClick() { function onDownloadClick() {
import('fileDownloader').then(({default: fileDownloader}) => { import('fileDownloader').then(({ default: fileDownloader }) => {
const downloadHref = apiClient.getItemDownloadUrl(currentItem.Id); const downloadHref = apiClient.getItemDownloadUrl(currentItem.Id);
fileDownloader.download([{ fileDownloader.download([{
url: downloadHref, url: downloadHref,
@ -1940,9 +1938,10 @@ import 'emby-select';
} }
function onMoreCommandsClick() { function onMoreCommandsClick() {
var button = this; const button = this;
var selectedItem = currentItem; let selectedItem = view.querySelector('.selectSource').value || currentItem.Id;
apiClient.getItem(apiClient.getCurrentUserId(), view.querySelector('.selectSource').value).then(function (item) {
apiClient.getItem(apiClient.getCurrentUserId(), selectedItem).then(function (item) {
selectedItem = item; selectedItem = item;
apiClient.getCurrentUser().then(function (user) { apiClient.getCurrentUser().then(function (user) {
@ -2029,6 +2028,4 @@ import 'emby-select';
self._currentPlaybackMediaSources = null; self._currentPlaybackMediaSources = null;
self.currentRecordingFields = null; self.currentRecordingFields = null;
}); });
} }
/* eslint-enable indent */