2013-04-03 21:21:46 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
// The base query options
|
|
|
|
|
var query = {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
SortBy: "SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "BoxSet",
|
|
|
|
|
Recursive: true,
|
2014-03-11 22:11:01 -04:00
|
|
|
|
Fields: "PrimaryImageAspectRatio",
|
2013-04-29 22:00:42 -04:00
|
|
|
|
StartIndex: 0
|
|
|
|
|
};
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2014-05-06 22:28:19 -04:00
|
|
|
|
function getSavedQueryKey() {
|
|
|
|
|
|
|
|
|
|
return 'collections' + (query.ParentId || '');
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
function reloadItems(page) {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-05-17 15:18:54 -04:00
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
|
|
|
|
$(document).scrollTop(0);
|
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
var html = '';
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create');
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-10-18 12:09:47 -04:00
|
|
|
|
updateFilterControls(page);
|
|
|
|
|
|
2014-03-07 13:48:55 -05:00
|
|
|
|
if (result.TotalRecordCount) {
|
2014-05-31 10:30:59 -04:00
|
|
|
|
|
2014-03-07 13:48:55 -05:00
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "portrait",
|
|
|
|
|
context: 'movies',
|
|
|
|
|
showTitle: true,
|
2014-04-09 20:47:57 -07:00
|
|
|
|
centerText: true,
|
|
|
|
|
lazy: true
|
2014-03-07 13:48:55 -05:00
|
|
|
|
});
|
2014-05-31 10:30:59 -04:00
|
|
|
|
|
2014-03-07 13:48:55 -05:00
|
|
|
|
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
|
2014-05-30 15:23:56 -04:00
|
|
|
|
$('.noItemsMessage', page).hide();
|
2014-03-07 13:48:55 -05:00
|
|
|
|
} else {
|
2014-05-31 10:30:59 -04:00
|
|
|
|
|
2014-05-30 15:23:56 -04:00
|
|
|
|
$('.noItemsMessage', page).show();
|
2014-03-07 13:48:55 -05:00
|
|
|
|
}
|
2013-04-11 11:43:57 -04:00
|
|
|
|
|
2014-03-16 00:23:58 -04:00
|
|
|
|
$('#items', page).html(html).trigger('create').createPosterItemMenus();
|
2013-04-11 11:43:57 -04:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-15 18:03:05 -04:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-15 18:03:05 -04:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('.selectPageSize', page).on('change', function () {
|
|
|
|
|
query.Limit = parseInt(this.value);
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-27 18:52:41 -04:00
|
|
|
|
|
2014-05-06 22:28:19 -04:00
|
|
|
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
2013-10-18 12:09:47 -04:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-10-18 12:09:47 -04: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');
|
|
|
|
|
|
|
|
|
|
$('#chkTrailer', page).checked(query.HasTrailer == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkThemeSong', page).checked(query.HasThemeSong == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkThemeVideo', page).checked(query.HasThemeVideo == true).checkboxradio('refresh');
|
|
|
|
|
|
|
|
|
|
$('.alphabetPicker', page).alphaValue(query.NameStartsWithOrGreater);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$(document).on('pageinit', "#boxsetsPage", function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
var page = this;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('.radioSortBy', this).on('click', function () {
|
|
|
|
|
query.SortBy = this.getAttribute('data-sortby');
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('.radioSortOrder', this).on('click', function () {
|
|
|
|
|
query.SortOrder = this.getAttribute('data-sortorder');
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('.chkStandardFilter', this).on('change', function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
var filters = query.Filters || "";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
filters = (',' + filters).replace(',' + filterName, '').substring(1);
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
if (this.checked) {
|
|
|
|
|
filters = filters ? (filters + ',' + filterName) : filterName;
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.Filters = filters;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('#chkTrailer', this).on('change', function () {
|
2013-04-06 14:57:38 -04:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasTrailer = this.checked ? true : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('#chkThemeSong', this).on('change', function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasThemeSong = this.checked ? true : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
$('#chkThemeVideo', this).on('change', function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasThemeVideo = this.checked ? true : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-05-16 15:00:42 -04:00
|
|
|
|
$('.alphabetPicker', this).on('alphaselect', function (e, character) {
|
|
|
|
|
|
2013-05-16 23:24:41 -04:00
|
|
|
|
query.NameStartsWithOrGreater = character;
|
2013-05-17 14:05:49 -04:00
|
|
|
|
query.StartIndex = 0;
|
2013-05-16 15:00:42 -04:00
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
|
|
|
|
|
}).on('alphaclear', function (e) {
|
|
|
|
|
|
2013-05-16 23:24:41 -04:00
|
|
|
|
query.NameStartsWithOrGreater = '';
|
2013-05-16 15:00:42 -04:00
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
}).on('pagebeforeshow', "#boxsetsPage", function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2014-07-05 01:21:13 -04:00
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
var context = getParameterByName('context');
|
|
|
|
|
|
|
|
|
|
if (context == 'movies') {
|
|
|
|
|
$('.collectionTabs', page).hide();
|
|
|
|
|
$('.movieTabs', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.collectionTabs', page).show();
|
|
|
|
|
$('.movieTabs', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-06 22:28:19 -04:00
|
|
|
|
query.ParentId = LibraryMenu.getTopParentId();
|
|
|
|
|
|
2013-05-15 15:40:47 -04: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-06 22:28:19 -04:00
|
|
|
|
LibraryBrowser.loadSavedQueryValues(getSavedQueryKey(), query);
|
2013-10-17 16:59:46 -04:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
reloadItems(this);
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-29 22:00:42 -04:00
|
|
|
|
}).on('pageshow', "#boxsetsPage", function () {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-10-18 12:09:47 -04:00
|
|
|
|
updateFilterControls(this);
|
2014-05-31 10:30:59 -04:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|
|
|
|
|
|
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
function showNewCollectionPanel(page, items) {
|
2014-05-31 10:30:59 -04:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
$('.fldSelectedItemIds', page).val(items.join(','));
|
2014-05-31 10:30:59 -04:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
var panel = $('.newCollectionPanel', page).panel('toggle');
|
|
|
|
|
|
|
|
|
|
populateCollections(panel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function populateCollections(panel) {
|
|
|
|
|
|
|
|
|
|
var select = $('#selectCollectionToAddTo', panel);
|
|
|
|
|
|
|
|
|
|
if (!select.length) {
|
|
|
|
|
|
|
|
|
|
$('#txtNewCollectionName', panel).val('').focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('.newCollectionInfo', panel).hide();
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
|
|
|
|
Recursive: true,
|
|
|
|
|
IncludeItemTypes: "BoxSet"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<option value="">' + Globalize.translate('OptionNewCollection') + '</option>';
|
|
|
|
|
|
|
|
|
|
html += result.Items.map(function (i) {
|
|
|
|
|
|
|
|
|
|
return '<option value="' + i.Id + '">' + i.Name + '</option>';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
select.html(html).val('').selectmenu('refresh').trigger('change');
|
|
|
|
|
|
|
|
|
|
});
|
2014-05-31 10:30:59 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('pageinit', ".collectionEditorPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.btnNewCollection', page).on('click', function () {
|
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
showNewCollectionPanel(page, []);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#selectCollectionToAddTo', page).on('change', function () {
|
|
|
|
|
|
|
|
|
|
if (this.value) {
|
|
|
|
|
$('.newCollectionInfo', page).hide();
|
|
|
|
|
$('#txtNewCollectionName', page).removeAttr('required');
|
|
|
|
|
} else {
|
|
|
|
|
$('.newCollectionInfo', page).show();
|
|
|
|
|
$('#txtNewCollectionName', page).attr('required', 'required');
|
|
|
|
|
}
|
2014-05-31 10:30:59 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pagebeforeshow', ".collectionEditorPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
|
|
|
|
|
|
|
|
|
if (user.Configuration.IsAdministrator) {
|
|
|
|
|
$('.btnNewCollection', page).removeClass('hide');
|
|
|
|
|
} else {
|
|
|
|
|
$('.btnNewCollection', page).addClass('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
2013-04-29 22:00:42 -04:00
|
|
|
|
});
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
function createCollection(page) {
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
var url = ApiClient.getUrl("Collections", {
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
Name: $('#txtNewCollectionName', page).val(),
|
|
|
|
|
IsLocked: !$('#chkEnableInternetMetadata', page).checked(),
|
|
|
|
|
Ids: $('.fldSelectedItemIds', page).val() || ''
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
//ParentId: getParameterByName('parentId') || LibraryMenu.getTopParentId()
|
|
|
|
|
|
|
|
|
|
});
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-07-02 01:16:59 -04:00
|
|
|
|
ApiClient.ajax({
|
2014-06-03 23:34:36 -04:00
|
|
|
|
type: "POST",
|
|
|
|
|
url: url,
|
|
|
|
|
dataType: "json"
|
2014-05-31 10:30:59 -04:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
}).done(function (result) {
|
2014-05-31 10:30:59 -04:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
var id = result.Id;
|
|
|
|
|
var destination = 'itemdetails.html?id=' + id;
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
var context = getParameterByName('context');
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
if (context) {
|
|
|
|
|
destination += "&context=" + context;
|
|
|
|
|
}
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
$('.newCollectionPanel', page).panel('toggle');
|
|
|
|
|
Dashboard.navigate(destination);
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
function addToCollection(page, id) {
|
2014-03-07 10:53:23 -05:00
|
|
|
|
|
2014-06-03 23:34:36 -04:00
|
|
|
|
var url = ApiClient.getUrl("Collections/" + id + "/Items", {
|
|
|
|
|
|
|
|
|
|
Ids: $('.fldSelectedItemIds', page).val() || ''
|
|
|
|
|
});
|
|
|
|
|
|
2014-07-02 01:16:59 -04:00
|
|
|
|
ApiClient.ajax({
|
2014-06-03 23:34:36 -04:00
|
|
|
|
type: "POST",
|
|
|
|
|
url: url
|
|
|
|
|
|
|
|
|
|
}).done(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var destination = 'itemdetails.html?id=' + id;
|
|
|
|
|
|
|
|
|
|
var context = getParameterByName('context');
|
|
|
|
|
|
|
|
|
|
if (context) {
|
|
|
|
|
destination += "&context=" + context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('.newCollectionPanel', page).panel('toggle');
|
|
|
|
|
Dashboard.navigate(destination);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.BoxSetEditor = {
|
|
|
|
|
|
|
|
|
|
showPanel: function (page, items) {
|
|
|
|
|
showNewCollectionPanel(page, items);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onNewCollectionSubmit: function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var page = $(this).parents('.page');
|
|
|
|
|
|
|
|
|
|
var collectionId = $('#selectCollectionToAddTo', page).val();
|
|
|
|
|
|
|
|
|
|
if (collectionId) {
|
|
|
|
|
addToCollection(page, collectionId);
|
|
|
|
|
} else {
|
|
|
|
|
createCollection(page);
|
|
|
|
|
}
|
2014-03-06 00:17:13 -05:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2013-04-03 21:21:46 -07:00
|
|
|
|
})(jQuery, document);
|