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-05-15 12:40:47 -07:00
|
|
|
|
|
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",
|
2013-04-28 13:30:33 -07:00
|
|
|
|
Fields: "UserData,DisplayMediaType,ItemCounts,DateCreated",
|
2013-04-14 14:30:10 -07:00
|
|
|
|
StartIndex: 0
|
|
|
|
|
};
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
2013-06-02 07:33:51 -07:00
|
|
|
|
var currentItem;
|
|
|
|
|
|
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-05-17 12:18:54 -07:00
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
|
|
|
|
$(document).scrollTop(0);
|
|
|
|
|
|
2013-04-14 14:30:10 -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({
|
2013-04-28 13:30:33 -07:00
|
|
|
|
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 () {
|
2013-04-14 14:30:10 -07:00
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
2013-03-28 22:45:21 -07:00
|
|
|
|
|
2013-06-02 07:33:51 -07:00
|
|
|
|
var promise = query.ParentId ? ApiClient.getItem(userId, query.ParentId) : ApiClient.getRootFolder(userId);
|
|
|
|
|
|
|
|
|
|
promise.done(function (item) {
|
|
|
|
|
|
|
|
|
|
currentItem = item;
|
2013-03-28 22:45:21 -07:00
|
|
|
|
|
2013-04-26 06:50:21 -07:00
|
|
|
|
var name = item.Name;
|
2013-03-28 22:45:21 -07:00
|
|
|
|
|
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-15 12:40:47 -07:00
|
|
|
|
|
2013-04-26 06:50:21 -07:00
|
|
|
|
Dashboard.setPageTitle(name);
|
2013-05-15 12:40:47 -07:00
|
|
|
|
|
2013-05-10 05:18:07 -07:00
|
|
|
|
if (ApiClient.isWebSocketOpen()) {
|
2013-05-21 20:59:55 -07:00
|
|
|
|
ApiClient.sendWebSocketMessage("Context", [item.Type, item.Id, item.Name].join('|'));
|
2013-05-10 05:18:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-14 14:30:10 -07:00
|
|
|
|
});
|
2013-05-15 12:40:47 -07:00
|
|
|
|
|
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-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-05-04 21:49:49 -07:00
|
|
|
|
$('#btnEdit', page).on('click', function () {
|
|
|
|
|
|
2013-06-02 07:33:51 -07:00
|
|
|
|
Dashboard.navigate("edititemmetadata.html?id=" + currentItem.Id);
|
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
|
|
|
|
|
2013-05-15 12:40:47 -07:00
|
|
|
|
query.Limit = LibraryBrowser.getDefaultPageSize();
|
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-27 17:39:05 -07:00
|
|
|
|
query.StartIndex = 0;
|
2013-05-15 12:40:47 -07:00
|
|
|
|
|
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-06-02 07:33:51 -07:00
|
|
|
|
|
|
|
|
|
}).on('pagehide', "#itemListPage", function () {
|
|
|
|
|
|
|
|
|
|
currentItem = null;
|
|
|
|
|
|
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);
|