diff --git a/dashboard-ui/bower_components/emby-webcomponents/cardbuilder/cardbuilder.js b/dashboard-ui/bower_components/emby-webcomponents/cardbuilder/cardbuilder.js index 318094d044..8aabaa6c7d 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/cardbuilder/cardbuilder.js +++ b/dashboard-ui/bower_components/emby-webcomponents/cardbuilder/cardbuilder.js @@ -429,15 +429,13 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'mediaInfo if (options.autoThumb && item.ImageTags && item.ImageTags.Primary && item.PrimaryImageAspectRatio && item.PrimaryImageAspectRatio >= 1.34) { - width = posterWidth; - height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null; + height = primaryImageAspectRatio ? Math.round(width / primaryImageAspectRatio) : null; imgUrl = ApiClient.getScaledImageUrl(item.Id, { type: "Primary", maxHeight: height, maxWidth: width, - tag: item.ImageTags.Primary, - enableImageEnhancers: enableImageEnhancers + tag: item.ImageTags.Primary }); if (primaryImageAspectRatio) { @@ -452,9 +450,8 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'mediaInfo imgUrl = ApiClient.getScaledImageUrl(item.Id, { type: "Thumb", - maxWidth: thumbWidth, - tag: item.ImageTags.Thumb, - enableImageEnhancers: enableImageEnhancers + maxWidth: width, + tag: item.ImageTags.Thumb }); } else if (options.preferThumb && item.ImageTags && item.ImageTags.Thumb) { diff --git a/dashboard-ui/channelitems.html b/dashboard-ui/channelitems.html index 0627264b30..89a8f2e070 100644 --- a/dashboard-ui/channelitems.html +++ b/dashboard-ui/channelitems.html @@ -6,6 +6,6 @@
-
+
\ No newline at end of file diff --git a/dashboard-ui/channels.html b/dashboard-ui/channels.html index 77dbcaf665..a8a0cfacf9 100644 --- a/dashboard-ui/channels.html +++ b/dashboard-ui/channels.html @@ -10,7 +10,7 @@
-
+
diff --git a/dashboard-ui/components/favoriteitems.js b/dashboard-ui/components/favoriteitems.js index c65c5b8a73..ae2e8898df 100644 --- a/dashboard-ui/components/favoriteitems.js +++ b/dashboard-ui/components/favoriteitems.js @@ -1,4 +1,4 @@ -define(['libraryBrowser', 'scrollStyles', 'emby-itemscontainer'], function (libraryBrowser) { +define(['libraryBrowser', 'cardBuilder', 'scrollStyles', 'emby-itemscontainer'], function (libraryBrowser, cardBuilder) { function enableScrollX() { return browserInfo.mobile && AppInfo.enableAppLayouts; @@ -85,23 +85,20 @@ if (enableScrollX()) { html += '
'; } else { - html += '
'; + html += '
'; } - html += libraryBrowser.getPosterViewHtml({ - items: result.Items, + html += cardBuilder.getCardsHtml(result.Items, { preferThumb: section.preferThumb, shape: section.shape, + centerText: section.centerText, overlayText: section.overlayText !== false, showTitle: section.showTitle, showParentTitle: section.showParentTitle, - lazy: true, - showDetailsMenu: true, - centerText: section.centerText, + scalable: true, overlayPlayButton: section.overlayPlayButton, overlayMoreButton: section.overlayMoreButton, - context: 'home-favorites', - defaultAction: section.defaultAction + action: section.defaultAction }); html += '
'; diff --git a/dashboard-ui/css/card.css b/dashboard-ui/css/card.css deleted file mode 100644 index da01eb1160..0000000000 --- a/dashboard-ui/css/card.css +++ /dev/null @@ -1,571 +0,0 @@ -.card { - display: inline-block; - text-align: left; - position: relative; - contain: style; -} - .card, .card a { - text-decoration: none; - font-weight: 400 !important; - } - -.buttonCard:hover .cardBox { - opacity: .6; -} - -.cardBox { - margin: 6px; -} - -@media all and (max-width: 500px) { - - .cardBox { - margin: 3px; - } -} - -.cardOverlayButtonContainer { - position: absolute; - bottom: 0; - right: 0; - padding: 1em .25em .5em 1em; -} - -.cardOverlayMoreButton, .cardOverlayPlayButton { - color: #fff !important; - background-color: rgba(0,0,0,.7) !important; - border-radius: 500px; -} - - .cardOverlayMoreButton:hover, .cardOverlayPlayButton:hover { - background-color: rgba(0,0,0,.9) !important; - transition: background-color .5s ease-out; - } - -.grayscale { - -webkit-filter: grayscale(100%); - -moz-filter: grayscale(100%); - filter: grayscale(100%); -} - -.bottomPaddedCard .cardBox:not(.visualCardBox) { - margin-bottom: 24px; -} - -.hiddenScrollX .bottomPaddedCard .cardBox { - margin-bottom: 0; -} - -.visualCardBox { - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - border-radius: 2px; - -moz-box-shadow: 0 2px 4px rgba(0,0,0,0.1); - -ms-box-shadow: 0 2px 4px rgba(0,0,0,0.1); - -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.1); - box-shadow: 0 2px 4px rgba(0,0,0,0.1); - background: #fff; -} - -.ui-body-b .visualCardBox { - border-radius: 3px; -} - -.defaultBackground .cardImage, .ui-body-b .visualCardBox { - background-color: #222326; -} - -.cardScalable { - position: relative; -} - -.backdropCard .cardPadder, .smallBackdropCard .cardPadder, .overflowBackdropCard .cardPadder { - padding-bottom: 56.25%; -} - -.squareCard .cardPadder, .overflowSquareCard .cardPadder { - padding-bottom: 100%; -} - -.letterBoxCard .cardPadder { - padding-bottom: 75%; -} - -.portraitCard .cardPadder, .overflowPortraitCard .cardPadder { - padding-bottom: 150%; -} - -.bannerCard .cardPadder { - padding-bottom: 18.5%; -} - -.cardContent { - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - /* Needed to keep the cardOverlayTarget from showing outside the bounds while it animates */ - overflow: hidden; -} - - .cardContent:not(.noHoverEffect):hover .cardImage { - opacity: .5; - } - - .cardContent .cardFooter { - position: absolute; - bottom: 0; - left: 0; - color: #eee; - padding: 6px 0 2px 0; - max-width: 100%; - background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.7) 100%) !important; /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0)), color-stop(100%,rgba(0,0,0,0.7))) !important; /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.7) 100%) !important; /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.7) 100%) !important; /* Opera 11.10+ */ - background: -ms-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.7) 100%) !important; /* IE10+ */ - background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.75) 100%) !important; /* W3C */ - } - - .cardContent .cardFooter:not(.fullCardFooter) { - background: rgba(0, 0, 0, .6) !important; - } - -.lightCardFooter { - background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.7) 100%) !important; /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0)), color-stop(100%,rgba(0,0,0,0.7))) !important; /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.7) 100%) !important; /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.7) 100%) !important; /* Opera 11.10+ */ - background: -ms-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.7) 100%) !important; /* IE10+ */ - background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.7) 100%) !important; /* W3C */ -} - -.fullCardFooter { - right: 0; -} - -.visualCardBox .outerCardFooter { - padding: .5em .3em; - position: relative; -} - -.btnCardOptions { - padding: 10px !important; - margin: 0 !important; - color: inherit; -} - -.cardText { - text-overflow: ellipsis; - overflow: hidden; - text-wrap: none; - white-space: nowrap; - padding: 5px 5px 2px; - font-weight: 400; - line-height: 1.4; -} - -.cardButtonContainer { - text-align: right; - float: right; - padding: 5px 0 2px; -} - -.cardContent .cardFooter .cardText { - font-size: 115%; -} - -.cardTextCentered { - text-align: center; -} - -.cardDefaultText { - position: absolute; - top: 30%; - left: 0; - right: 0; - text-align: center; - line-height: initial; -} - -.cardContent .cardText { - padding: 0 6px 4px 5px; -} - -.outerCardFooter .cardText + .cardText { - opacity: .6; -} - -.outerCardFooter .cardText:first-child { - padding-top: 7px; -} - -.cardImage { - background-size: contain; - background-repeat: no-repeat; - background-position: center bottom; - width: 100%; - height: 100%; - border-radius: 2px; -} - - .cardImage canvas { - width: 100%; - height: 100%; - } - -.coveredCardImage { - background-size: 100% 100%; - background-position: center center; -} - - .coveredCardImage.noScale { - background-size: cover; - } - -.centeredCardImage { - background-position: center center; -} - -.ui-body-b .iconCardImage { - color: #fff; -} - -.iconCardImage { - display: flex; - align-items: center; - text-align: center; - justify-content: center; -} - - .iconCardImage iron-icon { - width: 30%; - height: 30%; - } - -.bannerCard { - width: 100%; -} - -.squareCard { - width: 50%; -} - -.backdropCard { - width: 50%; -} - -.smallBackdropCard { - width: 50%; -} - -.portraitCard { - width: 33.333%; -} - -.overflowPortraitCard { - width: 40%; - max-width: 200px; -} - -.overflowBackdropCard { - width: 84%; - max-width: 400px; -} - -.cardProgress { - line-height: 7px; -} - - .cardProgress .itemProgressBar { - height: 7px; - width: 100%; - opacity: .8; - } - -.overflowSquareCard { - width: 42%; -} - -@media all and (max-width: 420px) { - - .backdropCard { - width: 100% !important; - } -} - -@media all and (min-width: 500px) { - - .smallBackdropCard { - width: 33.333%; - } - - .squareCard { - width: 33.333%; - } -} - -@media all and (min-width: 640px) { - - .portraitCard { - width: 25%; - } - - .overflowPortraitCard { - width: 36%; - } - - .overflowBackdropCard { - width: 60%; - } - - .overflowSquareCard { - width: 30%; - } -} - -@media all and (min-width: 700px) { - .squareCard { - width: 25%; - } -} - -@media all and (min-width: 770px) { - .backdropCard { - width: 33.333%; - } -} - -@media all and (min-width: 800px) { - - .bannerCard { - width: 50%; - } - - .portraitCard { - width: 20%; - } - - .smallBackdropCard { - width: 25%; - } -} - - -@media all and (min-width: 900px) { - - .squareCard { - width: 20%; - } -} - -@media all and (min-width: 1000px) { - - - .smallBackdropCard { - width: 20%; - } - - .overflowPortraitCard { - width: 23%; - } - - .overflowBackdropCard { - width: 40%; - } - - .overflowSquareCard { - width: 22%; - } -} - - -@media all and (min-width: 1200px) { - - .backdropCard { - width: 25%; - } - - .squareCard { - width: 16.666666666666666666666666666667%; - } - - .bannerCard { - width: 33.333%; - } - - .portraitCard { - width: 16.666666666666666666666666666667%; - } - - .smallBackdropCard { - width: 16.666666666666666666666666666667%; - } -} - - -@media all and (min-width: 1400px) { - - .squareCard { - width: 14.285714285714285714285714285714%; - } - - .portraitCard { - width: 14.285714285714285714285714285714%; - } - - .smallBackdropCard { - width: 14.285714285714285714285714285714%; - } -} - - -@media all and (min-width: 1600px) { - - .portraitCard { - width: 12.5%; - } - - .smallBackdropCard { - width: 12.5%; - } -} - - -@media all and (min-width: 1800px) { - - .squareCard { - width: 12.5%; - } - - .smallBackdropCard { - width: 10%; - } -} - -@media all and (min-width: 2100px) { - - .squareCard { - width: 11.111111111111111111111111111111%; - } - - .backdropCard { - width: 20%; - } - - .portraitCard { - width: 11.111111111111111111111111111111%; - } -} - -@media all and (min-width: 2200px) { - - .bannerCard { - width: 25%; - } - - .portraitCard { - width: 10%; - } -} - -@media all and (min-width: 2500px) { - - .backdropCard { - width: 16.666666666666666666666666666667%; - } -} - - -/** detailPage169 */ -.detailPage169Card .cardPadder { - padding-bottom: 56.25%; -} - - -.detailPage169Card { - width: 50%; -} - -@media all and (min-width: 800px) { - - .detailPage169Card { - width: 33.333%; - } -} - -@media all and (max-width: 420px) { - - .detailPage169Card { - width: 100% !important; - } -} - - -/** detailPagePortrait */ -.detailPagePortraitCard .cardPadder { - padding-bottom: 150%; -} - - -.detailPagePortraitCard { - width: 33.333%; -} - -@media all and (min-width: 540px) { - - .detailPagePortraitCard { - width: 25%; - } -} - - -/** detailPageSquare */ -.detailPageSquareCard .cardPadder { - padding-bottom: 100%; -} - - -.detailPageSquareCard { - width: 33.333%; -} - -@media all and (min-width: 540px) { - - .detailPageSquareCard { - width: 25%; - } -} - -/** horizontalBackdropCard */ -.horizontalBackdropCard .cardPadder { - padding-bottom: 56.25%; -} - - -.horizontalBackdropCard { - width: 75%; -} - -@media all and (min-width: 500px) { - - .horizontalBackdropCard { - width: 50%; - } -} - -@media all and (min-width: 800px) { - - .horizontalBackdropCard { - width: 31%; - } -} - -.horizontalBackdropCard .cardImage { - border-radius: 4px; -} - -.horizontalBackdropCard .cardBox { - margin: 2px !important; -} diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index c73631ff66..5efd439c80 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -907,80 +907,6 @@ span.itemCommunityRating:not(:empty) + .userDataIcons { line-height: 1.2; } -.itemProgress { - vertical-align: top; - font-size: 19px; - margin-right: 15px; - font-weight: bold; -} - -/* All HTML5 progress enabled browsers */ -.itemProgressBar { - /* Turns off styling - not usually needed, but good to know. */ - appearance: none; - -moz-appearance: none; - -webkit-appearance: none; - /* gets rid of default border in Firefox and Opera. */ - border: 0; - margin: 0; - height: 14px; - border: 0 solid #222; - border-radius: 0; - width: 50px; - margin-right: 5px; -} - -/* Undo these to original */ -.listItem .itemProgressBar { - width: auto; - margin: 0; - height: .56vh; -} - -/* Polyfill */ -.itemProgressBar[role]:after { - background-image: none; /* removes default background from polyfill */ -} - -/* - * Background of the progress bar background - */ - -/* Firefox and Polyfill */ -.itemProgressBar { - background: #000 !important; /* !important only needed in polyfill */ -} - - /* Chrome */ - .itemProgressBar::-webkit-progress-bar { - background: #000; - } - -.pare -/* - * Background of the progress bar value - */ -/* Firefox */ -.itemProgressBar::-moz-progress-bar { - border-radius: 0; - background-image: none; - background-color: #52B54B; -} - -/* Chrome */ -.itemProgressBar::-webkit-progress-value { - border-radius: 0; - background-image: none; - background-color: #52B54B; -} - -/* Polyfill */ -.itemProgressBar[aria-valuenow]:before { - border-radius: 0; - background-image: none; - background-color: #52B54B; -} - .recordingProgressBar::-moz-progress-bar { background-color: #cc3333; } @@ -993,12 +919,6 @@ span.itemCommunityRating:not(:empty) + .userDataIcons { background-color: #cc3333; } -.tileItem .itemProgressBar { - top: 2px; - width: 40px; - margin-right: 1em; -} - .timelineHeader { margin-bottom: .25em; line-height: 1.25em; @@ -1007,7 +927,6 @@ span.itemCommunityRating:not(:empty) + .userDataIcons { .itemsContainer { margin: 0 auto; - line-height: 0; } .alphabetPicker { diff --git a/dashboard-ui/home.html b/dashboard-ui/home.html index b98d8b6642..6f7fecd56b 100644 --- a/dashboard-ui/home.html +++ b/dashboard-ui/home.html @@ -25,7 +25,7 @@ ${ButtonSync}
-
+

${NoNextUpItemsMessage}

diff --git a/dashboard-ui/livetv.html b/dashboard-ui/livetv.html index 7657a46757..1a7cb1edc1 100644 --- a/dashboard-ui/livetv.html +++ b/dashboard-ui/livetv.html @@ -52,7 +52,7 @@
-
+
diff --git a/dashboard-ui/livetvitems.html b/dashboard-ui/livetvitems.html index 342c626d10..51c64d142e 100644 --- a/dashboard-ui/livetvitems.html +++ b/dashboard-ui/livetvitems.html @@ -4,7 +4,7 @@
-
+
\ No newline at end of file diff --git a/dashboard-ui/movies.html b/dashboard-ui/movies.html index 7710a3ffd2..04669ac6bf 100644 --- a/dashboard-ui/movies.html +++ b/dashboard-ui/movies.html @@ -98,14 +98,14 @@
-
+
-
+
diff --git a/dashboard-ui/music.html b/dashboard-ui/music.html index f4eaa2b224..922baaf452 100644 --- a/dashboard-ui/music.html +++ b/dashboard-ui/music.html @@ -115,7 +115,7 @@
-
+
diff --git a/dashboard-ui/scripts/channelitems.js b/dashboard-ui/scripts/channelitems.js index 7aa2100d1f..4300e9e014 100644 --- a/dashboard-ui/scripts/channelitems.js +++ b/dashboard-ui/scripts/channelitems.js @@ -1,4 +1,4 @@ -define(['jQuery', 'emby-itemscontainer'], function ($) { +define(['jQuery', 'cardBuilder', 'emby-itemscontainer'], function ($, cardBuilder) { var data = {}; @@ -129,7 +129,7 @@ updateFilterControls(page); - html = LibraryBrowser.getPosterViewHtml({ + html = cardBuilder.getCardsHtml({ items: result.Items, shape: "auto", defaultShape: 'square', diff --git a/dashboard-ui/scripts/channels.js b/dashboard-ui/scripts/channels.js index 6fea82dc1c..f01feeef28 100644 --- a/dashboard-ui/scripts/channels.js +++ b/dashboard-ui/scripts/channels.js @@ -1,4 +1,4 @@ -define(['libraryBrowser', 'emby-itemscontainer'], function (libraryBrowser) { +define(['libraryBrowser', 'cardBuilder', 'emby-itemscontainer'], function (libraryBrowser, cardBuilder) { // The base query options var query = { @@ -23,7 +23,7 @@ if (view == "Thumb") { - html = libraryBrowser.getPosterViewHtml({ + html = cardBuilder.getCardsHtml({ items: result.Items, shape: "backdrop", context: 'channels', @@ -36,7 +36,7 @@ } else if (view == "ThumbCard") { - html = libraryBrowser.getPosterViewHtml({ + html = cardBuilder.getCardsHtml({ items: result.Items, shape: "backdrop", preferThumb: true, diff --git a/dashboard-ui/scripts/episodes.js b/dashboard-ui/scripts/episodes.js index 1b0c32f752..edfd576d35 100644 --- a/dashboard-ui/scripts/episodes.js +++ b/dashboard-ui/scripts/episodes.js @@ -1,4 +1,4 @@ -define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'emby-itemscontainer'], function (events, libraryBrowser, imageLoader, listView) { +define(['events', 'libraryBrowser', 'imageLoader', 'listView', 'cardBuilder', 'emby-itemscontainer'], function (events, libraryBrowser, imageLoader, listView, cardBuilder) { return function (view, params, tabContent) { @@ -83,27 +83,25 @@ }); } else if (viewStyle == "PosterCard") { - html = libraryBrowser.getPosterViewHtml({ + html = cardBuilder.getCardsHtml({ items: result.Items, shape: "backdrop", showTitle: true, showParentTitle: true, - lazy: true, - cardLayout: true, - showDetailsMenu: true + scalable: true, + cardLayout: true }); } else { // poster - html = libraryBrowser.getPosterViewHtml({ + html = cardBuilder.getCardsHtml({ items: result.Items, shape: "backdrop", showTitle: true, showParentTitle: true, overlayText: true, - lazy: true, - showDetailsMenu: true, + scalable: true, overlayPlayButton: true }); } diff --git a/dashboard-ui/scripts/homenextup.js b/dashboard-ui/scripts/homenextup.js index 29dff7bd44..e8309187d8 100644 --- a/dashboard-ui/scripts/homenextup.js +++ b/dashboard-ui/scripts/homenextup.js @@ -1,4 +1,4 @@ -define(['components/categorysyncbuttons', 'emby-itemscontainer'], function (categorysyncbuttons) { +define(['components/categorysyncbuttons', 'cardBuilder', 'emby-itemscontainer'], function (categorysyncbuttons, cardBuilder) { function getNextUpPromise() { @@ -25,7 +25,7 @@ var html = ''; - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: result.Items, shape: "backdrop", showTitle: true, diff --git a/dashboard-ui/scripts/homeupcoming.js b/dashboard-ui/scripts/homeupcoming.js index f9b19cc143..a887964e93 100644 --- a/dashboard-ui/scripts/homeupcoming.js +++ b/dashboard-ui/scripts/homeupcoming.js @@ -1,4 +1,4 @@ -define(['datetime', 'emby-itemscontainer', 'scrollStyles'], function (datetime) { +define(['datetime', 'cardBuilder', 'emby-itemscontainer', 'scrollStyles'], function (datetime, cardBuilder) { function getUpcomingPromise() { @@ -102,10 +102,10 @@ if (enableScrollX()) { html += '
'; } else { - html += '
'; + html += '
'; } - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: group.items, showLocationTypeIndicator: false, shape: getThumbShape(), diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 5150c2f2d5..43e63ba007 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -1,4 +1,4 @@ -define(['viewManager', 'appSettings', 'appStorage', 'apphost', 'datetime', 'itemHelper', 'mediaInfo', 'scroller', 'indicators', 'dom', 'scrollStyles'], function (viewManager, appSettings, appStorage, appHost, datetime, itemHelper, mediaInfo, scroller, indicators, dom) { +define(['viewManager', 'appSettings', 'appStorage', 'apphost', 'datetime', 'itemHelper', 'mediaInfo', 'scroller', 'indicators', 'dom', 'imageLoader', 'scrollStyles'], function (viewManager, appSettings, appStorage, appHost, datetime, itemHelper, mediaInfo, scroller, indicators, dom, imageLoader) { function fadeInRight(elem) { @@ -39,52 +39,8 @@ var libraryBrowser = (function (window, document, screen) { - // Regular Expressions for parsing tags and attributes - var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, - // Match everything outside of normal chars and " (quote character) - NON_ALPHANUMERIC_REGEXP = /([^\#-~| |!])/g; - - /** - * Escapes all potentially dangerous characters, so that the - * resulting string can be safely inserted into attribute or - * element text. - * @param value - * @returns {string} escaped text - */ - function htmlEncode(value) { - return value. - replace(/&/g, '&'). - replace(SURROGATE_PAIR_REGEXP, function (value) { - var hi = value.charCodeAt(0); - var low = value.charCodeAt(1); - return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';'; - }). - replace(NON_ALPHANUMERIC_REGEXP, function (value) { - return '&#' + value.charCodeAt(0) + ';'; - }). - replace(//g, '>'); - } - var pageSizeKey = 'pagesize_v4'; - function getDesiredAspect(shape) { - - if (shape) { - shape = shape.toLowerCase(); - if (shape.indexOf('portrait') != -1) { - return (2 / 3); - } - if (shape.indexOf('backdrop') != -1) { - return (16 / 9); - } - if (shape.indexOf('square') != -1) { - return 1; - } - } - return null; - } - var libraryBrowser = { getDefaultPageSize: function (key, defaultValue) { @@ -435,110 +391,6 @@ }); }, - getItemCountsHtml: function (options, item) { - - var counts = []; - - var childText; - - if (item.Type == 'Playlist') { - - childText = ''; - - if (item.CumulativeRunTimeTicks) { - - var minutes = item.CumulativeRunTimeTicks / 600000000; - - minutes = minutes || 1; - - childText += Globalize.translate('ValueMinutes', Math.round(minutes)); - - } else { - childText += Globalize.translate('ValueMinutes', 0); - } - - counts.push(childText); - - } - else if (options.context == "movies") { - - if (item.MovieCount) { - - childText = item.MovieCount == 1 ? - Globalize.translate('ValueOneMovie') : - Globalize.translate('ValueMovieCount', item.MovieCount); - - counts.push(childText); - } - if (item.TrailerCount) { - - childText = item.TrailerCount == 1 ? - Globalize.translate('ValueOneTrailer') : - Globalize.translate('ValueTrailerCount', item.TrailerCount); - - counts.push(childText); - } - - } else if (options.context == "tv") { - - if (item.SeriesCount) { - - childText = item.SeriesCount == 1 ? - Globalize.translate('ValueOneSeries') : - Globalize.translate('ValueSeriesCount', item.SeriesCount); - - counts.push(childText); - } - if (item.EpisodeCount) { - - childText = item.EpisodeCount == 1 ? - Globalize.translate('ValueOneEpisode') : - Globalize.translate('ValueEpisodeCount', item.EpisodeCount); - - counts.push(childText); - } - - } else if (options.context == "games") { - - if (item.GameCount) { - - childText = item.GameCount == 1 ? - Globalize.translate('ValueOneGame') : - Globalize.translate('ValueGameCount', item.GameCount); - - counts.push(childText); - } - } else if (options.context == "music") { - - if (item.AlbumCount) { - - childText = item.AlbumCount == 1 ? - Globalize.translate('ValueOneAlbum') : - Globalize.translate('ValueAlbumCount', item.AlbumCount); - - counts.push(childText); - } - if (item.SongCount) { - - childText = item.SongCount == 1 ? - Globalize.translate('ValueOneSong') : - Globalize.translate('ValueSongCount', item.SongCount); - - counts.push(childText); - } - if (item.MusicVideoCount) { - - childText = item.MusicVideoCount == 1 ? - Globalize.translate('ValueOneMusicVideo') : - Globalize.translate('ValueMusicVideoCount', item.MusicVideoCount); - - counts.push(childText); - } - } - - return counts.join(' • '); - }, - getArtistLinksHtml: function (artists, cssClass) { var html = []; @@ -736,737 +588,6 @@ }, - getUserDataCssClass: function (key) { - - if (!key) return ''; - - return 'libraryItemUserData' + key.replace(new RegExp(' ', 'g'), ''); - }, - - getItemDataAttributesList: function (item, options, index) { - - var atts = []; - - atts.push({ - name: 'serverid', - value: item.ServerId || options.serverId - }); - - atts.push({ - name: 'id', - value: item.Id - }); - - if (options.context) { - atts.push({ - name: 'context', - value: options.context || '' - }); - } - - if (item.IsFolder) { - atts.push({ - name: 'isfolder', - value: item.IsFolder - }); - } - - atts.push({ - name: 'type', - value: item.Type - }); - - if (item.MediaType) { - atts.push({ - name: 'mediatype', - value: item.MediaType || '' - }); - } - - if (item.UserData && item.UserData.PlaybackPositionTicks) { - atts.push({ - name: 'positionticks', - value: (item.UserData.PlaybackPositionTicks || 0) - }); - } - - atts.push({ - name: 'index', - value: index - }); - - if (item.ChannelId) { - atts.push({ - name: 'channelid', - value: item.ChannelId - }); - } - - if (options.collectionId) { - atts.push({ - name: 'collectionid', - value: options.collectionId - }); - } - - return atts; - }, - - getItemDataAttributes: function (item, options, index) { - - var atts = LibraryBrowser.getItemDataAttributesList(item, options, index).map(function (i) { - return 'data-' + i.name + '="' + i.value + '"'; - }); - - var html = atts.join(' '); - - if (html) { - html = ' ' + html; - } - - return html; - }, - - shapes: ['square', 'portrait', 'banner', 'smallBackdrop', 'backdrop', 'overflowBackdrop', 'overflowPortrait', 'overflowSquare'], - - getPostersPerRow: function (screenWidth) { - - function getValue(shape) { - - switch (shape) { - - case 'portrait': - if (screenWidth >= 2200) return 10; - if (screenWidth >= 2100) return 9; - if (screenWidth >= 1600) return 8; - if (screenWidth >= 1400) return 7; - if (screenWidth >= 1200) return 6; - if (screenWidth >= 800) return 5; - if (screenWidth >= 640) return 4; - return 3; - case 'square': - if (screenWidth >= 2100) return 9; - if (screenWidth >= 1800) return 8; - if (screenWidth >= 1400) return 7; - if (screenWidth >= 1200) return 6; - if (screenWidth >= 900) return 5; - if (screenWidth >= 700) return 4; - if (screenWidth >= 500) return 3; - return 2; - case 'banner': - if (screenWidth >= 2200) return 4; - if (screenWidth >= 1200) return 3; - if (screenWidth >= 800) return 2; - return 1; - case 'backdrop': - if (screenWidth >= 2500) return 6; - if (screenWidth >= 2100) return 5; - if (screenWidth >= 1200) return 4; - if (screenWidth >= 770) return 3; - if (screenWidth >= 420) return 2; - return 1; - case 'smallBackdrop': - if (screenWidth >= 1440) return 8; - if (screenWidth >= 1100) return 6; - if (screenWidth >= 800) return 5; - if (screenWidth >= 600) return 4; - if (screenWidth >= 540) return 3; - if (screenWidth >= 420) return 2; - return 1; - case 'overflowPortrait': - if (screenWidth >= 1000) return 100 / 23; - if (screenWidth >= 640) return 100 / 36; - return 2.5; - case 'overflowSquare': - if (screenWidth >= 1000) return 100 / 22; - if (screenWidth >= 640) return 100 / 30; - return 100 / 42; - case 'overflowBackdrop': - if (screenWidth >= 1000) return 100 / 40; - if (screenWidth >= 640) return 100 / 60; - return 100 / 84; - default: - return 4; - } - } - - var info = {}; - - for (var i = 0, length = LibraryBrowser.shapes.length; i < length; i++) { - var currentShape = LibraryBrowser.shapes[i]; - info[currentShape] = getValue(currentShape); - } - return info; - }, - - posterSizes: [], - - getPosterViewInfo: function () { - - var screenWidth = window.innerWidth; - - if (!browserInfo.mobile) { - var roundScreenTo = 100; - screenWidth = Math.ceil(screenWidth / roundScreenTo) * roundScreenTo; - } - - var cachedResults = LibraryBrowser.posterSizes; - - for (var i = 0, length = cachedResults.length; i < length; i++) { - - if (cachedResults[i].screenWidth == screenWidth) { - return cachedResults[i]; - } - } - - var result = LibraryBrowser.getPosterViewInfoInternal(screenWidth); - result.screenWidth = screenWidth; - - cachedResults.push(result); - - return result; - }, - - getPosterViewInfoInternal: function (screenWidth) { - - var imagesPerRow = LibraryBrowser.getPostersPerRow(screenWidth); - - var result = {}; - result.screenWidth = screenWidth; - - for (var i = 0, length = LibraryBrowser.shapes.length; i < length; i++) { - var currentShape = LibraryBrowser.shapes[i]; - - var shapeWidth = screenWidth / imagesPerRow[currentShape]; - - result[currentShape + 'Width'] = Math.round(shapeWidth); - } - - return result; - }, - - setPosterViewData: function (options) { - - var items = options.items; - - options.shape = options.shape || "portrait"; - - var primaryImageAspectRatio = LibraryBrowser.getAveragePrimaryImageAspectRatio(items); - var isThumbAspectRatio = primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1.777777778) < .3; - var isSquareAspectRatio = primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1) < .33 || - primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1.3333334) < .01; - - if (options.shape == 'auto' || options.shape == 'autohome' || options.shape == 'autooverflow') { - - if (isThumbAspectRatio) { - options.shape = options.shape == 'autooverflow' ? 'overflowBackdrop' : 'backdrop'; - } else if (isSquareAspectRatio) { - options.coverImage = true; - options.shape = options.shape == 'autooverflow' ? 'overflowSquare' : 'square'; - } else if (primaryImageAspectRatio && primaryImageAspectRatio > 1.9) { - options.shape = 'banner'; - options.coverImage = true; - } else if (primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 0.6666667) < .2) { - options.shape = options.shape == 'autooverflow' ? 'overflowPortrait' : 'portrait'; - } else { - options.shape = options.defaultShape || (options.shape == 'autooverflow' ? 'overflowSquare' : 'square'); - } - } - - var posterInfo = LibraryBrowser.getPosterViewInfo(); - - var thumbWidth = posterInfo.backdropWidth; - var posterWidth = posterInfo.portraitWidth; - var squareSize = posterInfo.squareWidth; - var bannerWidth = posterInfo.bannerWidth; - - if (isThumbAspectRatio) { - posterWidth = thumbWidth; - } - else if (isSquareAspectRatio) { - posterWidth = squareSize; - } - - if (options.shape == 'overflowBackdrop') { - thumbWidth = posterInfo.overflowBackdropWidth; - } - else if (options.shape == 'overflowPortrait') { - posterWidth = posterInfo.overflowPortraitWidth; - } - else if (options.shape == 'overflowSquare') { - squareSize = posterInfo.overflowSquareWidth; - } - else if (options.shape == 'smallBackdrop') { - thumbWidth = posterInfo.smallBackdropWidth; - } - else if (options.shape == 'detailPagePortrait') { - posterWidth = 200; - } - else if (options.shape == 'detailPageSquare') { - posterWidth = 240; - squareSize = 240; - } - else if (options.shape == 'detailPage169') { - posterWidth = 320; - thumbWidth = 320; - } - - options.uiAspect = getDesiredAspect(options.shape); - options.primaryImageAspectRatio = primaryImageAspectRatio; - options.posterWidth = posterWidth; - options.thumbWidth = thumbWidth; - options.bannerWidth = bannerWidth; - options.squareSize = squareSize; - }, - - getPosterViewHtml: function (options) { - - LibraryBrowser.setPosterViewData(options); - - var items = options.items; - var currentIndexValue; - - options.shape = options.shape || "portrait"; - - var html = ""; - - var primaryImageAspectRatio; - var thumbWidth = options.thumbWidth; - var posterWidth = options.posterWidth; - var squareSize = options.squareSize; - var bannerWidth = options.bannerWidth; - - var dateText; - var uiAspect = options.uiAspect; - - for (var i = 0, length = items.length; i < length; i++) { - - var item = items[i]; - - dateText = null; - - primaryImageAspectRatio = LibraryBrowser.getAveragePrimaryImageAspectRatio([item]); - - if (options.showStartDateIndex) { - - if (item.StartDate) { - try { - - dateText = LibraryBrowser.getFutureDateText(datetime.parseISO8601Date(item.StartDate, true), true); - - } catch (err) { - } - } - - var newIndexValue = dateText || Globalize.translate('HeaderUnknownDate'); - - if (newIndexValue != currentIndexValue) { - - html += '

' + newIndexValue + '

'; - currentIndexValue = newIndexValue; - } - } else if (options.timeline) { - var year = item.ProductionYear || Globalize.translate('HeaderUnknownYear'); - - if (year != currentIndexValue) { - - html += '

' + year + '

'; - currentIndexValue = year; - } - } - - html += LibraryBrowser.getPosterViewItemHtml(item, i, options, primaryImageAspectRatio, thumbWidth, posterWidth, squareSize, bannerWidth, uiAspect); - } - - return html; - }, - - getPosterViewItemHtml: function (item, index, options, primaryImageAspectRatio, thumbWidth, posterWidth, squareSize, bannerWidth, uiAspect) { - - var html = ''; - var imgUrl = null; - var icon; - var width = null; - var height = null; - - var forceName = false; - - var enableImageEnhancers = options.enableImageEnhancers !== false; - - var cssClass = "card"; - - if (options.fullWidthOnMobile) { - cssClass += " fullWidthCardOnMobile"; - } - - var showTitle = options.showTitle == 'auto' ? true : options.showTitle; - - // Force the title for these - if (item.Type == 'PhotoAlbum' || item.Type == 'Folder') { - showTitle = true; - } - var coverImage = options.coverImage; - var imageItem = item.Type == 'Timer' ? (item.ProgramInfo || item) : item; - - if (options.autoThumb && imageItem.ImageTags && imageItem.ImageTags.Primary && imageItem.PrimaryImageAspectRatio && imageItem.PrimaryImageAspectRatio >= 1.34) { - - width = posterWidth; - height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null; - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Primary", - maxHeight: height, - maxWidth: width, - tag: imageItem.ImageTags.Primary, - enableImageEnhancers: enableImageEnhancers - }); - - if (primaryImageAspectRatio) { - if (uiAspect) { - if (Math.abs(primaryImageAspectRatio - uiAspect) <= .2) { - coverImage = true; - } - } - } - - } else if (options.autoThumb && imageItem.ImageTags && imageItem.ImageTags.Thumb) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Thumb", - maxWidth: thumbWidth, - tag: imageItem.ImageTags.Thumb, - enableImageEnhancers: enableImageEnhancers - }); - - } else if (options.preferBackdrop && imageItem.BackdropImageTags && imageItem.BackdropImageTags.length) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Backdrop", - maxWidth: thumbWidth, - tag: imageItem.BackdropImageTags[0], - enableImageEnhancers: enableImageEnhancers - }); - - } else if (options.preferThumb && imageItem.ImageTags && imageItem.ImageTags.Thumb) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Thumb", - maxWidth: thumbWidth, - tag: imageItem.ImageTags.Thumb, - enableImageEnhancers: enableImageEnhancers - }); - - } else if (options.preferBanner && imageItem.ImageTags && imageItem.ImageTags.Banner) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Banner", - maxWidth: bannerWidth, - tag: imageItem.ImageTags.Banner, - enableImageEnhancers: enableImageEnhancers - }); - - } else if (options.preferThumb && imageItem.SeriesThumbImageTag && options.inheritThumb !== false) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.SeriesId, { - type: "Thumb", - maxWidth: thumbWidth, - tag: imageItem.SeriesThumbImageTag, - enableImageEnhancers: enableImageEnhancers - }); - - } else if (options.preferThumb && imageItem.ParentThumbItemId && options.inheritThumb !== false) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.ParentThumbItemId, { - type: "Thumb", - maxWidth: thumbWidth, - enableImageEnhancers: enableImageEnhancers, - tag: imageItem.ParentThumbImageTag - }); - - } else if (options.preferThumb && imageItem.BackdropImageTags && imageItem.BackdropImageTags.length) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Backdrop", - maxWidth: thumbWidth, - tag: imageItem.BackdropImageTags[0], - enableImageEnhancers: enableImageEnhancers - }); - - forceName = true; - - } else if (imageItem.ImageTags && imageItem.ImageTags.Primary) { - - width = posterWidth; - height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null; - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Primary", - maxHeight: height, - maxWidth: width, - tag: imageItem.ImageTags.Primary, - enableImageEnhancers: enableImageEnhancers - }); - - if (primaryImageAspectRatio) { - if (uiAspect) { - if (Math.abs(primaryImageAspectRatio - uiAspect) <= .2) { - coverImage = true; - } - } - } - } - else if (imageItem.ParentPrimaryImageTag) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.ParentPrimaryImageItemId, { - type: "Primary", - maxWidth: posterWidth, - tag: item.ParentPrimaryImageTag, - enableImageEnhancers: enableImageEnhancers - }); - } - else if (imageItem.AlbumId && imageItem.AlbumPrimaryImageTag) { - - height = squareSize; - width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null; - - imgUrl = ApiClient.getScaledImageUrl(imageItem.AlbumId, { - type: "Primary", - maxHeight: height, - maxWidth: width, - tag: imageItem.AlbumPrimaryImageTag, - enableImageEnhancers: enableImageEnhancers - }); - - if (primaryImageAspectRatio) { - if (uiAspect) { - if (Math.abs(primaryImageAspectRatio - uiAspect) <= .2) { - coverImage = true; - } - } - } - } - else if (imageItem.Type == 'Season' && imageItem.ImageTags && imageItem.ImageTags.Thumb) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Thumb", - maxWidth: thumbWidth, - tag: imageItem.ImageTags.Thumb, - enableImageEnhancers: enableImageEnhancers - }); - - } - else if (imageItem.BackdropImageTags && imageItem.BackdropImageTags.length) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Backdrop", - maxWidth: thumbWidth, - tag: imageItem.BackdropImageTags[0], - enableImageEnhancers: enableImageEnhancers - }); - - } else if (imageItem.ImageTags && imageItem.ImageTags.Thumb) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, { - type: "Thumb", - maxWidth: thumbWidth, - tag: imageItem.ImageTags.Thumb, - enableImageEnhancers: enableImageEnhancers - }); - - } else if (imageItem.ParentThumbItemId) { - - imgUrl = ApiClient.getScaledImageUrl(imageItem.ParentThumbItemId, { - type: "Thumb", - maxWidth: thumbWidth, - enableImageEnhancers: enableImageEnhancers, - tag: imageItem.ParentThumbImageTag - }); - - } else if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist") { - - if (item.Name && showTitle) { - icon = 'library_music'; - } - cssClass += " defaultBackground"; - - } else if (item.Type == "Recording" || item.Type == "Program" || item.Type == "TvChannel") { - - if (item.Name && showTitle) { - icon = 'folder_open'; - } - - cssClass += " defaultBackground"; - } else if (item.MediaType == "Video" || item.Type == "Season" || item.Type == "Series") { - - if (item.Name && showTitle) { - icon = 'videocam'; - } - cssClass += " defaultBackground"; - } else if (item.Type == "Person") { - - if (item.Name && showTitle) { - icon = 'person'; - } - cssClass += " defaultBackground"; - } else { - if (item.Name && showTitle) { - icon = 'folder_open'; - } - cssClass += " defaultBackground"; - } - - icon = item.icon || icon; - cssClass += ' ' + options.shape + 'Card'; - - var mediaSourceCount = item.MediaSourceCount || 1; - - var href = options.linkItem === false ? '#' : LibraryBrowser.getHref(item, options.context); - - if (options.showChildCountIndicator && item.ChildCount && options.showLatestItemsPopup !== false) { - cssClass += ' groupedCard'; - } - - if ((showTitle || options.showItemCounts) && !options.overlayText) { - cssClass += ' bottomPaddedCard'; - } - - var dataAttributes = LibraryBrowser.getItemDataAttributes(item, options, index); - - var defaultAction = options.defaultAction; - if (defaultAction == 'play' || defaultAction == 'playallfromhere') { - if (item.PlayAccess != 'Full') { - defaultAction = null; - } - } - var defaultActionAttribute = defaultAction ? (' data-action="' + defaultAction + '"') : ''; - - // card - html += ''; - - var style = ""; - - if (imgUrl && !options.lazy) { - style += 'background-image:url(\'' + imgUrl + '\');'; - } - - var imageCssClass = 'cardImage'; - - if (icon) { - imageCssClass += " iconCardImage"; - } - - if (coverImage) { - imageCssClass += " coveredCardImage"; - if (item.MediaType == 'Photo' || item.Type == 'PhotoAlbum' || item.Type == 'Folder' || item.Type == 'Program' || item.Type == 'Recording') { - imageCssClass += " noScale"; - } - } - if (options.centerImage) { - imageCssClass += " centeredCardImage"; - } - - var dataSrc = ""; - - if (options.lazy && imgUrl) { - imageCssClass += " lazy"; - dataSrc = ' data-src="' + imgUrl + '"'; - } - - var cardboxCssClass = 'cardBox'; - - if (options.cardLayout) { - cardboxCssClass += ' visualCardBox'; - } - html += '
'; - html += '
'; - - html += '
'; - - var anchorCssClass = "cardContent"; - - anchorCssClass += ' mediaItem'; - - if (options.defaultAction) { - anchorCssClass += ' itemAction'; - } - - var transition = options.transition === false || !AppInfo.enableSectionTransitions ? '' : ' data-transition="slide"'; - var onclick = item.onclick ? ' onclick="' + item.onclick + '"' : ''; - html += ''; - html += '
'; - if (icon) { - html += '' + icon + ''; - } - html += '
'; - - if (item.LocationType == "Virtual" || item.LocationType == "Offline") { - if (options.showLocationTypeIndicator !== false) { - html += LibraryBrowser.getOfflineIndicatorHtml(item); - } - } else if (options.showUnplayedIndicator !== false) { - html += indicators.getPlayedIndicatorHtml(item); - } else if (options.showChildCountIndicator) { - html += LibraryBrowser.getGroupCountIndicator(item); - } - - if (item.SeriesTimerId) { - html += 'fiber_smart_record'; - } - - html += LibraryBrowser.getSyncIndicator(item); - - if (mediaSourceCount > 1) { - html += '
' + mediaSourceCount + '
'; - } - - var progressHtml = options.showProgress === false || item.IsFolder ? '' : LibraryBrowser.getItemProgressBarHtml((item.Type == 'Recording' ? item : item.UserData || {})); - - var footerOverlayed = false; - - if (options.overlayText || (forceName && !showTitle)) { - - var footerCssClass = progressHtml ? 'cardFooter fullCardFooter' : 'cardFooter'; - - html += LibraryBrowser.getCardFooterText(item, options, showTitle, imgUrl, forceName, footerCssClass, progressHtml, false); - footerOverlayed = true; - } - else if (progressHtml) { - html += '
'; - html += "
"; - html += progressHtml; - html += "
"; - //cardFooter - html += "
"; - - progressHtml = ''; - } - - // cardContent - html += ''; - - if (options.overlayPlayButton && !item.IsPlaceHolder && (item.LocationType != 'Virtual' || !item.MediaType || item.Type == 'Program') && item.Type != 'Person' && item.PlayAccess == 'Full') { - html += '
'; - } - if (options.overlayMoreButton) { - html += '
'; - } - - // cardScalable - html += '
'; - - if (!options.overlayText && !footerOverlayed) { - html += LibraryBrowser.getCardFooterText(item, options, showTitle, imgUrl, forceName, 'cardFooter outerCardFooter', progressHtml, true); - } - - // cardBox - html += '
'; - - // card - html += "
"; - - return html; - }, - getTextActionButton: function (item, text) { if (!text) { @@ -1480,195 +601,6 @@ return html; }, - getCardFooterText: function (item, options, showTitle, imgUrl, forceName, footerClass, progressHtml, isOuterFooter) { - - var html = ''; - - if (options.cardLayout) { - html += '
'; - html += ''; - html += "
"; - } - - var name = options.showTitle == 'auto' && !item.IsFolder && item.MediaType == 'Photo' ? '' : itemHelper.getDisplayName(item); - - if (!imgUrl && !showTitle) { - html += "
"; - html += htmlEncode(name); - html += "
"; - } - - var cssClass = options.centerText ? "cardText cardTextCentered" : "cardText"; - - var lines = []; - - var parentTitleUnderneath = item.Type == 'MusicAlbum' || item.Type == 'Audio' || item.Type == 'MusicVideo'; - if (options.showParentTitle && !parentTitleUnderneath) { - - if (isOuterFooter && item.Type == 'Episode' && item.SeriesName && item.SeriesId) { - - lines.push(LibraryBrowser.getTextActionButton({ - Id: item.SeriesId, - Name: item.SeriesName, - Type: 'Series', - IsFolder: true - })); - } - else { - - lines.push(item.EpisodeTitle ? item.Name : (item.SeriesName || item.Album || item.AlbumArtist || item.GameSystem || "")); - } - } - - if (showTitle || forceName) { - - lines.push(htmlEncode(name)); - } - - if (options.showParentTitle && parentTitleUnderneath) { - - if (isOuterFooter && item.AlbumArtists && item.AlbumArtists.length) { - item.AlbumArtists[0].Type = 'MusicArtist'; - item.AlbumArtists[0].IsFolder = true; - lines.push(LibraryBrowser.getTextActionButton(item.AlbumArtists[0])); - } else { - lines.push(item.EpisodeTitle ? item.Name : (item.SeriesName || item.Album || item.AlbumArtist || item.GameSystem || "")); - } - } - - if (options.showItemCounts) { - - var itemCountHtml = LibraryBrowser.getItemCountsHtml(options, item); - - lines.push(itemCountHtml); - } - - if (options.textLines) { - var additionalLines = options.textLines(item); - for (var i = 0, length = additionalLines.length; i < length; i++) { - lines.push(additionalLines[i]); - } - } - - if (options.showSongCount) { - - var songLine = ''; - - if (item.SongCount) { - songLine = item.SongCount == 1 ? - Globalize.translate('ValueOneSong') : - Globalize.translate('ValueSongCount', item.SongCount); - } - - lines.push(songLine); - } - - if (options.showPremiereDate) { - - if (item.PremiereDate) { - try { - - lines.push(LibraryBrowser.getPremiereDateText(item)); - - } catch (err) { - lines.push(''); - - } - } else { - lines.push(''); - } - } - - if (options.showYear) { - - lines.push(item.ProductionYear || ''); - } - - if (options.showChannelName) { - - lines.push(item.ChannelName || ''); - } - - if (options.showAirTime) { - - var airTimeText; - if (item.StartDate) { - - try { - var date = datetime.parseISO8601Date(item.StartDate); - - airTimeText = date.toLocaleDateString(); - - airTimeText += ', ' + datetime.getDisplayTime(date); - - if (item.EndDate) { - date = datetime.parseISO8601Date(item.EndDate); - airTimeText += ' - ' + datetime.getDisplayTime(date); - } - } - catch (e) { - console.log("Error parsing date: " + item.PremiereDate); - } - } - - lines.push(airTimeText || ''); - } - - if (item.Type == 'TvChannel') { - - if (item.CurrentProgram) { - lines.push(itemHelper.getDisplayName(item.CurrentProgram)); - } else { - lines.push(''); - } - } - - if (options.showSeriesYear) { - - if (item.Status == "Continuing") { - - lines.push(Globalize.translate('ValueSeriesYearToPresent', item.ProductionYear || '')); - - } else { - lines.push(item.ProductionYear || ''); - } - - } - - if (options.showProgramAirInfo) { - - var date = datetime.parseISO8601Date(item.StartDate, true); - - var text = item.StartDate ? - date.toLocaleString() : - ''; - - lines.push(text || ' '); - - lines.push(item.ChannelName || ' '); - } - - html += LibraryBrowser.getCardTextLines(lines, cssClass, !options.overlayText); - - if (options.overlayText) { - - if (progressHtml) { - html += "
"; - html += progressHtml; - html += "
"; - } - } - - if (html) { - html = '
' + html; - - //cardFooter - html += "
"; - } - - return html; - }, - getListItemInfo: function (elem) { var elemWithAttributes = elem; @@ -1689,35 +621,6 @@ }; }, - getCardTextLines: function (lines, cssClass, forceLines) { - - var html = ''; - - var valid = 0; - var i, length; - - for (i = 0, length = lines.length; i < length; i++) { - - var text = lines[i]; - - if (text) { - html += "
"; - html += text; - html += "
"; - valid++; - } - } - - if (forceLines) { - while (valid < length) { - html += "
 
"; - valid++; - } - } - - return html; - }, - getFutureDateText: function (date) { var weekday = []; @@ -1739,43 +642,6 @@ return date; }, - getPremiereDateText: function (item, date) { - - var studio = (item.Studios || [])[0]; - - if (!date) { - - var text = ''; - - if (item.AirTime) { - text += item.AirTime; - } - - if (studio) { - - if (text) { - text += " on " + studio; - } else { - text += studio; - } - } - - return text; - } - - var day = LibraryBrowser.getFutureDateText(date); - - if (item.AirTime) { - day += " at " + item.AirTime; - } - - if (studio) { - day += " on " + studio; - } - - return day; - }, - getOfflineIndicatorHtml: function (item) { if (item.LocationType == "Offline") { @@ -1829,60 +695,6 @@ return ''; }, - getAveragePrimaryImageAspectRatio: function (items) { - - var values = []; - - for (var i = 0, length = items.length; i < length; i++) { - - var ratio = items[i].PrimaryImageAspectRatio || 0; - - if (!ratio) { - continue; - } - - values[values.length] = ratio; - } - - if (!values.length) { - return null; - } - - // Use the median - values.sort(function (a, b) { return a - b; }); - - var half = Math.floor(values.length / 2); - - var result; - - if (values.length % 2) - result = values[half]; - else - result = (values[half - 1] + values[half]) / 2.0; - - // If really close to 2:3 (poster image), just return 2:3 - if (Math.abs(0.66666666667 - result) <= .15) { - return 0.66666666667; - } - - // If really close to 16:9 (episode image), just return 16:9 - if (Math.abs(1.777777778 - result) <= .2) { - return 1.777777778; - } - - // If really close to 1 (square image), just return 1 - if (Math.abs(1 - result) <= .15) { - return 1; - } - - // If really close to 4:3 (poster image), just return 2:3 - if (Math.abs(1.33333333333 - result) <= .15) { - return 1.33333333333; - } - - return result; - }, - metroColors: ["#6FBD45", "#4BB3DD", "#4164A5", "#E12026", "#800080", "#E1B222", "#008040", "#0094FF", "#FF00C7", "#FF870F", "#7F0037"], getRandomMetroColor: function () { diff --git a/dashboard-ui/scripts/livetvchannels.js b/dashboard-ui/scripts/livetvchannels.js index 50785f9275..b1612cf08d 100644 --- a/dashboard-ui/scripts/livetvchannels.js +++ b/dashboard-ui/scripts/livetvchannels.js @@ -1,4 +1,4 @@ -define(['emby-itemscontainer'], function () { +define(['cardBuilder', 'emby-itemscontainer'], function (cardBuilder) { return function (view, params, tabContent) { @@ -38,7 +38,7 @@ function getChannelsHtml(channels) { - return LibraryBrowser.getPosterViewHtml({ + return cardBuilder.getCardsHtml({ items: channels, shape: "square", showTitle: true, diff --git a/dashboard-ui/scripts/livetvitems.js b/dashboard-ui/scripts/livetvitems.js index 11be75fa0b..beef07a388 100644 --- a/dashboard-ui/scripts/livetvitems.js +++ b/dashboard-ui/scripts/livetvitems.js @@ -1,6 +1,4 @@ -define(['emby-itemscontainer'], function () { - - var view = LibraryBrowser.getDefaultItemsView('Poster', 'Poster'); +define(['cardBuilder', 'emby-itemscontainer'], function (cardBuilder) { var currentDate = new Date(); currentDate.setHours(0, 0, 0, 0); @@ -37,33 +35,18 @@ page.querySelector('.listTopPaging').innerHTML = pagingHtml; - if (view == "Poster") { - html = LibraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: query.IsMovie ? 'portrait' : "auto", - context: 'livetv', - showTitle: false, - centerText: true, - lazy: true, - showStartDateIndex: true, - overlayText: false, - showProgramAirInfo: true, - overlayMoreButton: true - }); - } - else if (view == "PosterCard") { - html = LibraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: "portrait", - context: 'livetv', - showTitle: true, - showStartDateIndex: true, - lazy: true, - cardLayout: true, - showProgramAirInfo: true, - overlayMoreButton: true - }); - } + html = cardBuilder.getCardsHtml({ + items: result.Items, + shape: query.IsMovie ? 'portrait' : "auto", + context: 'livetv', + showTitle: false, + centerText: true, + lazy: true, + showStartDateIndex: true, + overlayText: false, + showProgramAirInfo: true, + overlayMoreButton: true + }); var elem = page.querySelector('.itemsContainer'); elem.innerHTML = html + pagingHtml; diff --git a/dashboard-ui/scripts/livetvsuggested.js b/dashboard-ui/scripts/livetvsuggested.js index 902d3f536b..1e4660f428 100644 --- a/dashboard-ui/scripts/livetvsuggested.js +++ b/dashboard-ui/scripts/livetvsuggested.js @@ -1,4 +1,4 @@ -define(['libraryBrowser', 'scrollStyles', 'emby-itemscontainer'], function (libraryBrowser) { +define(['libraryBrowser', 'cardBuilder', 'scrollStyles', 'emby-itemscontainer'], function (libraryBrowser, cardBuilder) { function enableScrollX() { return browserInfo.mobile && AppInfo.enableAppLayouts; @@ -99,7 +99,7 @@ function renderItems(page, items, sectionClass, overlayButton, shape) { - var html = libraryBrowser.getPosterViewHtml({ + var html = cardBuilder.getCardsHtml({ items: items, shape: shape || (enableScrollX() ? 'autooverflow' : 'auto'), showTitle: true, @@ -130,8 +130,10 @@ for (var i = 0, length = containers.length; i < length; i++) { if (enableScrollX()) { containers[i].classList.add('hiddenScrollX'); + containers[i].classList.remove('verticalItemsContainer'); } else { containers[i].classList.remove('hiddenScrollX'); + containers[i].classList.add('verticalItemsContainer'); } } }; diff --git a/dashboard-ui/scripts/moviegenres.js b/dashboard-ui/scripts/moviegenres.js index 400f630a51..edd9c19dad 100644 --- a/dashboard-ui/scripts/moviegenres.js +++ b/dashboard-ui/scripts/moviegenres.js @@ -1,4 +1,4 @@ -define(['libraryBrowser'], function (libraryBrowser) { +define(['libraryBrowser', 'cardBuilder'], function (libraryBrowser, cardBuilder) { return function (view, params, tabContent) { @@ -16,7 +16,7 @@ SortOrder: "Ascending", IncludeItemTypes: "Movie", Recursive: true, - Fields: "DateCreated,SyncInfo,ItemCounts", + Fields: "DateCreated,SyncInfo,ItemCounts,PrimaryImageAspectRatio", StartIndex: 0 }, view: libraryBrowser.getSavedView(key) || libraryBrowser.getDefaultItemsView('Thumb', 'Thumb') @@ -55,59 +55,56 @@ var html = ''; var viewStyle = self.getCurrentViewStyle(); + var elem = context.querySelector('#items'); if (viewStyle == "Thumb") { - html = libraryBrowser.getPosterViewHtml({ - items: result.Items, + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, shape: "backdrop", preferThumb: true, - context: 'movies', + showTitle: false, + scalable: true, showItemCounts: true, centerText: true, - lazy: true, overlayMoreButton: true }); } else if (viewStyle == "ThumbCard") { - html = libraryBrowser.getPosterViewHtml({ - items: result.Items, + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, shape: "backdrop", preferThumb: true, - context: 'movies', + showTitle: false, + scalable: true, showItemCounts: true, - cardLayout: true, - showTitle: true, - lazy: true + centerText: true, + cardLayout: true }); } else if (viewStyle == "PosterCard") { - html = libraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: "portrait", - context: 'movies', + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, + shape: "auto", + showTitle: false, + scalable: true, showItemCounts: true, - lazy: true, - cardLayout: true, - showTitle: true + centerText: true, + cardLayout: true }); } else if (viewStyle == "Poster") { - html = libraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: "portrait", - context: 'movies', - centerText: true, + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, + shape: "auto", + showTitle: false, + scalable: true, showItemCounts: true, - lazy: true, + centerText: true, overlayMoreButton: true }); } - var elem = context.querySelector('#items'); - elem.innerHTML = html; - ImageLoader.lazyChildren(elem); - libraryBrowser.saveQueryValues(getSavedQueryKey(), query); Dashboard.hideLoadingMsg(); diff --git a/dashboard-ui/scripts/moviesrecommended.js b/dashboard-ui/scripts/moviesrecommended.js index ba4b944ff2..246d405817 100644 --- a/dashboard-ui/scripts/moviesrecommended.js +++ b/dashboard-ui/scripts/moviesrecommended.js @@ -1,14 +1,4 @@ -define(['libraryBrowser', 'components/categorysyncbuttons', 'scrollStyles', 'emby-itemscontainer'], function (libraryBrowser, categorysyncbuttons) { - - function getView() { - - return 'Poster'; - } - - function getResumeView() { - - return 'Thumb'; - } +define(['libraryBrowser', 'components/categorysyncbuttons', 'cardBuilder', 'scrollStyles', 'emby-itemscontainer'], function (libraryBrowser, categorysyncbuttons, cardBuilder) { function enableScrollX() { return browserInfo.mobile && AppInfo.enableAppLayouts; @@ -37,39 +27,13 @@ ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { - var view = getView(); - var html = ''; - - if (view == 'PosterCard') { - - html += libraryBrowser.getPosterViewHtml({ - items: items, - lazy: true, - shape: getPortraitShape(), - overlayText: false, - showTitle: true, - showYear: true, - cardLayout: true, - showDetailsMenu: true - - }); - - } else if (view == 'Poster') { - - html += libraryBrowser.getPosterViewHtml({ - items: items, - shape: getPortraitShape(), - centerText: true, - lazy: true, - overlayText: false, - showDetailsMenu: true, - overlayPlayButton: true - }); - } - - var recentlyAddedItems = page.querySelector('#recentlyAddedItems'); - recentlyAddedItems.innerHTML = html; - ImageLoader.lazyChildren(recentlyAddedItems); + var container = page.querySelector('#recentlyAddedItems'); + cardBuilder.buildCards(items, { + itemsContainer: container, + shape: getPortraitShape(), + scalable: true, + overlayPlayButton: true + }); }); } @@ -101,40 +65,14 @@ page.querySelector('#resumableSection').classList.add('hide'); } - var view = getResumeView(); - var html = ''; - - if (view == 'ThumbCard') { - - html += libraryBrowser.getPosterViewHtml({ - items: result.Items, - preferThumb: true, - shape: getThumbShape(), - showTitle: true, - showYear: true, - lazy: true, - cardLayout: true, - showDetailsMenu: true - - }); - - } else if (view == 'Thumb') { - - html += libraryBrowser.getPosterViewHtml({ - items: result.Items, - preferThumb: true, - shape: getThumbShape(), - overlayText: true, - showTitle: false, - lazy: true, - showDetailsMenu: true, - overlayPlayButton: true - }); - } - - var resumableItems = page.querySelector('#resumableItems'); - resumableItems.innerHTML = html; - ImageLoader.lazyChildren(resumableItems); + var container = page.querySelector('#resumableItems'); + cardBuilder.buildCards(result.Items, { + itemsContainer: container, + preferThumb: true, + shape: getThumbShape(), + scalable: true, + overlayPlayButton: true + }); }); } @@ -167,38 +105,17 @@ html += '

' + title + '

'; if (enableScrollX()) { - html += '
'; + html += '
'; } else { - html += '
'; + html += '
'; } - var view = getView(); + html += cardBuilder.getCardsHtml(recommendation.Items, { + shape: getPortraitShape(), + scalable: true, + overlayPlayButton: true + }); - if (view == 'PosterCard') { - - html += libraryBrowser.getPosterViewHtml({ - items: recommendation.Items, - lazy: true, - shape: getPortraitShape(), - overlayText: false, - showTitle: true, - showYear: true, - cardLayout: true, - showDetailsMenu: true - - }); - - } else if (view == 'Poster') { - - html += libraryBrowser.getPosterViewHtml({ - items: recommendation.Items, - shape: getPortraitShape(), - centerText: true, - lazy: true, - showDetailsMenu: true, - overlayPlayButton: true - }); - } html += '
'; html += '
'; @@ -244,8 +161,10 @@ for (var i = 0, length = containers.length; i < length; i++) { if (enableScrollX()) { containers[i].classList.add('hiddenScrollX'); + containers[i].classList.remove('verticalItemsContainer'); } else { containers[i].classList.remove('hiddenScrollX'); + containers[i].classList.add('verticalItemsContainer'); } } } diff --git a/dashboard-ui/scripts/moviestudios.js b/dashboard-ui/scripts/moviestudios.js index 5cd94eeb98..bf5f0d5dc3 100644 --- a/dashboard-ui/scripts/moviestudios.js +++ b/dashboard-ui/scripts/moviestudios.js @@ -1,4 +1,4 @@ -define(['libraryBrowser'], function (libraryBrowser) { +define(['libraryBrowser', 'cardBuilder'], function (libraryBrowser, cardBuilder) { // The base query options var data = {}; @@ -15,7 +15,7 @@ SortOrder: "Ascending", IncludeItemTypes: "Movie", Recursive: true, - Fields: "DateCreated,ItemCounts", + Fields: "DateCreated,ItemCounts,PrimaryImageAspectRatio", StartIndex: 0 } }; @@ -42,24 +42,18 @@ promise.then(function (result) { - var html = ''; - - html += libraryBrowser.getPosterViewHtml({ - items: result.Items, + var elem = context.querySelector('#items'); + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, shape: "backdrop", - showTitle: false, - context: 'movies', preferThumb: true, + showTitle: false, + scalable: true, showItemCounts: true, centerText: true, - lazy: true - + overlayMoreButton: true }); - var elem = context.querySelector('#items'); - elem.innerHTML = html; - ImageLoader.lazyChildren(elem); - Dashboard.hideLoadingMsg(); }); } diff --git a/dashboard-ui/scripts/musicfolders.js b/dashboard-ui/scripts/musicfolders.js index 16503ae373..21c520c5ec 100644 --- a/dashboard-ui/scripts/musicfolders.js +++ b/dashboard-ui/scripts/musicfolders.js @@ -1,4 +1,4 @@ -define(['events', 'libraryBrowser', 'imageLoader'], function (events, libraryBrowser, imageLoader) { +define(['events', 'libraryBrowser', 'imageLoader', 'cardBuilder'], function (events, libraryBrowser, imageLoader, cardBuilder) { return function (view, params, tabContent) { @@ -65,7 +65,7 @@ filterButton: false }); - var html = LibraryBrowser.getPosterViewHtml({ + var html = cardBuilder.getCardsHtml({ items: result.Items, shape: "square", context: 'folders', diff --git a/dashboard-ui/scripts/secondaryitems.js b/dashboard-ui/scripts/secondaryitems.js index 9d07586002..5dc76c0630 100644 --- a/dashboard-ui/scripts/secondaryitems.js +++ b/dashboard-ui/scripts/secondaryitems.js @@ -1,4 +1,4 @@ -define(['libraryBrowser', 'listView', 'emby-itemscontainer'], function (libraryBrowser, listView) { +define(['libraryBrowser', 'listView', 'cardBuilder', 'emby-itemscontainer'], function (libraryBrowser, listView, cardBuilder) { return function (view, params) { @@ -160,7 +160,7 @@ } // Poster - html = libraryBrowser.getPosterViewHtml(posterOptions); + html = cardBuilder.getCardsHtml(posterOptions); } var elem = view.querySelector('#items'); diff --git a/dashboard-ui/scripts/sections.js b/dashboard-ui/scripts/sections.js index 3d38436d7d..1352f15b38 100644 --- a/dashboard-ui/scripts/sections.js +++ b/dashboard-ui/scripts/sections.js @@ -1,4 +1,4 @@ -define(['libraryBrowser', 'appSettings', 'components/groupedcards', 'scrollStyles', 'emby-button', 'paper-icon-button-light', 'emby-itemscontainer'], function (LibraryBrowser, appSettings, groupedcards) { +define(['libraryBrowser', 'cardBuilder', 'appSettings', 'components/groupedcards', 'scrollStyles', 'emby-button', 'paper-icon-button-light', 'emby-itemscontainer'], function (LibraryBrowser, cardBuilder, appSettings, groupedcards) { function getUserViews(userId) { @@ -302,9 +302,9 @@ html += '
'; - html += '
'; + html += '
'; - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: items, preferThumb: true, shape: 'backdrop', @@ -348,9 +348,9 @@ if (scrollX) { html += '
'; } else { - html += '
'; + html += '
'; } - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: items, shape: getPortraitShape(), showUnplayedIndicator: false, @@ -390,10 +390,10 @@ if (scrollX) { html += '
'; } else { - html += '
'; + html += '
'; } - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: items, preferThumb: true, shape: getThumbShape(), @@ -429,8 +429,9 @@ if (result.Items.length) { html += '

' + Globalize.translate('HeaderLatestChannelMedia') + '

'; - html += '
'; - html += LibraryBrowser.getPosterViewHtml({ + html += '
'; + + html += cardBuilder.getCardsHtml({ items: result.Items, shape: 'auto', showTitle: true, @@ -473,9 +474,9 @@ if (scrollX) { html += '
'; } else { - html += '
'; + html += '
'; } - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: items, shape: scrollX ? 'overflowBackdrop' : shape, showTitle: showTitles, @@ -532,9 +533,9 @@ if (enableScrollX()) { html += '
'; } else { - html += '
'; + html += '
'; } - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: result.Items, preferThumb: true, shape: getThumbShape(), @@ -576,9 +577,9 @@ if (enableScrollX()) { html += '
'; } else { - html += '
'; + html += '
'; } - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: result.Items, preferThumb: true, shape: getThumbShape(), @@ -656,8 +657,8 @@ html += ''; html += '
'; - html += '
'; - html += LibraryBrowser.getPosterViewHtml({ + html += '
'; + html += cardBuilder.getCardsHtml({ items: result.Items, shape: 'autohome', defaultShape: 'square', @@ -704,9 +705,9 @@ if (enableScrollX()) { html += '
'; } else { - html += '
'; + html += '
'; } - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: result.Items, shape: enableScrollX() ? 'autooverflow' : 'auto', showTitle: true, diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 91f2a54f58..523551f103 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -2789,8 +2789,6 @@ var AppInfo = {}; deps.push('scripts/librarymenu'); - deps.push('css!css/card.css'); - console.log('onAppReady - loading dependencies'); require(deps, function (imageLoader, pageObjects) { diff --git a/dashboard-ui/scripts/tvgenres.js b/dashboard-ui/scripts/tvgenres.js index 00594c6d29..e11da1fb95 100644 --- a/dashboard-ui/scripts/tvgenres.js +++ b/dashboard-ui/scripts/tvgenres.js @@ -1,4 +1,4 @@ -define(['libraryBrowser'], function (libraryBrowser) { +define(['libraryBrowser', 'cardBuilder'], function (libraryBrowser, cardBuilder) { return function (view, params, tabContent) { @@ -16,7 +16,7 @@ SortOrder: "Ascending", IncludeItemTypes: "Series", Recursive: true, - Fields: "DateCreated,SyncInfo,ItemCounts", + Fields: "DateCreated,SyncInfo,ItemCounts,PrimaryImageAspectRatio", StartIndex: 0 }, view: libraryBrowser.getSavedView(key) || libraryBrowser.getDefaultItemsView('Thumb', 'Thumb') @@ -55,59 +55,56 @@ var html = ''; var viewStyle = self.getCurrentViewStyle(); + var elem = context.querySelector('#items'); if (viewStyle == "Thumb") { - html = libraryBrowser.getPosterViewHtml({ - items: result.Items, + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, shape: "backdrop", preferThumb: true, - context: 'tv', + showTitle: false, + scalable: true, showItemCounts: true, centerText: true, - lazy: true, overlayMoreButton: true }); } else if (viewStyle == "ThumbCard") { - html = libraryBrowser.getPosterViewHtml({ - items: result.Items, + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, shape: "backdrop", preferThumb: true, - context: 'tv', + showTitle: false, + scalable: true, showItemCounts: true, - cardLayout: true, - showTitle: true, - lazy: true + centerText: true, + cardLayout: true }); } else if (viewStyle == "PosterCard") { - html = libraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: "portrait", - context: 'tv', + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, + shape: "auto", + showTitle: false, + scalable: true, showItemCounts: true, - lazy: true, - cardLayout: true, - showTitle: true + centerText: true, + cardLayout: true }); } else if (viewStyle == "Poster") { - html = libraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: "portrait", - context: 'tv', - centerText: true, + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, + shape: "auto", + showTitle: false, + scalable: true, showItemCounts: true, - lazy: true, + centerText: true, overlayMoreButton: true }); } - var elem = context.querySelector('#items'); - elem.innerHTML = html; - ImageLoader.lazyChildren(elem); - libraryBrowser.saveQueryValues(getSavedQueryKey(), query); Dashboard.hideLoadingMsg(); @@ -121,7 +118,7 @@ return getPageData(tabContent).view; }; - self.setCurrentViewStyle = function(viewStyle) { + self.setCurrentViewStyle = function (viewStyle) { getPageData(tabContent).view = viewStyle; libraryBrowser.saveViewSetting(getSavedQueryKey(tabContent), viewStyle); fullyReload(); diff --git a/dashboard-ui/scripts/tvlatest.js b/dashboard-ui/scripts/tvlatest.js index 91989cfbf3..39ec77330d 100644 --- a/dashboard-ui/scripts/tvlatest.js +++ b/dashboard-ui/scripts/tvlatest.js @@ -1,4 +1,4 @@ -define(['components/categorysyncbuttons', 'components/groupedcards'], function (categorysyncbuttons, groupedcards) { +define(['components/categorysyncbuttons', 'components/groupedcards', 'cardBuilder'], function (categorysyncbuttons, groupedcards, cardBuilder) { function getView() { @@ -35,7 +35,7 @@ if (view == 'ThumbCard') { - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: items, shape: "backdrop", preferThumb: true, @@ -51,7 +51,7 @@ } else if (view == 'Thumb') { - html += LibraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: items, shape: "backdrop", preferThumb: true, diff --git a/dashboard-ui/scripts/tvrecommended.js b/dashboard-ui/scripts/tvrecommended.js index 9364795a5c..18909e65ba 100644 --- a/dashboard-ui/scripts/tvrecommended.js +++ b/dashboard-ui/scripts/tvrecommended.js @@ -1,19 +1,9 @@ -define(['libraryBrowser', 'components/categorysyncbuttons', 'scrollStyles', 'emby-itemscontainer'], function (libraryBrowser, categorysyncbuttons) { +define(['libraryBrowser', 'components/categorysyncbuttons', 'cardBuilder', 'scrollStyles', 'emby-itemscontainer'], function (libraryBrowser, categorysyncbuttons, cardBuilder) { return function (view, params) { var self = this; - function getView() { - - return 'Thumb'; - } - - function getResumeView() { - - return 'Poster'; - } - function reload() { Dashboard.showLoadingMsg(); @@ -43,41 +33,19 @@ view.querySelector('.noNextUpItems').classList.remove('hide'); } - var viewStyle = getView(); - var html = ''; + var container = view.querySelector('#nextUpItems'); + cardBuilder.buildCards(result.Items, { + itemsContainer: container, + preferThumb: true, + shape: "backdrop", + scalable: true, + showTitle: true, + showParentTitle: true, + overlayText: false, + centerText: true, + overlayPlayButton: AppInfo.enableAppLayouts + }); - if (viewStyle == 'ThumbCard') { - - html += libraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: "backdrop", - showTitle: true, - preferThumb: true, - showParentTitle: true, - lazy: true, - cardLayout: true, - showDetailsMenu: true - }); - - } else if (viewStyle == 'Thumb') { - - html += libraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: "backdrop", - showTitle: true, - showParentTitle: true, - overlayText: false, - lazy: true, - preferThumb: true, - showDetailsMenu: true, - centerText: true, - overlayPlayButton: AppInfo.enableAppLayouts - }); - } - - var elem = view.querySelector('#nextUpItems'); - elem.innerHTML = html; - ImageLoader.lazyChildren(elem); Dashboard.hideLoadingMsg(); }); } @@ -120,50 +88,33 @@ view.querySelector('#resumableSection').classList.add('hide'); } - var viewStyle = getResumeView(); - var html = ''; - - if (viewStyle == 'PosterCard') { - - html += libraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: getThumbShape(), - showTitle: true, - showParentTitle: true, - lazy: true, - cardLayout: true, - showDetailsMenu: true, - preferThumb: true - }); - - } else if (viewStyle == 'Poster') { - - html += libraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: getThumbShape(), - showTitle: true, - showParentTitle: true, - lazy: true, - showDetailsMenu: true, - overlayPlayButton: true, - preferThumb: true, - centerText: true - }); - } - - var elem = view.querySelector('#resumableItems'); - elem.innerHTML = html; - ImageLoader.lazyChildren(elem); + var container = view.querySelector('#resumableItems'); + cardBuilder.buildCards(result.Items, { + itemsContainer: container, + preferThumb: true, + shape: getThumbShape(), + scalable: true, + showTitle: true, + showParentTitle: true, + overlayText: false, + centerText: true, + overlayPlayButton: true + }); }); } self.initTab = function () { var tabContent = self.tabContent; + + var resumableItemsContainer = tabContent.querySelector('#resumableItems'); + if (enableScrollX()) { - tabContent.querySelector('#resumableItems').classList.add('hiddenScrollX'); + resumableItemsContainer.classList.add('hiddenScrollX'); + resumableItemsContainer.classList.remove('verticalItemsContainer'); } else { - tabContent.querySelector('#resumableItems').classList.remove('hiddenScrollX'); + resumableItemsContainer.classList.remove('hiddenScrollX'); + resumableItemsContainer.classList.add('verticalItemsContainer'); } categorysyncbuttons.init(tabContent); diff --git a/dashboard-ui/scripts/tvstudios.js b/dashboard-ui/scripts/tvstudios.js index a1d4313e24..8282c2b4ee 100644 --- a/dashboard-ui/scripts/tvstudios.js +++ b/dashboard-ui/scripts/tvstudios.js @@ -1,4 +1,4 @@ -define(['libraryBrowser'], function (libraryBrowser) { +define(['libraryBrowser', 'cardBuilder'], function (libraryBrowser, cardBuilder) { // The base query options var data = {}; @@ -15,7 +15,7 @@ SortOrder: "Ascending", IncludeItemTypes: "Series", Recursive: true, - Fields: "DateCreated,ItemCounts", + Fields: "DateCreated,ItemCounts,PrimaryImageAspectRatio", StartIndex: 0 } }; @@ -42,24 +42,18 @@ promise.then(function (result) { - var html = ''; - - html += libraryBrowser.getPosterViewHtml({ - items: result.Items, + var elem = context.querySelector('#items'); + cardBuilder.buildCards(result.Items, { + itemsContainer: elem, shape: "backdrop", - showTitle: false, - context: 'tv', preferThumb: true, + showTitle: false, + scalable: true, showItemCounts: true, centerText: true, - lazy: true - + overlayMoreButton: true }); - var elem = context.querySelector('#items'); - elem.innerHTML = html; - ImageLoader.lazyChildren(elem); - Dashboard.hideLoadingMsg(); }); } diff --git a/dashboard-ui/scripts/tvupcoming.js b/dashboard-ui/scripts/tvupcoming.js index eef18362eb..2acf476262 100644 --- a/dashboard-ui/scripts/tvupcoming.js +++ b/dashboard-ui/scripts/tvupcoming.js @@ -1,4 +1,4 @@ -define(['datetime', 'libraryBrowser', 'scrollStyles', 'emby-itemscontainer'], function (datetime, libraryBrowser) { +define(['datetime', 'libraryBrowser', 'cardBuilder', 'scrollStyles', 'emby-itemscontainer'], function (datetime, libraryBrowser, cardBuilder) { function getUpcomingPromise(context, params) { @@ -104,10 +104,10 @@ if (enableScrollX()) { html += '
'; } else { - html += '
'; + html += '
'; } - html += libraryBrowser.getPosterViewHtml({ + html += cardBuilder.getCardsHtml({ items: group.items, showLocationTypeIndicator: false, shape: getThumbShape(), diff --git a/dashboard-ui/secondaryitems.html b/dashboard-ui/secondaryitems.html index 2f55f833f8..703ea68e85 100644 --- a/dashboard-ui/secondaryitems.html +++ b/dashboard-ui/secondaryitems.html @@ -5,7 +5,7 @@
-
+
\ No newline at end of file diff --git a/dashboard-ui/tv.html b/dashboard-ui/tv.html index 443a8d3ab1..2921ef4b9a 100644 --- a/dashboard-ui/tv.html +++ b/dashboard-ui/tv.html @@ -34,7 +34,7 @@ ${ButtonSync}
-
+
@@ -48,7 +48,7 @@ ${ButtonSync}
-
+
@@ -86,7 +86,7 @@
-
+
@@ -96,14 +96,14 @@
-
+
-
+