mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 02:48:19 -07:00
182 lines
4.9 KiB
JavaScript
182 lines
4.9 KiB
JavaScript
var ItemListPage = {
|
|
|
|
onPageShow: function () {
|
|
|
|
ItemListPage.reload();
|
|
},
|
|
|
|
reload: function () {
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
var parentId = getParameterByName('parentId');
|
|
|
|
var query = {
|
|
Fields: "PrimaryImageAspectRatio",
|
|
SortBy: "SortName",
|
|
Recursive: getParameterByName('Recursive') == 'true'
|
|
};
|
|
|
|
var filters = [];
|
|
|
|
if (getParameterByName('IsResumable') == 'true') {
|
|
filters.push("IsResumable");
|
|
$('#chkResumable', page).checked(true).checkboxradio("refresh");
|
|
}
|
|
|
|
if (getParameterByName('IsFavorite') == 'true') {
|
|
filters.push("IsFavorite");
|
|
$('#chkIsFavorite', page).checked(true).checkboxradio("refresh");
|
|
}
|
|
|
|
if (getParameterByName('IsRecentlyAdded') == 'true') {
|
|
filters.push("IsRecentlyAdded");
|
|
$('#chkRecentlyAdded', page).checked(true).checkboxradio("refresh");
|
|
}
|
|
|
|
query.Filters = filters.join(',');
|
|
|
|
if (parentId) {
|
|
query.parentId = parentId;
|
|
|
|
ApiClient.getItem(Dashboard.getCurrentUserId(), parentId).done(ItemListPage.renderTitle);
|
|
}
|
|
else {
|
|
$('#itemName', page).html(getParameterByName('Title') || "Media Library");
|
|
}
|
|
|
|
ItemListPage.refreshItems(query);
|
|
},
|
|
|
|
refreshItems: function (query) {
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
page.itemQuery = query;
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(ItemListPage.renderItems);
|
|
},
|
|
|
|
renderItems: function (result) {
|
|
|
|
var items = result.Items;
|
|
|
|
var query = $.mobile.activePage.itemQuery;
|
|
|
|
var renderOptions = {
|
|
|
|
items: items,
|
|
useAverageAspectRatio: query.Recursive !== true,
|
|
showTitle: query.Recursive
|
|
};
|
|
|
|
var html = Dashboard.getPosterViewHtml(renderOptions);
|
|
|
|
$('#listItems', $.mobile.activePage).html(html);
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
},
|
|
|
|
renderTitle: function (item) {
|
|
|
|
|
|
$('#itemName', $.mobile.activePage).html(item.Name);
|
|
},
|
|
|
|
sortBy: function (sortBy) {
|
|
|
|
var query = $.mobile.activePage.itemQuery;
|
|
query.SortBy = sortBy;
|
|
ItemListPage.refreshItems(query);
|
|
},
|
|
|
|
sortOrder: function (order) {
|
|
|
|
var query = $.mobile.activePage.itemQuery;
|
|
query.SortOrder = order;
|
|
ItemListPage.refreshItems(query);
|
|
},
|
|
|
|
filter: function(name, add)
|
|
{
|
|
var query = $.mobile.activePage.itemQuery;
|
|
var filters = query.Filters || "";
|
|
|
|
filters = (',' + filters).replace(',' + name, '').substring(1);
|
|
|
|
if (add) {
|
|
filters = filters ? (filters + ',' + name) : name;
|
|
}
|
|
|
|
query.Filters = filters;
|
|
|
|
query.Recursive = filters.length ? true : false;
|
|
|
|
ItemListPage.refreshItems(query);
|
|
},
|
|
|
|
showSortPanel: function () {
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
$('#viewpanel', page).hide();
|
|
$('#filterpanel', page).hide();
|
|
$('#indexpanel', page).hide();
|
|
$('#sortpanel', page).show();
|
|
|
|
$('#btnViewPanel', page).buttonMarkup({ theme: "c" });
|
|
$('#btnSortPanel', page).buttonMarkup({ theme: "a" });
|
|
$('#btnIndexPanel', page).buttonMarkup({ theme: "c" });
|
|
$('#btnFilterPanel', page).buttonMarkup({ theme: "c" });
|
|
},
|
|
|
|
showViewPanel: function () {
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
$('#viewpanel', page).show();
|
|
$('#filterpanel', page).hide();
|
|
$('#indexpanel', page).hide();
|
|
$('#sortpanel', page).hide();
|
|
|
|
$('#btnViewPanel', page).buttonMarkup({ theme: "a" });
|
|
$('#btnSortPanel', page).buttonMarkup({ theme: "c" });
|
|
$('#btnIndexPanel', page).buttonMarkup({ theme: "c" });
|
|
$('#btnFilterPanel', page).buttonMarkup({ theme: "c" });
|
|
},
|
|
|
|
showIndexPanel: function () {
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
$('#viewpanel', page).hide();
|
|
$('#filterpanel', page).hide();
|
|
$('#indexpanel', page).show();
|
|
$('#sortpanel', page).hide();
|
|
|
|
$('#btnViewPanel', page).buttonMarkup({ theme: "c" });
|
|
$('#btnSortPanel', page).buttonMarkup({ theme: "c" });
|
|
$('#btnIndexPanel', page).buttonMarkup({ theme: "a" });
|
|
$('#btnFilterPanel', page).buttonMarkup({ theme: "c" });
|
|
},
|
|
|
|
showFilterPanel: function () {
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
$('#viewpanel', page).hide();
|
|
$('#filterpanel', page).show();
|
|
$('#indexpanel', page).hide();
|
|
$('#sortpanel', page).hide();
|
|
|
|
$('#btnViewPanel', page).buttonMarkup({ theme: "c" });
|
|
$('#btnSortPanel', page).buttonMarkup({ theme: "c" });
|
|
$('#btnIndexPanel', page).buttonMarkup({ theme: "c" });
|
|
$('#btnFilterPanel', page).buttonMarkup({ theme: "a" });
|
|
}
|
|
};
|
|
|
|
$(document).on('pageshow', "#itemListPage", ItemListPage.onPageShow);
|