progress on movies home page

This commit is contained in:
Luke Pulverenti 2013-04-01 11:59:56 -04:00
parent 89472754ad
commit ae312524dd
7 changed files with 103 additions and 45 deletions

View file

@ -424,7 +424,7 @@ form, .readOnlyContent {
.posterViewItem img { .posterViewItem img {
max-width: 155px; max-width: 155px;
max-height: 148px; max-height: 125px;
vertical-align: bottom; vertical-align: bottom;
} }
@ -486,7 +486,7 @@ form, .readOnlyContent {
.posterViewItem img { .posterViewItem img {
max-width: 190px; max-width: 190px;
max-height: 190px; max-height: 160px;
} }
} }
@ -494,7 +494,7 @@ form, .readOnlyContent {
.posterViewItem img { .posterViewItem img {
max-width: 250px; max-width: 250px;
max-height: 250px; max-height: 200px;
} }
} }
@ -519,7 +519,7 @@ form, .readOnlyContent {
.posterViewItem img { .posterViewItem img {
max-width: 300px; max-width: 300px;
max-height: 300px; max-height: 250px;
} }
} }

View file

@ -5,7 +5,7 @@
</head> </head>
<body> <body>
<div id="moviesPage" data-role="page" class="page libraryPage noLogoPage" data-theme="a"> <div id="moviesPage" data-role="page" class="page libraryPage noLogoPage" data-theme="a">
<h1 class="libraryPageHeader"><a href="index.html" class="imageLink"> <h1 class="libraryPageHeader"><a href="../index.html" class="imageLink">
<img src="css/images/home.png"></a>Movies</h1> <img src="css/images/home.png"></a>Movies</h1>
<div data-role="content"> <div data-role="content">
<div data-role="controlgroup" data-type="horizontal" class="libraryViewNav" data-mini="true"> <div data-role="controlgroup" data-type="horizontal" class="libraryViewNav" data-mini="true">

View file

@ -18,15 +18,20 @@
<a href="#" data-role="button">Favorites</a> <a href="#" data-role="button">Favorites</a>
</div> </div>
<h1 class="listHeader firstListHeader">Latest Movies</h1> <div class="ehsContent">
<h1 class="listHeader firstListHeader">Latest Movies</h1>
<div> <div id="recentlyAddedItems">
</div>
<div id="resumableSection" style="display: none;">
<h1 class="listHeader">Resume</h1>
<div id="resumableItems">
</div>
</div>
</div> </div>
<h1 class="listHeader">Resume</h1>
<div></div>
</div> </div>
</div> </div>
</body> </body>

View file

@ -1,24 +1,12 @@
var AboutPage = { (function ($, document) {
onPageShow: function () { $(document).on('pageshow', "#aboutPage", function () {
AboutPage.pollForInfo();
},
var page = this;
pollForInfo: function () { ApiClient.getSystemInfo().done(function(info) {
ApiClient.getSystemInfo().done(AboutPage.renderInfo); $('#appVersionNumber', page).html(info.Version);
}, });
});
renderInfo: function (info) { })(jQuery, document);
AboutPage.renderSystemInfo(info);
},
renderSystemInfo: function (info) {
var page = $.mobile.activePage;
$('#appVersionNumber', page).html(info.Version);
},
};
$(document).on('pageshow', "#aboutPage", AboutPage.onPageShow);

View file

@ -1,10 +1,10 @@
var IndexPage = { (function ($, document) {
onPageShow: function () { $(document).on('pageshow', "#indexPage", function () {
IndexPage.loadLibrary(Dashboard.getCurrentUserId(), this);
},
loadLibrary: function (userId, page) { var page = this;
var userId = Dashboard.getCurrentUserId();
if (!userId) { if (!userId) {
return; return;
@ -25,7 +25,6 @@
})); }));
}); });
} });
};
$(document).on('pageshow', "#indexPage", IndexPage.onPageShow); })(jQuery, document);

View file

@ -0,0 +1,56 @@
(function ($, document) {
$(document).on('pageshow', "#moviesRecommendedPage", function () {
var page = this;
var options = {
SortBy: "DateCreated",
SortOrder: "Descending",
IncludeItemTypes: "Movie",
Limit: 5,
Recursive: true,
Fields: "PrimaryImageAspectRatio"
};
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
$('#recentlyAddedItems', page).html(Dashboard.getPosterViewHtml({
items: result.Items,
useAverageAspectRatio: true
}));
});
options = {
SortBy: "DatePlayed",
SortOrder: "Descending",
IncludeItemTypes: "Movie",
Filters: "IsResumable",
Limit: 5,
Recursive: true,
Fields: "PrimaryImageAspectRatio"
};
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
if (result.Items.length) {
$('#resumableSection', page).show();
} else {
$('#resumableSection', page).hide();
}
$('#resumableItems', page).html(Dashboard.getPosterViewHtml({
items: result.Items,
useAverageAspectRatio: true
}));
});
});
})(jQuery, document);

View file

@ -493,8 +493,7 @@ var Dashboard = {
getAveragePrimaryImageAspectRatio: function (items) { getAveragePrimaryImageAspectRatio: function (items) {
var total = 0; var values = [];
var count = 0;
for (var i = 0, length = items.length; i < length; i++) { for (var i = 0, length = items.length; i < length; i++) {
@ -504,11 +503,22 @@ var Dashboard = {
continue; continue;
} }
total += ratio; values[values.length] = ratio;
count++;
} }
return count == 0 ? 1 : total / count; if (!values.length) {
return null;
}
// Use the median
values.sort(function (a, b) { return a - b; });
var half = Math.floor(values.length / 2);
if (values.length % 2)
return values[half];
else
return (values[half - 1] + values[half]) / 2.0;
}, },
showUserFlyout: function () { showUserFlyout: function () {