From 71b97c20199e628618bed456e886a5ae7d9beb08 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 18 Jul 2020 23:47:02 -0400 Subject: Display refactoring (#674) * Move setupNestedPopups to Display * Move auto-play timer and delay into Display * Move some message handler definitions into Display * Move default optionsContext definition --- ext/bg/js/search.js | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index b046806e..a3741da0 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -19,11 +19,8 @@ * ClipboardMonitor * DOM * Display - * Frontend - * PopupFactory * QueryParser * api - * dynamicLoader * wanakana */ @@ -63,11 +60,6 @@ class DisplaySearch extends Display { this._runtimeMessageHandlers = new Map([ ['updateSearchQuery', {async: false, handler: this._onExternalSearchUpdate.bind(this)}] ]); - - this.setOptionsContext({ - depth: 0, - url: window.location.href - }); } async prepare() { @@ -407,7 +399,11 @@ class DisplaySearch extends Display { yomichan.off('optionsUpdated', onOptionsUpdated); try { - await this._setupNestedPopups(); + await this.setupNestedPopups({ + depth: 1, + proxy: false, + isSearchPage: true + }); } catch (e) { yomichan.logError(e); } @@ -417,31 +413,4 @@ class DisplaySearch extends Display { await onOptionsUpdated(); } - - async _setupNestedPopups() { - await dynamicLoader.loadScripts([ - '/mixed/js/text-scanner.js', - '/mixed/js/frame-client.js', - '/fg/js/frame-offset-forwarder.js', - '/fg/js/popup.js', - '/fg/js/popup-factory.js', - '/fg/js/frontend.js' - ]); - - const {frameId} = await api.frameInformationGet(); - - const popupFactory = new PopupFactory(frameId); - popupFactory.prepare(); - - const frontend = new Frontend( - frameId, - popupFactory, - { - depth: 1, - proxy: false, - isSearchPage: true - } - ); - await frontend.prepare(); - } } -- cgit v1.2.3