jellyfin-web/dashboard-ui/scripts/tvstudios.js

80 lines
2.0 KiB
JavaScript
Raw Normal View History

define([], function () {
2016-03-18 12:43:17 -07:00
// The base query options
var data = {};
function getQuery(params) {
var key = getSavedQueryKey();
var pageData = data[key];
if (!pageData) {
pageData = data[key] = {
query: {
SortBy: "SortName",
SortOrder: "Ascending",
IncludeItemTypes: "Series",
Recursive: true,
Fields: "DateCreated,ItemCounts",
2016-04-23 11:40:36 -07:00
StartIndex: 0
2016-03-18 12:43:17 -07:00
}
};
pageData.query.ParentId = params.topParentId;
}
return pageData.query;
}
function getSavedQueryKey() {
return LibraryBrowser.getSavedQueryKey('studios');
}
2016-06-29 10:43:34 -07:00
function getPromise(context, params) {
2016-03-18 12:43:17 -07:00
var query = getQuery(params);
Dashboard.showLoadingMsg();
2016-06-29 10:43:34 -07:00
return ApiClient.getStudios(Dashboard.getCurrentUserId(), query);
}
function reloadItems(context, params, promise) {
promise.then(function (result) {
2016-03-18 12:43:17 -07:00
var html = '';
html += LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "backdrop",
showTitle: false,
context: 'tv',
preferThumb: true,
showItemCounts: true,
centerText: true,
lazy: true
});
var elem = context.querySelector('#items');
elem.innerHTML = html;
ImageLoader.lazyChildren(elem);
Dashboard.hideLoadingMsg();
});
2015-06-29 18:56:25 -07:00
}
2016-03-18 12:43:17 -07:00
return function (view, params, tabContent) {
2016-06-29 10:43:34 -07:00
var self = this;
var promise;
self.preRender = function () {
promise = getPromise(view, params);
};
2016-03-18 12:43:17 -07:00
self.renderTab = function () {
2016-06-29 10:43:34 -07:00
reloadItems(tabContent, params, promise);
2016-03-18 12:43:17 -07:00
};
};
});