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

Migrate appRouter to ES6

This commit is contained in:
MrTimscampi 2020-07-30 20:34:21 +02:00
parent e2aff66203
commit 4aa0ef4936
28 changed files with 652 additions and 709 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);
@ -147,7 +147,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 +166,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 +231,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,8 +241,8 @@ 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}) => {
@ -252,14 +252,14 @@ export class BookPlayer {
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

@ -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');
@ -822,8 +822,8 @@ function tryRemoveElement(elem) {
}
});
if (this._currentPlayOptions.fullscreen) {
appRouter.showVideoOsd().then(this.onNavigatedToOsd);
if (self._currentPlayOptions.fullscreen) {
appRouter.show('videoosd.html').then(this.onNavigatedToOsd);
} else {
appRouter.setTransparency('backdrop');
this.#videoDialog.classList.remove('videoPlayerContainer-onTop');

View file

@ -106,7 +106,7 @@ function onPlaying(instance, playOptions, resolve) {
instance.timeUpdateInterval = setInterval(onTimeUpdate.bind(instance), 500);
if (playOptions.fullscreen) {
appRouter.showVideoOsd().then(function () {
appRouter.show('videoosd.html').then(function () {
instance.videoDialog.classList.remove('onTop');
});
} else {