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

179 lines
5.1 KiB
JavaScript
Raw Normal View History

(function ($, document) {
2013-03-26 19:48:33 -07:00
2013-04-18 19:52:22 -07:00
var view = "Poster";
// The base query options
var query = {
2013-03-05 23:22:19 -07:00
SortBy: "SortName",
SortOrder: "Ascending",
Fields: "UserData,DisplayMediaType,ItemCounts,DateCreated",
2013-05-03 12:34:25 -07:00
Limit: LibraryBrowser.getDefaultPageSize(),
StartIndex: 0
};
2013-03-05 23:22:19 -07:00
function reloadItems(page) {
2013-03-30 07:57:30 -07:00
Dashboard.showLoadingMsg();
var userId = Dashboard.getCurrentUserId();
2013-03-05 23:22:19 -07:00
ApiClient.getItems(userId, query).done(function (result) {
2013-03-30 07:57:30 -07:00
var html = '';
2013-03-26 19:48:33 -07:00
2013-04-19 09:28:06 -07:00
$('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create');
2013-03-05 23:22:19 -07:00
2013-04-18 19:52:22 -07:00
if (view == "Backdrop") {
html += LibraryBrowser.getPosterDetailViewHtml({
items: result.Items,
preferBackdrop: true
});
}
else if (view == "Poster") {
html += LibraryBrowser.getPosterDetailViewHtml({
items: result.Items
2013-04-18 19:52:22 -07:00
});
}
2013-03-30 07:57:30 -07:00
2013-04-19 09:28:06 -07:00
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
2013-03-26 19:48:33 -07:00
2013-04-19 09:28:06 -07:00
$('#items', page).html(html).trigger('create');
2013-03-26 19:48:33 -07:00
2013-04-18 22:08:18 -07:00
$('.selectPage', page).on('change', function () {
query.StartIndex = (parseInt(this.value) - 1) * query.Limit;
reloadItems(page);
});
2013-03-05 23:22:19 -07:00
2013-04-18 22:08:18 -07:00
$('.btnNextPage', page).on('click', function () {
2013-04-15 15:03:05 -07:00
query.StartIndex += query.Limit;
reloadItems(page);
});
2013-04-18 22:08:18 -07:00
$('.btnPreviousPage', page).on('click', function () {
2013-04-15 15:03:05 -07:00
query.StartIndex -= query.Limit;
reloadItems(page);
});
2013-04-27 15:52:41 -07:00
$('.selectPageSize', page).on('change', function () {
query.Limit = parseInt(this.value);
query.StartIndex = 0;
reloadItems(page);
});
Dashboard.hideLoadingMsg();
});
ApiClient.getItem(userId, query.ParentId).done(function (item) {
2013-04-26 06:50:21 -07:00
var name = item.Name;
2013-04-26 06:50:21 -07:00
if (item.IndexNumber != null) {
name = item.IndexNumber + " - " + name;
}
if (item.ParentIndexNumber != null) {
name = item.ParentIndexNumber + "." + name;
}
$('#itemName', page).html(name);
2013-05-10 05:18:07 -07:00
2013-04-26 06:50:21 -07:00
Dashboard.setPageTitle(name);
2013-05-10 05:18:07 -07:00
if (ApiClient.isWebSocketOpen()) {
ApiClient.sendWebSocketMessage("Context", [item.Type, item.Id].join('|'));
}
});
2013-05-04 21:49:49 -07:00
Dashboard.getCurrentUser().done(function (user) {
if (user.Configuration.IsAdministrator) {
$('#editButtonContainer', page).show();
} else {
$('#editButtonContainer', page).hide();
}
});
}
2013-03-30 07:57:30 -07:00
$(document).on('pageinit', "#itemListPage", function () {
2013-03-30 07:57:30 -07:00
2013-04-18 19:52:22 -07:00
var page = this;
$('.radioSortBy', this).on('click', function () {
query.StartIndex = 0;
query.SortBy = this.getAttribute('data-sortby');
reloadItems(page);
});
$('.radioSortOrder', this).on('click', function () {
query.StartIndex = 0;
query.SortOrder = this.getAttribute('data-sortorder');
reloadItems(page);
});
$('.chkStandardFilter', this).on('change', function () {
var filterName = this.getAttribute('data-filter');
var filters = query.Filters || "";
filters = (',' + filters).replace(',' + filterName, '').substring(1);
if (this.checked) {
filters = filters ? (filters + ',' + filterName) : filterName;
}
query.StartIndex = 0;
query.Filters = filters;
reloadItems(page);
});
$('#selectView', this).on('change', function () {
view = this.value;
reloadItems(page);
});
2013-03-30 07:57:30 -07:00
2013-05-04 21:49:49 -07:00
$('#btnEdit', page).on('click', function () {
2013-05-12 18:46:56 -07:00
Dashboard.navigate("edititemimages.html?id=" + query.ParentId);
2013-05-04 21:49:49 -07:00
});
2013-04-16 09:45:28 -07:00
}).on('pageshow', "#itemListPage", function () {
2013-03-30 07:57:30 -07:00
query.ParentId = getParameterByName('parentId');
2013-04-18 19:52:22 -07:00
query.Filters = "";
query.SortBy = "SortName";
query.SortOrder = "Ascending";
query.StartIndex = 0;
2013-04-18 19:52:22 -07:00
reloadItems(this);
2013-03-30 07:57:30 -07:00
2013-04-18 19:52:22 -07:00
// Reset form values using the last used query
$('.radioSortBy', this).each(function () {
this.checked = query.SortBy == this.getAttribute('data-sortby');
}).checkboxradio('refresh');
$('.radioSortOrder', this).each(function () {
this.checked = query.SortOrder == this.getAttribute('data-sortorder');
}).checkboxradio('refresh');
$('.chkStandardFilter', this).each(function () {
var filters = "," + (query.Filters || "");
var filterName = this.getAttribute('data-filter');
this.checked = filters.indexOf(',' + filterName) != -1;
}).checkboxradio('refresh');
$('#selectView', this).val(view).selectmenu('refresh');
});
2013-03-05 23:22:19 -07:00
})(jQuery, document);