diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-10-02 21:11:06 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-10-02 21:12:24 -0400 |
commit | fa7ee468c0b8b877bb6d94a031464525b1a87c6b (patch) | |
tree | f6013a27558fdab23dedf69f5401214fd3b59bf1 /ext/fg/js/float.js | |
parent | 7380ada1f12c382d423133c2e9142f36a6634067 (diff) |
Simplify float initialization
Diffstat (limited to 'ext/fg/js/float.js')
-rw-r--r-- | ext/fg/js/float.js | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 8f561fec..88842eef 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -96,6 +96,18 @@ class DisplayFloat extends Display { } } + initialize(options, popupInfo, url) { + const css = options.general.customPopupCss; + if (css) { + this.setStyle(css); + } + + const {id, depth, parentFrameId} = popupInfo; + this.optionsContext.depth = depth; + this.optionsContext.url = url; + popupNestedInitialize(id, depth, parentFrameId, url); + } + setStyle(css) { const parent = document.head; @@ -122,34 +134,11 @@ DisplayFloat.onKeyDownHandlers = { }; DisplayFloat.messageHandlers = { - termsShow: (self, {definitions, options, context}) => { - self.termsShow(definitions, options, context); - }, - - kanjiShow: (self, {definitions, options, context}) => { - self.kanjiShow(definitions, options, context); - }, - - clearAutoPlayTimer: (self) => { - self.clearAutoPlayTimer(); - }, - - orphaned: (self) => { - self.onOrphaned(); - }, - - setOptions: (self, options) => { - const css = options.general.customPopupCss; - if (css) { - self.setStyle(css); - } - }, - - popupNestedInitialize: (self, {id, depth, parentFrameId, url}) => { - self.optionsContext.depth = depth; - self.optionsContext.url = url; - popupNestedInitialize(id, depth, parentFrameId, url); - } + termsShow: (self, {definitions, options, context}) => self.termsShow(definitions, options, context), + kanjiShow: (self, {definitions, options, context}) => self.kanjiShow(definitions, options, context), + clearAutoPlayTimer: (self) => self.clearAutoPlayTimer(), + orphaned: (self) => self.onOrphaned(), + initialize: (self, {options, popupInfo, url}) => self.initialize(options, popupInfo, url) }; window.yomichan_display = new DisplayFloat(); |