From fe875bbd99980b175fc366a2bfd4395be9cbad72 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 20 Feb 2024 10:13:57 -0500 Subject: Constructor simplification (#713) * Update AudioDownloader * Update Translator * Update ClipboardMonitor * Update ClipboardReader * Update PanelElement * Update QueryParser * Update DisplayGenerator * Update DisplayHistory * Update DOMDataBinder * Remove unnecessary cast * Update Popup types * One declaration per line * Remove optionals from Frontend constructor * Fix Translator constructor --- ext/js/app/popup-factory.js | 28 ++++++++++++++-------------- ext/js/app/popup-proxy.js | 15 ++++++--------- ext/js/app/popup-window.js | 13 +++++-------- ext/js/app/popup.js | 17 +++++++---------- 4 files changed, 32 insertions(+), 41 deletions(-) (limited to 'ext/js/app') diff --git a/ext/js/app/popup-factory.js b/ext/js/app/popup-factory.js index 4338bb3a..9cada2c8 100644 --- a/ext/js/app/popup-factory.js +++ b/ext/js/app/popup-factory.js @@ -120,12 +120,12 @@ export class PopupFactory { if (id === null) { id = generateId(16); } - const popup = new PopupWindow({ - application: this._application, + const popup = new PopupWindow( + this._application, id, depth, - frameId: currentFrameId - }); + currentFrameId + ); this._popups.set(id, popup); return popup; } else if (frameId === currentFrameId) { @@ -133,13 +133,13 @@ export class PopupFactory { if (id === null) { id = generateId(16); } - const popup = new Popup({ - application: this._application, + const popup = new Popup( + this._application, id, depth, - frameId: currentFrameId, + currentFrameId, childrenSupported - }); + ); if (parent !== null) { if (parent.child !== null) { throw new Error('Parent popup already has a child'); @@ -162,13 +162,13 @@ export class PopupFactory { childrenSupported }); id = info.id; - const popup = new PopupProxy({ - application: this._application, + const popup = new PopupProxy( + this._application, id, - depth: info.depth, - frameId: info.frameId, - frameOffsetForwarder: useFrameOffsetForwarder ? this._frameOffsetForwarder : null - }); + info.depth, + info.frameId, + useFrameOffsetForwarder ? this._frameOffsetForwarder : null + ); this._popups.set(id, popup); return popup; } diff --git a/ext/js/app/popup-proxy.js b/ext/js/app/popup-proxy.js index 910b2f06..40baf65b 100644 --- a/ext/js/app/popup-proxy.js +++ b/ext/js/app/popup-proxy.js @@ -26,16 +26,13 @@ import {log} from '../core/log.js'; */ export class PopupProxy extends EventDispatcher { /** - * Creates a new instance. - * @param {import('popup').PopupProxyConstructorDetails} details Details about how to set up the instance. + * @param {import('../application.js').Application} application The main application instance. + * @param {string} id The identifier of the popup. + * @param {number} depth The depth of the popup. + * @param {number} frameId The frameId of the host frame. + * @param {?import('../comm/frame-offset-forwarder.js').FrameOffsetForwarder} frameOffsetForwarder A `FrameOffsetForwarder` instance which is used to determine frame positioning. */ - constructor({ - application, - id, - depth, - frameId, - frameOffsetForwarder - }) { + constructor(application, id, depth, frameId, frameOffsetForwarder) { super(); /** @type {import('../application.js').Application} */ this._application = application; diff --git a/ext/js/app/popup-window.js b/ext/js/app/popup-window.js index 32c4d67b..01696676 100644 --- a/ext/js/app/popup-window.js +++ b/ext/js/app/popup-window.js @@ -24,15 +24,12 @@ import {EventDispatcher} from '../core/event-dispatcher.js'; */ export class PopupWindow extends EventDispatcher { /** - * Creates a new instance. - * @param {import('popup').PopupWindowConstructorDetails} details Details about how to set up the instance. + * @param {import('../application.js').Application} application The main application instance. + * @param {string} id The identifier of the popup. + * @param {number} depth The depth of the popup. + * @param {number} frameId The frameId of the host frame. */ - constructor({ - application, - id, - depth, - frameId - }) { + constructor(application, id, depth, frameId) { super(); /** @type {import('../application.js').Application} */ this._application = application; diff --git a/ext/js/app/popup.js b/ext/js/app/popup.js index 4caf8241..e9c37d00 100644 --- a/ext/js/app/popup.js +++ b/ext/js/app/popup.js @@ -32,16 +32,13 @@ import {ThemeController} from './theme-controller.js'; */ export class Popup extends EventDispatcher { /** - * Creates a new instance. - * @param {import('popup').PopupConstructorDetails} details The details used to construct the new instance. - */ - constructor({ - application, - id, - depth, - frameId, - childrenSupported - }) { + * @param {import('../application.js').Application} application The main application instance. + * @param {string} id The identifier of the popup. + * @param {number} depth The depth of the popup. + * @param {number} frameId The frameId of the host frame. + * @param {boolean} childrenSupported Whether or not the popup is able to show child popups. + */ + constructor(application, id, depth, frameId, childrenSupported) { super(); /** @type {import('../application.js').Application} */ this._application = application; -- cgit v1.2.3