From 7c43c7858ae796a1d4d0546683a0a05f73af89ff Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 28 Apr 2013 13:21:56 -0400 Subject: [PATCH] display video backdrops on detail page --- ApiClient.js | 29 +++++ dashboard-ui/itemdetails.html | 6 + dashboard-ui/scripts/Itemdetailpage.js | 154 +++++++++++-------------- dashboard-ui/scripts/search.js | 4 +- packages.config | 2 +- 5 files changed, 103 insertions(+), 92 deletions(-) diff --git a/ApiClient.js b/ApiClient.js index 42aa7d52c0..9999c0fe0f 100644 --- a/ApiClient.js +++ b/ApiClient.js @@ -1733,6 +1733,35 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + self.getVideoBackdrops = function (userId, itemId) { + + if (!userId) { + throw new Error("null userId"); + } + if (!itemId) { + throw new Error("null itemId"); + } + + var url = self.getUrl("Users/" + userId + "/Items/" + itemId + "/VideoBackdrops"); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + + self.getSearchHints = function (options) { + + var url = self.getUrl("Search/Hints", options); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + /** * Gets special features for an item */ diff --git a/dashboard-ui/itemdetails.html b/dashboard-ui/itemdetails.html index b8aab4258f..f429743365 100644 --- a/dashboard-ui/itemdetails.html +++ b/dashboard-ui/itemdetails.html @@ -170,6 +170,12 @@
+
+ +
diff --git a/dashboard-ui/scripts/Itemdetailpage.js b/dashboard-ui/scripts/Itemdetailpage.js index 5f6fe464dc..0dff815334 100644 --- a/dashboard-ui/scripts/Itemdetailpage.js +++ b/dashboard-ui/scripts/Itemdetailpage.js @@ -221,10 +221,15 @@ } $('#themeSongsCollapsible', page).hide(); + $('#videoBackdropsCollapsible', page).hide(); ApiClient.getThemeSongs(Dashboard.getCurrentUserId(), item.Id).done(function (result) { renderThemeSongs(page, item, result); }); + + ApiClient.getVideoBackdrops(Dashboard.getCurrentUserId(), item.Id).done(function (result) { + renderVideoBackdrops(page, item, result); + }); } function renderDetails(page, item, context) { @@ -310,6 +315,16 @@ } } + function renderVideoBackdrops(page, item, result) { + + if (result.Items.length) { + + $('#videoBackdropsCollapsible', page).show(); + + $('#videoBackdropsContent', page).html(getVideosHtml(result.Items)).trigger('create'); + } + } + function renderScenes(page, item) { var html = ''; @@ -446,98 +461,65 @@ $('#mediaInfoContent', page).html(html).trigger('create'); } - function renderSpecials(page, item) { + function getVideosHtml(items) { + var html = ''; + for (var i = 0, length = items.length; i < length; i++) { + + var item = items[i]; + + html += ''; + } + + return html; + } + + function renderSpecials(page, item) { + ApiClient.getSpecialFeatures(Dashboard.getCurrentUserId(), item.Id).done(function (specials) { - for (var i = 0, length = specials.length; i < length; i++) { - - var special = specials[i]; - - html += ''; - } - - $('#specialsContent', page).html(html); + $('#specialsContent', page).html(getVideosHtml(specials)); }); } function renderTrailers(page, item) { - var html = ''; ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), item.Id).done(function (trailers) { - for (var i = 0, length = trailers.length; i < length; i++) { - - var trailer = trailers[i]; - - html += ''; - } - - $('#trailersContent', page).html(html); + $('#trailersContent', page).html(getVideosHtml(trailers)); }); } @@ -633,15 +615,9 @@ self.play = play; - self.playTrailer = function (index) { - ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), currentItem.Id).done(function (trailers) { - MediaPlayer.play([trailers[index]]); - }); - }; - - self.playSpecial = function (index) { - ApiClient.getSpecialFeatures(Dashboard.getCurrentUserId(), currentItem.Id).done(function (specials) { - MediaPlayer.play([specials[index]]); + self.playById = function (id) { + ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) { + MediaPlayer.play([item]); }); }; } diff --git a/dashboard-ui/scripts/search.js b/dashboard-ui/scripts/search.js index 7f1224f507..aa787e6e35 100644 --- a/dashboard-ui/scripts/search.js +++ b/dashboard-ui/scripts/search.js @@ -64,7 +64,7 @@ var currentTimeout = searchHintTimeout; - $.getJSON(ApiClient.getUrl("Search/Hints", { userId: Dashboard.getCurrentUserId(), searchTerm: searchTerm, limit: 10 })).done(function (result) { + ApiClient.getSearchHints(ApiClient.getUrl({ userId: Dashboard.getCurrentUserId(), searchTerm: searchTerm, limit: 10 })).done(function (result) { if (currentTimeout != searchHintTimeout) { return; @@ -253,7 +253,7 @@ } window.Search = new search(); - + $(document).on('pagehide', ".libraryPage", function () { hideFlyout(this); diff --git a/packages.config b/packages.config index 31331b60d3..56ad5f6568 100644 --- a/packages.config +++ b/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file