From a1d106dc5d93d4fdd828d74ecdae050e741547cb Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 6 Mar 2022 15:36:32 +0100 Subject: [PATCH 1/3] Use proper private methods in `web/pdf_cursor_tools.js` --- web/pdf_cursor_tools.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/web/pdf_cursor_tools.js b/web/pdf_cursor_tools.js index 39cc532f7..b2a2ab2ba 100644 --- a/web/pdf_cursor_tools.js +++ b/web/pdf_cursor_tools.js @@ -46,7 +46,7 @@ class PDFCursorTools { element: this.container, }); - this._addEventListeners(); + this.#addEventListeners(); // Defer the initial `switchTool` call, to give other viewer components // time to initialize *and* register 'cursortoolchanged' event listeners. @@ -106,23 +106,17 @@ class PDFCursorTools { // in order to prevent setting it to an invalid state. this.active = tool; - this._dispatchEvent(); + this.#dispatchEvent(); } - /** - * @private - */ - _dispatchEvent() { + #dispatchEvent() { this.eventBus.dispatch("cursortoolchanged", { source: this, tool: this.active, }); } - /** - * @private - */ - _addEventListeners() { + #addEventListeners() { this.eventBus._on("switchcursortool", evt => { this.switchTool(evt.tool); }); From f33769db2d8df4068a9c5ef11da766cc1fa119c7 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 6 Mar 2022 15:41:38 +0100 Subject: [PATCH 2/3] Use proper private methods in `web/pdf_find_bar.js` --- web/pdf_find_bar.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/web/pdf_find_bar.js b/web/pdf_find_bar.js index c004017a7..d13d39494 100644 --- a/web/pdf_find_bar.js +++ b/web/pdf_find_bar.js @@ -87,7 +87,7 @@ class PDFFindBar { this.dispatchEvent("diacriticmatchingchange"); }); - this.eventBus._on("resize", this._adjustWidth.bind(this)); + this.eventBus._on("resize", this.#adjustWidth.bind(this)); } reset() { @@ -130,7 +130,7 @@ class PDFFindBar { findMsg.then(msg => { this.findMsg.textContent = msg; - this._adjustWidth(); + this.#adjustWidth(); }); this.updateResultsCount(matchesCount); @@ -165,7 +165,7 @@ class PDFFindBar { this.findResultsCount.textContent = msg; // Since `updateResultsCount` may be called from `PDFFindController`, // ensure that the width of the findbar is always updated correctly. - this._adjustWidth(); + this.#adjustWidth(); }); } @@ -179,7 +179,7 @@ class PDFFindBar { this.findField.select(); this.findField.focus(); - this._adjustWidth(); + this.#adjustWidth(); } close() { @@ -202,10 +202,7 @@ class PDFFindBar { } } - /** - * @private - */ - _adjustWidth() { + #adjustWidth() { if (!this.opened) { return; } From 6500aafd00fa0b390df3c141429cd8a5fe12f5f8 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 6 Mar 2022 15:44:53 +0100 Subject: [PATCH 3/3] Use proper private methods in `web/secondary_toolbar.js` --- web/secondary_toolbar.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js index 3b1f33d44..fc8369e70 100644 --- a/web/secondary_toolbar.js +++ b/web/secondary_toolbar.js @@ -159,13 +159,13 @@ class SecondaryToolbar { // Bind the event listeners for click, cursor tool, and scroll/spread mode // actions. - this._bindClickListeners(); - this._bindCursorToolsListener(options); - this._bindScrollModeListener(options); - this._bindSpreadModeListener(options); + this.#bindClickListeners(); + this.#bindCursorToolsListener(options); + this.#bindScrollModeListener(options); + this.#bindSpreadModeListener(options); // Bind the event listener for adjusting the 'max-height' of the toolbar. - this.eventBus._on("resize", this._setMaxHeight.bind(this)); + this.eventBus._on("resize", this.#setMaxHeight.bind(this)); } /** @@ -177,31 +177,31 @@ class SecondaryToolbar { setPageNumber(pageNumber) { this.pageNumber = pageNumber; - this._updateUIState(); + this.#updateUIState(); } setPagesCount(pagesCount) { this.pagesCount = pagesCount; - this._updateUIState(); + this.#updateUIState(); } reset() { this.pageNumber = 0; this.pagesCount = 0; - this._updateUIState(); + this.#updateUIState(); // Reset the Scroll/Spread buttons too, since they're document specific. this.eventBus.dispatch("secondarytoolbarreset", { source: this }); } - _updateUIState() { + #updateUIState() { this.items.firstPage.disabled = this.pageNumber <= 1; this.items.lastPage.disabled = this.pageNumber >= this.pagesCount; this.items.pageRotateCw.disabled = this.pagesCount === 0; this.items.pageRotateCcw.disabled = this.pagesCount === 0; } - _bindClickListeners() { + #bindClickListeners() { // Button to toggle the visibility of the secondary toolbar. this.toggleButton.addEventListener("click", this.toggle.bind(this)); @@ -222,7 +222,7 @@ class SecondaryToolbar { } } - _bindCursorToolsListener(buttons) { + #bindCursorToolsListener(buttons) { this.eventBus._on("cursortoolchanged", function ({ tool }) { buttons.cursorSelectToolButton.classList.toggle( "toggled", @@ -235,7 +235,7 @@ class SecondaryToolbar { }); } - _bindScrollModeListener(buttons) { + #bindScrollModeListener(buttons) { const scrollModeChanged = ({ mode }) => { buttons.scrollPageButton.classList.toggle( "toggled", @@ -279,7 +279,7 @@ class SecondaryToolbar { }); } - _bindSpreadModeListener(buttons) { + #bindSpreadModeListener(buttons) { function spreadModeChanged({ mode }) { buttons.spreadNoneButton.classList.toggle( "toggled", @@ -308,7 +308,7 @@ class SecondaryToolbar { return; } this.opened = true; - this._setMaxHeight(); + this.#setMaxHeight(); this.toggleButton.classList.add("toggled"); this.toggleButton.setAttribute("aria-expanded", "true"); @@ -333,10 +333,7 @@ class SecondaryToolbar { } } - /** - * @private - */ - _setMaxHeight() { + #setMaxHeight() { if (!this.opened) { return; // Only adjust the 'max-height' if the toolbar is visible. }