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

Migrate bundle, qualityOptions, appHost and appLoader

This commit is contained in:
MrTimscampi 2020-07-16 22:19:09 +02:00
parent 9640f13830
commit f16df9788a
39 changed files with 1075 additions and 723 deletions

View file

@ -27,16 +27,16 @@ export class BookPlayer {
this._loaded = false;
loading.show();
let elem = this.createMediaElement();
const elem = this.createMediaElement();
return this.setCurrentSrc(elem, options);
}
stop() {
this.unbindEvents();
let elem = this._mediaElement;
let tocElement = this._tocElement;
let rendition = this._rendition;
const elem = this._mediaElement;
const tocElement = this._tocElement;
const rendition = this._rendition;
if (elem) {
dialogHelper.close(elem);
@ -93,11 +93,9 @@ export class BookPlayer {
}
onWindowKeyUp(e) {
let key = keyboardnavigation.getKeyName(e);
// TODO: depending on the event this can be the document or the rendition itself
let rendition = this._rendition || this;
let book = rendition.book;
const key = keyboardnavigation.getKeyName(e);
const rendition = this._rendition;
const book = rendition.book;
if (this._loaded === false) return;
switch (key) {
@ -147,7 +145,7 @@ export class BookPlayer {
}
bindMediaElementEvents() {
let elem = this._mediaElement;
const elem = this._mediaElement;
elem.addEventListener('close', this.onDialogClosed, {once: true});
elem.querySelector('.btnBookplayerExit').addEventListener('click', this.onDialogClosed, {once: true});
@ -166,7 +164,7 @@ export class BookPlayer {
}
unbindMediaElementEvents() {
let elem = this._mediaElement;
const elem = this._mediaElement;
elem.removeEventListener('close', this.onDialogClosed);
elem.querySelector('.btnBookplayerExit').removeEventListener('click', this.onDialogClosed);
@ -231,7 +229,7 @@ export class BookPlayer {
}
setCurrentSrc(elem, options) {
let item = options.items[0];
const item = options.items[0];
this._currentItem = item;
this.streamInfo = {
started: true,
@ -241,25 +239,25 @@ export class BookPlayer {
}
};
let serverId = item.ServerId;
let apiClient = connectionManager.getApiClient(serverId);
const serverId = item.ServerId;
const apiClient = connectionManager.getApiClient(serverId);
return new Promise((resolve, reject) => {
import('epubjs').then(({default: epubjs}) => {
let downloadHref = apiClient.getItemDownloadUrl(item.Id);
let book = epubjs(downloadHref, {openAs: 'epub'});
let rendition = book.renderTo(elem, {width: '100%', height: '97%'});
const downloadHref = apiClient.getItemDownloadUrl(item.Id);
const book = epubjs(downloadHref, {openAs: 'epub'});
const rendition = book.renderTo(elem, {width: '100%', height: '97%'});
this._currentSrc = downloadHref;
this._rendition = rendition;
let cancellationToken = {
const cancellationToken = {
shouldCancel: false
};
this._cancellationToken = cancellationToken;
return rendition.display().then(() => {
let epubElem = document.querySelector('.epub-container');
const epubElem = document.querySelector('.epub-container');
epubElem.style.display = 'none';
this.bindEvents();

View file

@ -11,7 +11,7 @@ export default class TableOfContents {
}
destroy() {
let elem = this._elem;
const elem = this._elem;
if (elem) {
this.unbindEvents();
dialogHelper.close(elem);
@ -21,14 +21,14 @@ export default class TableOfContents {
}
bindEvents() {
let elem = this._elem;
const elem = this._elem;
elem.addEventListener('close', this.onDialogClosed, {once: true});
elem.querySelector('.btnBookplayerTocClose').addEventListener('click', this.onDialogClosed, {once: true});
}
unbindEvents() {
let elem = this._elem;
const elem = this._elem;
elem.removeEventListener('close', this.onDialogClosed);
elem.querySelector('.btnBookplayerTocClose').removeEventListener('click', this.onDialogClosed);
@ -39,10 +39,10 @@ export default class TableOfContents {
}
replaceLinks(contents, f) {
let links = contents.querySelectorAll('a[href]');
const links = contents.querySelectorAll('a[href]');
links.forEach((link) => {
let href = link.getAttribute('href');
const href = link.getAttribute('href');
link.onclick = () => {
f(href);
@ -52,9 +52,9 @@ export default class TableOfContents {
}
createMediaElement() {
let rendition = this._rendition;
const rendition = this._rendition;
let elem = dialogHelper.createDialog({
const elem = dialogHelper.createDialog({
size: 'small',
autoFocus: false,
removeOnClose: true
@ -69,7 +69,7 @@ export default class TableOfContents {
rendition.book.navigation.forEach((chapter) => {
tocHtml += '<li>';
// Remove '../' from href
let link = chapter.href.startsWith('../') ? chapter.href.substr(3) : chapter.href;
const link = chapter.href.startsWith('../') ? chapter.href.substr(3) : chapter.href;
tocHtml += `<a href="${rendition.book.path.directory + link}">${chapter.label}</a>`;
tocHtml += '</li>';
});
@ -78,7 +78,7 @@ export default class TableOfContents {
elem.innerHTML = tocHtml;
this.replaceLinks(elem, (href) => {
let relative = rendition.book.path.relative(href);
const relative = rendition.book.path.relative(href);
rendition.display(relative);
this.destroy();
});

View file

@ -12,7 +12,7 @@ define(['connectionManager', 'globalize', 'userSettings', 'apphost'], function (
}
function showMessage(text, userSettingsKey, appHostFeature) {
if (appHost.supports(appHostFeature)) {
if (appHost.default.supports(appHostFeature)) {
return Promise.resolve();
}

View file

@ -334,8 +334,8 @@ define(['events', 'browser', 'require', 'apphost', 'appSettings', 'htmlMediaHelp
};
HtmlAudioPlayer.prototype.getDeviceProfile = function (item) {
if (appHost.getDeviceProfile) {
return appHost.getDeviceProfile(item);
if (appHost.default.getDeviceProfile) {
return appHost.default.getDeviceProfile(item);
}
return getDefaultProfile();

View file

@ -105,7 +105,7 @@ function tryRemoveElement(elem) {
}
function hidePrePlaybackPage() {
let animatedPage = document.querySelector('.page:not(.hide)');
const animatedPage = document.querySelector('.page:not(.hide)');
animatedPage.classList.add('hide');
// At this point, we must hide the scrollbar placeholder, so it's not being displayed while the item is being loaded
document.body.classList.remove('force-scroll');
@ -1288,7 +1288,7 @@ function tryRemoveElement(elem) {
}
let html = '';
let cssClass = 'htmlvideoplayer';
const cssClass = 'htmlvideoplayer';
// Can't autoplay in these browsers so we need to use the full controls, at least until playback starts
if (!appHost.supports('htmlvideoautoplay')) {