From a9982263b01c10a79902add5e5f13b64e29fd776 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Thu, 15 Aug 2019 20:17:52 +0300 Subject: [PATCH 1/4] unused filter audio launguage --- src/components/filterdialog/filterdialog.js | 27 +++++++------------ .../filterdialog/filterdialog.template.html | 5 ---- src/strings/cs.json | 1 - src/strings/da.json | 1 - src/strings/de.json | 1 - src/strings/en-gb.json | 1 - src/strings/en-us.json | 1 - src/strings/es-mx.json | 1 - src/strings/es.json | 1 - src/strings/fr.json | 1 - src/strings/hu.json | 1 - src/strings/it.json | 1 - src/strings/ja.json | 1 - src/strings/kk.json | 1 - src/strings/nl.json | 1 - src/strings/pl.json | 1 - src/strings/pt-br.json | 1 - src/strings/ru.json | 1 - src/strings/zh-cn.json | 1 - src/strings/zh-tw.json | 1 - 20 files changed, 9 insertions(+), 41 deletions(-) diff --git a/src/components/filterdialog/filterdialog.js b/src/components/filterdialog/filterdialog.js index d23bdb41d3..73abf94632 100644 --- a/src/components/filterdialog/filterdialog.js +++ b/src/components/filterdialog/filterdialog.js @@ -21,8 +21,6 @@ define(["dialogHelper", "globalize", "connectionManager", "events", "browser", " return -1 != ("|" + (query.Tags || "") + "|").indexOf("|" + i + "|") }), renderOptions(context, ".yearFilters", "chkYearFilter", result.Years, function(i) { return -1 != ("," + (query.Years || "") + ",").indexOf("," + i + ",") - }), renderOptions(context, ".audioLanguagesFilters", "chkAudioLanguagesFilter", result.AudioLanguages, function(i) { - return -1 != ("," + (query.AudioLanguages || "") + ",").indexOf("," + i + ",") }) } @@ -71,7 +69,7 @@ define(["dialogHelper", "globalize", "connectionManager", "events", "browser", " } function setVisibility(context, options) { - "livetvchannels" != options.mode && "albums" != options.mode && "artists" != options.mode && "albumartists" != options.mode && "songs" != options.mode || hideByClass(context, "videoStandard"), 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(".audioLanguagesFilters").classList.remove("hide")), "movies" != options.mode && "episodes" != options.mode || context.querySelector(".videoTypeFilters").classList.remove("hide"), options.mode, "movies" != options.mode && "series" != options.mode && "episodes" != options.mode || context.querySelector(".features").classList.remove("hide"), "series" == options.mode && context.querySelector(".seriesStatus").classList.remove("hide"), "episodes" == options.mode && showByClass(context, "episodeFilter") + "livetvchannels" != options.mode && "albums" != options.mode && "artists" != options.mode && "albumartists" != options.mode && "songs" != options.mode || hideByClass(context, "videoStandard"), 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")), "movies" != options.mode && "episodes" != options.mode || context.querySelector(".videoTypeFilters").classList.remove("hide"), options.mode, "movies" != options.mode && "series" != options.mode && "episodes" != options.mode || context.querySelector(".features").classList.remove("hide"), "series" == options.mode && context.querySelector(".seriesStatus").classList.remove("hide"), "episodes" == options.mode && showByClass(context, "episodeFilter") } function showByClass(context, className) { @@ -125,14 +123,14 @@ define(["dialogHelper", "globalize", "connectionManager", "events", "browser", " for (elems = context.querySelectorAll(".chkStandardFilter"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("change", onStandardFilterChange); for (elems = context.querySelectorAll(".chkVideoTypeFilter"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("change", onVideoTypeFilterChange); for (context.querySelector(".chk3DFilter").addEventListener("change", function() { - query.StartIndex = 0, query.Is3D = !!this.checked || null, triggerChange(self) - }), context.querySelector(".chk4KFilter").addEventListener("change", function() { - query.StartIndex = 0, query.Is4K = !!this.checked || null, triggerChange(self) - }), context.querySelector(".chkHDFilter").addEventListener("change", function() { - query.StartIndex = 0, query.IsHD = !!this.checked || null, triggerChange(self) - }), context.querySelector(".chkSDFilter").addEventListener("change", function() { - query.StartIndex = 0, query.IsHD = !this.checked && null, triggerChange(self) - }), elems = context.querySelectorAll(".chkStatus"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("change", onStatusChange); + query.StartIndex = 0, query.Is3D = !!this.checked || null, triggerChange(self) + }), context.querySelector(".chk4KFilter").addEventListener("change", function() { + query.StartIndex = 0, query.Is4K = !!this.checked || null, triggerChange(self) + }), context.querySelector(".chkHDFilter").addEventListener("change", function() { + query.StartIndex = 0, query.IsHD = !!this.checked || null, triggerChange(self) + }), context.querySelector(".chkSDFilter").addEventListener("change", function() { + query.StartIndex = 0, query.IsHD = !this.checked && null, triggerChange(self) + }), elems = context.querySelectorAll(".chkStatus"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("change", onStatusChange); context.querySelector("#chkTrailer").addEventListener("change", function() { query.StartIndex = 0, query.HasTrailer = !!this.checked || null, triggerChange(self) }), context.querySelector("#chkThemeSong").addEventListener("change", function() { @@ -171,13 +169,6 @@ define(["dialogHelper", "globalize", "connectionManager", "events", "browser", " delimiter = ","; return filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1), chkYearFilter.checked && (filters = filters ? filters + delimiter + filterName : filterName), query.StartIndex = 0, query.Years = filters, void triggerChange(self) } - var chkAudioLanguagesFilter = parentWithClass(e.target, "chkAudioLanguagesFilter"); - if (chkAudioLanguagesFilter) { - var filterName = chkAudioLanguagesFilter.getAttribute("data-filter"), - filters = query.AudioLanguages || "", - delimiter = ","; - return filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1), chkAudioLanguagesFilter.checked && (filters = filters ? filters + delimiter + filterName : filterName), query.StartIndex = 0, query.AudioLanguages = filters, void triggerChange(self) - } var chkOfficialRatingFilter = parentWithClass(e.target, "chkOfficialRatingFilter"); if (chkOfficialRatingFilter) { var filterName = chkOfficialRatingFilter.getAttribute("data-filter"), diff --git a/src/components/filterdialog/filterdialog.template.html b/src/components/filterdialog/filterdialog.template.html index 70b5c1c67f..3f334a009f 100644 --- a/src/components/filterdialog/filterdialog.template.html +++ b/src/components/filterdialog/filterdialog.template.html @@ -139,9 +139,4 @@
- -
-
-
-
diff --git a/src/strings/cs.json b/src/strings/cs.json index de25d4903e..dab172c6ed 100644 --- a/src/strings/cs.json +++ b/src/strings/cs.json @@ -1317,7 +1317,6 @@ "HeaderAllowMediaDeletionFrom": "Povolit smazání médií z", "HeaderAppearsOn": "Appears On", "HeaderAudio": "Audio", - "HeaderAudioLanguages": "Jazyk zvuku", "HeaderBlockItemsWithNoRating": "Blokovat položky s žádnými nebo nerozpoznanými informacemi o hodnocení:", "HeaderCameraUploadHelp": "Aplikace Jellyfin mohou automaticky nahrávat fotografie z mobilních zařízení do serveru Jellyfin.", "HeaderChapterImages": "Obrázky kapitol", diff --git a/src/strings/da.json b/src/strings/da.json index 6f35639797..419e8bd854 100644 --- a/src/strings/da.json +++ b/src/strings/da.json @@ -1231,7 +1231,6 @@ "HeaderApp": "App", "HeaderAppearsOn": "Forekommer I", "HeaderAudioBooks": "Lydbøger", - "HeaderAudioLanguages": "Lyd Sprog", "HeaderBranding": "Mærkning", "HeaderContinueListening": "Fortsæt med At Høre", "HeaderDestination": "Destination", diff --git a/src/strings/de.json b/src/strings/de.json index e8eda96e63..ed9b757496 100644 --- a/src/strings/de.json +++ b/src/strings/de.json @@ -284,7 +284,6 @@ "HeaderApiKeysHelp": "Externe Applikationen benötigen einen API-Schlüssel, um mit dem Jellyfin-Server zu kommunizieren. API-Schlüssel werden beim Anmelden mit einem Jellyfin-Konto oder durch eine manuelle Freigabe vergeben.", "HeaderAppearsOn": "Erscheint auf", "HeaderAudioBooks": "Hörbücher", - "HeaderAudioLanguages": "Audiosprachen", "HeaderAudioSettings": "Audioeinstellungen", "HeaderAutomaticUpdates": "Automatische Updates", "HeaderBlockItemsWithNoRating": "Blockiere Inhalte mit keiner oder nicht erkannter Altersfreigabe:", diff --git a/src/strings/en-gb.json b/src/strings/en-gb.json index 5873d8ae70..b52ed97965 100644 --- a/src/strings/en-gb.json +++ b/src/strings/en-gb.json @@ -336,7 +336,6 @@ "HeaderApp": "App", "HeaderAppearsOn": "Appears On", "HeaderAudioBooks": "Audio Books", - "HeaderAudioLanguages": "Audio Languages", "HeaderAudioSettings": "Audio Settings", "HeaderAutomaticUpdates": "Automatic Updates", "HeaderBooks": "Books", diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 2f793837da..461686a39f 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -302,7 +302,6 @@ "HeaderApp": "App", "HeaderAppearsOn": "Appears On", "HeaderAudioBooks": "Audio Books", - "HeaderAudioLanguages": "Audio Languages", "HeaderAudioSettings": "Audio Settings", "HeaderAutomaticUpdates": "Automatic Updates", "HeaderBlockItemsWithNoRating": "Block items with no or unrecognized rating information:", diff --git a/src/strings/es-mx.json b/src/strings/es-mx.json index 3d97101656..093d2c62c6 100644 --- a/src/strings/es-mx.json +++ b/src/strings/es-mx.json @@ -1370,7 +1370,6 @@ "General": "General", "HeaderAdmin": "Administrador", "HeaderApp": "App", - "HeaderAudioLanguages": "Idiomas de audio", "HeaderError": "Error", "HeaderFavoriteMovies": "Peliculas favoritas", "HeaderFavoriteShows": "Programas favoritos", diff --git a/src/strings/es.json b/src/strings/es.json index 546a163c2a..933d1744c2 100644 --- a/src/strings/es.json +++ b/src/strings/es.json @@ -1294,7 +1294,6 @@ "HeaderAlbums": "Álbumes", "HeaderApp": "Aplicación", "HeaderAppearsOn": "Aparece en", - "HeaderAudioLanguages": "Idiomas de audio", "HeaderBranding": "Remarcado", "HeaderError": "Error", "HeaderMusicQuality": "Calidad de sonido", diff --git a/src/strings/fr.json b/src/strings/fr.json index 7b4e6e2bcd..fe92a007ef 100644 --- a/src/strings/fr.json +++ b/src/strings/fr.json @@ -288,7 +288,6 @@ "HeaderApp": "Application", "HeaderAppearsOn": "Apparait dans", "HeaderAudioBooks": "Livres audios", - "HeaderAudioLanguages": "Langues audio", "HeaderAudioSettings": "Réglages audio", "HeaderAutomaticUpdates": "Mises à jour automatiques", "HeaderBlockItemsWithNoRating": "Bloquer les éléments avec des informations de classification inconnues ou n'en disposant pas :", diff --git a/src/strings/hu.json b/src/strings/hu.json index f68990484b..d9dcb76b8c 100644 --- a/src/strings/hu.json +++ b/src/strings/hu.json @@ -726,7 +726,6 @@ "HeaderApiKey": "API Kulcs", "HeaderApiKeys": "API Kulcsok", "HeaderAppearsOn": "Megjelenik", - "HeaderAudioLanguages": "Audió nyelv", "HeaderBooks": "Könyvek", "HeaderCancelRecording": "Felvétel törlése", "HeaderCancelSeries": "Sorozat törlése", diff --git a/src/strings/it.json b/src/strings/it.json index 9ffaa90f9e..21fd12db90 100644 --- a/src/strings/it.json +++ b/src/strings/it.json @@ -1317,7 +1317,6 @@ "General": "Generale", "HeaderApp": "Applicazione", "HeaderAppearsOn": "Appare In", - "HeaderAudioLanguages": "Lingue Audio", "HeaderCastAndCrew": "Cast", "HeaderCastCrew": "Cast", "HeaderMedia": "Media", diff --git a/src/strings/ja.json b/src/strings/ja.json index c0b95102d9..bdc9a18cda 100644 --- a/src/strings/ja.json +++ b/src/strings/ja.json @@ -307,7 +307,6 @@ "HeaderApp": "アプリ", "HeaderAppearsOn": "表示", "HeaderAudioBooks": "オーディオブック", - "HeaderAudioLanguages": "音声言語", "HeaderAudioSettings": "音声設定", "HeaderAutomaticUpdates": "自動更新", "HeaderBlockItemsWithNoRating": "評価情報がない、または認識できないアイテムをブロックします。", diff --git a/src/strings/kk.json b/src/strings/kk.json index 2ffcf68b47..5eadaea6c1 100644 --- a/src/strings/kk.json +++ b/src/strings/kk.json @@ -1421,7 +1421,6 @@ "Yes": "Iá", "Yesterday": "Keshe", "ChangingMetadataImageSettingsNewContent": "Metaderekterdi nemese sýretterdi júkteý parametrlerin ózgertýi tek tasyǵyshhanaǵa ústelgen jańa mazmunǵa qoldanylady. Ózgeristerdi qoldanystaǵy ataýlarǵa qoldaný úshin olardyń metaderekterin qolmen jańǵyrtý qajet.", - "HeaderAudioLanguages": "Dybys tilderi", "LabelDynamicExternalId": "{0} Id:", "LeaveBlankToNotSetAPassword": "Mindetti emes - bos qaldyrsańyz, paról paıdalanylmaıdy", "MessageImageFileTypeAllowed": "Tek qana JPEG jáne PNG faıldary qoldaýda.", diff --git a/src/strings/nl.json b/src/strings/nl.json index 829da15b67..c5e8149f9f 100644 --- a/src/strings/nl.json +++ b/src/strings/nl.json @@ -1288,7 +1288,6 @@ "Genres": "Genres", "GenresValue": "Genres: {0}", "HeaderAlbums": "Albums", - "HeaderAudioLanguages": "Geluidstalen", "HeaderCastAndCrew": "Cast & Crew", "HeaderCastCrew": "Cast & Crew", "Art": "Afbeeldingen", diff --git a/src/strings/pl.json b/src/strings/pl.json index 6bf14d171e..9c767c7a7e 100644 --- a/src/strings/pl.json +++ b/src/strings/pl.json @@ -1376,7 +1376,6 @@ "ButtonOk": "Ok", "ButtonStart": "Start", "FormatValue": "Format: {0}", - "HeaderAudioLanguages": "Języki Audio", "HeaderFavoriteMovies": "Ulubione filmy", "HeaderFavoriteShows": "Ulubione seriale", "HeaderFavoriteEpisodes": "Ulubione odcinki", diff --git a/src/strings/pt-br.json b/src/strings/pt-br.json index d76284a78f..f71871a1ad 100644 --- a/src/strings/pt-br.json +++ b/src/strings/pt-br.json @@ -1336,7 +1336,6 @@ "GuideProviderLogin": "Provedor", "HeaderAdmin": "Administrador", "HeaderApp": "Aplicativo", - "HeaderAudioLanguages": "Opções de áudio", "HeaderStatus": "Status", "HeaderTags": "Marcações", "Horizontal": "Horizontal", diff --git a/src/strings/ru.json b/src/strings/ru.json index 61c0892efb..48adafa84b 100644 --- a/src/strings/ru.json +++ b/src/strings/ru.json @@ -1386,7 +1386,6 @@ "Yes": "Да", "Yesterday": "Вчера", "ChangingMetadataImageSettingsNewContent": "Изменения в настройках загрузки метаданных или иллюстраций применяются только к новому содержанию, добавляемому в медиатеку. Чтобы применить изменения к наличным произведениям, необходимо обновить их метаданные вручную.", - "HeaderAudioLanguages": "Языки аудио", "LabelDynamicExternalId": "{0} Ид:", "LeaveBlankToNotSetAPassword": "Необязательно - оставьте пустым, чтобы не назначать пароль", "MessageImageFileTypeAllowed": "Поддерживаются только файлы JPEG и PNG.", diff --git a/src/strings/zh-cn.json b/src/strings/zh-cn.json index 9423fc3720..1cbd93e334 100644 --- a/src/strings/zh-cn.json +++ b/src/strings/zh-cn.json @@ -1350,7 +1350,6 @@ "ErrorDeletingItem": "服务器删除项目时出错。请确认服务器具有对媒体文件夹的写入权限并重试。", "GroupBySeries": "按系列分组", "HeaderApp": "应用程序", - "HeaderAudioLanguages": "音频语言", "DirectStreamHelp1": "该媒体文件的分辨率和编码(H.264、AC3 等)与您的设备兼容,但容器格式(.mkv、.avi、.wmv 等)不受支持。因此,视频在串流至您的设备之前将会被即时封装为另一种格式。", "HeaderAppearsOn": "出现于", "HeaderCancelSeries": "取消系列", diff --git a/src/strings/zh-tw.json b/src/strings/zh-tw.json index a9f9f80c04..821a8cd414 100644 --- a/src/strings/zh-tw.json +++ b/src/strings/zh-tw.json @@ -582,7 +582,6 @@ "HeaderAppearsOn": "同時出現於", "HeaderAudio": "音訊", "HeaderAudioBooks": "有聲書", - "HeaderAudioLanguages": "音訊語言", "HeaderAudioSettings": "音訊設定", "HeaderAudioTracks": "音軌", "HeaderBackdrops": "背景", From b2a2b03b37152993f540257efa0e220a9b2a847d Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Fri, 13 Sep 2019 19:11:15 +0300 Subject: [PATCH 2/4] deminify filterdialog.js --- src/components/filterdialog/filterdialog.js | 464 ++++++++++++++------ 1 file changed, 340 insertions(+), 124 deletions(-) diff --git a/src/components/filterdialog/filterdialog.js b/src/components/filterdialog/filterdialog.js index 73abf94632..289242e9c1 100644 --- a/src/components/filterdialog/filterdialog.js +++ b/src/components/filterdialog/filterdialog.js @@ -1,27 +1,52 @@ -define(["dialogHelper", "globalize", "connectionManager", "events", "browser", "require", "emby-checkbox", "emby-collapse", "css!./style"], function(dialogHelper, globalize, connectionManager, events, browser, require) { +define(["dialogHelper", "globalize", "connectionManager", "events", "browser", "require", "emby-checkbox", "emby-collapse", "css!./style"], function (dialogHelper, globalize, connectionManager, events, browser, require) { "use strict"; function renderOptions(context, selector, cssClass, items, isCheckedFn) { var elem = context.querySelector(selector); - items.length ? elem.classList.remove("hide") : elem.classList.add("hide"); + if (items.length) { + elem.classList.remove("hide"); + } else { + elem.classList.add("hide"); + } var html = ""; - html += '
', html += items.map(function(filter) { - var itemHtml = "", - checkedHtml = isCheckedFn(filter) ? " checked" : ""; - return itemHtml += "" - }).join(""), html += "
", elem.querySelector(".filterOptions").innerHTML = html + html += '
'; + html += items.map(function (filter) { + var itemHtml = ""; + var checkedHtml = isCheckedFn(filter) ? " checked" : ""; + itemHtml += ""; + return itemHtml; + }).join(""); + html += "
"; + elem.querySelector(".filterOptions").innerHTML = html; } function renderFilters(context, result, query) { - result.Tags && (result.Tags.length = Math.min(result.Tags.length, 50)), renderOptions(context, ".genreFilters", "chkGenreFilter", result.Genres, function(i) { - return -1 != ("|" + (query.Genres || "") + "|").indexOf("|" + i + "|") - }), renderOptions(context, ".officialRatingFilters", "chkOfficialRatingFilter", result.OfficialRatings, function(i) { - return -1 != ("|" + (query.OfficialRatings || "") + "|").indexOf("|" + i + "|") - }), renderOptions(context, ".tagFilters", "chkTagFilter", result.Tags, function(i) { - return -1 != ("|" + (query.Tags || "") + "|").indexOf("|" + i + "|") - }), renderOptions(context, ".yearFilters", "chkYearFilter", result.Years, function(i) { - return -1 != ("," + (query.Years || "") + ",").indexOf("," + i + ",") - }) + if (result.Tags) { + result.Tags.length = Math.min(result.Tags.length, 50); + } + renderOptions(context, ".genreFilters", "chkGenreFilter", result.Genres, function (i) { + var delimeter = "|"; + return (delimeter + (query.Genres || "") + delimeter).indexOf(delimeter + i + delimeter) != -1; + }); + renderOptions(context, ".officialRatingFilters", "chkOfficialRatingFilter", result.OfficialRatings, function (i) { + var delimeter = "|"; + return (delimeter + (query.OfficialRatings || "") + delimeter).indexOf(delimeter + i + delimeter) != -1; + }); + renderOptions(context, ".tagFilters", "chkTagFilter", result.Tags, function (i) { + var delimeter = "|"; + return (delimeter + (query.Tags || "") + delimeter).indexOf(delimeter + i + delimeter) != -1; + }); + renderOptions(context, ".yearFilters", "chkYearFilter", result.Years, function (i) { + var delimeter = ","; + return (delimeter + (query.Years || "") + delimeter).indexOf(delimeter + i + delimeter) != -1; + }); + renderOptions(context, ".audioLanguagesFilters", "chkAudioLanguagesFilter", result.AudioLanguages, function (i) { + var delimeter = ","; + return (delimeter + (query.AudioLanguages || "") + delimeter).indexOf(delimeter + i + delimeter) != -1; + }); } function loadDynamicFilters(context, apiClient, userId, itemQuery) { @@ -29,170 +54,361 @@ define(["dialogHelper", "globalize", "connectionManager", "events", "browser", " UserId: userId, ParentId: itemQuery.ParentId, IncludeItemTypes: itemQuery.IncludeItemTypes - })).then(function(result) { - renderFilters(context, result, itemQuery) - }) + })).then(function (result) { + renderFilters(context, result, itemQuery); + }); } function updateFilterControls(context, options) { - var elems, i, length, query = options.query; - if ("livetvchannels" == options.mode) context.querySelector(".chkFavorite").checked = 1 == query.IsFavorite, context.querySelector(".chkLikes").checked = 1 == query.IsLiked, context.querySelector(".chkDislikes").checked = 1 == query.IsDisliked; - else - for (elems = context.querySelectorAll(".chkStandardFilter"), i = 0, length = elems.length; i < length; i++) { - var chkStandardFilter = elems[i], - filters = "," + (query.Filters || ""), - filterName = chkStandardFilter.getAttribute("data-filter"); - chkStandardFilter.checked = -1 != filters.indexOf("," + filterName) + var elems; + var i; + var length; + var 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; + } 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 (elems = context.querySelectorAll(".chkVideoTypeFilter"), i = 0, length = elems.length; i < length; i++) { - var chkVideoTypeFilter = elems[i], - filters = "," + (query.VideoTypes || ""), - filterName = chkVideoTypeFilter.getAttribute("data-filter"); - chkVideoTypeFilter.checked = -1 != filters.indexOf("," + filterName) } - for (context.querySelector(".chk3DFilter").checked = 1 == query.Is3D, context.querySelector(".chkHDFilter").checked = 1 == query.IsHD, context.querySelector(".chk4KFilter").checked = 1 == query.Is4K, context.querySelector(".chkSDFilter").checked = 1 == query.IsHD, context.querySelector("#chkSubtitle").checked = 1 == query.HasSubtitles, context.querySelector("#chkTrailer").checked = 1 == query.HasTrailer, context.querySelector("#chkThemeSong").checked = 1 == query.HasThemeSong, context.querySelector("#chkThemeVideo").checked = 1 == query.HasThemeVideo, context.querySelector("#chkSpecialFeature").checked = 1 == query.HasSpecialFeature, context.querySelector("#chkSpecialEpisode").checked = 0 == query.ParentIndexNumber, context.querySelector("#chkMissingEpisode").checked = 1 == query.IsMissing, context.querySelector("#chkFutureEpisode").checked = 1 == query.IsUnaired, i = 0, length = elems.length; i < length; i++) { - var chkStatus = elems[i], - filters = "," + (query.SeriesStatus || ""), - filterName = chkStatus.getAttribute("data-filter"); - chkStatus.checked = -1 != filters.indexOf("," + 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; + } + 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; } } function triggerChange(instance) { - events.trigger(instance, "filterchange") + events.trigger(instance, "filterchange"); } function parentWithClass(elem, className) { - for (; !elem.classList || !elem.classList.contains(className);) - if (!(elem = elem.parentNode)) return null; - return elem + while (!elem.classList || !elem.classList.contains(className)) { + elem = elem.parentNode; + if (!elem) { + return null; + } + } + return elem; } function setVisibility(context, options) { - "livetvchannels" != options.mode && "albums" != options.mode && "artists" != options.mode && "albumartists" != options.mode && "songs" != options.mode || hideByClass(context, "videoStandard"), 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")), "movies" != options.mode && "episodes" != options.mode || context.querySelector(".videoTypeFilters").classList.remove("hide"), options.mode, "movies" != options.mode && "series" != options.mode && "episodes" != options.mode || context.querySelector(".features").classList.remove("hide"), "series" == options.mode && context.querySelector(".seriesStatus").classList.remove("hide"), "episodes" == options.mode && showByClass(context, "episodeFilter") + 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"); + } + + 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 == "series") { + context.querySelector(".seriesStatus").classList.remove("hide"); + } + + if (options.mode == "episodes") { + showByClass(context, "episodeFilter"); + } } function showByClass(context, className) { - for (var elems = context.querySelectorAll("." + className), i = 0, length = elems.length; i < length; i++) elems[i].classList.remove("hide") + var elems = context.querySelectorAll("." + className); + + for (var i = 0, length = elems.length; i < length; i++) { + elems[i].classList.remove("hide"); + } } function hideByClass(context, className) { - for (var elems = context.querySelectorAll("." + className), i = 0, length = elems.length; i < length; i++) elems[i].classList.add("hide") + var elems = context.querySelectorAll("." + className); + + for (var i = 0, length = elems.length; i < length; i++) { + elems[i].classList.add("hide"); + } } function enableDynamicFilters(mode) { - return "movies" == mode || "series" == mode || "albums" == mode || "albumartists" == mode || "artists" == mode || "songs" == mode || "episodes" == mode + return mode == "movies" || mode == "series" || mode == "albums" || mode == "albumartists" || mode == "artists" || mode == "songs" || mode == "episodes"; } - return function(options) { + + return function (options) { function onFavoriteChange() { var query = options.query; - query.StartIndex = 0, query.IsFavorite = !!this.checked || null, triggerChange(self) + query.StartIndex = 0; + query.IsFavorite = !!this.checked || null; + triggerChange(self); } function onStandardFilterChange() { - var query = options.query, - filterName = this.getAttribute("data-filter"), - filters = query.Filters || ""; - filters = ("," + filters).replace("," + filterName, "").substring(1), this.checked && (filters = filters ? filters + "," + filterName : filterName), query.StartIndex = 0, query.Filters = filters, triggerChange(self) + var query = options.query; + var filterName = this.getAttribute("data-filter"); + var filters = query.Filters || ""; + filters = ("," + filters).replace("," + filterName, "").substring(1); + + if (this.checked) { + filters = filters ? filters + "," + filterName : filterName; + } + + query.StartIndex = 0; + query.Filters = filters; + triggerChange(self); } function onVideoTypeFilterChange() { - var query = options.query, - filterName = this.getAttribute("data-filter"), - filters = query.VideoTypes || ""; - filters = ("," + filters).replace("," + filterName, "").substring(1), this.checked && (filters = filters ? filters + "," + filterName : filterName), query.StartIndex = 0, query.VideoTypes = filters, triggerChange(self) + var query = options.query; + var filterName = this.getAttribute("data-filter"); + var filters = query.VideoTypes || ""; + filters = ("," + filters).replace("," + filterName, "").substring(1); + + if (this.checked) { + filters = filters ? filters + "," + filterName : filterName; + } + + query.StartIndex = 0; + query.VideoTypes = filters; + triggerChange(self); } function onStatusChange() { - var query = options.query, - filterName = this.getAttribute("data-filter"), - filters = query.SeriesStatus || ""; - filters = ("," + filters).replace("," + filterName, "").substring(1), this.checked && (filters = filters ? filters + "," + filterName : filterName), query.SeriesStatus = filters, query.StartIndex = 0, triggerChange(self) + var query = options.query; + var filterName = this.getAttribute("data-filter"); + var filters = query.SeriesStatus || ""; + filters = ("," + filters).replace("," + filterName, "").substring(1); + + if (this.checked) { + filters = filters ? filters + "," + filterName : filterName; + } + + query.SeriesStatus = filters; + query.StartIndex = 0; + triggerChange(self); } function bindEvents(context) { - var elems, i, length, query = options.query; - if ("livetvchannels" == options.mode) { - for (elems = context.querySelectorAll(".chkFavorite"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("change", onFavoriteChange); - context.querySelector(".chkLikes").addEventListener("change", function() { - query.StartIndex = 0, query.IsLiked = !!this.checked || null, triggerChange(self) - }), context.querySelector(".chkDislikes").addEventListener("change", function() { - query.StartIndex = 0, query.IsDisliked = !!this.checked || null, triggerChange(self) - }) - } else - for (elems = context.querySelectorAll(".chkStandardFilter"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("change", onStandardFilterChange); - for (elems = context.querySelectorAll(".chkVideoTypeFilter"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("change", onVideoTypeFilterChange); - for (context.querySelector(".chk3DFilter").addEventListener("change", function() { - query.StartIndex = 0, query.Is3D = !!this.checked || null, triggerChange(self) - }), context.querySelector(".chk4KFilter").addEventListener("change", function() { - query.StartIndex = 0, query.Is4K = !!this.checked || null, triggerChange(self) - }), context.querySelector(".chkHDFilter").addEventListener("change", function() { - query.StartIndex = 0, query.IsHD = !!this.checked || null, triggerChange(self) - }), context.querySelector(".chkSDFilter").addEventListener("change", function() { - query.StartIndex = 0, query.IsHD = !this.checked && null, triggerChange(self) - }), elems = context.querySelectorAll(".chkStatus"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("change", onStatusChange); - context.querySelector("#chkTrailer").addEventListener("change", function() { - query.StartIndex = 0, query.HasTrailer = !!this.checked || null, triggerChange(self) - }), context.querySelector("#chkThemeSong").addEventListener("change", function() { - query.StartIndex = 0, query.HasThemeSong = !!this.checked || null, triggerChange(self) - }), context.querySelector("#chkSpecialFeature").addEventListener("change", function() { - query.StartIndex = 0, query.HasSpecialFeature = !!this.checked || null, triggerChange(self) - }), context.querySelector("#chkThemeVideo").addEventListener("change", function() { - query.StartIndex = 0, query.HasThemeVideo = !!this.checked || null, triggerChange(self) - }), context.querySelector("#chkMissingEpisode").addEventListener("change", function() { - query.StartIndex = 0, this.checked ? (query.IsMissing = !0, query.IsUnaired = !1) : (query.IsMissing = !1, query.IsUnaired = context.querySelector("#chkFutureEpisode").checked || null), triggerChange(self) - }), context.querySelector("#chkSpecialEpisode").addEventListener("change", function() { - query.StartIndex = 0, query.ParentIndexNumber = this.checked ? 0 : null, triggerChange(self) - }), context.querySelector("#chkFutureEpisode").addEventListener("change", function() { - query.StartIndex = 0, this.checked ? (query.IsUnaired = !0, query.IsMissing = null) : (query.IsUnaired = null, query.IsMissing = context.querySelector("#chkMissingEpisode").checked), triggerChange(self) - }), context.querySelector("#chkSubtitle").addEventListener("change", function() { - query.StartIndex = 0, query.HasSubtitles = !!this.checked || null, triggerChange(self) - }), context.addEventListener("change", function(e) { + var elems; + var i; + var length; + var query = options.query; + + if (options.mode == "livetvchannels") { + elems = context.querySelectorAll(".chkFavorite"); + for (i = 0, length = elems.length; i < length; i++) { + elems[i].addEventListener("change", onFavoriteChange); + } + context.querySelector(".chkLikes").addEventListener("change", function () { + query.StartIndex = 0; + query.IsLiked = this.checked ? true : null; + triggerChange(self); + }); + context.querySelector(".chkDislikes").addEventListener("change", function () { + query.StartIndex = 0; + query.IsDisliked = this.checked ? true : null; + triggerChange(self); + }); + } else { + elems = context.querySelectorAll(".chkStandardFilter"); + for (i = 0, length = elems.length; i < length; i++) { + elems[i].addEventListener("change", onStandardFilterChange); + } + } + elems = context.querySelectorAll(".chkVideoTypeFilter"); + for (i = 0, length = elems.length; i < length; i++) { + elems[i].addEventListener("change", onVideoTypeFilterChange); + } + context.querySelector(".chk3DFilter").addEventListener("change", function () { + query.StartIndex = 0; + query.Is3D = this.checked ? true : null; + triggerChange(self); + }); + context.querySelector(".chk4KFilter").addEventListener("change", function () { + query.StartIndex = 0; + query.Is4K = this.checked ? true : null; + triggerChange(self); + }); + context.querySelector(".chkHDFilter").addEventListener("change", function () { + query.StartIndex = 0; + query.IsHD = this.checked ? true : null; + triggerChange(self); + }); + context.querySelector(".chkSDFilter").addEventListener("change", function () { + query.StartIndex = 0; + query.IsHD = this.checked ? false : null; + triggerChange(self); + }); + elems = context.querySelectorAll(".chkStatus"); + for (i = 0, length = elems.length; i < length; i++) { + elems[i].addEventListener("change", onStatusChange); + } + context.querySelector("#chkTrailer").addEventListener("change", function () { + query.StartIndex = 0; + query.HasTrailer = this.checked ? true : null; + triggerChange(self); + }); + context.querySelector("#chkThemeSong").addEventListener("change", function () { + query.StartIndex = 0; + query.HasThemeSong = this.checked ? true : null; + triggerChange(self); + }); + context.querySelector("#chkSpecialFeature").addEventListener("change", function () { + query.StartIndex = 0; + query.HasSpecialFeature = this.checked ? true : null; + triggerChange(self); + }); + context.querySelector("#chkThemeVideo").addEventListener("change", function () { + query.StartIndex = 0; + query.HasThemeVideo = this.checked ? true : null; + triggerChange(self); + }); + context.querySelector("#chkMissingEpisode").addEventListener("change", function () { + query.StartIndex = 0; + query.IsMissing = this.checked ? true : false; + triggerChange(self); + }); + context.querySelector("#chkSpecialEpisode").addEventListener("change", function () { + query.StartIndex = 0; + query.ParentIndexNumber = this.checked ? 0 : null; + triggerChange(self); + }); + context.querySelector("#chkFutureEpisode").addEventListener("change", function () { + query.StartIndex = 0; + if (this.checked) { + query.IsUnaired = true; + query.IsVirtualUnaired = null; + } else { + query.IsUnaired = null; + query.IsVirtualUnaired = false; + } + triggerChange(self); + }); + context.querySelector("#chkSubtitle").addEventListener("change", function () { + query.StartIndex = 0; + query.HasSubtitles = this.checked ? true : null; + triggerChange(self); + }); + context.addEventListener("change", function (e) { var chkGenreFilter = parentWithClass(e.target, "chkGenreFilter"); if (chkGenreFilter) { - var filterName = chkGenreFilter.getAttribute("data-filter"), - filters = query.Genres || "", - delimiter = "|"; - return filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1), chkGenreFilter.checked && (filters = filters ? filters + delimiter + filterName : filterName), query.StartIndex = 0, query.Genres = filters, void triggerChange(self) + var filterName = chkGenreFilter.getAttribute("data-filter"); + var filters = query.Genres || ""; + var 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); + return; } var chkTagFilter = parentWithClass(e.target, "chkTagFilter"); if (chkTagFilter) { - var filterName = chkTagFilter.getAttribute("data-filter"), - filters = query.Tags || "", - delimiter = "|"; - return filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1), chkTagFilter.checked && (filters = filters ? filters + delimiter + filterName : filterName), query.StartIndex = 0, query.Tags = filters, void triggerChange(self) + var filterName = chkTagFilter.getAttribute("data-filter"); + var filters = query.Tags || ""; + var 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); + return; } var chkYearFilter = parentWithClass(e.target, "chkYearFilter"); if (chkYearFilter) { - var filterName = chkYearFilter.getAttribute("data-filter"), - filters = query.Years || "", - delimiter = ","; - return filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1), chkYearFilter.checked && (filters = filters ? filters + delimiter + filterName : filterName), query.StartIndex = 0, query.Years = filters, void triggerChange(self) + var filterName = chkYearFilter.getAttribute("data-filter"); + var filters = query.Years || ""; + var 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); + return; } var chkOfficialRatingFilter = parentWithClass(e.target, "chkOfficialRatingFilter"); if (chkOfficialRatingFilter) { - var filterName = chkOfficialRatingFilter.getAttribute("data-filter"), - filters = query.OfficialRatings || "", - delimiter = "|"; - return filters = (delimiter + filters).replace(delimiter + filterName, "").substring(1), chkOfficialRatingFilter.checked && (filters = filters ? filters + delimiter + filterName : filterName), query.StartIndex = 0, query.OfficialRatings = filters, void triggerChange(self) + var filterName = chkOfficialRatingFilter.getAttribute("data-filter"); + var filters = query.OfficialRatings || ""; + var 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; } - }) + }); } + var self = this; - self.show = function() { - return new Promise(function(resolve, reject) { - require(["text!./filterdialog.template.html"], function(template) { + + self.show = function () { + return new Promise(function (resolve, reject) { + require(["text!./filterdialog.template.html"], function (template) { var dlg = dialogHelper.createDialog({ - removeOnClose: !0, - modal: !1 + removeOnClose: true, + modal: false }); - if (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), dialogHelper.open(dlg), dlg.addEventListener("close", resolve), updateFilterControls(dlg, options), bindEvents(dlg), enableDynamicFilters(options.mode)) { + 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); + 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) + loadDynamicFilters(dlg, apiClient, apiClient.getCurrentUserId(), options.query); } - }) - }) - } - } + }); + }); + }; + }; }); From 51bbe65262542e616a788e46bab45ccb13889bce Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Fri, 13 Sep 2019 19:44:30 +0300 Subject: [PATCH 3/4] remove audio language filter --- src/components/filterdialog/filterdialog.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/filterdialog/filterdialog.js b/src/components/filterdialog/filterdialog.js index 289242e9c1..7301c65669 100644 --- a/src/components/filterdialog/filterdialog.js +++ b/src/components/filterdialog/filterdialog.js @@ -43,10 +43,6 @@ define(["dialogHelper", "globalize", "connectionManager", "events", "browser", " var delimeter = ","; return (delimeter + (query.Years || "") + delimeter).indexOf(delimeter + i + delimeter) != -1; }); - renderOptions(context, ".audioLanguagesFilters", "chkAudioLanguagesFilter", result.AudioLanguages, function (i) { - var delimeter = ","; - return (delimeter + (query.AudioLanguages || "") + delimeter).indexOf(delimeter + i + delimeter) != -1; - }); } function loadDynamicFilters(context, apiClient, userId, itemQuery) { From 97a5f84ced1ee0dad9f19953a68fc5f86752b7b5 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Fri, 13 Sep 2019 20:50:22 +0300 Subject: [PATCH 4/4] make headerfilters and headerstatus collapsible --- .../filterdialog/filterdialog.template.html | 120 +++++++++--------- src/components/filterdialog/style.css | 4 +- 2 files changed, 65 insertions(+), 59 deletions(-) diff --git a/src/components/filterdialog/filterdialog.template.html b/src/components/filterdialog/filterdialog.template.html index 3f334a009f..20f0f2fc91 100644 --- a/src/components/filterdialog/filterdialog.template.html +++ b/src/components/filterdialog/filterdialog.template.html @@ -1,62 +1,67 @@
-

- ${HeaderFilters} -

-
- - - - - - - - - -
-
-
-

- ${HeaderStatus} -

-
- - + +
+
+
+ + + + + + + + + +
+
+
+ +
+
+
+ + +
-
@@ -104,7 +109,8 @@