summaryrefslogtreecommitdiff
path: root/ext/fg/js/float.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-07-09 17:52:44 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-07-09 18:06:27 -0400
commitad897713e6acbcbd56962e8514ac866926da3cdd (patch)
tree7a16f525c2cc7a3ac2d1241544100f40091102fa /ext/fg/js/float.js
parent8b8482d2555342ee3e28b33f018b4246348e0702 (diff)
Add support for custom popup CSS
Diffstat (limited to 'ext/fg/js/float.js')
-rw-r--r--ext/fg/js/float.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 1f08702d..1deb61a9 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -21,6 +21,7 @@ class DisplayFloat extends Display {
constructor() {
super($('#spinner'), $('#definitions'));
this.autoPlayAudioTimer = null;
+ this.styleNode = null;
$(window).on('message', utilAsync(this.onMessage.bind(this)));
}
@@ -62,6 +63,13 @@ class DisplayFloat extends Display {
orphaned: () => {
this.onOrphaned();
+ },
+
+ setOptions: (options) => {
+ const css = options.general.customPopupCss;
+ if (css) {
+ this.setStyle(css);
+ }
}
};
@@ -101,6 +109,20 @@ class DisplayFloat extends Display {
this.autoPlayAudioTimer = null;
}
}
+
+ setStyle(css) {
+ const parent = document.head;
+
+ if (this.styleNode === null) {
+ this.styleNode = document.createElement('style');
+ }
+
+ this.styleNode.textContent = css;
+
+ if (this.styleNode.parentNode !== parent) {
+ parent.appendChild(this.styleNode);
+ }
+ }
}
window.yomichan_display = new DisplayFloat();