split live tv scripts

This commit is contained in:
Luke Pulverenti 2015-08-18 11:52:48 -04:00
parent ceeb569571
commit 41a15fa8b3
7 changed files with 106 additions and 155 deletions

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="liveTvSuggestedPage" data-role="page" class="page libraryPage liveTvPage pageWithAbsoluteTabs" data-contextname="${HeaderLiveTv}" data-backdroptype="series,movie" data-require="scripts/livetvsuggested,paperbuttonstyle,livetvcss,scripts/livetvchannels,scripts/livetvseriestimers,scripts/livetvtimers,scripts/livetvrecordings,scripts/registrationservices,scripts/livetvcomponents,scripts/livetvguide">
<div id="liveTvSuggestedPage" data-role="page" class="page libraryPage liveTvPage pageWithAbsoluteTabs" data-contextname="${HeaderLiveTv}" data-backdroptype="series,movie" data-require="scripts/livetvsuggested,livetvcss,scripts/livetvcomponents">
<div class="libraryViewNav libraryViewNavWithMinHeight">
<paper-tabs style="display:none;min-width:660px;margin:auto;">
@ -29,7 +29,7 @@
<div class="ehsContent fullWidth">
<neon-animated-pages>
<neon-animatable>
<div class="pageTabContent suggestedTabContent">
<div class="pageTabContent suggestedTabContent" data-index="0">
<div id="activePrograms" class="homePageSection">
<h1 class="listHeader">${HeaderWhatsOnTV}</h1>
<div class="activeProgramItems itemsContainer"></div>
@ -59,7 +59,7 @@
</div>
</neon-animatable>
<neon-animatable>
<div class="pageTabContent guideTabContent" style="width:auto;">
<div class="pageTabContent guideTabContent" style="width:auto;" data-index="1">
<div class="tvGuide">
<div class="tvGuideHeader">
<div class="channelTimeslotHeader">
@ -82,7 +82,7 @@
</div>
</neon-animatable>
<neon-animatable>
<div class="pageTabContent channelsTabContent">
<div class="pageTabContent channelsTabContent" data-index="2">
<div class="viewSettings">
<div class="listTopPaging">
</div>
@ -91,7 +91,7 @@
</div>
</neon-animatable>
<neon-animatable>
<div class="pageTabContent recordingsTabContent">
<div class="pageTabContent recordingsTabContent" data-index="3">
<div id="activeRecordings" style="display: none;">
<h1 class="listHeader">${HeaderActiveRecordings}</h1>
<div class="recordingItems itemsContainer"></div>
@ -112,13 +112,13 @@
</div>
</neon-animatable>
<neon-animatable>
<div class="pageTabContent timersTabContent">
<div class="pageTabContent timersTabContent" data-index="4">
<div style="max-width: 700px; margin: 0 auto;" id="items">
</div>
</div>
</neon-animatable>
<neon-animatable>
<div class="pageTabContent seriesTimersTabContent">
<div class="pageTabContent seriesTimersTabContent" data-index="5">
<div style="max-width: 700px; margin: 0 auto;" id="items">
</div>
</div>

View File

@ -14,15 +14,6 @@
});
}
function showLoadingMessage(page) {
Dashboard.showLoadingMsg();
}
function hideLoadingMessage(page) {
Dashboard.hideLoadingMsg();
}
function renderChannels(page, viewPanel, result) {
$('.listTopPaging', page).html(LibraryBrowser.getQueryPagingHtml({
@ -59,13 +50,13 @@
function reloadItems(page, viewPanel) {
showLoadingMessage(page);
Dashboard.showLoadingMsg();
ApiClient.getLiveTvChannels(query).done(function (result) {
renderChannels(page, viewPanel, result);
hideLoadingMessage(page);
Dashboard.hideLoadingMsg();
LibraryBrowser.setLastRefreshed(page);
});
@ -79,17 +70,16 @@
$('#selectPageSize', page).val(query.Limit).selectmenu('refresh');
}
$(document).on('pageinitdepends', "#liveTvSuggestedPage", function () {
window.LiveTvPage.initChannelsTab = function (page, tabContent) {
var page = this.querySelector('.channelsTabContent');
var viewPanel = this.querySelector('.channelViewPanel');
var viewPanel = page.querySelector('.channelViewPanel');
$('#chkFavorite', viewPanel).on('change', function () {
query.StartIndex = 0;
query.IsFavorite = this.checked ? true : null;
reloadItems(page, viewPanel);
reloadItems(tabContent, viewPanel);
});
@ -98,7 +88,7 @@
query.StartIndex = 0;
query.IsLiked = this.checked ? true : null;
reloadItems(page, viewPanel);
reloadItems(tabContent, viewPanel);
});
$('#chkDislikes', viewPanel).on('change', function () {
@ -106,37 +96,27 @@
query.StartIndex = 0;
query.IsDisliked = this.checked ? true : null;
reloadItems(page, viewPanel);
reloadItems(tabContent, viewPanel);
});
$('#selectPageSize', viewPanel).on('change', function () {
query.Limit = parseInt(this.value);
query.StartIndex = 0;
reloadItems(page, viewPanel);
reloadItems(tabContent, viewPanel);
});
};
});
window.LiveTvPage.renderChannelsTab = function (page, tabContent) {
$(document).on('pageinitdepends', "#liveTvSuggestedPage", function () {
var viewPanel = page.querySelector('.channelViewPanel');
var page = this;
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
if (parseInt(this.selected) == 2) {
var tabContent = page.querySelector('.channelsTabContent');
var viewPanel = page.querySelector('.channelViewPanel');
if (LibraryBrowser.needsRefresh(tabContent)) {
query.UserId = Dashboard.getCurrentUserId();
LibraryBrowser.loadSavedQueryValues('movies', query);
query.Limit = query.Limit || LibraryBrowser.getDefaultPageSize();
reloadItems(tabContent, viewPanel);
updateFilterControls(viewPanel);
}
}
});
});
if (LibraryBrowser.needsRefresh(tabContent)) {
query.UserId = Dashboard.getCurrentUserId();
LibraryBrowser.loadSavedQueryValues('movies', query);
query.Limit = query.Limit || LibraryBrowser.getDefaultPageSize();
reloadItems(tabContent, viewPanel);
updateFilterControls(viewPanel);
}
};
})(jQuery, document);

View File

@ -446,24 +446,22 @@
});
}
$(document).on('pageinitdepends', "#liveTvSuggestedPage", function () {
window.LiveTvPage.initGuideTab = function (page, tabContent) {
var page = this.querySelector('.guideTabContent');
Events.on(tabContent.querySelector('.programGrid'), 'scroll', function () {
Events.on(page.querySelector('.programGrid'), 'scroll', function () {
onProgramGridScroll(page, this);
onProgramGridScroll(tabContent, this);
});
if ($.browser.mobile) {
page.querySelector('.tvGuide').classList.add('mobileGuide');
tabContent.querySelector('.tvGuide').classList.add('mobileGuide');
} else {
page.querySelector('.tvGuide').classList.remove('mobileGuide');
tabContent.querySelector('.tvGuide').classList.remove('mobileGuide');
Events.on(page.querySelector('.timeslotHeaders'), 'scroll', function () {
Events.on(tabContent.querySelector('.timeslotHeaders'), 'scroll', function () {
onTimeslotHeadersScroll(page, this);
onTimeslotHeadersScroll(tabContent, this);
});
}
@ -471,36 +469,28 @@
requirejs(["thirdparty/headroom"], function () {
// construct an instance of Headroom, passing the element
var headroom = new Headroom(page.querySelector('.tvGuideHeader'));
var headroom = new Headroom(tabContent.querySelector('.tvGuideHeader'));
// initialise
headroom.init();
});
}
$('.btnUnlockGuide', page).on('click', function () {
$('.btnUnlockGuide', tabContent).on('click', function () {
reloadPage(page);
reloadPage(tabContent);
});
$('.btnSelectDate', page).on('click', function () {
$('.btnSelectDate', tabContent).on('click', function () {
selectDate(page);
selectDate(tabContent);
});
};
}).on('pageinitdepends', "#liveTvSuggestedPage", function () {
window.LiveTvPage.renderGuideTab = function (page, tabContent) {
var page = this;
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
if (parseInt(this.selected) == 1) {
var tabContent = page.querySelector('.guideTabContent');
if (LibraryBrowser.needsRefresh(tabContent)) {
reloadPage(tabContent);
}
}
});
});
if (LibraryBrowser.needsRefresh(tabContent)) {
reloadPage(tabContent);
}
};
})(jQuery, document);

View File

@ -101,21 +101,11 @@
});
}
$(document).on('pageinitdepends', "#liveTvSuggestedPage", function () {
window.LiveTvPage.renderRecordingsTab = function (page, tabContent) {
var page = this;
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
if (parseInt(this.selected) == 3) {
var tabContent = page.querySelector('.recordingsTabContent');
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
}
});
});
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
})(jQuery, document);

View File

@ -110,54 +110,11 @@
});
}
function updateFilterControls(page) {
window.LiveTvPage.renderSeriesTimersTab = function (page, tabContent) {
// 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');
}
$(document).on('pageinitdepends', "#liveTvSuggestedPage", function () {
var page = this;
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
if (parseInt(this.selected) == 5) {
var tabContent = page.querySelector('.seriesTimersTabContent');
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
}
});
}).on('pageinitdepends', "#liveTvSuggestedPage", function () {
var page = this.querySelector('.seriesTimersTabContent');
$('.radioSortBy', page).on('click', function () {
query.StartIndex = 0;
query.SortBy = this.getAttribute('data-sortby');
reload(page);
});
$('.radioSortOrder', page).on('click', function () {
query.StartIndex = 0;
query.SortOrder = this.getAttribute('data-sortorder');
reload(page);
});
updateFilterControls(this);
});
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
})(jQuery, document);

View File

@ -121,9 +121,7 @@
});
}
function loadSuggestedTab(page) {
var tabContent = page.querySelector('.suggestedTabContent');
function renderSuggestedTab(page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
@ -132,14 +130,55 @@
function loadTab(page, index) {
var tabContent = page.querySelector('.pageTabContent[data-index=\'' + index + '\']');
var depends = [];
var scope = 'LiveTvPage';
var renderMethod = '';
var initMethod = '';
switch (index) {
case 0:
loadSuggestedTab(page);
renderMethod = 'renderSuggestedTab';
break;
case 1:
depends.push('scripts/registrationservices');
depends.push('scripts/livetvguide');
renderMethod = 'renderGuideTab';
initMethod = 'initGuideTab';
break;
case 2:
depends.push('scripts/livetvchannels');
renderMethod = 'renderChannelsTab';
initMethod = 'initChannelsTab';
break;
case 3:
depends.push('scripts/livetvrecordings');
renderMethod = 'renderRecordingsTab';
break;
case 4:
depends.push('scripts/livetvtimers');
renderMethod = 'renderTimersTab';
break;
case 5:
depends.push('scripts/livetvseriestimers');
renderMethod = 'renderSeriesTimersTab';
break;
default:
break;
}
require(depends, function () {
if (initMethod && !tabContent.initComplete) {
window[scope][initMethod](page, tabContent);
tabContent.initComplete = true;
}
window[scope][renderMethod](page, tabContent);
});
}
$(document).on('pageinitdepends', "#liveTvSuggestedPage", function () {
@ -173,4 +212,8 @@
});
window.LiveTvPage = {
renderSuggestedTab: renderSuggestedTab
};
})(jQuery, document);

View File

@ -133,20 +133,11 @@
});
}
$(document).on('pageinitdepends', "#liveTvSuggestedPage", function () {
window.LiveTvPage.renderTimersTab = function (page, tabContent) {
var page = this;
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
if (parseInt(this.selected) == 4) {
var tabContent = page.querySelector('.timersTabContent');
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
}
});
});
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
})(jQuery, document);