2013-05-27 18:59:26 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
|
|
|
|
// The base query options
|
|
|
|
|
var query = {
|
|
|
|
|
|
|
|
|
|
SortBy: "SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "MusicVideo",
|
|
|
|
|
Recursive: true,
|
2014-12-10 23:20:28 -07:00
|
|
|
|
Fields: "DateCreated,SyncInfo",
|
2013-05-27 18:59:26 -07:00
|
|
|
|
StartIndex: 0
|
|
|
|
|
};
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
function getSavedQueryKey() {
|
|
|
|
|
|
|
|
|
|
return 'musicvideos' + (query.ParentId || '');
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-27 18:59:26 -07:00
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
|
|
|
|
|
|
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
|
|
|
|
$(document).scrollTop(0);
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
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-01-22 23:15:15 -07:00
|
|
|
|
})).trigger('create');
|
2013-05-27 18:59:26 -07:00
|
|
|
|
|
2013-10-18 09:09:47 -07:00
|
|
|
|
updateFilterControls(page);
|
2014-11-09 21:20:11 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
var view = 'Poster';
|
|
|
|
|
|
|
|
|
|
if (AppInfo.hasLowImageBandwidth) {
|
|
|
|
|
if (view == 'Poster') {
|
|
|
|
|
view = 'PosterCard';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (view == "Poster") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "square",
|
|
|
|
|
context: 'music',
|
|
|
|
|
showTitle: true,
|
|
|
|
|
lazy: true,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
centerText: true,
|
|
|
|
|
showDetailsMenu: true
|
2015-05-12 21:55:19 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (view == "PosterCard") {
|
|
|
|
|
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "square",
|
|
|
|
|
context: 'music',
|
|
|
|
|
showTitle: true,
|
|
|
|
|
centerText: true,
|
|
|
|
|
cardLayout: true,
|
|
|
|
|
lazy: true,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
showParentTitle: true,
|
|
|
|
|
showDetailsMenu: true
|
2015-05-12 21:55:19 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-05-27 18:59:26 -07:00
|
|
|
|
|
|
|
|
|
$('#items', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
2014-11-09 21:20:11 -07:00
|
|
|
|
|
2013-05-27 18:59:26 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-18 09:09:47 -07:00
|
|
|
|
function updateFilterControls(page) {
|
|
|
|
|
|
|
|
|
|
// Reset form values using the last used query
|
|
|
|
|
$('.radioSortBy', page).each(function () {
|
|
|
|
|
|
|
|
|
|
this.checked = (query.SortBy || '').toLowerCase() == this.getAttribute('data-sortby').toLowerCase();
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
|
|
|
|
$('.radioSortOrder', page).each(function () {
|
|
|
|
|
|
|
|
|
|
this.checked = (query.SortOrder || '').toLowerCase() == this.getAttribute('data-sortorder').toLowerCase();
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
|
|
|
|
$('.chkStandardFilter', page).each(function () {
|
|
|
|
|
|
|
|
|
|
var filters = "," + (query.Filters || "");
|
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
|
|
|
|
|
this.checked = filters.indexOf(',' + filterName) != -1;
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
2014-11-09 21:20:11 -07:00
|
|
|
|
$('.alphabetPicker', page).alphaValue(query.NameStartsWithOrGreater);
|
|
|
|
|
$('#selectPageSize', page).val(query.Limit).selectmenu('refresh');
|
|
|
|
|
}
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2014-11-09 21:20:11 -07:00
|
|
|
|
var filtersLoaded;
|
|
|
|
|
function reloadFiltersIfNeeded(page) {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2014-11-09 21:20:11 -07:00
|
|
|
|
if (!filtersLoaded) {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2014-11-09 21:20:11 -07:00
|
|
|
|
filtersLoaded = true;
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2014-11-09 21:20:11 -07:00
|
|
|
|
QueryFilters.loadFilters(page, Dashboard.getCurrentUserId(), query, function () {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2014-11-09 21:20:11 -07:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-10-18 09:09:47 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-27 18:59:26 -07:00
|
|
|
|
$(document).on('pageinit', "#musicVideosPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2014-11-09 21:20:11 -07:00
|
|
|
|
$('.viewPanel', page).on('panelopen', function () {
|
|
|
|
|
|
|
|
|
|
reloadFiltersIfNeeded(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-05-27 18:59:26 -07:00
|
|
|
|
$('.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);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.alphabetPicker', this).on('alphaselect', function (e, character) {
|
|
|
|
|
|
|
|
|
|
query.NameStartsWithOrGreater = character;
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
|
|
|
|
|
}).on('alphaclear', function (e) {
|
|
|
|
|
|
|
|
|
|
query.NameStartsWithOrGreater = '';
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
$('#selectPageSize', page).on('change', function () {
|
|
|
|
|
query.Limit = parseInt(this.value);
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-05-27 18:59:26 -07:00
|
|
|
|
}).on('pagebeforeshow', "#musicVideosPage", function () {
|
|
|
|
|
|
2014-11-09 21:20:11 -07:00
|
|
|
|
var page = this;
|
|
|
|
|
|
2014-06-04 19:32:40 -07:00
|
|
|
|
query.ParentId = LibraryMenu.getTopParentId();
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2013-05-27 18:59:26 -07:00
|
|
|
|
var limit = LibraryBrowser.getDefaultPageSize();
|
|
|
|
|
|
|
|
|
|
// If the default page size has changed, the start index will have to be reset
|
|
|
|
|
if (limit != query.Limit) {
|
|
|
|
|
query.Limit = limit;
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
LibraryBrowser.loadSavedQueryValues(getSavedQueryKey(), query);
|
2014-11-09 21:20:11 -07:00
|
|
|
|
QueryFilters.onPageShow(page, query);
|
2013-10-17 13:59:46 -07:00
|
|
|
|
|
2014-11-09 21:20:11 -07:00
|
|
|
|
reloadItems(page);
|
2013-05-27 18:59:26 -07:00
|
|
|
|
|
|
|
|
|
}).on('pageshow', "#musicVideosPage", function () {
|
|
|
|
|
|
2013-10-18 09:09:47 -07:00
|
|
|
|
updateFilterControls(this);
|
2013-05-27 18:59:26 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|