2013-04-01 17:54:06 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
var view = "Tile";
|
2013-04-08 14:05:00 -07:00
|
|
|
|
|
2013-04-01 20:28:20 -07:00
|
|
|
|
// The base query options
|
|
|
|
|
var query = {
|
2013-04-01 17:54:06 -07:00
|
|
|
|
|
2013-04-01 20:28:20 -07:00
|
|
|
|
SortBy: "SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "Movie",
|
|
|
|
|
Recursive: true,
|
2013-04-09 21:38:04 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,UserData,DisplayMediaType,ItemCounts,DateCreated",
|
2013-04-09 09:42:55 -07:00
|
|
|
|
Limit: LibraryBrowser.getDetaultPageSize(),
|
2013-04-08 14:05:00 -07:00
|
|
|
|
StartIndex: 0
|
2013-04-01 20:28:20 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2013-04-01 20:28:20 -07:00
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
|
2013-04-01 17:54:06 -07:00
|
|
|
|
|
2013-04-08 14:05:00 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var showPaging = result.TotalRecordCount > query.Limit;
|
|
|
|
|
|
|
|
|
|
if (showPaging) {
|
2013-04-11 05:23:02 -07:00
|
|
|
|
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true);
|
2013-04-08 14:05:00 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
if (view == "Tile") {
|
|
|
|
|
html += LibraryBrowser.getPosterDetailViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
useAverageAspectRatio: true,
|
|
|
|
|
preferBackdrop: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (view == "Poster") {
|
2013-04-11 08:43:57 -07:00
|
|
|
|
html += LibraryBrowser.getPosterDetailViewHtml({
|
2013-04-04 21:15:00 -07:00
|
|
|
|
items: result.Items,
|
|
|
|
|
useAverageAspectRatio: true
|
2013-04-08 14:05:00 -07:00
|
|
|
|
});
|
2013-04-04 21:15:00 -07:00
|
|
|
|
}
|
2013-04-08 14:05:00 -07:00
|
|
|
|
|
|
|
|
|
if (showPaging) {
|
2013-04-08 22:06:13 -07:00
|
|
|
|
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
|
2013-04-04 21:15:00 -07:00
|
|
|
|
}
|
2013-04-01 20:28:20 -07:00
|
|
|
|
|
2013-04-11 12:36:50 -07:00
|
|
|
|
var elem = $('#items', page).html(html).trigger('create');
|
2013-04-08 14:05:00 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
$('select', elem).on('change', function () {
|
2013-04-08 14:05:00 -07:00
|
|
|
|
query.StartIndex = (parseInt(this.value) - 1) * query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
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-08 14:05:00 -07:00
|
|
|
|
|
2013-04-01 20:28:20 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-04-01 17:54:06 -07:00
|
|
|
|
});
|
2013-04-01 20:28:20 -07:00
|
|
|
|
}
|
2013-04-01 17:54:06 -07:00
|
|
|
|
|
2013-04-01 20:28:20 -07:00
|
|
|
|
$(document).on('pageinit', "#moviesPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
2013-04-01 17:54:06 -07:00
|
|
|
|
|
2013-04-01 20:28:20 -07:00
|
|
|
|
$('.radioSortBy', this).on('click', function () {
|
2013-04-08 14:05:00 -07:00
|
|
|
|
query.StartIndex = 0;
|
2013-04-01 20:28:20 -07:00
|
|
|
|
query.SortBy = this.getAttribute('data-sortby');
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.radioSortOrder', this).on('click', function () {
|
2013-04-08 14:05:00 -07:00
|
|
|
|
query.StartIndex = 0;
|
2013-04-01 20:28:20 -07:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 14:05:00 -07:00
|
|
|
|
query.StartIndex = 0;
|
2013-04-01 20:28:20 -07:00
|
|
|
|
query.Filters = filters;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-04 08:38:41 -07:00
|
|
|
|
|
|
|
|
|
$('.chkVideoTypeFilter', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
var filters = query.VideoTypes || "";
|
|
|
|
|
|
|
|
|
|
filters = (',' + filters).replace(',' + filterName, '').substring(1);
|
|
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
filters = filters ? (filters + ',' + filterName) : filterName;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 14:05:00 -07:00
|
|
|
|
query.StartIndex = 0;
|
2013-04-04 08:38:41 -07:00
|
|
|
|
query.VideoTypes = filters;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-08 14:05:00 -07:00
|
|
|
|
|
2013-04-04 21:15:00 -07:00
|
|
|
|
$('#selectView', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
view = this.value;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-04 08:38:41 -07:00
|
|
|
|
|
2013-04-07 06:34:46 -07:00
|
|
|
|
$('#chk3D', this).on('change', function () {
|
|
|
|
|
|
2013-04-08 14:05:00 -07:00
|
|
|
|
query.StartIndex = 0;
|
2013-04-07 06:34:46 -07:00
|
|
|
|
query.VideoFormats = this.checked ? this.getAttribute('data-filter') : null;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-08 14:05:00 -07:00
|
|
|
|
}).on('pagebeforeshow', "#moviesPage", function () {
|
|
|
|
|
|
2013-04-06 11:57:38 -07:00
|
|
|
|
reloadItems(this);
|
2013-04-08 14:05:00 -07:00
|
|
|
|
|
2013-04-01 20:28:20 -07:00
|
|
|
|
}).on('pageshow', "#moviesPage", function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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');
|
2013-04-04 08:38:41 -07:00
|
|
|
|
|
|
|
|
|
$('.chkVideoTypeFilter', this).each(function () {
|
|
|
|
|
|
|
|
|
|
var filters = "," + (query.VideoTypes || "");
|
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
|
|
|
|
|
this.checked = filters.indexOf(',' + filterName) != -1;
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
2013-04-06 11:59:21 -07:00
|
|
|
|
|
|
|
|
|
$('#selectView', this).val(view).selectmenu('refresh');
|
2013-04-08 14:05:00 -07:00
|
|
|
|
|
2013-04-07 06:34:46 -07:00
|
|
|
|
$('#chk3D', this).checked(query.VideoFormats == "Digital3D,Sbs3D").checkboxradio('refresh');
|
2013-04-01 20:28:20 -07:00
|
|
|
|
});
|
2013-04-01 17:54:06 -07:00
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|