make web client images more efficient by using max height instead of height

This commit is contained in:
Luke Pulverenti 2013-11-09 13:44:38 -05:00
parent 25cb195ec6
commit 144ee15789
5 changed files with 47 additions and 34 deletions

View File

@ -502,7 +502,7 @@
var query = {
ParentId: item.Id,
SortBy: sortBy,
Fields: "PrimaryImageAspectRatio,ItemCounts,DateCreated,AudioInfo"
Fields: "ItemCounts,DateCreated,AudioInfo"
};
if (item.Type == "Series" || item.Type == "Season") {

View File

@ -63,7 +63,7 @@
return { attr: { id: item.Id, rel: rel, itemtype: item.Type }, data: htmlName, state: state };
}
function loadNode(page, node, openItems, selectedId, callback) {
function loadNode(page, node, openItems, selectedId, currentUser, callback) {
if (node == '-1') {
@ -76,13 +76,20 @@
return;
}
ApiClient.getItems(Dashboard.getCurrentUserId(), {
var query = {
ParentId: node.attr("id"),
SortBy: 'SortName',
Fields: 'MetadataSettings'
};
if (!currentUser.Configuration.DisplayMissingEpisodes) {
query.IsMissing = false;
}
if (!currentUser.Configuration.DisplayUnairedEpisodes) {
query.IsVirtualUnaired = false;
}
}).done(function (result) {
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
var nodes = result.Items.map(function (i) {
@ -120,20 +127,20 @@
$(document).scrollTop(0);
}
function initializeTree(page, openItems, selectedId) {
function initializeTree(page, currentUser, openItems, selectedId) {
$('.libraryTree', page).jstree({
"plugins": ["themes", "ui", "json_data"],
data: function (node, callback) {
loadNode(page, node, openItems, selectedId, callback);
loadNode(page, node, openItems, selectedId, currentUser, callback);
},
json_data: {
data: function (node, callback) {
loadNode(page, node, openItems, selectedId, callback);
loadNode(page, node, openItems, selectedId, currentUser, callback);
}
},
@ -164,22 +171,26 @@
var page = this;
var id = MetadataEditor.currentItemId;
Dashboard.getCurrentUser().done(function(user) {
var id = MetadataEditor.currentItemId;
if (id) {
if (id) {
ApiClient.getAncestorItems(id, Dashboard.getCurrentUserId()).done(function (ancestors) {
ApiClient.getAncestorItems(id, user.Id).done(function (ancestors) {
var ids = ancestors.map(function (i) {
return i.Id;
var ids = ancestors.map(function (i) {
return i.Id;
});
initializeTree(page, user, ids, id);
});
initializeTree(page, ids, id);
});
} else {
initializeTree(page, user, []);
}
} else {
initializeTree(page, []);
}
});
}).on('pagebeforehide', ".metadataEditorPage", function () {

View File

@ -10,7 +10,9 @@
IncludeItemTypes: "Episode",
Recursive: true,
Fields: "DateCreated,SeriesInfo",
StartIndex: 0
StartIndex: 0,
IsMissing: false,
IsVirtualUnaired: false
};
function reloadItems(page) {
@ -49,7 +51,7 @@
query.StartIndex = 0;
query.SortOrder = 'Ascending';
query.SortBy = $('.defaultSort', page).data('sortby');
reloadItems(page);
});
@ -83,7 +85,7 @@
}
function updateFilterControls(page) {
// Reset form values using the last used query
$('.radioSortBy', page).each(function () {
@ -224,15 +226,23 @@
$('#chkMissingEpisode', this).on('change', function () {
query.StartIndex = 0;
query.IsMissing = this.checked ? true : null;
query.IsMissing = this.checked ? true : false;
reloadItems(page);
});
$('#chkFutureEpisode', this).on('change', function () {
query.StartIndex = 0;
query.IsUnaired = this.checked ? true : null;
if (this.checked) {
query.IsUnaired = true;
query.IsVirtualUnaired = null;
} else {
query.IsUnaired = null;
query.IsVirtualUnaired = false;
}
reloadItems(page);
});

View File

@ -66,8 +66,6 @@
options.shape = options.preferBackdrop ? "backdrop" : "poster";
}
var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
var html = '';
for (var i = 0, length = items.length; i < length; i++) {
@ -87,7 +85,6 @@
var imgUrl = null;
var isDefault = false;
var height = null;
var width = null;
var cssClass = "tileItem";
@ -117,23 +114,19 @@
else if (item.ImageTags && item.ImageTags.Primary) {
height = 300;
width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null;
imgUrl = LibraryBrowser.getImageUrl(item, 'Primary', 0, {
height: height,
width: width
maxheight: height
});
}
else if (item.AlbumId && item.AlbumPrimaryImageTag) {
height = 300;
width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null;
imgUrl = ApiClient.getImageUrl(item.AlbumId, {
type: "Primary",
height: 100,
width: width,
tag: item.AlbumPrimaryImageTag
});

View File

@ -11,7 +11,7 @@
IncludeItemTypes: "Episode",
Limit: 30,
Recursive: true,
Fields: "PrimaryImageAspectRatio,SeriesInfo,UserData",
Fields: "SeriesInfo,UserData",
IsUnaired: true
};
@ -23,7 +23,6 @@
}
$('#upcomingItems', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
useAverageAspectRatio: true,
showLocationTypeIndicator: false,
showNewIndicator: false,
shape: "backdrop",