From b7b071a02fd09f25eb6a0cca4be94e86930d25fa Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 26 Mar 2013 22:48:33 -0400 Subject: [PATCH] sort and display uniformly --- dashboard-ui/scripts/itemlistpage.js | 25 +++++++++++-------- dashboard-ui/scripts/site.js | 37 +++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/dashboard-ui/scripts/itemlistpage.js b/dashboard-ui/scripts/itemlistpage.js index bf89fa8138..2538796381 100644 --- a/dashboard-ui/scripts/itemlistpage.js +++ b/dashboard-ui/scripts/itemlistpage.js @@ -1,5 +1,5 @@ var ItemListPage = { - + onPageShow: function () { ItemListPage.reload(); @@ -11,33 +11,38 @@ var parentId = getParameterByName('parentId'); - var query = {}; - + var query = { + SortBy: "SortName", + + Fields: "PrimaryImageAspectRatio" + }; + if (parentId) { query.parentId = parentId; - + ApiClient.getItem(userId, parentId).done(ItemListPage.renderTitle); } ApiClient.getItems(userId, query).done(ItemListPage.renderItems); }, - - renderItems: function(result) { + + renderItems: function (result) { var items = result.Items; var renderOptions = { - - items: items + + items: items, + useAverageAspectRatio: true }; var html = Dashboard.getPosterViewHtml(renderOptions); $('#listItems', $.mobile.activePage).html(html); }, - + renderTitle: function (item) { - + $('#itemName', $.mobile.activePage).html(item.Name); } diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 3e70c5c310..1e2405ef62 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -423,10 +423,14 @@ var Dashboard = { getPosterViewHtml: function (options) { + var items = options.items; + + var primaryImageAspectRatio = options.useAverageAspectRatio ? Dashboard.getAveragePrimaryImageAspectRatio(items) : null; + var html = ""; - for (var i = 0, length = options.items.length; i < length; i++) { - var item = options.items[i]; + for (var i = 0, length = items.length; i < length; i++) { + var item = items[i]; var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary; @@ -446,11 +450,17 @@ var Dashboard = { tag: item.BackdropImageTags[0] }) + "' />"; } else if (hasPrimaryImage) { + + var height = 300; + var width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null; + html += ""; + } else if (item.BackdropImageTags && item.BackdropImageTags.length) { html += "