From f7f83f08d4e24e973bd2d7caff8559b53bced0fd Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Sun, 22 Dec 2019 16:32:11 +0300 Subject: [PATCH] Add show/hide backdrop --- src/controllers/itemdetailpage.js | 38 +++++++++++++++++++++++++++++++ src/itemdetails.html | 29 +++++++++++++++++------ src/strings/en-us.json | 2 ++ 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/src/controllers/itemdetailpage.js b/src/controllers/itemdetailpage.js index 523b6faf55..8f68009572 100644 --- a/src/controllers/itemdetailpage.js +++ b/src/controllers/itemdetailpage.js @@ -463,12 +463,18 @@ define(["loading", "appRouter", "layoutManager", "userSettings", "connectionMana var imgUrl; var screenWidth = screen.availWidth; var hasbackdrop = false; + var backdropWrapper = page.querySelector(".backdropWrapper"); var itemBackdropElement = page.querySelector("#itemBackdrop"); + var btnBackdropShow = page.querySelector(".btnBackdropShow"); var usePrimaryImage = item.MediaType === "Video" && item.Type !== "Movie" && item.Type !== "Trailer" || item.MediaType && item.MediaType !== "Video" || item.Type === "MusicAlbum" || item.Type === "MusicArtist"; + if (layoutManager.mobile) { + backdropWrapper.classList.remove("hide"); + } + if ("Program" === item.Type && item.ImageTags && item.ImageTags.Thumb) { imgUrl = apiClient.getScaledImageUrl(item.Id, { type: "Thumb", @@ -476,6 +482,7 @@ define(["loading", "appRouter", "layoutManager", "userSettings", "connectionMana tag: item.ImageTags.Thumb }); itemBackdropElement.classList.remove("noBackdrop"); + btnBackdropShow.classList.remove("hide"); imageLoader.lazyImage(itemBackdropElement, imgUrl, false); hasbackdrop = true; } else if (usePrimaryImage && item.ImageTags && item.ImageTags.Primary) { @@ -485,6 +492,7 @@ define(["loading", "appRouter", "layoutManager", "userSettings", "connectionMana tag: item.ImageTags.Primary }); itemBackdropElement.classList.remove("noBackdrop"); + btnBackdropShow.classList.remove("hide"); imageLoader.lazyImage(itemBackdropElement, imgUrl, false); hasbackdrop = true; } else if (item.BackdropImageTags && item.BackdropImageTags.length) { @@ -494,6 +502,7 @@ define(["loading", "appRouter", "layoutManager", "userSettings", "connectionMana tag: item.BackdropImageTags[0] }); itemBackdropElement.classList.remove("noBackdrop"); + btnBackdropShow.classList.remove("hide"); imageLoader.lazyImage(itemBackdropElement, imgUrl, false); hasbackdrop = true; } else if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) { @@ -503,6 +512,7 @@ define(["loading", "appRouter", "layoutManager", "userSettings", "connectionMana tag: item.ParentBackdropImageTags[0] }); itemBackdropElement.classList.remove("noBackdrop"); + btnBackdropShow.classList.remove("hide"); imageLoader.lazyImage(itemBackdropElement, imgUrl, false); hasbackdrop = true; } else if (item.ImageTags && item.ImageTags.Thumb) { @@ -512,10 +522,12 @@ define(["loading", "appRouter", "layoutManager", "userSettings", "connectionMana tag: item.ImageTags.Thumb }); itemBackdropElement.classList.remove("noBackdrop"); + btnBackdropShow.classList.remove("hide"); imageLoader.lazyImage(itemBackdropElement, imgUrl, false); hasbackdrop = true; } else { itemBackdropElement.classList.add("noBackdrop"); + btnBackdropShow.classList.add("hide"); itemBackdropElement.style.backgroundImage = ""; } @@ -1913,6 +1925,26 @@ define(["loading", "appRouter", "layoutManager", "userSettings", "connectionMana }); } + function showBackdrop(instance, page, apiClient, params) { + var backdropWrapper = page.querySelector(".backdropWrapper"); + var btnBackdropHide = page.querySelector(".btnBackdropHide"); + var btnBackdropShow = page.querySelector(".btnBackdropShow"); + + backdropWrapper.classList.remove("hide"); + btnBackdropHide.classList.remove("hide"); + btnBackdropShow.classList.add("hide"); + } + + function hideBackdrop(instance, page, apiClient, params) { + var backdropWrapper = page.querySelector(".backdropWrapper"); + var btnBackdropHide = page.querySelector(".btnBackdropHide"); + var btnBackdropShow = page.querySelector(".btnBackdropShow"); + + backdropWrapper.classList.add("hide"); + btnBackdropHide.classList.add("hide"); + btnBackdropShow.classList.remove("hide"); + } + function getPlayOptions(startPosition) { var audioStreamIndex = view.querySelector(".selectAudio").value || null; return { @@ -2076,6 +2108,12 @@ define(["loading", "appRouter", "layoutManager", "userSettings", "connectionMana renderAudioSelections(view, self._currentPlaybackMediaSources); renderSubtitleSelections(view, self._currentPlaybackMediaSources); }); + view.querySelector(".btnBackdropShow").addEventListener("click", function () { + showBackdrop(self, view, apiClient, params); + }); + view.querySelector(".btnBackdropHide").addEventListener("click", function () { + hideBackdrop(self, view, apiClient, params); + }); view.addEventListener("click", function (e) { if (dom.parentWithClass(e.target, "moreScenes")) { apiClient.getCurrentUser().then(function (user) { diff --git a/src/itemdetails.html b/src/itemdetails.html index c210bdf216..79ddd67480 100644 --- a/src/itemdetails.html +++ b/src/itemdetails.html @@ -1,13 +1,14 @@
-
- +
+
+ +
+ +
- - -
@@ -109,6 +110,20 @@
${ButtonMore}
+ + + +
diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 2edeb69e88..e2d7cfba89 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -84,6 +84,7 @@ "ButtonGotIt": "Got It", "ButtonGuide": "Guide", "ButtonHelp": "Help", + "ButtonHide": "Hide", "ButtonHome": "Home", "ButtonInfo": "Info", "ButtonLearnMore": "Learn more", @@ -120,6 +121,7 @@ "ButtonSelectView": "Select view", "ButtonSend": "Send", "ButtonSettings": "Settings", + "ButtonShow": "Show", "ButtonShuffle": "Shuffle", "ButtonShutdown": "Shutdown", "ButtonSignIn": "Sign In",