(function ($, document) { $(document).on('pagebeforeshow', "#moviesLatestPage", function () { var screenWidth = $(window).width(); var page = this; var options = { SortBy: "DateCreated", SortOrder: "Descending", IncludeItemTypes: "Movie", Limit: screenWidth >= 1920 ? 32 : (screenWidth >= 1440 ? 24 : (screenWidth >= 800 ? 18 : 12)), Recursive: true, Fields: "PrimaryImageAspectRatio", Filters: "IsUnplayed" }; ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) { $('#recentlyAddedItems', page).html(LibraryBrowser.getPosterViewHtml({ items: result.Items })).createPosterItemMenus(); }); options = { SortBy: "DateCreated", SortOrder: "Descending", IncludeItemTypes: "Trailer", Limit: screenWidth >= 1920 ? 8 : (screenWidth >= 1440 ? 8 : 6), Recursive: true, Fields: "PrimaryImageAspectRatio", Filters: "IsUnplayed" }; ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) { if (result.Items.length) { $('#trailerSection', page).show(); } else { $('#trailerSection', page).hide(); } $('#trailerItems', page).html(LibraryBrowser.getPosterViewHtml({ items: result.Items })).createPosterItemMenus(); }); }); })(jQuery, document);