mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
add buttons to increase and decrease font sizes in book-player
This commit is contained in:
parent
727f6e450b
commit
581f5c7bb9
2 changed files with 38 additions and 3 deletions
|
@ -29,15 +29,20 @@ export class BookPlayer {
|
|||
this.theme = 'light';
|
||||
}
|
||||
this.themes = {
|
||||
'dark': { 'body': { 'color': '#d8dadc', 'background': '#000' } },
|
||||
'sepia': { 'body': { 'color': '#d8a262', 'background': '#000' } },
|
||||
'light': { 'body': { 'color': '#000', 'background': '#fff' } }
|
||||
'dark': { 'body': { 'color': '#d8dadc', 'background': '#000', 'font-size': 'medium' } },
|
||||
'sepia': { 'body': { 'color': '#d8a262', 'background': '#000', 'font-size': 'medium' } },
|
||||
'light': { 'body': { 'color': '#000', 'background': '#fff', 'font-size': 'medium' } }
|
||||
}
|
||||
this.themeOrder = ['dark', 'sepia', 'light'];
|
||||
|
||||
this.fontSize = 'medium';
|
||||
this.fontSizeOrder = ['x-small', 'small', 'medium', 'large', 'x-large'];
|
||||
|
||||
this.onDialogClosed = this.onDialogClosed.bind(this);
|
||||
this.openTableOfContents = this.openTableOfContents.bind(this);
|
||||
this.rotateTheme = this.rotateTheme.bind(this);
|
||||
this.increaseFontSize = this.increaseFontSize.bind(this);
|
||||
this.decreaseFontSize = this.decreaseFontSize.bind(this);
|
||||
this.previous = this.previous.bind(this);
|
||||
this.next = this.next.bind(this);
|
||||
this.onWindowKeyUp = this.onWindowKeyUp.bind(this);
|
||||
|
@ -177,6 +182,8 @@ export class BookPlayer {
|
|||
elem.querySelector('#btnBookplayerToc').addEventListener('click', this.openTableOfContents);
|
||||
elem.querySelector('#btnBookplayerFullscreen').addEventListener('click', this.toggleFullscreen);
|
||||
elem.querySelector('#btnBookplayerRotateTheme').addEventListener('click', this.rotateTheme);
|
||||
elem.querySelector('#btnBookplayerIncreaseFontSize').addEventListener('click', this.increaseFontSize);
|
||||
elem.querySelector('#btnBookplayerDecreaseFontSize').addEventListener('click', this.decreaseFontSize);
|
||||
elem.querySelector('#btnBookplayerPrev')?.addEventListener('click', this.previous);
|
||||
elem.querySelector('#btnBookplayerNext')?.addEventListener('click', this.next);
|
||||
}
|
||||
|
@ -198,6 +205,8 @@ export class BookPlayer {
|
|||
elem.querySelector('#btnBookplayerToc').removeEventListener('click', this.openTableOfContents);
|
||||
elem.querySelector('#btnBookplayerFullscreen').removeEventListener('click', this.toggleFullscreen);
|
||||
elem.querySelector('#btnBookplayerRotateTheme').removeEventListener('click', this.rotateTheme);
|
||||
elem.querySelector('#btnBookplayerIncreaseFontSize').removeEventListener('click', this.increaseFontSize);
|
||||
elem.querySelector('#btnBookplayerDecreaseFontSize').removeEventListener('click', this.decreaseFontSize);
|
||||
elem.querySelector('#btnBookplayerPrev')?.removeEventListener('click', this.previous);
|
||||
elem.querySelector('#btnBookplayerNext')?.removeEventListener('click', this.next);
|
||||
}
|
||||
|
@ -237,6 +246,26 @@ export class BookPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
increaseFontSize() {
|
||||
if (this.loaded) {
|
||||
if (this.fontSize !== this.fontSizeOrder[this.fontSizeOrder.length - 1]) {
|
||||
const newFontSize = this.fontSizeOrder[(this.fontSizeOrder.indexOf(this.fontSize) + 1)];
|
||||
this.rendition.themes.fontSize(newFontSize);
|
||||
this.fontSize = newFontSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
decreaseFontSize() {
|
||||
if (this.loaded) {
|
||||
if (this.fontSize !== this.fontSizeOrder[0]) {
|
||||
const newFontSize = this.fontSizeOrder[(this.fontSizeOrder.indexOf(this.fontSize) - 1)];
|
||||
this.rendition.themes.fontSize(newFontSize);
|
||||
this.fontSize = newFontSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
previous(e) {
|
||||
e?.preventDefault();
|
||||
if (this.rendition) {
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
<button is="paper-icon-button-light" id="btnBookplayerRotateTheme" class="autoSize bookplayerButton hide-mouse-idle-tv" tabindex="-1">
|
||||
<span class="material-icons bookplayerButtonIcon remove_red_eye" aria-hidden="true"></span>
|
||||
</button>
|
||||
<button is="paper-icon-button-light" id="btnBookplayerDecreaseFontSize" class="autoSize bookplayerButton hide-mouse-idle-tv" tabindex="-1">
|
||||
<span class="material-icons bookplayerButtonIcon text_decrease" aria-hidden="true"></span>
|
||||
</button>
|
||||
<button is="paper-icon-button-light" id="btnBookplayerIncreaseFontSize" class="autoSize bookplayerButton hide-mouse-idle-tv" tabindex="-1">
|
||||
<span class="material-icons bookplayerButtonIcon text_increase" aria-hidden="true"></span>
|
||||
</button>
|
||||
<button is="paper-icon-button-light" id="btnBookplayerFullscreen" class="autoSize bookplayerButton hide-mouse-idle-tv" tabindex="-1">
|
||||
<span class="material-icons bookplayerButtonIcon fullscreen" aria-hidden="true"></span>
|
||||
</button>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue