mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update live tv tabs
This commit is contained in:
parent
26dcecb51f
commit
2fd65cdcd9
7 changed files with 513 additions and 502 deletions
|
@ -1,4 +1,4 @@
|
||||||
<div id="liveTvSuggestedPage" data-dom-cache="true" data-role="page" class="page libraryPage liveTvPage pageWithAbsoluteTabs" data-contextname="${HeaderLiveTv}" data-backdroptype="series,movie" data-require="scripts/livetvsuggested,livetvcss,scripts/livetvcomponents,paper-checkbox">
|
<div id="liveTvSuggestedPage" data-dom-cache="true" data-role="page" class="page libraryPage liveTvPage pageWithAbsoluteTabs" data-contextname="${HeaderLiveTv}" data-backdroptype="series,movie">
|
||||||
|
|
||||||
<div class="libraryViewNav">
|
<div class="libraryViewNav">
|
||||||
<button class="pageTabButton is-active" data-index="0">${TabSuggestions}</button>
|
<button class="pageTabButton is-active" data-index="0">${TabSuggestions}</button>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
define(['jQuery'], function ($) {
|
define(['jQuery'], function ($) {
|
||||||
|
|
||||||
|
return function (view, params, tabContent) {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
var data = {};
|
var data = {};
|
||||||
|
|
||||||
function getPageData(context) {
|
function getPageData(context) {
|
||||||
|
@ -45,11 +48,11 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderChannels(page, result) {
|
function renderChannels(context, result) {
|
||||||
|
|
||||||
var query = getQuery(page);
|
var query = getQuery(context);
|
||||||
|
|
||||||
$('.listTopPaging', page).html(LibraryBrowser.getQueryPagingHtml({
|
$('.listTopPaging', context).html(LibraryBrowser.getQueryPagingHtml({
|
||||||
startIndex: query.StartIndex,
|
startIndex: query.StartIndex,
|
||||||
limit: query.Limit,
|
limit: query.Limit,
|
||||||
totalRecordCount: result.TotalRecordCount,
|
totalRecordCount: result.TotalRecordCount,
|
||||||
|
@ -60,63 +63,64 @@
|
||||||
|
|
||||||
var html = getChannelsHtml(result.Items);
|
var html = getChannelsHtml(result.Items);
|
||||||
|
|
||||||
var elem = page.querySelector('#items');
|
var elem = context.querySelector('#items');
|
||||||
elem.innerHTML = html;
|
elem.innerHTML = html;
|
||||||
ImageLoader.lazyChildren(elem);
|
ImageLoader.lazyChildren(elem);
|
||||||
|
|
||||||
$('.btnNextPage', page).on('click', function () {
|
$('.btnNextPage', context).on('click', function () {
|
||||||
query.StartIndex += query.Limit;
|
query.StartIndex += query.Limit;
|
||||||
reloadItems(page);
|
reloadItems(context);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btnPreviousPage', page).on('click', function () {
|
$('.btnPreviousPage', context).on('click', function () {
|
||||||
query.StartIndex -= query.Limit;
|
query.StartIndex -= query.Limit;
|
||||||
reloadItems(page);
|
reloadItems(context);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.btnFilter', page).on('click', function () {
|
$('.btnFilter', context).on('click', function () {
|
||||||
showFilterMenu(page);
|
showFilterMenu(context);
|
||||||
});
|
});
|
||||||
|
|
||||||
LibraryBrowser.saveQueryValues(getSavedQueryKey(page), query);
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(context), query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showFilterMenu(page) {
|
function showFilterMenu(context) {
|
||||||
|
|
||||||
require(['components/filterdialog/filterdialog'], function (filterDialogFactory) {
|
require(['components/filterdialog/filterdialog'], function (filterDialogFactory) {
|
||||||
|
|
||||||
var filterDialog = new filterDialogFactory({
|
var filterDialog = new filterDialogFactory({
|
||||||
query: getQuery(page),
|
query: getQuery(context),
|
||||||
mode: 'livetvchannels'
|
mode: 'livetvchannels'
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(filterDialog, 'filterchange', function () {
|
Events.on(filterDialog, 'filterchange', function () {
|
||||||
reloadItems(page);
|
reloadItems(context);
|
||||||
});
|
});
|
||||||
|
|
||||||
filterDialog.show();
|
filterDialog.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadItems(page) {
|
function reloadItems(context) {
|
||||||
|
|
||||||
Dashboard.showLoadingMsg();
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
var query = getQuery(page);
|
var query = getQuery(context);
|
||||||
|
|
||||||
query.UserId = Dashboard.getCurrentUserId();
|
query.UserId = Dashboard.getCurrentUserId();
|
||||||
|
|
||||||
ApiClient.getLiveTvChannels(query).then(function (result) {
|
ApiClient.getLiveTvChannels(query).then(function (result) {
|
||||||
|
|
||||||
renderChannels(page, result);
|
renderChannels(context, result);
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.hideLoadingMsg();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.LiveTvPage.renderChannelsTab = function (page, tabContent) {
|
self.renderTab = function () {
|
||||||
|
|
||||||
reloadItems(tabContent);
|
reloadItems(tabContent);
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
|
@ -1,17 +1,15 @@
|
||||||
define(['tvguide'], function (tvguide) {
|
define(['tvguide'], function (tvguide) {
|
||||||
|
|
||||||
window.LiveTvPage.initGuideTab = function (page, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
|
|
||||||
};
|
var self = this;
|
||||||
|
var guideInstance;
|
||||||
window.LiveTvPage.renderGuideTab = function (page, tabContent) {
|
self.renderTab = function () {
|
||||||
|
if (!guideInstance) {
|
||||||
if (!page.guideInstance) {
|
guideInstance = new tvguide({
|
||||||
|
|
||||||
page.guideInstance = new tvguide({
|
|
||||||
element: tabContent
|
element: tabContent
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
};
|
||||||
});
|
});
|
|
@ -1,4 +1,4 @@
|
||||||
define(['jQuery'], function ($) {
|
define(['jQuery', 'scripts/livetvcomponents'], function ($) {
|
||||||
|
|
||||||
function getRecordingGroupHtml(group) {
|
function getRecordingGroupHtml(group) {
|
||||||
|
|
||||||
|
@ -30,12 +30,12 @@
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderRecordingGroups(page, groups) {
|
function renderRecordingGroups(context, groups) {
|
||||||
|
|
||||||
if (groups.length) {
|
if (groups.length) {
|
||||||
$('#recordingGroups', page).show();
|
$('#recordingGroups', context).show();
|
||||||
} else {
|
} else {
|
||||||
$('#recordingGroups', page).hide();
|
$('#recordingGroups', context).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
var html = '';
|
var html = '';
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
|
||||||
page.querySelector('#recordingGroupItems').innerHTML = html;
|
context.querySelector('#recordingGroupItems').innerHTML = html;
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.hideLoadingMsg();
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
ImageLoader.lazyChildren(recordingItems);
|
ImageLoader.lazyChildren(recordingItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderActiveRecordings(page) {
|
function renderActiveRecordings(context) {
|
||||||
|
|
||||||
ApiClient.getLiveTvRecordings({
|
ApiClient.getLiveTvRecordings({
|
||||||
|
|
||||||
|
@ -88,12 +88,12 @@
|
||||||
|
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
|
|
||||||
renderRecordings(page.querySelector('#activeRecordings'), result.Items);
|
renderRecordings(context.querySelector('#activeRecordings'), result.Items);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderLatestRecordings(page) {
|
function renderLatestRecordings(context) {
|
||||||
|
|
||||||
ApiClient.getLiveTvRecordings({
|
ApiClient.getLiveTvRecordings({
|
||||||
|
|
||||||
|
@ -104,15 +104,15 @@
|
||||||
|
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
|
|
||||||
renderRecordings(page.querySelector('#latestRecordings'), result.Items);
|
renderRecordings(context.querySelector('#latestRecordings'), result.Items);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTimers(page, timers) {
|
function renderTimers(context, timers) {
|
||||||
|
|
||||||
LiveTvHelpers.getTimersHtml(timers).then(function (html) {
|
LiveTvHelpers.getTimersHtml(timers).then(function (html) {
|
||||||
|
|
||||||
var elem = page.querySelector('#upcomingRecordings');
|
var elem = context.querySelector('#upcomingRecordings');
|
||||||
|
|
||||||
if (html) {
|
if (html) {
|
||||||
elem.classList.remove('hide');
|
elem.classList.remove('hide');
|
||||||
|
@ -127,21 +127,21 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderUpcomingRecordings(page) {
|
function renderUpcomingRecordings(context) {
|
||||||
|
|
||||||
ApiClient.getLiveTvTimers().then(function (result) {
|
ApiClient.getLiveTvTimers().then(function (result) {
|
||||||
|
|
||||||
renderTimers(page, result.Items);
|
renderTimers(context, result.Items);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function reload(page) {
|
function reload(context) {
|
||||||
|
|
||||||
Dashboard.showLoadingMsg();
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
renderUpcomingRecordings(page);
|
renderUpcomingRecordings(context);
|
||||||
renderActiveRecordings(page);
|
renderActiveRecordings(context);
|
||||||
renderLatestRecordings(page);
|
renderLatestRecordings(context);
|
||||||
|
|
||||||
ApiClient.getLiveTvRecordingGroups({
|
ApiClient.getLiveTvRecordingGroups({
|
||||||
|
|
||||||
|
@ -150,21 +150,21 @@
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
|
|
||||||
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
|
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
|
||||||
renderRecordingGroups(page, result.Items);
|
renderRecordingGroups(context, result.Items);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.LiveTvPage.initRecordingsTab = function (page, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
|
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
|
||||||
reload(tabContent);
|
reload(tabContent);
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
window.LiveTvPage.renderRecordingsTab = function (page, tabContent) {
|
|
||||||
|
|
||||||
|
self.renderTab = function () {
|
||||||
reload(tabContent);
|
reload(tabContent);
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
|
@ -6,7 +6,7 @@
|
||||||
SortOrder: "Ascending"
|
SortOrder: "Ascending"
|
||||||
};
|
};
|
||||||
|
|
||||||
function deleteSeriesTimer(page, id) {
|
function deleteSeriesTimer(context, id) {
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@
|
||||||
toast(Globalize.translate('MessageSeriesCancelled'));
|
toast(Globalize.translate('MessageSeriesCancelled'));
|
||||||
});
|
});
|
||||||
|
|
||||||
reload(page);
|
reload(context);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTimers(page, timers) {
|
function renderTimers(context, timers) {
|
||||||
|
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
||||||
|
@ -88,32 +88,36 @@
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
var elem = $('#items', page).html(html);
|
var elem = $('#items', context).html(html);
|
||||||
|
|
||||||
$('.btnCancelSeries', elem).on('click', function () {
|
$('.btnCancelSeries', elem).on('click', function () {
|
||||||
|
|
||||||
deleteSeriesTimer(page, this.getAttribute('data-seriestimerid'));
|
deleteSeriesTimer(context, this.getAttribute('data-seriestimerid'));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.hideLoadingMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
function reload(page) {
|
function reload(context) {
|
||||||
|
|
||||||
Dashboard.showLoadingMsg();
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
ApiClient.getLiveTvSeriesTimers(query).then(function (result) {
|
ApiClient.getLiveTvSeriesTimers(query).then(function (result) {
|
||||||
|
|
||||||
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
|
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
|
||||||
renderTimers(page, result.Items);
|
renderTimers(context, result.Items);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.LiveTvPage.renderSeriesTimersTab = function (page, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
self.renderTab = function () {
|
||||||
|
|
||||||
reload(tabContent);
|
reload(tabContent);
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
|
@ -125,106 +125,110 @@
|
||||||
ImageLoader.lazyChildren(elem);
|
ImageLoader.lazyChildren(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSuggestedTab(page, tabContent) {
|
return function (view, params) {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
self.initTab = function () {
|
||||||
|
|
||||||
|
var tabContent = view.querySelector('.pageTabContent[data-index=\'' + 0 + '\']');
|
||||||
if (enableScrollX()) {
|
if (enableScrollX()) {
|
||||||
$('.itemsContainer', tabContent).addClass('hiddenScrollX').createCardMenus();
|
$('.itemsContainer', tabContent).addClass('hiddenScrollX').createCardMenus();
|
||||||
} else {
|
} else {
|
||||||
$('.itemsContainer', tabContent).removeClass('hiddenScrollX').createCardMenus();
|
$('.itemsContainer', tabContent).removeClass('hiddenScrollX').createCardMenus();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function renderSuggestedTab(page, tabContent) {
|
|
||||||
|
|
||||||
|
self.renderTab = function () {
|
||||||
|
var tabContent = view.querySelector('.pageTabContent[data-index=\'' + 0 + '\']');
|
||||||
reload(tabContent);
|
reload(tabContent);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
var tabControllers = [];
|
||||||
|
var renderedTabs = [];
|
||||||
|
|
||||||
function loadTab(page, index) {
|
function loadTab(page, index) {
|
||||||
|
|
||||||
var tabContent = page.querySelector('.pageTabContent[data-index=\'' + index + '\']');
|
var tabContent = page.querySelector('.pageTabContent[data-index=\'' + index + '\']');
|
||||||
var depends = [];
|
var depends = [];
|
||||||
var scope = 'LiveTvPage';
|
|
||||||
var renderMethod = '';
|
|
||||||
var initMethod = '';
|
|
||||||
|
|
||||||
var viewMenuBar = document.querySelector('.viewMenuBar');
|
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
renderMethod = 'renderSuggestedTab';
|
|
||||||
initMethod = 'initSuggestedTab';
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
depends.push('registrationservices');
|
|
||||||
depends.push('scripts/livetvguide');
|
depends.push('scripts/livetvguide');
|
||||||
renderMethod = 'renderGuideTab';
|
|
||||||
initMethod = 'initGuideTab';
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
depends.push('scripts/livetvchannels');
|
depends.push('scripts/livetvchannels');
|
||||||
depends.push('paper-icon-item');
|
depends.push('paper-icon-item');
|
||||||
depends.push('paper-item-body');
|
depends.push('paper-item-body');
|
||||||
renderMethod = 'renderChannelsTab';
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
depends.push('scripts/livetvrecordings');
|
depends.push('scripts/livetvrecordings');
|
||||||
initMethod = 'initRecordingsTab';
|
|
||||||
renderMethod = 'renderRecordingsTab';
|
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
depends.push('scripts/livetvseriestimers');
|
depends.push('scripts/livetvseriestimers');
|
||||||
renderMethod = 'renderSeriesTimersTab';
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
require(depends, function () {
|
require(depends, function (controllerFactory) {
|
||||||
|
|
||||||
if (initMethod && !tabContent.initComplete) {
|
if (index == 0) {
|
||||||
|
self.tabContent = tabContent;
|
||||||
|
}
|
||||||
|
var controller = tabControllers[index];
|
||||||
|
if (!controller) {
|
||||||
|
controller = index ? new controllerFactory(view, params, tabContent) : self;
|
||||||
|
tabControllers[index] = controller;
|
||||||
|
|
||||||
window[scope][initMethod](page, tabContent);
|
if (controller.initTab) {
|
||||||
tabContent.initComplete = true;
|
controller.initTab();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window[scope][renderMethod](page, tabContent);
|
if (renderedTabs.indexOf(index) == -1) {
|
||||||
|
renderedTabs.push(index);
|
||||||
|
controller.renderTab();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pageIdOn('pageinit', "liveTvSuggestedPage", function () {
|
var mdlTabs = view.querySelector('.libraryViewNav');
|
||||||
|
|
||||||
var page = this;
|
var baseUrl = 'tv.html';
|
||||||
|
var topParentId = params.topParentId;
|
||||||
|
if (topParentId) {
|
||||||
|
baseUrl += '?topParentId=' + topParentId;
|
||||||
|
}
|
||||||
|
|
||||||
var mdlTabs = page.querySelector('.libraryViewNav');
|
libraryBrowser.configurePaperLibraryTabs(view, mdlTabs, view.querySelectorAll('.pageTabContent'));
|
||||||
|
|
||||||
libraryBrowser.configurePaperLibraryTabs(page, mdlTabs, page.querySelectorAll('.pageTabContent'));
|
|
||||||
|
|
||||||
mdlTabs.addEventListener('tabchange', function (e) {
|
mdlTabs.addEventListener('tabchange', function (e) {
|
||||||
loadTab(page, parseInt(e.detail.selectedTabIndex));
|
loadTab(view, parseInt(e.detail.selectedTabIndex));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
pageIdOn('viewshow', "liveTvSuggestedPage", function () {
|
view.addEventListener('viewshow', function (e) {
|
||||||
|
|
||||||
var page = this;
|
|
||||||
|
|
||||||
// Needed on the guide tab
|
// Needed on the guide tab
|
||||||
// Ideally this should be moved to the guide tab on show/hide
|
// Ideally this should be moved to the guide tab on show/hide
|
||||||
document.body.classList.add('autoScrollY');
|
document.body.classList.add('autoScrollY');
|
||||||
});
|
});
|
||||||
|
|
||||||
pageIdOn('viewbeforehide', "liveTvSuggestedPage", function () {
|
view.addEventListener('viewbeforehide', function (e) {
|
||||||
|
|
||||||
var page = this;
|
|
||||||
|
|
||||||
document.body.classList.remove('autoScrollY');
|
document.body.classList.remove('autoScrollY');
|
||||||
});
|
});
|
||||||
|
|
||||||
window.LiveTvPage = {
|
view.addEventListener('viewdestroy', function (e) {
|
||||||
renderSuggestedTab: renderSuggestedTab,
|
|
||||||
initSuggestedTab: initSuggestedTab
|
|
||||||
};
|
|
||||||
|
|
||||||
|
tabControllers.forEach(function (t) {
|
||||||
|
if (t.destroy) {
|
||||||
|
t.destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
});
|
});
|
|
@ -2613,7 +2613,8 @@ var AppInfo = {};
|
||||||
|
|
||||||
defineRoute({
|
defineRoute({
|
||||||
path: '/livetv.html',
|
path: '/livetv.html',
|
||||||
dependencies: ['paper-button'],
|
dependencies: ['paper-button', 'livetvcss', 'paper-checkbox'],
|
||||||
|
controller: 'scripts/livetvsuggested',
|
||||||
autoFocus: false
|
autoFocus: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue