diff --git a/src/components/filterdialog/filterdialog.js b/src/components/filterdialog/filterdialog.js index 1dfd04c679..fb00181069 100644 --- a/src/components/filterdialog/filterdialog.js +++ b/src/components/filterdialog/filterdialog.js @@ -1,49 +1,59 @@ -define(['dom', 'dialogHelper', 'globalize', 'connectionManager', 'events', 'browser', 'require', 'emby-checkbox', 'emby-collapse', 'css!./style'], function (dom, dialogHelper, globalize, connectionManager, events, browser, require) { - 'use strict'; +import dom from "dom"; +import dialogHelper from "dialogHelper"; +import globalize from "globalize"; +import connectionManager from "connectionManager"; +import events from "events"; +import "emby-checkbox"; +import "emby-collapse"; +import "css!./style.css"; +/* eslint-disable indent */ function renderOptions(context, selector, cssClass, items, isCheckedFn) { - var elem = context.querySelector(selector); + const elem = context.querySelector(selector); if (items.length) { - elem.classList.remove('hide'); + elem.classList.remove("hide"); } else { - elem.classList.add('hide'); + elem.classList.add("hide"); } - var html = ''; + let html = ""; html += '
'; html += items.map(function (filter) { - var itemHtml = ''; - var checkedHtml = isCheckedFn(filter) ? ' checked' : ''; - itemHtml += '"; return itemHtml; - }).join(''); - html += '
'; - elem.querySelector('.filterOptions').innerHTML = html; + }).join(""); + html += ""; + elem.querySelector(".filterOptions").innerHTML = html; } function renderFilters(context, result, query) { - renderOptions(context, '.genreFilters', 'chkGenreFilter', result.Genres, function (i) { - var delimeter = '|'; - return (delimeter + (query.Genres || '') + delimeter).indexOf(delimeter + i + delimeter) != -1; + if (result.Tags) { + result.Tags.length = Math.min(result.Tags.length, 50); + } + renderOptions(context, ".genreFilters", "chkGenreFilter", result.Genres, function (i) { + const delimeter = "|"; + return (delimeter + (query.Genres || "") + delimeter).includes(delimeter + i + delimeter); }); - renderOptions(context, '.officialRatingFilters', 'chkOfficialRatingFilter', result.OfficialRatings, function (i) { - var delimeter = '|'; - return (delimeter + (query.OfficialRatings || '') + delimeter).indexOf(delimeter + i + delimeter) != -1; + renderOptions(context, ".officialRatingFilters", "chkOfficialRatingFilter", result.OfficialRatings, function (i) { + const delimeter = "|"; + return (delimeter + (query.OfficialRatings || "") + delimeter).includes(delimeter + i + delimeter); }); - renderOptions(context, '.tagFilters', 'chkTagFilter', result.Tags, function (i) { - var delimeter = '|'; - return (delimeter + (query.Tags || '') + delimeter).indexOf(delimeter + i + delimeter) != -1; + renderOptions(context, ".tagFilters", "chkTagFilter", result.Tags, function (i) { + const delimeter = "|"; + return (delimeter + (query.Tags || "") + delimeter).includes(delimeter + i + delimeter); }); - renderOptions(context, '.yearFilters', 'chkYearFilter', result.Years, function (i) { - var delimeter = ','; - return (delimeter + (query.Years || '') + delimeter).indexOf(delimeter + i + delimeter) != -1; + renderOptions(context, ".yearFilters", "chkYearFilter", result.Years, function (i) { + const delimeter = ","; + return (delimeter + (query.Years || "") + delimeter).includes(delimeter + i + delimeter); }); } function loadDynamicFilters(context, apiClient, userId, itemQuery) { - return apiClient.getJSON(apiClient.getUrl('Items/Filters', { + return apiClient.getJSON(apiClient.getUrl("Items/Filters", { UserId: userId, ParentId: itemQuery.ParentId, IncludeItemTypes: itemQuery.IncludeItemTypes @@ -52,346 +62,380 @@ define(['dom', 'dialogHelper', 'globalize', 'connectionManager', 'events', 'brow }); } + /** + * @param context {HTMLDivElement} Dialog + * @param options {any} Options + */ function updateFilterControls(context, options) { - var elems; - var i; - var length; - var query = options.query; + const query = options.query; - if (options.mode == 'livetvchannels') { - context.querySelector('.chkFavorite').checked = query.IsFavorite == true; - context.querySelector('.chkLikes').checked = query.IsLiked == true; - context.querySelector('.chkDislikes').checked = query.IsDisliked == true; + if (options.mode === "livetvchannels") { + context.querySelector(".chkFavorite").checked = query.IsFavorite === true; + context.querySelector(".chkLikes").checked = query.IsLiked === true; + context.querySelector(".chkDislikes").checked = query.IsDisliked === true; } else { - elems = context.querySelectorAll('.chkStandardFilter'); - for (i = 0, length = elems.length; i < length; i++) { - var chkStandardFilter = elems[i]; - var filters = ',' + (query.Filters || ''); - var filterName = chkStandardFilter.getAttribute('data-filter'); - chkStandardFilter.checked = filters.indexOf(',' + filterName) != -1; + for (const elem of context.querySelectorAll(".chkStandardFilter")) { + const filters = "," + (query.Filters || ""); + const filterName = elem.getAttribute("data-filter"); + elem.checked = filters.includes("," + filterName); } } - elems = context.querySelectorAll('.chkVideoTypeFilter'); - for (i = 0, length = elems.length; i < length; i++) { - var chkVideoTypeFilter = elems[i]; - var filters = ',' + (query.VideoTypes || ''); - var filterName = chkVideoTypeFilter.getAttribute('data-filter'); - chkVideoTypeFilter.checked = filters.indexOf(',' + filterName) != -1; + for (const elem of context.querySelectorAll(".chkVideoTypeFilter")) { + const filters = "," + (query.VideoTypes || ""); + const filterName = elem.getAttribute("data-filter"); + elem.checked = filters.includes("," + filterName); } - context.querySelector('.chk3DFilter').checked = query.Is3D == true; - context.querySelector('.chkHDFilter').checked = query.IsHD == true; - context.querySelector('.chk4KFilter').checked = query.Is4K == true; - context.querySelector('.chkSDFilter').checked = query.IsHD == true; - context.querySelector('#chkSubtitle').checked = query.HasSubtitles == true; - context.querySelector('#chkTrailer').checked = query.HasTrailer == true; - context.querySelector('#chkThemeSong').checked = query.HasThemeSong == true; - context.querySelector('#chkThemeVideo').checked = query.HasThemeVideo == true; - context.querySelector('#chkSpecialFeature').checked = query.HasSpecialFeature == true; - context.querySelector('#chkSpecialEpisode').checked = query.ParentIndexNumber == 0; - context.querySelector('#chkMissingEpisode').checked = query.IsMissing == true; - context.querySelector('#chkFutureEpisode').checked = query.IsUnaired == true; - for (i = 0, length = elems.length; i < length; i++) { - var chkStatus = elems[i]; - var filters = ',' + (query.SeriesStatus || ''); - var filterName = chkStatus.getAttribute('data-filter'); - chkStatus.checked = filters.indexOf(',' + filterName) != -1; + context.querySelector(".chk3DFilter").checked = query.Is3D === true; + context.querySelector(".chkHDFilter").checked = query.IsHD === true; + context.querySelector(".chk4KFilter").checked = query.Is4K === true; + context.querySelector(".chkSDFilter").checked = query.IsHD === true; + context.querySelector("#chkSubtitle").checked = query.HasSubtitles === true; + context.querySelector("#chkTrailer").checked = query.HasTrailer === true; + context.querySelector("#chkThemeSong").checked = query.HasThemeSong === true; + context.querySelector("#chkThemeVideo").checked = query.HasThemeVideo === true; + context.querySelector("#chkSpecialFeature").checked = query.HasSpecialFeature === true; + context.querySelector("#chkSpecialEpisode").checked = query.ParentIndexNumber === 0; + context.querySelector("#chkMissingEpisode").checked = query.IsMissing === true; + context.querySelector("#chkFutureEpisode").checked = query.IsUnaired === true; + for (const elem of context.querySelectorAll(".chkStatus")) { + const filters = "," + (query.SeriesStatus || ""); + const filterName = elem.getAttribute("data-filter"); + elem.checked = filters.includes("," + filterName); } } + /** + * @param instance {FilterDialog} An instance of FilterDialog + */ function triggerChange(instance) { - events.trigger(instance, 'filterchange'); + events.trigger(instance, "filterchange"); } function setVisibility(context, options) { - if (options.mode == 'livetvchannels' || options.mode == 'albums' || options.mode == 'artists' || options.mode == 'albumartists' || options.mode == 'songs') { - hideByClass(context, 'videoStandard'); + if (options.mode === "livetvchannels" || options.mode === "albums" || options.mode === "artists" || options.mode === "albumartists" || options.mode === "songs") { + hideByClass(context, "videoStandard"); } if (enableDynamicFilters(options.mode)) { - context.querySelector('.genreFilters').classList.remove('hide'); - context.querySelector('.officialRatingFilters').classList.remove('hide'); - context.querySelector('.tagFilters').classList.remove('hide'); - context.querySelector('.yearFilters').classList.remove('hide'); + context.querySelector(".genreFilters").classList.remove("hide"); + context.querySelector(".officialRatingFilters").classList.remove("hide"); + context.querySelector(".tagFilters").classList.remove("hide"); + context.querySelector(".yearFilters").classList.remove("hide"); } - if (options.mode == 'movies' || options.mode == 'episodes') { - context.querySelector('.videoTypeFilters').classList.remove('hide'); + if (options.mode === "movies" || options.mode === "episodes") { + context.querySelector(".videoTypeFilters").classList.remove("hide"); } - if (options.mode == 'movies' || options.mode == 'series' || options.mode == 'episodes') { - context.querySelector('.features').classList.remove('hide'); + if (options.mode === "movies" || options.mode === "series" || options.mode === "episodes") { + context.querySelector(".features").classList.remove("hide"); } - if (options.mode == 'series') { - context.querySelector('.seriesStatus').classList.remove('hide'); + if (options.mode === "series") { + context.querySelector(".seriesStatus").classList.remove("hide"); } - if (options.mode == 'episodes') { - showByClass(context, 'episodeFilter'); + if (options.mode === "episodes") { + showByClass(context, "episodeFilter"); } } function showByClass(context, className) { - var elems = context.querySelectorAll('.' + className); + const elems = context.querySelectorAll("." + className); - for (var i = 0, length = elems.length; i < length; i++) { - elems[i].classList.remove('hide'); + let i = 0; + const length = elems.length; + for (; i < length; i++) { + elems[i].classList.remove("hide"); } } function hideByClass(context, className) { - var elems = context.querySelectorAll('.' + className); + const elems = context.querySelectorAll("." + className); - for (var i = 0, length = elems.length; i < length; i++) { - elems[i].classList.add('hide'); + let i = 0; + const length = elems.length; + for (; i < length; i++) { + elems[i].classList.add("hide"); } } function enableDynamicFilters(mode) { - return mode == 'movies' || mode == 'series' || mode == 'albums' || mode == 'albumartists' || mode == 'artists' || mode == 'songs' || mode == 'episodes'; + return mode === "movies" || mode === "series" || mode === "albums" || mode === "albumartists" || mode === "artists" || mode === "songs" || mode === "episodes"; } - return function (options) { - function onFavoriteChange() { - var query = options.query; - query.StartIndex = 0; - query.IsFavorite = !!this.checked || null; - triggerChange(self); + class FilterDialog { + constructor(options) { + /** + * @private + */ + this.options = options; } - function onStandardFilterChange() { - var query = options.query; - var filterName = this.getAttribute('data-filter'); - var filters = query.Filters || ''; - filters = (',' + filters).replace(',' + filterName, '').substring(1); + /** + * @private + */ + onFavoriteChange(elem) { + const query = this.options.query; + query.StartIndex = 0; + query.IsFavorite = !!elem.checked || null; + triggerChange(this); + } - if (this.checked) { - filters = filters ? filters + ',' + filterName : filterName; + /** + * @private + */ + onStandardFilterChange(elem) { + const query = this.options.query; + const filterName = elem.getAttribute("data-filter"); + let filters = query.Filters || ""; + filters = ("," + filters).replace("," + filterName, "").substring(1); + + if (elem.checked) { + filters = filters ? filters + "," + filterName : filterName; } query.StartIndex = 0; query.Filters = filters; - triggerChange(self); + triggerChange(this); } - function onVideoTypeFilterChange() { - var query = options.query; - var filterName = this.getAttribute('data-filter'); - var filters = query.VideoTypes || ''; - filters = (',' + filters).replace(',' + filterName, '').substring(1); + /** + * @private + */ + onVideoTypeFilterChange(elem) { + const query = this.options.query; + const filterName = elem.getAttribute("data-filter"); + let filters = query.VideoTypes || ""; + filters = ("," + filters).replace("," + filterName, "").substring(1); - if (this.checked) { - filters = filters ? filters + ',' + filterName : filterName; + if (elem.checked) { + filters = filters ? filters + "," + filterName : filterName; } query.StartIndex = 0; query.VideoTypes = filters; - triggerChange(self); + triggerChange(this); } - function onStatusChange() { - var query = options.query; - var filterName = this.getAttribute('data-filter'); - var filters = query.SeriesStatus || ''; - filters = (',' + filters).replace(',' + filterName, '').substring(1); + /** + * @private + */ + onStatusChange(elem) { + const query = this.options.query; + const filterName = elem.getAttribute("data-filter"); + let filters = query.SeriesStatus || ""; + filters = ("," + filters).replace("," + filterName, "").substring(1); - if (this.checked) { - filters = filters ? filters + ',' + filterName : filterName; + if (elem.checked) { + filters = filters ? filters + "," + filterName : filterName; } query.SeriesStatus = filters; query.StartIndex = 0; - triggerChange(self); + triggerChange(this); } - function bindEvents(context) { - var elems; - var i; - var length; - var query = options.query; + /** + * @param context {HTMLDivElement} The dialog + */ + bindEvents(context) { + const query = this.options.query; - if (options.mode == 'livetvchannels') { - elems = context.querySelectorAll('.chkFavorite'); - for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('change', onFavoriteChange); + if (this.options.mode === "livetvchannels") { + for (const elem of context.querySelectorAll(".chkFavorite")) { + elem.addEventListener("change", () => this.onFavoriteChange(elem)); } - context.querySelector('.chkLikes').addEventListener('change', function () { + + const chkLikes = context.querySelector(".chkLikes"); + chkLikes.addEventListener("change", () => { query.StartIndex = 0; - query.IsLiked = this.checked ? true : null; - triggerChange(self); + query.IsLiked = chkLikes.checked ? true : null; + triggerChange(this); }); - context.querySelector('.chkDislikes').addEventListener('change', function () { + const chkDislikes = context.querySelector(".chkDislikes"); + chkDislikes.addEventListener("change", () => { query.StartIndex = 0; - query.IsDisliked = this.checked ? true : null; - triggerChange(self); + query.IsDisliked = chkDislikes.checked ? true : null; + triggerChange(this); }); } else { - elems = context.querySelectorAll('.chkStandardFilter'); - for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('change', onStandardFilterChange); + for (const elem of context.querySelectorAll(".chkStandardFilter")) { + elem.addEventListener("change", () => this.onStandardFilterChange(elem)); } } - elems = context.querySelectorAll('.chkVideoTypeFilter'); - for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('change', onVideoTypeFilterChange); + + for (const elem of context.querySelectorAll(".chkVideoTypeFilter")) { + elem.addEventListener("change", () => this.onVideoTypeFilterChange(elem)); } - context.querySelector('.chk3DFilter').addEventListener('change', function () { + const chk3DFilter = context.querySelector(".chk3DFilter"); + chk3DFilter.addEventListener("change", () => { query.StartIndex = 0; - query.Is3D = this.checked ? true : null; - triggerChange(self); + query.Is3D = chk3DFilter.checked ? true : null; + triggerChange(this); }); - context.querySelector('.chk4KFilter').addEventListener('change', function () { + const chk4KFilter = context.querySelector(".chk4KFilter"); + chk4KFilter.addEventListener("change", () => { query.StartIndex = 0; - query.Is4K = this.checked ? true : null; - triggerChange(self); + query.Is4K = chk4KFilter.checked ? true : null; + triggerChange(this); }); - context.querySelector('.chkHDFilter').addEventListener('change', function () { + const chkHDFilter = context.querySelector(".chkHDFilter"); + chkHDFilter.addEventListener("change", () => { query.StartIndex = 0; - query.IsHD = this.checked ? true : null; - triggerChange(self); + query.IsHD = chkHDFilter.checked ? true : null; + triggerChange(this); }); - context.querySelector('.chkSDFilter').addEventListener('change', function () { + const chkSDFilter = context.querySelector(".chkSDFilter"); + chkSDFilter.addEventListener("change", () => { query.StartIndex = 0; - query.IsHD = this.checked ? false : null; - triggerChange(self); + query.IsHD = chkSDFilter.checked ? false : null; + triggerChange(this); }); - elems = context.querySelectorAll('.chkStatus'); - for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('change', onStatusChange); + for (const elem of context.querySelectorAll(".chkStatus")) { + elem.addEventListener("change", () => this.onStatusChange(elem)); } - context.querySelector('#chkTrailer').addEventListener('change', function () { + const chkTrailer = context.querySelector("#chkTrailer"); + chkTrailer.addEventListener("change", () => { query.StartIndex = 0; - query.HasTrailer = this.checked ? true : null; - triggerChange(self); + query.HasTrailer = chkTrailer.checked ? true : null; + triggerChange(this); }); - context.querySelector('#chkThemeSong').addEventListener('change', function () { + const chkThemeSong = context.querySelector("#chkThemeSong"); + chkThemeSong.addEventListener("change", () => { query.StartIndex = 0; - query.HasThemeSong = this.checked ? true : null; - triggerChange(self); + query.HasThemeSong = chkThemeSong.checked ? true : null; + triggerChange(this); }); - context.querySelector('#chkSpecialFeature').addEventListener('change', function () { + const chkSpecialFeature = context.querySelector("#chkSpecialFeature"); + chkSpecialFeature.addEventListener("change", () => { query.StartIndex = 0; - query.HasSpecialFeature = this.checked ? true : null; - triggerChange(self); + query.HasSpecialFeature = chkSpecialFeature.checked ? true : null; + triggerChange(this); }); - context.querySelector('#chkThemeVideo').addEventListener('change', function () { + const chkThemeVideo = context.querySelector("#chkThemeVideo"); + chkThemeVideo.addEventListener("change", () => { query.StartIndex = 0; - query.HasThemeVideo = this.checked ? true : null; - triggerChange(self); + query.HasThemeVideo = chkThemeVideo.checked ? true : null; + triggerChange(this); }); - context.querySelector('#chkMissingEpisode').addEventListener('change', function () { + const chkMissingEpisode = context.querySelector("#chkMissingEpisode"); + chkMissingEpisode.addEventListener("change", () => { query.StartIndex = 0; - query.IsMissing = this.checked ? true : false; - triggerChange(self); + query.IsMissing = !!chkMissingEpisode.checked; + triggerChange(this); }); - context.querySelector('#chkSpecialEpisode').addEventListener('change', function () { + const chkSpecialEpisode = context.querySelector("#chkSpecialEpisode"); + chkSpecialEpisode.addEventListener("change", () => { query.StartIndex = 0; - query.ParentIndexNumber = this.checked ? 0 : null; - triggerChange(self); + query.ParentIndexNumber = chkSpecialEpisode.checked ? 0 : null; + triggerChange(this); }); - context.querySelector('#chkFutureEpisode').addEventListener('change', function () { + const chkFutureEpisode = context.querySelector("#chkFutureEpisode"); + chkFutureEpisode.addEventListener("change", () => { query.StartIndex = 0; - if (this.checked) { + if (chkFutureEpisode.checked) { query.IsUnaired = true; query.IsVirtualUnaired = null; } else { query.IsUnaired = null; query.IsVirtualUnaired = false; } - triggerChange(self); + triggerChange(this); }); - context.querySelector('#chkSubtitle').addEventListener('change', function () { + const chkSubtitle = context.querySelector("#chkSubtitle"); + chkSubtitle.addEventListener("change", () => { query.StartIndex = 0; - query.HasSubtitles = this.checked ? true : null; - triggerChange(self); + query.HasSubtitles = chkSubtitle.checked ? true : null; + triggerChange(this); }); - context.addEventListener('change', function (e) { - var chkGenreFilter = dom.parentWithClass(e.target, 'chkGenreFilter'); + context.addEventListener("change", () => { + const chkGenreFilter = dom.parentWithClass(context, "chkGenreFilter"); if (chkGenreFilter) { - var filterName = chkGenreFilter.getAttribute('data-filter'); - var filters = query.Genres || ''; - var delimiter = '|'; - filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1); + const filterName = chkGenreFilter.getAttribute("data-filter"); + let filters = query.Genres || ""; + const delimiter = "|"; + filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1); if (chkGenreFilter.checked) { filters = filters ? (filters + delimiter + filterName) : filterName; } query.StartIndex = 0; query.Genres = filters; - triggerChange(self); + triggerChange(this); return; } - var chkTagFilter = dom.parentWithClass(e.target, 'chkTagFilter'); + const chkTagFilter = dom.parentWithClass(context, "chkTagFilter"); if (chkTagFilter) { - var filterName = chkTagFilter.getAttribute('data-filter'); - var filters = query.Tags || ''; - var delimiter = '|'; - filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1); + const filterName = chkTagFilter.getAttribute("data-filter"); + let filters = query.Tags || ""; + const delimiter = "|"; + filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1); if (chkTagFilter.checked) { filters = filters ? (filters + delimiter + filterName) : filterName; } query.StartIndex = 0; query.Tags = filters; - triggerChange(self); + triggerChange(this); return; } - var chkYearFilter = dom.parentWithClass(e.target, 'chkYearFilter'); + const chkYearFilter = dom.parentWithClass(context, "chkYearFilter"); if (chkYearFilter) { - var filterName = chkYearFilter.getAttribute('data-filter'); - var filters = query.Years || ''; - var delimiter = ','; - filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1); + const filterName = chkYearFilter.getAttribute("data-filter"); + let filters = query.Years || ""; + const delimiter = ","; + filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1); if (chkYearFilter.checked) { filters = filters ? (filters + delimiter + filterName) : filterName; } query.StartIndex = 0; query.Years = filters; - triggerChange(self); + triggerChange(this); return; } - var chkOfficialRatingFilter = dom.parentWithClass(e.target, 'chkOfficialRatingFilter'); + const chkOfficialRatingFilter = dom.parentWithClass(context, "chkOfficialRatingFilter"); if (chkOfficialRatingFilter) { - var filterName = chkOfficialRatingFilter.getAttribute('data-filter'); - var filters = query.OfficialRatings || ''; - var delimiter = '|'; - filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1); + const filterName = chkOfficialRatingFilter.getAttribute("data-filter"); + let filters = query.OfficialRatings || ""; + const delimiter = "|"; + filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1); if (chkOfficialRatingFilter.checked) { filters = filters ? (filters + delimiter + filterName) : filterName; } query.StartIndex = 0; query.OfficialRatings = filters; - triggerChange(self); - return; + triggerChange(this); } }); } - var self = this; - - self.show = function () { - return new Promise(function (resolve, reject) { - require(['text!./filterdialog.template.html'], function (template) { - var dlg = dialogHelper.createDialog({ + show() { + return import("text!./filterdialog.template.html").then((template) => { + return new Promise((resolve) => { + const dlg = dialogHelper.createDialog({ removeOnClose: true, modal: false }); - dlg.classList.add('ui-body-a'); - dlg.classList.add('background-theme-a'); - dlg.classList.add('formDialog'); - dlg.classList.add('filterDialog'); + dlg.classList.add("ui-body-a"); + dlg.classList.add("background-theme-a"); + dlg.classList.add("formDialog"); + dlg.classList.add("filterDialog"); dlg.innerHTML = globalize.translateDocument(template); - setVisibility(dlg, options); + setVisibility(dlg, this.options); dialogHelper.open(dlg); - dlg.addEventListener('close', resolve); - updateFilterControls(dlg, options); - bindEvents(dlg); - if (enableDynamicFilters(options.mode)) { - dlg.classList.add('dynamicFilterDialog'); - var apiClient = connectionManager.getApiClient(options.serverId); - loadDynamicFilters(dlg, apiClient, apiClient.getCurrentUserId(), options.query); + dlg.addEventListener("close", resolve); + updateFilterControls(dlg, this.options); + this.bindEvents(dlg); + if (enableDynamicFilters(this.options.mode)) { + dlg.classList.add("dynamicFilterDialog"); + const apiClient = connectionManager.getApiClient(this.options.serverId); + loadDynamicFilters(dlg, apiClient, apiClient.getCurrentUserId(), this.options.query); } }); }); - }; - }; -}); + } + } + +/* eslint-enable indent */ + +export default FilterDialog; diff --git a/src/controllers/livetv/livetvchannels.js b/src/controllers/livetv/livetvchannels.js index 7f22d3dd13..2701ad1719 100644 --- a/src/controllers/livetv/livetvchannels.js +++ b/src/controllers/livetv/livetvchannels.js @@ -1,5 +1,5 @@ -define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'userSettings', 'emby-itemscontainer'], function (cardBuilder, imageLoader, libraryBrowser, loading, events, userSettings) { - 'use strict'; +define(["cardBuilder", "imageLoader", "libraryBrowser", "loading", "events", "userSettings", "emby-itemscontainer"], function (cardBuilder, imageLoader, libraryBrowser, loading, events, userSettings) { + "use strict"; return function (view, params, tabContent) { function getPageData() { @@ -7,7 +7,7 @@ define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'us pageData = { query: { StartIndex: 0, - Fields: 'PrimaryImageAspectRatio' + Fields: "PrimaryImageAspectRatio" } }; } @@ -26,7 +26,7 @@ define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'us function getChannelsHtml(channels) { return cardBuilder.getCardsHtml({ items: channels, - shape: 'square', + shape: "square", showTitle: true, lazy: true, cardLayout: true, @@ -60,7 +60,7 @@ define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'us } var query = getQuery(); - context.querySelector('.paging').innerHTML = libraryBrowser.getQueryPagingHtml({ + context.querySelector(".paging").innerHTML = libraryBrowser.getQueryPagingHtml({ startIndex: query.StartIndex, limit: query.Limit, totalRecordCount: result.TotalRecordCount, @@ -69,30 +69,30 @@ define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'us filterButton: false }); var html = getChannelsHtml(result.Items); - var elem = context.querySelector('#items'); + var elem = context.querySelector("#items"); elem.innerHTML = html; imageLoader.lazyChildren(elem); var i; var length; var elems; - for (elems = context.querySelectorAll('.btnNextPage'), i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onNextPageClick); + for (elems = context.querySelectorAll(".btnNextPage"), i = 0, length = elems.length; i < length; i++) { + elems[i].addEventListener("click", onNextPageClick); } - for (elems = context.querySelectorAll('.btnPreviousPage'), i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onPreviousPageClick); + for (elems = context.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++) { + elems[i].addEventListener("click", onPreviousPageClick); } } function showFilterMenu(context) { - require(['components/filterdialog/filterdialog'], function (filterDialogFactory) { + require(["components/filterdialog/filterdialog"], function ({default: filterDialogFactory}) { var filterDialog = new filterDialogFactory({ query: getQuery(), - mode: 'livetvchannels', + mode: "livetvchannels", serverId: ApiClient.serverId() }); - events.on(filterDialog, 'filterchange', function () { + events.on(filterDialog, "filterchange", function () { reloadItems(context); }); filterDialog.show(); @@ -110,7 +110,7 @@ define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'us loading.hide(); isLoading = false; - require(['autoFocuser'], function (autoFocuser) { + require(["autoFocuser"], function (autoFocuser) { autoFocuser.autoFocus(view); }); }); @@ -119,7 +119,7 @@ define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'us var pageData; var self = this; var isLoading = false; - tabContent.querySelector('.btnFilter').addEventListener('click', function () { + tabContent.querySelector(".btnFilter").addEventListener("click", function () { showFilterMenu(tabContent); }); diff --git a/src/controllers/movies/movietrailers.js b/src/controllers/movies/movietrailers.js index 25d41d4fba..08842a6f15 100644 --- a/src/controllers/movies/movietrailers.js +++ b/src/controllers/movies/movietrailers.js @@ -1,5 +1,5 @@ -define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (layoutManager, loading, events, libraryBrowser, imageLoader, alphaPicker, listView, cardBuilder, userSettings, globalize) { - 'use strict'; +define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "alphaPicker", "listView", "cardBuilder", "userSettings", "emby-itemscontainer"], function (layoutManager, loading, events, libraryBrowser, imageLoader, alphaPicker, listView, cardBuilder, userSettings) { + "use strict"; return function (view, params, tabContent) { function getPageData(context) { @@ -9,16 +9,16 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' if (!pageData) { pageData = data[key] = { query: { - SortBy: 'SortName', - SortOrder: 'Ascending', - IncludeItemTypes: 'Trailer', + SortBy: "SortName", + SortOrder: "Ascending", + IncludeItemTypes: "Trailer", Recursive: true, - Fields: 'PrimaryImageAspectRatio,SortName,BasicSyncInfo', + Fields: "PrimaryImageAspectRatio,SortName,BasicSyncInfo", ImageTypeLimit: 1, - EnableImageTypes: 'Primary,Backdrop,Banner,Thumb', + EnableImageTypes: "Primary,Backdrop,Banner,Thumb", StartIndex: 0 }, - view: libraryBrowser.getSavedView(key) || 'Poster' + view: libraryBrowser.getSavedView(key) || "Poster" }; if (userSettings.libraryPageSize() > 0) { @@ -37,7 +37,7 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' function getSavedQueryKey(context) { if (!context.savedQueryKey) { - context.savedQueryKey = libraryBrowser.getSavedQueryKey('trailers'); + context.savedQueryKey = libraryBrowser.getSavedQueryKey("trailers"); } return context.savedQueryKey; @@ -85,43 +85,43 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' var html; var viewStyle = self.getCurrentViewStyle(); - if (viewStyle == 'Thumb') { + if (viewStyle == "Thumb") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'backdrop', + shape: "backdrop", preferThumb: true, - context: 'movies', + context: "movies", overlayPlayButton: true }); - } else if (viewStyle == 'ThumbCard') { + } else if (viewStyle == "ThumbCard") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'backdrop', + shape: "backdrop", preferThumb: true, - context: 'movies', + context: "movies", cardLayout: true, showTitle: true, showYear: true, centerText: true }); - } else if (viewStyle == 'Banner') { + } else if (viewStyle == "Banner") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'banner', + shape: "banner", preferBanner: true, - context: 'movies' + context: "movies" }); - } else if (viewStyle == 'List') { + } else if (viewStyle == "List") { html = listView.getListViewHtml({ items: result.Items, - context: 'movies', + context: "movies", sortBy: query.SortBy }); - } else if (viewStyle == 'PosterCard') { + } else if (viewStyle == "PosterCard") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'portrait', - context: 'movies', + shape: "portrait", + context: "movies", showTitle: true, showYear: true, cardLayout: true, @@ -130,8 +130,8 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' } else { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'portrait', - context: 'movies', + shape: "portrait", + context: "movies", centerText: true, overlayPlayButton: true, showTitle: true, @@ -141,27 +141,27 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' var i; var length; - var elems = tabContent.querySelectorAll('.paging'); + var elems = tabContent.querySelectorAll(".paging"); for (i = 0, length = elems.length; i < length; i++) { elems[i].innerHTML = pagingHtml; } - elems = tabContent.querySelectorAll('.btnNextPage'); + elems = tabContent.querySelectorAll(".btnNextPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onNextPageClick); + elems[i].addEventListener("click", onNextPageClick); } - elems = tabContent.querySelectorAll('.btnPreviousPage'); + elems = tabContent.querySelectorAll(".btnPreviousPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onPreviousPageClick); + elems[i].addEventListener("click", onPreviousPageClick); } if (!result.Items.length) { - html = '

' + globalize.translate('MessageNoTrailersFound') + '

'; + html = '

' + Globalize.translate("MessageNoTrailersFound") + "

"; } - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var itemsContainer = tabContent.querySelector(".itemsContainer"); itemsContainer.innerHTML = html; imageLoader.lazyChildren(itemsContainer); libraryBrowser.saveQueryValues(getSavedQueryKey(tabContent), query); @@ -180,13 +180,13 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' var isLoading = false; self.showFilterMenu = function () { - require(['components/filterdialog/filterdialog'], function (filterDialogFactory) { + require(["components/filterdialog/filterdialog"], function ({default: filterDialogFactory}) { var filterDialog = new filterDialogFactory({ query: getQuery(tabContent), - mode: 'movies', + mode: "movies", serverId: ApiClient.serverId() }); - events.on(filterDialog, 'filterchange', function () { + events.on(filterDialog, "filterchange", function () { getQuery(tabContent).StartIndex = 0; reloadItems(); }); @@ -199,9 +199,9 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' }; function initPage(tabContent) { - var alphaPickerElement = tabContent.querySelector('.alphaPicker'); - var itemsContainer = tabContent.querySelector('.itemsContainer'); - alphaPickerElement.addEventListener('alphavaluechanged', function (e) { + var alphaPickerElement = tabContent.querySelector(".alphaPicker"); + var itemsContainer = tabContent.querySelector(".itemsContainer"); + alphaPickerElement.addEventListener("alphavaluechanged", function (e) { var newValue = e.detail.value; var query = getQuery(tabContent); query.NameStartsWithOrGreater = newValue; @@ -210,39 +210,39 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' }); self.alphaPicker = new alphaPicker({ element: alphaPickerElement, - valueChangeEvent: 'click' + valueChangeEvent: "click" }); - tabContent.querySelector('.alphaPicker').classList.add('alphabetPicker-right'); - alphaPickerElement.classList.add('alphaPicker-fixed-right'); - itemsContainer.classList.add('padded-right-withalphapicker'); + tabContent.querySelector(".alphaPicker").classList.add("alphabetPicker-right"); + alphaPickerElement.classList.add("alphaPicker-fixed-right"); + itemsContainer.classList.add("padded-right-withalphapicker"); - tabContent.querySelector('.btnFilter').addEventListener('click', function () { + tabContent.querySelector(".btnFilter").addEventListener("click", function () { self.showFilterMenu(); }); - tabContent.querySelector('.btnSort').addEventListener('click', function (e) { + tabContent.querySelector(".btnSort").addEventListener("click", function (e) { libraryBrowser.showSortMenu({ items: [{ - name: globalize.translate('OptionNameSort'), - id: 'SortName' + name: Globalize.translate("OptionNameSort"), + id: "SortName" }, { - name: globalize.translate('OptionImdbRating'), - id: 'CommunityRating,SortName' + name: Globalize.translate("OptionImdbRating"), + id: "CommunityRating,SortName" }, { - name: globalize.translate('OptionDateAdded'), - id: 'DateCreated,SortName' + name: Globalize.translate("OptionDateAdded"), + id: "DateCreated,SortName" }, { - name: globalize.translate('OptionDatePlayed'), - id: 'DatePlayed,SortName' + name: Globalize.translate("OptionDatePlayed"), + id: "DatePlayed,SortName" }, { - name: globalize.translate('OptionParentalRating'), - id: 'OfficialRating,SortName' + name: Globalize.translate("OptionParentalRating"), + id: "OfficialRating,SortName" }, { - name: globalize.translate('OptionPlayCount'), - id: 'PlayCount,SortName' + name: Globalize.translate("OptionPlayCount"), + id: "PlayCount,SortName" }, { - name: globalize.translate('OptionReleaseDate'), - id: 'PremiereDate,SortName' + name: Globalize.translate("OptionReleaseDate"), + id: "PremiereDate,SortName" }], callback: function () { getQuery(tabContent).StartIndex = 0; diff --git a/src/controllers/music/musicalbums.js b/src/controllers/music/musicalbums.js index ecb51f9dc3..2aaca4f2db 100644 --- a/src/controllers/music/musicalbums.js +++ b/src/controllers/music/musicalbums.js @@ -1,5 +1,5 @@ -define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (layoutManager, playbackManager, loading, events, libraryBrowser, imageLoader, alphaPicker, listView, cardBuilder, userSettings, globalize) { - 'use strict'; +define(["layoutManager", "playbackManager", "loading", "events", "libraryBrowser", "imageLoader", "alphaPicker", "listView", "cardBuilder", "userSettings", "emby-itemscontainer"], function (layoutManager, playbackManager, loading, events, libraryBrowser, imageLoader, alphaPicker, listView, cardBuilder, userSettings) { + "use strict"; return function (view, params, tabContent) { function playAll() { @@ -23,16 +23,16 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser if (!pageData) { pageData = { query: { - SortBy: 'SortName', - SortOrder: 'Ascending', - IncludeItemTypes: 'MusicAlbum', + SortBy: "SortName", + SortOrder: "Ascending", + IncludeItemTypes: "MusicAlbum", Recursive: true, - Fields: 'PrimaryImageAspectRatio,SortName,BasicSyncInfo', + Fields: "PrimaryImageAspectRatio,SortName,BasicSyncInfo", ImageTypeLimit: 1, - EnableImageTypes: 'Primary,Backdrop,Banner,Thumb', + EnableImageTypes: "Primary,Backdrop,Banner,Thumb", StartIndex: 0 }, - view: libraryBrowser.getSavedView(key) || 'Poster' + view: libraryBrowser.getSavedView(key) || "Poster" }; if (userSettings.libraryPageSize() > 0) { @@ -52,7 +52,7 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser function getSavedQueryKey() { if (!savedQueryKey) { - savedQueryKey = libraryBrowser.getSavedQueryKey('musicalbums'); + savedQueryKey = libraryBrowser.getSavedQueryKey("musicalbums"); } return savedQueryKey; @@ -60,17 +60,17 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser function onViewStyleChange() { var viewStyle = self.getCurrentViewStyle(); - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var itemsContainer = tabContent.querySelector(".itemsContainer"); - if ('List' == viewStyle) { - itemsContainer.classList.add('vertical-list'); - itemsContainer.classList.remove('vertical-wrap'); + if ("List" == viewStyle) { + itemsContainer.classList.add("vertical-list"); + itemsContainer.classList.remove("vertical-wrap"); } else { - itemsContainer.classList.remove('vertical-list'); - itemsContainer.classList.add('vertical-wrap'); + itemsContainer.classList.remove("vertical-list"); + itemsContainer.classList.add("vertical-wrap"); } - itemsContainer.innerHTML = ''; + itemsContainer.innerHTML = ""; } function reloadItems(page) { @@ -114,18 +114,18 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser filterButton: false }); var viewStyle = self.getCurrentViewStyle(); - if (viewStyle == 'List') { + if (viewStyle == "List") { html = listView.getListViewHtml({ items: result.Items, - context: 'music', + context: "music", sortBy: query.SortBy, addToListButton: true }); - } else if (viewStyle == 'PosterCard') { + } else if (viewStyle == "PosterCard") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'square', - context: 'music', + shape: "square", + context: "music", showTitle: true, coverImage: true, showParentTitle: true, @@ -135,8 +135,8 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser } else { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'square', - context: 'music', + shape: "square", + context: "music", showTitle: true, showParentTitle: true, lazy: true, @@ -146,30 +146,30 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser } var i; var length; - var elems = tabContent.querySelectorAll('.paging'); + var elems = tabContent.querySelectorAll(".paging"); for (i = 0, length = elems.length; i < length; i++) { elems[i].innerHTML = pagingHtml; } - elems = tabContent.querySelectorAll('.btnNextPage'); + elems = tabContent.querySelectorAll(".btnNextPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onNextPageClick); + elems[i].addEventListener("click", onNextPageClick); } - elems = tabContent.querySelectorAll('.btnPreviousPage'); + elems = tabContent.querySelectorAll(".btnPreviousPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onPreviousPageClick); + elems[i].addEventListener("click", onPreviousPageClick); } - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var itemsContainer = tabContent.querySelector(".itemsContainer"); itemsContainer.innerHTML = html; imageLoader.lazyChildren(itemsContainer); libraryBrowser.saveQueryValues(getSavedQueryKey(), query); loading.hide(); isLoading = false; - require(['autoFocuser'], function (autoFocuser) { + require(["autoFocuser"], function (autoFocuser) { autoFocuser.autoFocus(tabContent); }); }); @@ -186,13 +186,13 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser var isLoading = false; self.showFilterMenu = function () { - require(['components/filterdialog/filterdialog'], function (filterDialogFactory) { + require(["components/filterdialog/filterdialog"], function ({default: filterDialogFactory}) { var filterDialog = new filterDialogFactory({ query: getQuery(), - mode: 'albums', + mode: "albums", serverId: ApiClient.serverId() }); - events.on(filterDialog, 'filterchange', function () { + events.on(filterDialog, "filterchange", function () { getQuery().StartIndex = 0; reloadItems(tabContent); }); @@ -205,10 +205,10 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser }; function initPage(tabContent) { - var alphaPickerElement = tabContent.querySelector('.alphaPicker'); - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var alphaPickerElement = tabContent.querySelector(".alphaPicker"); + var itemsContainer = tabContent.querySelector(".itemsContainer"); - alphaPickerElement.addEventListener('alphavaluechanged', function (e) { + alphaPickerElement.addEventListener("alphavaluechanged", function (e) { var newValue = e.detail.value; var query = getQuery(); query.NameStartsWithOrGreater = newValue; @@ -217,39 +217,39 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser }); self.alphaPicker = new alphaPicker({ element: alphaPickerElement, - valueChangeEvent: 'click' + valueChangeEvent: "click" }); - tabContent.querySelector('.alphaPicker').classList.add('alphabetPicker-right'); - alphaPickerElement.classList.add('alphaPicker-fixed-right'); - itemsContainer.classList.add('padded-right-withalphapicker'); + tabContent.querySelector(".alphaPicker").classList.add("alphabetPicker-right"); + alphaPickerElement.classList.add("alphaPicker-fixed-right"); + itemsContainer.classList.add("padded-right-withalphapicker"); - tabContent.querySelector('.btnFilter').addEventListener('click', function () { + tabContent.querySelector(".btnFilter").addEventListener("click", function () { self.showFilterMenu(); }); - tabContent.querySelector('.btnSort').addEventListener('click', function (e) { + tabContent.querySelector(".btnSort").addEventListener("click", function (e) { libraryBrowser.showSortMenu({ items: [{ - name: globalize.translate('OptionNameSort'), - id: 'SortName' + name: Globalize.translate("OptionNameSort"), + id: "SortName" }, { - name: globalize.translate('OptionAlbumArtist'), - id: 'AlbumArtist,SortName' + name: Globalize.translate("OptionAlbumArtist"), + id: "AlbumArtist,SortName" }, { - name: globalize.translate('OptionCommunityRating'), - id: 'CommunityRating,SortName' + name: Globalize.translate("OptionCommunityRating"), + id: "CommunityRating,SortName" }, { - name: globalize.translate('OptionCriticRating'), - id: 'CriticRating,SortName' + name: Globalize.translate("OptionCriticRating"), + id: "CriticRating,SortName" }, { - name: globalize.translate('OptionDateAdded'), - id: 'DateCreated,SortName' + name: Globalize.translate("OptionDateAdded"), + id: "DateCreated,SortName" }, { - name: globalize.translate('OptionReleaseDate'), - id: 'ProductionYear,PremiereDate,SortName' + name: Globalize.translate("OptionReleaseDate"), + id: "ProductionYear,PremiereDate,SortName" }, { - name: globalize.translate('OptionRandom'), - id: 'Random,SortName' + name: Globalize.translate("OptionRandom"), + id: "Random,SortName" }], callback: function () { getQuery().StartIndex = 0; @@ -259,11 +259,11 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser button: e.target }); }); - var btnSelectView = tabContent.querySelector('.btnSelectView'); - btnSelectView.addEventListener('click', function (e) { - libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(',')); + var btnSelectView = tabContent.querySelector(".btnSelectView"); + btnSelectView.addEventListener("click", function (e) { + libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), "List,Poster,PosterCard".split(",")); }); - btnSelectView.addEventListener('layoutchange', function (e) { + btnSelectView.addEventListener("layoutchange", function (e) { var viewStyle = e.detail.viewStyle; getPageData().view = viewStyle; libraryBrowser.saveViewSetting(getSavedQueryKey(), viewStyle); @@ -271,8 +271,8 @@ define(['layoutManager', 'playbackManager', 'loading', 'events', 'libraryBrowser onViewStyleChange(); reloadItems(tabContent); }); - tabContent.querySelector('.btnPlayAll').addEventListener('click', playAll); - tabContent.querySelector('.btnShuffle').addEventListener('click', shuffle); + tabContent.querySelector(".btnPlayAll").addEventListener("click", playAll); + tabContent.querySelector(".btnShuffle").addEventListener("click", shuffle); } initPage(tabContent); diff --git a/src/controllers/music/musicartists.js b/src/controllers/music/musicartists.js index bd9341be6d..a3f05d381d 100644 --- a/src/controllers/music/musicartists.js +++ b/src/controllers/music/musicartists.js @@ -1,5 +1,5 @@ -define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'apphost', 'userSettings', 'emby-itemscontainer'], function (layoutManager, loading, events, libraryBrowser, imageLoader, alphaPicker, listView, cardBuilder, appHost, userSettings) { - 'use strict'; +define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "alphaPicker", "listView", "cardBuilder", "apphost", "userSettings", "emby-itemscontainer"], function (layoutManager, loading, events, libraryBrowser, imageLoader, alphaPicker, listView, cardBuilder, appHost, userSettings) { + "use strict"; return function (view, params, tabContent) { function getPageData(context) { @@ -8,13 +8,13 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' if (!pageData) { var queryValues = { - SortBy: 'SortName', - SortOrder: 'Ascending', + SortBy: "SortName", + SortOrder: "Ascending", Recursive: true, - Fields: 'PrimaryImageAspectRatio,SortName,BasicSyncInfo', + Fields: "PrimaryImageAspectRatio,SortName,BasicSyncInfo", StartIndex: 0, ImageTypeLimit: 1, - EnableImageTypes: 'Primary,Backdrop,Banner,Thumb' + EnableImageTypes: "Primary,Backdrop,Banner,Thumb" }; if (userSettings.libraryPageSize() > 0) { @@ -23,7 +23,7 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' pageData = data[key] = { query: queryValues, - view: libraryBrowser.getSavedView(key) || 'Poster' + view: libraryBrowser.getSavedView(key) || "Poster" }; pageData.query.ParentId = params.topParentId; libraryBrowser.loadSavedQueryValues(key, pageData.query); @@ -46,17 +46,17 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' function onViewStyleChange() { var viewStyle = self.getCurrentViewStyle(); - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var itemsContainer = tabContent.querySelector(".itemsContainer"); - if ('List' == viewStyle) { - itemsContainer.classList.add('vertical-list'); - itemsContainer.classList.remove('vertical-wrap'); + if ("List" == viewStyle) { + itemsContainer.classList.add("vertical-list"); + itemsContainer.classList.remove("vertical-wrap"); } else { - itemsContainer.classList.remove('vertical-list'); - itemsContainer.classList.add('vertical-wrap'); + itemsContainer.classList.remove("vertical-list"); + itemsContainer.classList.add("vertical-wrap"); } - itemsContainer.innerHTML = ''; + itemsContainer.innerHTML = ""; } function reloadItems(page) { @@ -103,16 +103,16 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' filterButton: false }); var viewStyle = self.getCurrentViewStyle(); - if (viewStyle == 'List') { + if (viewStyle == "List") { html = listView.getListViewHtml({ items: result.Items, sortBy: query.SortBy }); - } else if (viewStyle == 'PosterCard') { + } else if (viewStyle == "PosterCard") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'square', - context: 'music', + shape: "square", + context: "music", showTitle: true, coverImage: true, cardLayout: true @@ -120,8 +120,8 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' } else { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'square', - context: 'music', + shape: "square", + context: "music", showTitle: true, coverImage: true, lazy: true, @@ -131,30 +131,30 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' } var i; var length; - var elems = tabContent.querySelectorAll('.paging'); + var elems = tabContent.querySelectorAll(".paging"); for (i = 0, length = elems.length; i < length; i++) { elems[i].innerHTML = pagingHtml; } - elems = tabContent.querySelectorAll('.btnNextPage'); + elems = tabContent.querySelectorAll(".btnNextPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onNextPageClick); + elems[i].addEventListener("click", onNextPageClick); } - elems = tabContent.querySelectorAll('.btnPreviousPage'); + elems = tabContent.querySelectorAll(".btnPreviousPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onPreviousPageClick); + elems[i].addEventListener("click", onPreviousPageClick); } - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var itemsContainer = tabContent.querySelector(".itemsContainer"); itemsContainer.innerHTML = html; imageLoader.lazyChildren(itemsContainer); libraryBrowser.saveQueryValues(getSavedQueryKey(page), query); loading.hide(); isLoading = false; - require(['autoFocuser'], function (autoFocuser) { + require(["autoFocuser"], function (autoFocuser) { autoFocuser.autoFocus(tabContent); }); }); @@ -170,13 +170,13 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' var isLoading = false; self.showFilterMenu = function () { - require(['components/filterdialog/filterdialog'], function (filterDialogFactory) { + require(["components/filterdialog/filterdialog"], function ({default: filterDialogFactory}) { var filterDialog = new filterDialogFactory({ query: getQuery(tabContent), mode: self.mode, serverId: ApiClient.serverId() }); - events.on(filterDialog, 'filterchange', function () { + events.on(filterDialog, "filterchange", function () { getQuery(tabContent).StartIndex = 0; reloadItems(tabContent); }); @@ -189,10 +189,10 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' }; function initPage(tabContent) { - var alphaPickerElement = tabContent.querySelector('.alphaPicker'); - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var alphaPickerElement = tabContent.querySelector(".alphaPicker"); + var itemsContainer = tabContent.querySelector(".itemsContainer"); - alphaPickerElement.addEventListener('alphavaluechanged', function (e) { + alphaPickerElement.addEventListener("alphavaluechanged", function (e) { var newValue = e.detail.value; var query = getQuery(tabContent); query.NameStartsWithOrGreater = newValue; @@ -201,21 +201,21 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' }); self.alphaPicker = new alphaPicker({ element: alphaPickerElement, - valueChangeEvent: 'click' + valueChangeEvent: "click" }); - tabContent.querySelector('.alphaPicker').classList.add('alphabetPicker-right'); - alphaPickerElement.classList.add('alphaPicker-fixed-right'); - itemsContainer.classList.add('padded-right-withalphapicker'); + tabContent.querySelector(".alphaPicker").classList.add("alphabetPicker-right"); + alphaPickerElement.classList.add("alphaPicker-fixed-right"); + itemsContainer.classList.add("padded-right-withalphapicker"); - tabContent.querySelector('.btnFilter').addEventListener('click', function () { + tabContent.querySelector(".btnFilter").addEventListener("click", function () { self.showFilterMenu(); }); - var btnSelectView = tabContent.querySelector('.btnSelectView'); - btnSelectView.addEventListener('click', function (e) { - libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(',')); + var btnSelectView = tabContent.querySelector(".btnSelectView"); + btnSelectView.addEventListener("click", function (e) { + libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), "List,Poster,PosterCard".split(",")); }); - btnSelectView.addEventListener('layoutchange', function (e) { + btnSelectView.addEventListener("layoutchange", function (e) { var viewStyle = e.detail.viewStyle; getPageData(tabContent).view = viewStyle; libraryBrowser.saveViewSetting(getSavedQueryKey(tabContent), viewStyle); diff --git a/src/controllers/music/songs.js b/src/controllers/music/songs.js index 8e50cd720c..21743bc922 100644 --- a/src/controllers/music/songs.js +++ b/src/controllers/music/songs.js @@ -1,5 +1,5 @@ -define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'loading', 'userSettings', 'globalize', 'emby-itemscontainer'], function (events, libraryBrowser, imageLoader, listView, loading, userSettings, globalize) { - 'use strict'; +define(["events", "libraryBrowser", "imageLoader", "listView", "loading", "userSettings", "emby-itemscontainer"], function (events, libraryBrowser, imageLoader, listView, loading, userSettings) { + "use strict"; return function (view, params, tabContent) { function getPageData(context) { @@ -9,14 +9,14 @@ define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'loading', 'userS if (!pageData) { pageData = data[key] = { query: { - SortBy: 'Album,SortName', - SortOrder: 'Ascending', - IncludeItemTypes: 'Audio', + SortBy: "Album,SortName", + SortOrder: "Ascending", + IncludeItemTypes: "Audio", Recursive: true, - Fields: 'AudioInfo,ParentId', + Fields: "AudioInfo,ParentId", StartIndex: 0, ImageTypeLimit: 1, - EnableImageTypes: 'Primary' + EnableImageTypes: "Primary" } }; @@ -37,7 +37,7 @@ define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'loading', 'userS function getSavedQueryKey(context) { if (!context.savedQueryKey) { - context.savedQueryKey = libraryBrowser.getSavedQueryKey('songs'); + context.savedQueryKey = libraryBrowser.getSavedQueryKey("songs"); } return context.savedQueryKey; @@ -85,35 +85,35 @@ define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'loading', 'userS }); var html = listView.getListViewHtml({ items: result.Items, - action: 'playallfromhere', + action: "playallfromhere", smallIcon: true, artist: true, addToListButton: true }); - var elems = tabContent.querySelectorAll('.paging'); + var elems = tabContent.querySelectorAll(".paging"); for (i = 0, length = elems.length; i < length; i++) { elems[i].innerHTML = pagingHtml; } - elems = tabContent.querySelectorAll('.btnNextPage'); + elems = tabContent.querySelectorAll(".btnNextPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onNextPageClick); + elems[i].addEventListener("click", onNextPageClick); } - elems = tabContent.querySelectorAll('.btnPreviousPage'); + elems = tabContent.querySelectorAll(".btnPreviousPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onPreviousPageClick); + elems[i].addEventListener("click", onPreviousPageClick); } - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var itemsContainer = tabContent.querySelector(".itemsContainer"); itemsContainer.innerHTML = html; imageLoader.lazyChildren(itemsContainer); libraryBrowser.saveQueryValues(getSavedQueryKey(page), query); loading.hide(); isLoading = false; - require(['autoFocuser'], function (autoFocuser) { + require(["autoFocuser"], function (autoFocuser) { autoFocuser.autoFocus(page); }); }); @@ -124,13 +124,13 @@ define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'loading', 'userS var isLoading = false; self.showFilterMenu = function () { - require(['components/filterdialog/filterdialog'], function (filterDialogFactory) { + require(["components/filterdialog/filterdialog"], function ({default: filterDialogFactory}) { var filterDialog = new filterDialogFactory({ query: getQuery(tabContent), - mode: 'songs', + mode: "songs", serverId: ApiClient.serverId() }); - events.on(filterDialog, 'filterchange', function () { + events.on(filterDialog, "filterchange", function () { getQuery(tabContent).StartIndex = 0; reloadItems(tabContent); }); @@ -143,38 +143,38 @@ define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'loading', 'userS }; function initPage(tabContent) { - tabContent.querySelector('.btnFilter').addEventListener('click', function () { + tabContent.querySelector(".btnFilter").addEventListener("click", function () { self.showFilterMenu(); }); - tabContent.querySelector('.btnSort').addEventListener('click', function (e) { + tabContent.querySelector(".btnSort").addEventListener("click", function (e) { libraryBrowser.showSortMenu({ items: [{ - name: globalize.translate('OptionTrackName'), - id: 'Name' + name: Globalize.translate("OptionTrackName"), + id: "Name" }, { - name: globalize.translate('OptionAlbum'), - id: 'Album,SortName' + name: Globalize.translate("OptionAlbum"), + id: "Album,SortName" }, { - name: globalize.translate('OptionAlbumArtist'), - id: 'AlbumArtist,Album,SortName' + name: Globalize.translate("OptionAlbumArtist"), + id: "AlbumArtist,Album,SortName" }, { - name: globalize.translate('OptionArtist'), - id: 'Artist,Album,SortName' + name: Globalize.translate("OptionArtist"), + id: "Artist,Album,SortName" }, { - name: globalize.translate('OptionDateAdded'), - id: 'DateCreated,SortName' + name: Globalize.translate("OptionDateAdded"), + id: "DateCreated,SortName" }, { - name: globalize.translate('OptionDatePlayed'), - id: 'DatePlayed,SortName' + name: Globalize.translate("OptionDatePlayed"), + id: "DatePlayed,SortName" }, { - name: globalize.translate('OptionPlayCount'), - id: 'PlayCount,SortName' + name: Globalize.translate("OptionPlayCount"), + id: "PlayCount,SortName" }, { - name: globalize.translate('OptionReleaseDate'), - id: 'PremiereDate,AlbumArtist,Album,SortName' + name: Globalize.translate("OptionReleaseDate"), + id: "PremiereDate,AlbumArtist,Album,SortName" }, { - name: globalize.translate('OptionRuntime'), - id: 'Runtime,AlbumArtist,Album,SortName' + name: Globalize.translate("OptionRuntime"), + id: "Runtime,AlbumArtist,Album,SortName" }], callback: function () { getQuery(tabContent).StartIndex = 0; diff --git a/src/controllers/shows/episodes.js b/src/controllers/shows/episodes.js index ca9a807cbf..b274952939 100644 --- a/src/controllers/shows/episodes.js +++ b/src/controllers/shows/episodes.js @@ -1,5 +1,5 @@ -define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (loading, events, libraryBrowser, imageLoader, listView, cardBuilder, userSettings, globalize) { - 'use strict'; +define(["loading", "events", "libraryBrowser", "imageLoader", "listView", "cardBuilder", "userSettings", "emby-itemscontainer"], function (loading, events, libraryBrowser, imageLoader, listView, cardBuilder, userSettings) { + "use strict"; return function (view, params, tabContent) { function getPageData(context) { @@ -9,17 +9,17 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB if (!pageData) { pageData = data[key] = { query: { - SortBy: 'SeriesSortName,SortName', - SortOrder: 'Ascending', - IncludeItemTypes: 'Episode', + SortBy: "SeriesSortName,SortName", + SortOrder: "Ascending", + IncludeItemTypes: "Episode", Recursive: true, - Fields: 'PrimaryImageAspectRatio,MediaSourceCount,UserData', + Fields: "PrimaryImageAspectRatio,MediaSourceCount,UserData", IsMissing: false, ImageTypeLimit: 1, - EnableImageTypes: 'Primary,Backdrop,Thumb', + EnableImageTypes: "Primary,Backdrop,Thumb", StartIndex: 0 }, - view: libraryBrowser.getSavedView(key) || 'Poster' + view: libraryBrowser.getSavedView(key) || "Poster" }; if (userSettings.libraryPageSize() > 0) { @@ -39,7 +39,7 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB function getSavedQueryKey(context) { if (!context.savedQueryKey) { - context.savedQueryKey = libraryBrowser.getSavedQueryKey('episodes'); + context.savedQueryKey = libraryBrowser.getSavedQueryKey("episodes"); } return context.savedQueryKey; @@ -47,17 +47,17 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB function onViewStyleChange() { var viewStyle = self.getCurrentViewStyle(); - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var itemsContainer = tabContent.querySelector(".itemsContainer"); - if ('List' == viewStyle) { - itemsContainer.classList.add('vertical-list'); - itemsContainer.classList.remove('vertical-wrap'); + if ("List" == viewStyle) { + itemsContainer.classList.add("vertical-list"); + itemsContainer.classList.remove("vertical-wrap"); } else { - itemsContainer.classList.remove('vertical-list'); - itemsContainer.classList.add('vertical-wrap'); + itemsContainer.classList.remove("vertical-list"); + itemsContainer.classList.add("vertical-wrap"); } - itemsContainer.innerHTML = ''; + itemsContainer.innerHTML = ""; } function reloadItems(page) { @@ -100,17 +100,17 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB filterButton: false }); var viewStyle = self.getCurrentViewStyle(); - var itemsContainer = tabContent.querySelector('.itemsContainer'); - if (viewStyle == 'List') { + var itemsContainer = tabContent.querySelector(".itemsContainer"); + if (viewStyle == "List") { html = listView.getListViewHtml({ items: result.Items, sortBy: query.SortBy, showParentTitle: true }); - } else if (viewStyle == 'PosterCard') { + } else if (viewStyle == "PosterCard") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'backdrop', + shape: "backdrop", showTitle: true, showParentTitle: true, scalable: true, @@ -119,7 +119,7 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB } else { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'backdrop', + shape: "backdrop", showTitle: true, showParentTitle: true, overlayText: false, @@ -132,19 +132,19 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB var length; var elems; - elems = tabContent.querySelectorAll('.paging'); + elems = tabContent.querySelectorAll(".paging"); for (i = 0, length = elems.length; i < length; i++) { elems[i].innerHTML = pagingHtml; } - elems = tabContent.querySelectorAll('.btnNextPage'); + elems = tabContent.querySelectorAll(".btnNextPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onNextPageClick); + elems[i].addEventListener("click", onNextPageClick); } - elems = tabContent.querySelectorAll('.btnPreviousPage'); + elems = tabContent.querySelectorAll(".btnPreviousPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onPreviousPageClick); + elems[i].addEventListener("click", onPreviousPageClick); } itemsContainer.innerHTML = html; @@ -153,7 +153,7 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB loading.hide(); isLoading = false; - require(['autoFocuser'], function (autoFocuser) { + require(["autoFocuser"], function (autoFocuser) { autoFocuser.autoFocus(page); }); }); @@ -164,13 +164,13 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB var isLoading = false; self.showFilterMenu = function () { - require(['components/filterdialog/filterdialog'], function (filterDialogFactory) { + require(["components/filterdialog/filterdialog"], function ({default: filterDialogFactory}) { var filterDialog = new filterDialogFactory({ query: getQuery(tabContent), - mode: 'episodes', + mode: "episodes", serverId: ApiClient.serverId() }); - events.on(filterDialog, 'filterchange', function () { + events.on(filterDialog, "filterchange", function () { reloadItems(tabContent); }); filterDialog.show(); @@ -182,35 +182,35 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB }; function initPage(tabContent) { - tabContent.querySelector('.btnFilter').addEventListener('click', function () { + tabContent.querySelector(".btnFilter").addEventListener("click", function () { self.showFilterMenu(); }); - tabContent.querySelector('.btnSort').addEventListener('click', function (e) { + tabContent.querySelector(".btnSort").addEventListener("click", function (e) { libraryBrowser.showSortMenu({ items: [{ - name: globalize.translate('OptionNameSort'), - id: 'SeriesSortName,SortName' + name: Globalize.translate("OptionNameSort"), + id: "SeriesSortName,SortName" }, { - name: globalize.translate('OptionTvdbRating'), - id: 'CommunityRating,SeriesSortName,SortName' + name: Globalize.translate("OptionTvdbRating"), + id: "CommunityRating,SeriesSortName,SortName" }, { - name: globalize.translate('OptionDateAdded'), - id: 'DateCreated,SeriesSortName,SortName' + name: Globalize.translate("OptionDateAdded"), + id: "DateCreated,SeriesSortName,SortName" }, { - name: globalize.translate('OptionPremiereDate'), - id: 'PremiereDate,SeriesSortName,SortName' + name: Globalize.translate("OptionPremiereDate"), + id: "PremiereDate,SeriesSortName,SortName" }, { - name: globalize.translate('OptionDatePlayed'), - id: 'DatePlayed,SeriesSortName,SortName' + name: Globalize.translate("OptionDatePlayed"), + id: "DatePlayed,SeriesSortName,SortName" }, { - name: globalize.translate('OptionParentalRating'), - id: 'OfficialRating,SeriesSortName,SortName' + name: Globalize.translate("OptionParentalRating"), + id: "OfficialRating,SeriesSortName,SortName" }, { - name: globalize.translate('OptionPlayCount'), - id: 'PlayCount,SeriesSortName,SortName' + name: Globalize.translate("OptionPlayCount"), + id: "PlayCount,SeriesSortName,SortName" }, { - name: globalize.translate('OptionRuntime'), - id: 'Runtime,SeriesSortName,SortName' + name: Globalize.translate("OptionRuntime"), + id: "Runtime,SeriesSortName,SortName" }], callback: function () { reloadItems(tabContent); @@ -219,11 +219,11 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB button: e.target }); }); - var btnSelectView = tabContent.querySelector('.btnSelectView'); - btnSelectView.addEventListener('click', function (e) { - libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(',')); + var btnSelectView = tabContent.querySelector(".btnSelectView"); + btnSelectView.addEventListener("click", function (e) { + libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), "List,Poster,PosterCard".split(",")); }); - btnSelectView.addEventListener('layoutchange', function (e) { + btnSelectView.addEventListener("layoutchange", function (e) { var viewStyle = e.detail.viewStyle; getPageData(tabContent).view = viewStyle; libraryBrowser.saveViewSetting(getSavedQueryKey(tabContent), viewStyle); diff --git a/src/controllers/shows/tvshows.js b/src/controllers/shows/tvshows.js index 753516f902..96aef86ca0 100644 --- a/src/controllers/shows/tvshows.js +++ b/src/controllers/shows/tvshows.js @@ -1,5 +1,5 @@ -define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardBuilder', 'alphaPicker', 'userSettings', 'globalize', 'emby-itemscontainer'], function (layoutManager, loading, events, libraryBrowser, imageLoader, listView, cardBuilder, alphaPicker, userSettings, globalize) { - 'use strict'; +define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "listView", "cardBuilder", "alphaPicker", "userSettings", "emby-itemscontainer"], function (layoutManager, loading, events, libraryBrowser, imageLoader, listView, cardBuilder, alphaPicker, userSettings) { + "use strict"; return function (view, params, tabContent) { function getPageData(context) { @@ -9,16 +9,16 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' if (!pageData) { pageData = data[key] = { query: { - SortBy: 'SortName', - SortOrder: 'Ascending', - IncludeItemTypes: 'Series', + SortBy: "SortName", + SortOrder: "Ascending", + IncludeItemTypes: "Series", Recursive: true, - Fields: 'PrimaryImageAspectRatio,BasicSyncInfo', + Fields: "PrimaryImageAspectRatio,BasicSyncInfo", ImageTypeLimit: 1, - EnableImageTypes: 'Primary,Backdrop,Banner,Thumb', + EnableImageTypes: "Primary,Backdrop,Banner,Thumb", StartIndex: 0 }, - view: libraryBrowser.getSavedView(key) || 'Poster' + view: libraryBrowser.getSavedView(key) || "Poster" }; if (userSettings.libraryPageSize() > 0) { @@ -38,7 +38,7 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' function getSavedQueryKey(context) { if (!context.savedQueryKey) { - context.savedQueryKey = libraryBrowser.getSavedQueryKey('series'); + context.savedQueryKey = libraryBrowser.getSavedQueryKey("series"); } return context.savedQueryKey; @@ -46,17 +46,17 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' function onViewStyleChange() { var viewStyle = self.getCurrentViewStyle(); - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var itemsContainer = tabContent.querySelector(".itemsContainer"); - if ('List' == viewStyle) { - itemsContainer.classList.add('vertical-list'); - itemsContainer.classList.remove('vertical-wrap'); + if ("List" == viewStyle) { + itemsContainer.classList.add("vertical-list"); + itemsContainer.classList.remove("vertical-wrap"); } else { - itemsContainer.classList.remove('vertical-list'); - itemsContainer.classList.add('vertical-wrap'); + itemsContainer.classList.remove("vertical-list"); + itemsContainer.classList.add("vertical-wrap"); } - itemsContainer.innerHTML = ''; + itemsContainer.innerHTML = ""; } function reloadItems(page) { @@ -100,45 +100,45 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' filterButton: false }); var viewStyle = self.getCurrentViewStyle(); - if (viewStyle == 'Thumb') { + if (viewStyle == "Thumb") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'backdrop', + shape: "backdrop", preferThumb: true, - context: 'tvshows', + context: "tvshows", overlayMoreButton: true, showTitle: true, centerText: true }); - } else if (viewStyle == 'ThumbCard') { + } else if (viewStyle == "ThumbCard") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'backdrop', + shape: "backdrop", preferThumb: true, - context: 'tvshows', + context: "tvshows", cardLayout: true, showTitle: true, showYear: true, centerText: true }); - } else if (viewStyle == 'Banner') { + } else if (viewStyle == "Banner") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'banner', + shape: "banner", preferBanner: true, - context: 'tvshows' + context: "tvshows" }); - } else if (viewStyle == 'List') { + } else if (viewStyle == "List") { html = listView.getListViewHtml({ items: result.Items, - context: 'tvshows', + context: "tvshows", sortBy: query.SortBy }); - } else if (viewStyle == 'PosterCard') { + } else if (viewStyle == "PosterCard") { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'portrait', - context: 'tvshows', + shape: "portrait", + context: "tvshows", showTitle: true, showYear: true, centerText: true, @@ -147,8 +147,8 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' } else { html = cardBuilder.getCardsHtml({ items: result.Items, - shape: 'portrait', - context: 'tvshows', + shape: "portrait", + context: "tvshows", centerText: true, lazy: true, overlayMoreButton: true, @@ -158,30 +158,30 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' } var i; var length; - var elems = tabContent.querySelectorAll('.paging'); + var elems = tabContent.querySelectorAll(".paging"); for (i = 0, length = elems.length; i < length; i++) { elems[i].innerHTML = pagingHtml; } - elems = tabContent.querySelectorAll('.btnNextPage'); + elems = tabContent.querySelectorAll(".btnNextPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onNextPageClick); + elems[i].addEventListener("click", onNextPageClick); } - elems = tabContent.querySelectorAll('.btnPreviousPage'); + elems = tabContent.querySelectorAll(".btnPreviousPage"); for (i = 0, length = elems.length; i < length; i++) { - elems[i].addEventListener('click', onPreviousPageClick); + elems[i].addEventListener("click", onPreviousPageClick); } - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var itemsContainer = tabContent.querySelector(".itemsContainer"); itemsContainer.innerHTML = html; imageLoader.lazyChildren(itemsContainer); libraryBrowser.saveQueryValues(getSavedQueryKey(page), query); loading.hide(); isLoading = false; - require(['autoFocuser'], function (autoFocuser) { + require(["autoFocuser"], function (autoFocuser) { autoFocuser.autoFocus(page); }); }); @@ -197,13 +197,13 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' var isLoading = false; self.showFilterMenu = function () { - require(['components/filterdialog/filterdialog'], function (filterDialogFactory) { + require(["components/filterdialog/filterdialog"], function ({default: filterDialogFactory}) { var filterDialog = new filterDialogFactory({ query: getQuery(tabContent), - mode: 'series', + mode: "series", serverId: ApiClient.serverId() }); - events.on(filterDialog, 'filterchange', function () { + events.on(filterDialog, "filterchange", function () { getQuery(tabContent).StartIndex = 0; reloadItems(tabContent); }); @@ -216,10 +216,10 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' }; function initPage(tabContent) { - var alphaPickerElement = tabContent.querySelector('.alphaPicker'); - var itemsContainer = tabContent.querySelector('.itemsContainer'); + var alphaPickerElement = tabContent.querySelector(".alphaPicker"); + var itemsContainer = tabContent.querySelector(".itemsContainer"); - alphaPickerElement.addEventListener('alphavaluechanged', function (e) { + alphaPickerElement.addEventListener("alphavaluechanged", function (e) { var newValue = e.detail.value; var query = getQuery(tabContent); query.NameStartsWithOrGreater = newValue; @@ -228,36 +228,36 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' }); self.alphaPicker = new alphaPicker({ element: alphaPickerElement, - valueChangeEvent: 'click' + valueChangeEvent: "click" }); - tabContent.querySelector('.alphaPicker').classList.add('alphabetPicker-right'); - alphaPickerElement.classList.add('alphaPicker-fixed-right'); - itemsContainer.classList.add('padded-right-withalphapicker'); + tabContent.querySelector(".alphaPicker").classList.add("alphabetPicker-right"); + alphaPickerElement.classList.add("alphaPicker-fixed-right"); + itemsContainer.classList.add("padded-right-withalphapicker"); - tabContent.querySelector('.btnFilter').addEventListener('click', function () { + tabContent.querySelector(".btnFilter").addEventListener("click", function () { self.showFilterMenu(); }); - tabContent.querySelector('.btnSort').addEventListener('click', function (e) { + tabContent.querySelector(".btnSort").addEventListener("click", function (e) { libraryBrowser.showSortMenu({ items: [{ - name: globalize.translate('OptionNameSort'), - id: 'SortName' + name: Globalize.translate("OptionNameSort"), + id: "SortName" }, { - name: globalize.translate('OptionImdbRating'), - id: 'CommunityRating,SortName' + name: Globalize.translate("OptionImdbRating"), + id: "CommunityRating,SortName" }, { - name: globalize.translate('OptionDateAdded'), - id: 'DateCreated,SortName' + name: Globalize.translate("OptionDateAdded"), + id: "DateCreated,SortName" }, { - name: globalize.translate('OptionDatePlayed'), - id: 'DatePlayed,SortName' + name: Globalize.translate("OptionDatePlayed"), + id: "DatePlayed,SortName" }, { - name: globalize.translate('OptionParentalRating'), - id: 'OfficialRating,SortName' + name: Globalize.translate("OptionParentalRating"), + id: "OfficialRating,SortName" }, { - name: globalize.translate('OptionReleaseDate'), - id: 'PremiereDate,SortName' + name: Globalize.translate("OptionReleaseDate"), + id: "PremiereDate,SortName" }], callback: function () { getQuery(tabContent).StartIndex = 0; @@ -267,11 +267,11 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', ' button: e.target }); }); - var btnSelectView = tabContent.querySelector('.btnSelectView'); - btnSelectView.addEventListener('click', function (e) { - libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'Banner,List,Poster,PosterCard,Thumb,ThumbCard'.split(',')); + var btnSelectView = tabContent.querySelector(".btnSelectView"); + btnSelectView.addEventListener("click", function (e) { + libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), "Banner,List,Poster,PosterCard,Thumb,ThumbCard".split(",")); }); - btnSelectView.addEventListener('layoutchange', function (e) { + btnSelectView.addEventListener("layoutchange", function (e) { var viewStyle = e.detail.viewStyle; getPageData(tabContent).view = viewStyle; libraryBrowser.saveViewSetting(getSavedQueryKey(tabContent), viewStyle);