1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

fix next up order

This commit is contained in:
Luke Pulverenti 2016-06-29 12:31:01 -04:00
parent b1a7dbd507
commit dc90abdf0f
7 changed files with 117 additions and 21 deletions

View file

@ -1,13 +1,6 @@
define([], function () { define([], function () {
function reload(page) { function getNextUpPromise() {
Dashboard.showLoadingMsg();
loadNextUp(page, 'home-nextup');
}
function loadNextUp(page) {
var query = { var query = {
@ -18,7 +11,11 @@
EnableImageTypes: "Primary,Backdrop,Banner,Thumb" EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
}; };
ApiClient.getNextUpEpisodes(query).then(function (result) { return ApiClient.getNextUpEpisodes(query);
}
function loadNextUp(page, promise) {
promise.then(function (result) {
if (result.Items.length) { if (result.Items.length) {
page.querySelector('.noNextUpItems').classList.add('hide'); page.querySelector('.noNextUpItems').classList.add('hide');
@ -51,10 +48,16 @@
return function (view, params, tabContent) { return function (view, params, tabContent) {
var self = this; var self = this;
var nextUpPromise;
self.preRender = function () {
nextUpPromise = getNextUpPromise();
};
self.renderTab = function () { self.renderTab = function () {
reload(tabContent); Dashboard.showLoadingMsg();
loadNextUp(view, nextUpPromise);
}; };
}; };

View file

@ -1,6 +1,7 @@
define(['datetime', 'scrollStyles'], function (datetime) { define(['datetime', 'scrollStyles'], function (datetime) {
function loadUpcoming(page) { function getUpcomingPromise() {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
var query = { var query = {
@ -13,7 +14,12 @@
EnableTotalRecordCount: false EnableTotalRecordCount: false
}; };
ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming", query)).then(function (result) { return ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming", query));
}
function loadUpcoming(page, promise) {
promise.then(function (result) {
var items = result.Items; var items = result.Items;
@ -125,10 +131,16 @@
return function (view, params, tabContent) { return function (view, params, tabContent) {
var self = this; var self = this;
var upcomingPromise;
self.preRender = function () {
upcomingPromise = getUpcomingPromise();
};
self.renderTab = function () { self.renderTab = function () {
loadUpcoming(tabContent); Dashboard.showLoadingMsg();
loadUpcoming(view, upcomingPromise);
}; };
}; };

View file

@ -255,9 +255,8 @@
var tabControllers = []; var tabControllers = [];
var renderedTabs = []; var renderedTabs = [];
function loadTab(page, index) { function getTabController(page, index, callback) {
var tabContent = view.querySelector('.pageTabContent[data-index=\'' + index + '\']');
var depends = []; var depends = [];
switch (index) { switch (index) {
@ -279,12 +278,14 @@
} }
require(depends, function (controllerFactory) { require(depends, function (controllerFactory) {
var tabContent;
if (index == 0) { if (index == 0) {
tabContent = view.querySelector('.pageTabContent[data-index=\'' + index + '\']');
self.tabContent = tabContent; self.tabContent = tabContent;
} }
var controller = tabControllers[index]; var controller = tabControllers[index];
if (!controller) { if (!controller) {
tabContent = view.querySelector('.pageTabContent[data-index=\'' + index + '\']');
controller = index ? new controllerFactory(view, params, tabContent) : self; controller = index ? new controllerFactory(view, params, tabContent) : self;
tabControllers[index] = controller; tabControllers[index] = controller;
@ -293,6 +294,24 @@
} }
} }
callback(controller);
});
}
function preLoadTab(page, index) {
getTabController(page, index, function (controller) {
if (renderedTabs.indexOf(index) == -1) {
if (controller.preRender) {
controller.preRender();
}
}
});
}
function loadTab(page, index) {
getTabController(page, index, function (controller) {
if (renderedTabs.indexOf(index) == -1) { if (renderedTabs.indexOf(index) == -1) {
renderedTabs.push(index); renderedTabs.push(index);
controller.renderTab(); controller.renderTab();
@ -300,6 +319,10 @@
}); });
} }
mdlTabs.addEventListener('beforetabchange', function (e) {
preLoadTab(view, parseInt(e.detail.selectedTabIndex));
});
mdlTabs.addEventListener('tabchange', function (e) { mdlTabs.addEventListener('tabchange', function (e) {
loadTab(view, parseInt(e.detail.selectedTabIndex)); loadTab(view, parseInt(e.detail.selectedTabIndex));
}); });

View file

@ -215,6 +215,11 @@
var current = LibraryBrowser.selectedTab(tabs); var current = LibraryBrowser.selectedTab(tabs);
tabs.selectedTabIndex = selected; tabs.selectedTabIndex = selected;
if (current == selected) { if (current == selected) {
tabs.dispatchEvent(new CustomEvent("beforetabchange", {
detail: {
selectedTabIndex: selected
}
}));
tabs.dispatchEvent(new CustomEvent("tabchange", { tabs.dispatchEvent(new CustomEvent("tabchange", {
detail: { detail: {
selectedTabIndex: selected selectedTabIndex: selected
@ -289,6 +294,12 @@
var index = parseInt(link.getAttribute('data-index')); var index = parseInt(link.getAttribute('data-index'));
var newPanel = panels[index]; var newPanel = panels[index];
tabs.dispatchEvent(new CustomEvent("beforetabchange", {
detail: {
selectedTabIndex: index
}
}));
// If toCenter is called syncronously within the click event, it sometimes ends up canceling it // If toCenter is called syncronously within the click event, it sometimes ends up canceling it
setTimeout(function () { setTimeout(function () {
@ -355,6 +366,11 @@
LibraryBrowser.selectedTab(pageTabsContainer, 0); LibraryBrowser.selectedTab(pageTabsContainer, 0);
return; return;
} }
pageTabsContainer.dispatchEvent(new CustomEvent("beforetabchange", {
detail: {
selectedTabIndex: LibraryBrowser.selectedTab(pageTabsContainer)
}
}));
pageTabsContainer.dispatchEvent(new CustomEvent("tabchange", { pageTabsContainer.dispatchEvent(new CustomEvent("tabchange", {
detail: { detail: {
selectedTabIndex: LibraryBrowser.selectedTab(pageTabsContainer) selectedTabIndex: LibraryBrowser.selectedTab(pageTabsContainer)

View file

@ -3028,7 +3028,7 @@ var AppInfo = {};
defineRoute({ defineRoute({
path: '/wizardcomponents.html', path: '/wizardcomponents.html',
dependencies: ['dashboardcss', 'emby-button', 'emby-input'], dependencies: ['dashboardcss', 'emby-button', 'emby-input', 'emby-select'],
autoFocus: false, autoFocus: false,
anonymous: true, anonymous: true,
controller: 'scripts/wizardcomponents' controller: 'scripts/wizardcomponents'

View file

@ -12,6 +12,12 @@
ApiClient.getSystemInfo().then(function (systemInfo) { ApiClient.getSystemInfo().then(function (systemInfo) {
if (systemInfo.OperatingSystem == 'Windows') {
view.querySelector('.fldSelectEncoderPathType').classList.add('hide');
} else {
view.querySelector('.fldSelectEncoderPathType').classList.remove('hide');
}
if (systemInfo.OperatingSystem == 'Windows' && systemInfo.SystemArchitecture != 'Arm') { if (systemInfo.OperatingSystem == 'Windows' && systemInfo.SystemArchitecture != 'Arm') {
view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', '<a target="_blank" href="https://ffmpeg.zeranoe.com/builds">https://ffmpeg.zeranoe.com</a>'); view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', '<a target="_blank" href="https://ffmpeg.zeranoe.com/builds">https://ffmpeg.zeranoe.com</a>');
@ -45,6 +51,10 @@
view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', '<a target="_blank" href="http://ffmpeg.org">https://ffmpeg.org/download.html</a>'); view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', '<a target="_blank" href="http://ffmpeg.org">https://ffmpeg.org/download.html</a>');
view.querySelector('.downloadInstructions').innerHTML = ''; view.querySelector('.downloadInstructions').innerHTML = '';
} }
var selectEncoderPath = view.querySelector('#selectEncoderPath');
selectEncoderPath.value = 'Custom';
onSelectEncoderPathChange.call(selectEncoderPath);
}); });
} }
@ -60,6 +70,30 @@
}); });
} }
function parentWithClass(elem, className) {
while (!elem.classList || !elem.classList.contains(className)) {
elem = elem.parentNode;
if (!elem) {
return null;
}
}
return elem;
}
function onSelectEncoderPathChange(e) {
var page = parentWithClass(this, 'page');
if (this.value == 'Custom') {
page.querySelector('.fldEncoderPath').classList.remove('hide');
} else {
page.querySelector('.fldEncoderPath').classList.add('hide');
}
}
return function (view, params) { return function (view, params) {
view.querySelector('#btnSelectEncoderPath').addEventListener("click", function () { view.querySelector('#btnSelectEncoderPath').addEventListener("click", function () {
@ -99,6 +133,7 @@
return false; return false;
}); });
view.querySelector('#selectEncoderPath').addEventListener('change', onSelectEncoderPathChange);
view.addEventListener('viewbeforeshow', function (e) { view.addEventListener('viewbeforeshow', function (e) {

View file

@ -31,7 +31,14 @@
<div style="margin-left:.5em;">${EnterFFmpegLocation}</div> <div style="margin-left:.5em;">${EnterFFmpegLocation}</div>
</div> </div>
<div class="inputContainer fldEncoderPath" style="margin-top:1em;"> <br /><br />
<div class="selectContainer fldSelectEncoderPathType hide">
<select is="emby-select" id="selectEncoderPath" label="${LabelffmpegVersion}">
<option value="System">${OptionUseSystemInstalledVersion}</option>
<option value="Custom">${OptionUseMyCustomVersion}</option>
</select>
</div>
<div class="inputContainer fldEncoderPath hide">
<div style="display: flex; align-items: center;"> <div style="display: flex; align-items: center;">
<div style="flex-grow:1;"> <div style="flex-grow:1;">
<input is="emby-input" class="txtEncoderPath" label="${LabelffmpegPath}" autocomplete="off" required /> <input is="emby-input" class="txtEncoderPath" label="${LabelffmpegPath}" autocomplete="off" required />