2013-04-14 14:30:10 -07:00
|
|
|
|
(function ($, document) {
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
2013-04-18 19:52:22 -07:00
|
|
|
|
var view = "Poster";
|
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
// The base query options
|
|
|
|
|
var query = {
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
SortBy: "SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
Fields: "PrimaryImageAspectRatio,UserData,DisplayMediaType,ItemCounts,DateCreated",
|
|
|
|
|
Limit: LibraryBrowser.getDetaultPageSize(),
|
|
|
|
|
StartIndex: 0
|
|
|
|
|
};
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
function reloadItems(page) {
|
2013-03-28 22:45:21 -07:00
|
|
|
|
|
2013-03-30 07:57:30 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
ApiClient.getItems(userId, query).done(function (result) {
|
2013-03-30 07:57:30 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
var html = '';
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
var showPaging = result.TotalRecordCount > query.Limit;
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
if (showPaging) {
|
|
|
|
|
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true);
|
|
|
|
|
}
|
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,
|
|
|
|
|
useAverageAspectRatio: true,
|
|
|
|
|
preferBackdrop: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (view == "Poster") {
|
|
|
|
|
html += LibraryBrowser.getPosterDetailViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
useAverageAspectRatio: true
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-03-30 07:57:30 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
if (showPaging) {
|
|
|
|
|
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
|
|
|
|
|
}
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
var elem = $('#items', page).html(html).trigger('create');
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
$('select', elem).on('change', function () {
|
|
|
|
|
query.StartIndex = (parseInt(this.value) - 1) * query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
2013-04-15 15:03:05 -07:00
|
|
|
|
$('.btnNextPage', elem).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', elem).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
2013-03-28 22:45:21 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
ApiClient.getItem(userId, query.ParentId).done(function (item) {
|
2013-03-28 22:45:21 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
$('#itemName', page).html(item.Name);
|
2013-03-28 22:45:21 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-03-30 07:57:30 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -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-04-16 09:45:28 -07:00
|
|
|
|
}).on('pageshow', "#itemListPage", function () {
|
2013-03-30 07:57:30 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
query.ParentId = getParameterByName('parentId');
|
2013-04-18 19:52:22 -07:00
|
|
|
|
query.Filters = "";
|
|
|
|
|
query.SortBy = "SortName";
|
|
|
|
|
query.SortOrder = "Ascending";
|
|
|
|
|
|
2013-04-14 14:30:10 -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-04-14 14:30:10 -07:00
|
|
|
|
});
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
})(jQuery, document);
|