From 2b0b8cd6654a9d645a3dd1f494ef0135a24f3ae6 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 9 Aug 2022 21:32:02 +0200 Subject: [PATCH] Add more private properties/methods in `web/toolbar.js` --- web/toolbar.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/web/toolbar.js b/web/toolbar.js index fea035992..11df06ff9 100644 --- a/web/toolbar.js +++ b/web/toolbar.js @@ -53,6 +53,8 @@ const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading"; */ class Toolbar { + #wasLocalized = false; + /** * @param {ToolbarOptions} options * @param {EventBus} eventBus @@ -109,29 +111,28 @@ class Toolbar { editorInkParamsToolbar: options.editorInkParamsToolbar, }; - this._wasLocalized = false; this.reset(); // Bind the event listeners for click and various other actions. - this._bindListeners(options); + this.#bindListeners(options); } setPageNumber(pageNumber, pageLabel) { this.pageNumber = pageNumber; this.pageLabel = pageLabel; - this._updateUIState(false); + this.#updateUIState(false); } setPagesCount(pagesCount, hasPageLabels) { this.pagesCount = pagesCount; this.hasPageLabels = hasPageLabels; - this._updateUIState(true); + this.#updateUIState(true); } setPageScale(pageScaleValue, pageScale) { this.pageScaleValue = (pageScaleValue || pageScale).toString(); this.pageScale = pageScale; - this._updateUIState(false); + this.#updateUIState(false); } reset() { @@ -141,14 +142,14 @@ class Toolbar { this.pagesCount = 0; this.pageScaleValue = DEFAULT_SCALE_VALUE; this.pageScale = DEFAULT_SCALE; - this._updateUIState(true); + this.#updateUIState(true); this.updateLoadingIndicatorState(); // Reset the Editor buttons too, since they're document specific. this.eventBus.dispatch("toolbarreset", { source: this }); } - _bindListeners(options) { + #bindListeners(options) { const { pageNumber, scaleSelect } = this.items; const self = this; @@ -203,9 +204,9 @@ class Toolbar { scaleSelect.oncontextmenu = noContextMenuHandler; this.eventBus._on("localized", () => { - this._wasLocalized = true; + this.#wasLocalized = true; this.#adjustScaleWidth(); - this._updateUIState(true); + this.#updateUIState(true); }); this.#bindEditorToolsListener(options); @@ -244,6 +245,7 @@ class Toolbar { } }; this.eventBus._on("annotationeditormodechanged", editorModeChanged); + this.eventBus._on("toolbarreset", evt => { if (evt.source === this) { editorModeChanged( @@ -254,8 +256,8 @@ class Toolbar { }); } - _updateUIState(resetNumPages = false) { - if (!this._wasLocalized) { + #updateUIState(resetNumPages = false) { + if (!this.#wasLocalized) { // Don't update the UI state until we localize the toolbar. return; }