2013-04-03 21:21:46 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var data = {};
|
2015-08-15 11:46:57 -07:00
|
|
|
|
function getPageData() {
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var key = getSavedQueryKey();
|
|
|
|
|
var pageData = data[key];
|
|
|
|
|
|
|
|
|
|
if (!pageData) {
|
|
|
|
|
pageData = data[key] = {
|
|
|
|
|
query: {
|
|
|
|
|
SortBy: "SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "BoxSet",
|
|
|
|
|
Recursive: true,
|
|
|
|
|
Fields: "PrimaryImageAspectRatio,SortName,SyncInfo,CanDelete",
|
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
|
|
|
|
|
StartIndex: 0,
|
|
|
|
|
Limit: LibraryBrowser.getDefaultPageSize()
|
2015-08-15 11:46:57 -07:00
|
|
|
|
},
|
|
|
|
|
view: LibraryBrowser.getSavedView(key) || LibraryBrowser.getDefaultItemsView('Poster', 'Poster')
|
2015-08-15 11:17:22 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.loadSavedQueryValues(key, pageData.query);
|
|
|
|
|
}
|
2015-08-15 11:46:57 -07:00
|
|
|
|
return pageData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getQuery() {
|
|
|
|
|
|
|
|
|
|
return getPageData().query;
|
2015-08-15 11:17:22 -07:00
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2014-05-06 19:28:19 -07:00
|
|
|
|
function getSavedQueryKey() {
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
return getWindowUrl();
|
2014-05-06 19:28:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
function reloadItems(page, viewPanel) {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 19:00:42 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var query = getQuery();
|
2014-07-19 21:46:29 -07:00
|
|
|
|
var promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), query);
|
|
|
|
|
var promise2 = Dashboard.getCurrentUser();
|
|
|
|
|
|
|
|
|
|
$.when(promise1, promise2).done(function (response1, response2) {
|
|
|
|
|
|
|
|
|
|
var result = response1[0];
|
|
|
|
|
var user = response2[0];
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-05-17 12:18:54 -07:00
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
2015-06-28 07:45:21 -07:00
|
|
|
|
window.scrollTo(0, 0);
|
2013-05-17 12:18:54 -07:00
|
|
|
|
|
2013-04-29 19:00:42 -07:00
|
|
|
|
var html = '';
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
$('.listTopPaging', page).html(LibraryBrowser.getQueryPagingHtml({
|
2014-07-19 21:46:29 -07:00
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
|
|
|
|
viewButton: true,
|
|
|
|
|
showLimit: false,
|
2015-08-15 11:17:22 -07:00
|
|
|
|
viewPanelClass: 'collectionViewPanel'
|
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
})).trigger('create');
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
updateFilterControls(page, viewPanel);
|
2015-01-22 23:15:15 -07:00
|
|
|
|
var trigger = false;
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2014-03-07 11:48:55 -07:00
|
|
|
|
if (result.TotalRecordCount) {
|
2014-05-31 07:30:59 -07:00
|
|
|
|
|
2015-08-15 11:46:57 -07:00
|
|
|
|
var view = getPageData().view;
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var context = getParameterByName('context');
|
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
if (view == "List") {
|
|
|
|
|
|
|
|
|
|
html = LibraryBrowser.getListViewHtml({
|
|
|
|
|
items: result.Items,
|
2015-08-15 11:17:22 -07:00
|
|
|
|
context: context,
|
2014-07-05 12:57:18 -07:00
|
|
|
|
sortBy: query.SortBy
|
|
|
|
|
});
|
2015-01-22 23:15:15 -07:00
|
|
|
|
trigger = true;
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
|
|
|
|
else if (view == "Poster") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
2015-01-22 23:15:15 -07:00
|
|
|
|
shape: "auto",
|
2015-08-15 11:17:22 -07:00
|
|
|
|
context: context,
|
2015-01-22 23:15:15 -07:00
|
|
|
|
showTitle: true,
|
2014-07-05 12:57:18 -07:00
|
|
|
|
centerText: true,
|
|
|
|
|
lazy: true
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-05-12 21:55:19 -07:00
|
|
|
|
else if (view == "PosterCard") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "auto",
|
2015-08-15 11:17:22 -07:00
|
|
|
|
context: context,
|
2015-05-12 21:55:19 -07:00
|
|
|
|
showTitle: true,
|
|
|
|
|
cardLayout: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
showItemCounts: true
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-04-02 14:01:42 -07:00
|
|
|
|
else if (view == "Thumb") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
2015-08-15 11:17:22 -07:00
|
|
|
|
context: context,
|
2015-04-02 14:01:42 -07:00
|
|
|
|
showTitle: true,
|
|
|
|
|
centerText: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
preferThumb: true
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-05-12 21:55:19 -07:00
|
|
|
|
else if (view == "ThumbCard") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
2015-08-15 11:17:22 -07:00
|
|
|
|
context: context,
|
2015-05-12 21:55:19 -07:00
|
|
|
|
showTitle: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
preferThumb: true,
|
|
|
|
|
cardLayout: true,
|
|
|
|
|
showItemCounts: true
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-05-31 07:30:59 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
$('.noItemsMessage', page).hide();
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2014-03-07 11:48:55 -07:00
|
|
|
|
} else {
|
2014-05-31 07:30:59 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
$('.noItemsMessage', page).show();
|
2014-03-07 11:48:55 -07:00
|
|
|
|
}
|
2013-04-11 08:43:57 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var elem = page.querySelector('.itemsContainer');
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2015-01-22 23:15:15 -07:00
|
|
|
|
|
|
|
|
|
if (trigger) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
$(elem).trigger('create');
|
2015-01-22 23:15:15 -07:00
|
|
|
|
}
|
2013-04-11 08:43:57 -07:00
|
|
|
|
|
2013-04-29 19:00:42 -07:00
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(page, viewPanel);
|
2013-04-29 19:00:42 -07:00
|
|
|
|
});
|
2013-04-15 15:03:05 -07:00
|
|
|
|
|
2013-04-29 19:00:42 -07:00
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(page, viewPanel);
|
2013-04-29 19:00:42 -07:00
|
|
|
|
});
|
2013-04-15 15:03:05 -07:00
|
|
|
|
|
2014-05-06 19:28:19 -07:00
|
|
|
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2013-04-29 19:00:42 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
function updateFilterControls(tabContent, viewPanel) {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var query = getQuery();
|
2013-10-18 09:09:47 -07:00
|
|
|
|
// Reset form values using the last used query
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.radioSortBy', viewPanel).each(function () {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
|
|
|
|
this.checked = (query.SortBy || '').toLowerCase() == this.getAttribute('data-sortby').toLowerCase();
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.radioSortOrder', viewPanel).each(function () {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
|
|
|
|
this.checked = (query.SortOrder || '').toLowerCase() == this.getAttribute('data-sortorder').toLowerCase();
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.chkStandardFilter', viewPanel).each(function () {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
|
|
|
|
var filters = "," + (query.Filters || "");
|
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
|
|
|
|
|
this.checked = filters.indexOf(',' + filterName) != -1;
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
2015-08-15 11:46:57 -07:00
|
|
|
|
$('select.selectView', viewPanel).val(getPageData().view).selectmenu('refresh');
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.chkTrailer', viewPanel).checked(query.HasTrailer == true).checkboxradio('refresh');
|
|
|
|
|
$('.chkThemeSong', viewPanel).checked(query.HasThemeSong == true).checkboxradio('refresh');
|
|
|
|
|
$('.chkThemeVideo', viewPanel).checked(query.HasThemeVideo == true).checkboxradio('refresh');
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('select.selectPageSize', viewPanel).val(query.Limit).selectmenu('refresh');
|
2013-10-18 09:09:47 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-15 11:30:52 -07:00
|
|
|
|
function initPage(tabContent, viewPanel) {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.radioSortBy', viewPanel).on('click', function () {
|
|
|
|
|
var query = getQuery();
|
2013-04-29 19:00:42 -07:00
|
|
|
|
query.SortBy = this.getAttribute('data-sortby');
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(tabContent, viewPanel);
|
2013-04-29 19:00:42 -07:00
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.radioSortOrder', viewPanel).on('click', function () {
|
|
|
|
|
var query = getQuery();
|
2013-04-29 19:00:42 -07:00
|
|
|
|
query.SortOrder = this.getAttribute('data-sortorder');
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(tabContent, viewPanel);
|
2013-04-29 19:00:42 -07:00
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.chkStandardFilter', viewPanel).on('change', function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var query = getQuery();
|
2013-04-29 19:00:42 -07:00
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
var filters = query.Filters || "";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 19:00:42 -07:00
|
|
|
|
filters = (',' + filters).replace(',' + filterName, '').substring(1);
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 19:00:42 -07:00
|
|
|
|
if (this.checked) {
|
|
|
|
|
filters = filters ? (filters + ',' + filterName) : filterName;
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 19:00:42 -07:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.Filters = filters;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(tabContent, viewPanel);
|
2013-04-29 19:00:42 -07:00
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.chkTrailer', viewPanel).on('change', function () {
|
2013-04-06 11:57:38 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var query = getQuery();
|
2013-04-29 19:00:42 -07:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasTrailer = this.checked ? true : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(tabContent, viewPanel);
|
2013-04-29 19:00:42 -07:00
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.chkThemeSong', viewPanel).on('change', function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var query = getQuery();
|
2013-04-29 19:00:42 -07:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasThemeSong = this.checked ? true : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(tabContent, viewPanel);
|
2013-04-29 19:00:42 -07:00
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.chkThemeVideo', viewPanel).on('change', function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var query = getQuery();
|
2013-04-29 19:00:42 -07:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasThemeVideo = this.checked ? true : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(tabContent, viewPanel);
|
2013-04-29 19:00:42 -07:00
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('select.selectView', viewPanel).on('change', function () {
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2015-08-15 11:46:57 -07:00
|
|
|
|
var newView = this.value;
|
|
|
|
|
getPageData().view = newView;
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(tabContent, viewPanel);
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2015-08-15 11:46:57 -07:00
|
|
|
|
LibraryBrowser.saveViewSetting(getSavedQueryKey(), newView);
|
2014-07-05 12:57:18 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('select.selectPageSize', viewPanel).on('change', function () {
|
|
|
|
|
var query = getQuery();
|
2014-07-19 21:46:29 -07:00
|
|
|
|
query.Limit = parseInt(this.value);
|
|
|
|
|
query.StartIndex = 0;
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(tabContent, viewPanel);
|
2014-07-19 21:46:29 -07:00
|
|
|
|
});
|
2015-08-15 11:17:22 -07:00
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#moviesRecommendedPage", function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
|
var page = this;
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var index = 3;
|
|
|
|
|
var tabContent = page.querySelector('.pageTabContent[data-index=\'' + index + '\']');
|
|
|
|
|
var viewPanel = $('.collectionViewPanel', page);
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
|
2013-05-15 12:40:47 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
if (parseInt(this.selected) == index) {
|
2015-08-15 11:30:52 -07:00
|
|
|
|
if (!tabContent.initComplete) {
|
|
|
|
|
initPage(tabContent, viewPanel);
|
|
|
|
|
tabContent.initComplete = true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
if (LibraryBrowser.needsRefresh(tabContent)) {
|
|
|
|
|
reloadItems(tabContent, viewPanel);
|
|
|
|
|
updateFilterControls(viewPanel);
|
|
|
|
|
}
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
2014-05-31 07:30:59 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#boxsetsPage", function () {
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var page = this;
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var content = page;
|
|
|
|
|
var viewPanel = page.querySelector('.viewPanel');
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-08-15 11:30:52 -07:00
|
|
|
|
initPage(content, viewPanel);
|
2014-05-31 07:30:59 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
}).on('pagebeforeshowready', "#boxsetsPage", function () {
|
2014-05-31 07:30:59 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var content = page;
|
|
|
|
|
var viewPanel = page.querySelector('.viewPanel');
|
2014-05-31 07:30:59 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
reloadItems(content, viewPanel);
|
|
|
|
|
updateFilterControls(content, viewPanel);
|
2013-04-29 19:00:42 -07:00
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|