2013-11-20 14:08:12 -07:00
|
|
|
|
(function ($, document, apiClient) {
|
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
var query = {
|
|
|
|
|
|
|
|
|
|
StartIndex: 0
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-20 14:08:12 -07:00
|
|
|
|
function getChannelsHtml(channels) {
|
|
|
|
|
|
2014-01-07 11:39:35 -07:00
|
|
|
|
return LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: channels,
|
2014-08-04 20:41:56 -07:00
|
|
|
|
shape: "smallBackdrop",
|
2014-01-07 11:39:35 -07:00
|
|
|
|
centerText: true
|
|
|
|
|
});
|
2013-11-20 14:08:12 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
function showLoadingMessage(page) {
|
|
|
|
|
|
|
|
|
|
$('.popupLoading', page).popup('open');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideLoadingMessage(page) {
|
|
|
|
|
$('.popupLoading', page).popup('close');
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
function renderChannels(page, result) {
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
var pagingHtml = LibraryBrowser.getQueryPagingHtml({
|
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
|
|
|
|
viewButton: true,
|
|
|
|
|
showLimit: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.listTopPaging', page).html(pagingHtml).trigger('create');
|
2014-01-10 06:52:01 -07:00
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
updateFilterControls(this);
|
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
var html = getChannelsHtml(result.Items);
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
html += pagingHtml;
|
2014-01-10 06:52:01 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('#items', page).html(html).trigger('create').createCardMenus();
|
2013-11-20 14:08:12 -07:00
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.saveQueryValues('movies', query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reloadItems(page) {
|
2014-05-23 16:58:28 -07:00
|
|
|
|
|
|
|
|
|
showLoadingMessage(page);
|
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
apiClient.getLiveTvChannels(query).done(function (result) {
|
|
|
|
|
|
|
|
|
|
renderChannels(page, result);
|
2014-05-23 16:58:28 -07:00
|
|
|
|
|
|
|
|
|
hideLoadingMessage(page);
|
2014-01-10 06:52:01 -07:00
|
|
|
|
});
|
2013-11-20 14:08:12 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
function updateFilterControls(page) {
|
|
|
|
|
|
|
|
|
|
$('#chkFavorite', page).checked(query.IsFavorite == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkLikes', page).checked(query.IsLiked == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkDislikes', page).checked(query.IsDisliked == true).checkboxradio('refresh');
|
2014-07-19 21:46:29 -07:00
|
|
|
|
$('#selectPageSize', page).val(query.Limit).selectmenu('refresh');
|
2014-05-23 16:58:28 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('pageinit', "#liveTvChannelsPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('#chkFavorite', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.IsFavorite = this.checked ? true : null;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#chkLikes', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.IsLiked = this.checked ? true : null;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#chkDislikes', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.IsDisliked = this.checked ? true : null;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
|
2014-06-04 12:39:16 -07:00
|
|
|
|
}).on('pageshow', "#liveTvChannelsPage", function () {
|
2013-11-20 14:08:12 -07:00
|
|
|
|
|
2014-06-04 12:39:16 -07:00
|
|
|
|
// Can't use pagebeforeshow here or the loading popup won't center correctly
|
2013-11-20 14:08:12 -07:00
|
|
|
|
var page = this;
|
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
var limit = LibraryBrowser.getDefaultPageSize();
|
2013-11-25 19:53:48 -07:00
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2013-11-20 14:08:12 -07:00
|
|
|
|
|
2014-01-10 06:52:01 -07:00
|
|
|
|
query.UserId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.loadSavedQueryValues('movies', query);
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
2014-05-23 16:58:28 -07:00
|
|
|
|
|
|
|
|
|
updateFilterControls(this);
|
2014-06-04 12:39:16 -07:00
|
|
|
|
|
2013-11-20 14:08:12 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, ApiClient);
|