2013-03-05 23:22:19 -07:00
|
|
|
|
var ItemListPage = {
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
2013-03-05 23:22:19 -07:00
|
|
|
|
onPageShow: function () {
|
|
|
|
|
|
|
|
|
|
ItemListPage.reload();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reload: function () {
|
|
|
|
|
|
2013-03-30 07:57:30 -07:00
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
|
2013-03-05 23:22:19 -07:00
|
|
|
|
var parentId = getParameterByName('parentId');
|
|
|
|
|
|
2013-03-26 19:48:33 -07:00
|
|
|
|
var query = {
|
2013-03-28 22:45:21 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio",
|
2013-03-30 07:57:30 -07:00
|
|
|
|
Recursive: getParameterByName('Recursive') == 'true'
|
2013-03-26 19:48:33 -07:00
|
|
|
|
};
|
|
|
|
|
|
2013-03-30 07:57:30 -07:00
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-31 10:39:28 -07:00
|
|
|
|
var sortBy = getParameterByName('SortBy') || 'SortName';
|
|
|
|
|
query.SortBy = sortBy;
|
|
|
|
|
$('.radioSortBy', page).checked(false).checkboxradio("refresh");
|
|
|
|
|
$('#radio' + sortBy, page).checked(true).checkboxradio("refresh");
|
|
|
|
|
|
|
|
|
|
var order = getParameterByName('SortOrder') || 'Ascending';
|
|
|
|
|
|
|
|
|
|
query.SortOrder = order;
|
|
|
|
|
$('.radioSortOrder', page).checked(false).checkboxradio("refresh");
|
|
|
|
|
$('#radio' + order, page).checked(true).checkboxradio("refresh");
|
|
|
|
|
|
2013-03-30 07:57:30 -07:00
|
|
|
|
query.Filters = filters.join(',');
|
2013-03-31 10:39:28 -07:00
|
|
|
|
//query.limit = 100;
|
2013-03-30 07:57:30 -07:00
|
|
|
|
|
2013-03-05 23:22:19 -07:00
|
|
|
|
if (parentId) {
|
|
|
|
|
query.parentId = parentId;
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
2013-03-28 22:45:21 -07:00
|
|
|
|
ApiClient.getItem(Dashboard.getCurrentUserId(), parentId).done(ItemListPage.renderTitle);
|
2013-03-30 07:57:30 -07:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$('#itemName', page).html(getParameterByName('Title') || "Media Library");
|
2013-03-05 23:22:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-28 22:45:21 -07:00
|
|
|
|
ItemListPage.refreshItems(query);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
refreshItems: function (query) {
|
|
|
|
|
|
2013-03-30 07:57:30 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2013-03-28 22:45:21 -07:00
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
|
|
|
|
|
page.itemQuery = query;
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(ItemListPage.renderItems);
|
2013-03-05 23:22:19 -07:00
|
|
|
|
},
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
|
|
|
|
renderItems: function (result) {
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
|
|
|
|
var items = result.Items;
|
|
|
|
|
|
2013-03-30 07:57:30 -07:00
|
|
|
|
var query = $.mobile.activePage.itemQuery;
|
|
|
|
|
|
2013-03-05 23:22:19 -07:00
|
|
|
|
var renderOptions = {
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
|
|
|
|
items: items,
|
2013-03-30 07:57:30 -07:00
|
|
|
|
useAverageAspectRatio: query.Recursive !== true,
|
|
|
|
|
showTitle: query.Recursive
|
2013-03-05 23:22:19 -07:00
|
|
|
|
};
|
|
|
|
|
|
2013-04-01 22:14:37 -07:00
|
|
|
|
var html = LibraryBrowser.getPosterViewHtml(renderOptions);
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
|
|
|
|
$('#listItems', $.mobile.activePage).html(html);
|
2013-03-30 07:57:30 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-03-05 23:22:19 -07:00
|
|
|
|
},
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
2013-03-05 23:22:19 -07:00
|
|
|
|
renderTitle: function (item) {
|
2013-03-26 19:48:33 -07:00
|
|
|
|
|
2013-03-05 23:22:19 -07:00
|
|
|
|
|
|
|
|
|
$('#itemName', $.mobile.activePage).html(item.Name);
|
2013-03-28 22:45:21 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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);
|
2013-03-30 07:57:30 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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" });
|
2013-03-05 23:22:19 -07:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$(document).on('pageshow', "#itemListPage", ItemListPage.onPageShow);
|