Merge pull request #15296 from Snuffleupagus/toolbars-reset
Move the `reset`-calls to occur last in the toolbar-constructors
This commit is contained in:
commit
fa48e90e3c
@ -152,14 +152,14 @@ class SecondaryToolbar {
|
|||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
|
|
||||||
this.reset();
|
|
||||||
|
|
||||||
// Bind the event listeners for click, cursor tool, and scroll/spread mode
|
// Bind the event listeners for click, cursor tool, and scroll/spread mode
|
||||||
// actions.
|
// actions.
|
||||||
this.#bindClickListeners();
|
this.#bindClickListeners();
|
||||||
this.#bindCursorToolsListener(options);
|
this.#bindCursorToolsListener(options);
|
||||||
this.#bindScrollModeListener(options);
|
this.#bindScrollModeListener(options);
|
||||||
this.#bindSpreadModeListener(options);
|
this.#bindSpreadModeListener(options);
|
||||||
|
|
||||||
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,6 +53,8 @@ const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class Toolbar {
|
class Toolbar {
|
||||||
|
#wasLocalized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ToolbarOptions} options
|
* @param {ToolbarOptions} options
|
||||||
* @param {EventBus} eventBus
|
* @param {EventBus} eventBus
|
||||||
@ -109,29 +111,28 @@ class Toolbar {
|
|||||||
editorInkParamsToolbar: options.editorInkParamsToolbar,
|
editorInkParamsToolbar: options.editorInkParamsToolbar,
|
||||||
};
|
};
|
||||||
|
|
||||||
this._wasLocalized = false;
|
|
||||||
this.reset();
|
|
||||||
|
|
||||||
// Bind the event listeners for click and various other actions.
|
// Bind the event listeners for click and various other actions.
|
||||||
this._bindListeners(options);
|
this.#bindListeners(options);
|
||||||
|
|
||||||
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
setPageNumber(pageNumber, pageLabel) {
|
setPageNumber(pageNumber, pageLabel) {
|
||||||
this.pageNumber = pageNumber;
|
this.pageNumber = pageNumber;
|
||||||
this.pageLabel = pageLabel;
|
this.pageLabel = pageLabel;
|
||||||
this._updateUIState(false);
|
this.#updateUIState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPagesCount(pagesCount, hasPageLabels) {
|
setPagesCount(pagesCount, hasPageLabels) {
|
||||||
this.pagesCount = pagesCount;
|
this.pagesCount = pagesCount;
|
||||||
this.hasPageLabels = hasPageLabels;
|
this.hasPageLabels = hasPageLabels;
|
||||||
this._updateUIState(true);
|
this.#updateUIState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPageScale(pageScaleValue, pageScale) {
|
setPageScale(pageScaleValue, pageScale) {
|
||||||
this.pageScaleValue = (pageScaleValue || pageScale).toString();
|
this.pageScaleValue = (pageScaleValue || pageScale).toString();
|
||||||
this.pageScale = pageScale;
|
this.pageScale = pageScale;
|
||||||
this._updateUIState(false);
|
this.#updateUIState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
@ -141,14 +142,14 @@ class Toolbar {
|
|||||||
this.pagesCount = 0;
|
this.pagesCount = 0;
|
||||||
this.pageScaleValue = DEFAULT_SCALE_VALUE;
|
this.pageScaleValue = DEFAULT_SCALE_VALUE;
|
||||||
this.pageScale = DEFAULT_SCALE;
|
this.pageScale = DEFAULT_SCALE;
|
||||||
this._updateUIState(true);
|
this.#updateUIState(true);
|
||||||
this.updateLoadingIndicatorState();
|
this.updateLoadingIndicatorState();
|
||||||
|
|
||||||
// Reset the Editor buttons too, since they're document specific.
|
// Reset the Editor buttons too, since they're document specific.
|
||||||
this.eventBus.dispatch("toolbarreset", { source: this });
|
this.eventBus.dispatch("toolbarreset", { source: this });
|
||||||
}
|
}
|
||||||
|
|
||||||
_bindListeners(options) {
|
#bindListeners(options) {
|
||||||
const { pageNumber, scaleSelect } = this.items;
|
const { pageNumber, scaleSelect } = this.items;
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
@ -203,9 +204,9 @@ class Toolbar {
|
|||||||
scaleSelect.oncontextmenu = noContextMenuHandler;
|
scaleSelect.oncontextmenu = noContextMenuHandler;
|
||||||
|
|
||||||
this.eventBus._on("localized", () => {
|
this.eventBus._on("localized", () => {
|
||||||
this._wasLocalized = true;
|
this.#wasLocalized = true;
|
||||||
this.#adjustScaleWidth();
|
this.#adjustScaleWidth();
|
||||||
this._updateUIState(true);
|
this.#updateUIState(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.#bindEditorToolsListener(options);
|
this.#bindEditorToolsListener(options);
|
||||||
@ -244,6 +245,7 @@ class Toolbar {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.eventBus._on("annotationeditormodechanged", editorModeChanged);
|
this.eventBus._on("annotationeditormodechanged", editorModeChanged);
|
||||||
|
|
||||||
this.eventBus._on("toolbarreset", evt => {
|
this.eventBus._on("toolbarreset", evt => {
|
||||||
if (evt.source === this) {
|
if (evt.source === this) {
|
||||||
editorModeChanged(
|
editorModeChanged(
|
||||||
@ -254,8 +256,8 @@ class Toolbar {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateUIState(resetNumPages = false) {
|
#updateUIState(resetNumPages = false) {
|
||||||
if (!this._wasLocalized) {
|
if (!this.#wasLocalized) {
|
||||||
// Don't update the UI state until we localize the toolbar.
|
// Don't update the UI state until we localize the toolbar.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user