mirror of
https://github.com/koloml/furbooru-tagging-assistant.git
synced 2025-12-23 23:02:58 +00:00
Apply the preference
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
import {BaseComponent} from "$lib/components/base/BaseComponent.js";
|
||||
import {getComponent} from "$lib/components/base/ComponentUtils.js";
|
||||
import MiscSettings from "$lib/extension/settings/MiscSettings.js";
|
||||
|
||||
export class ImageShowFullscreenButton extends BaseComponent {
|
||||
/**
|
||||
* @type {MediaBoxTools}
|
||||
*/
|
||||
#mediaBoxTools;
|
||||
#isFullscreenButtonEnabled = false;
|
||||
|
||||
build() {
|
||||
this.container.innerText = '🔍';
|
||||
ImageShowFullscreenButton.#resolveFullscreenViewer();
|
||||
|
||||
ImageShowFullscreenButton.#miscSettings ??= new MiscSettings();
|
||||
}
|
||||
|
||||
init() {
|
||||
@@ -20,6 +24,24 @@ export class ImageShowFullscreenButton extends BaseComponent {
|
||||
}
|
||||
|
||||
this.on('click', this.#onButtonClicked.bind(this));
|
||||
|
||||
if (ImageShowFullscreenButton.#miscSettings) {
|
||||
ImageShowFullscreenButton.#miscSettings.resolveFullscreenViewerEnabled()
|
||||
.then(isEnabled => {
|
||||
this.#isFullscreenButtonEnabled = isEnabled;
|
||||
this.#updateFullscreenButtonVisibility();
|
||||
})
|
||||
.then(() => {
|
||||
ImageShowFullscreenButton.#miscSettings.subscribe(settings => {
|
||||
this.#isFullscreenButtonEnabled = settings.fullscreenViewer;
|
||||
this.#updateFullscreenButtonVisibility();
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#updateFullscreenButtonVisibility() {
|
||||
this.container.classList.toggle('is-visible', this.#isFullscreenButtonEnabled);
|
||||
}
|
||||
|
||||
#onButtonClicked() {
|
||||
@@ -113,6 +135,11 @@ export class ImageShowFullscreenButton extends BaseComponent {
|
||||
videoElement.remove();
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {MiscSettings|null}
|
||||
*/
|
||||
static #miscSettings = null;
|
||||
}
|
||||
|
||||
export function createImageShowFullscreenButton() {
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
.media-box-show-fullscreen {
|
||||
.media-box-show-fullscreen.is-visible {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user