Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all event listeners into Toolbar.prototype.#bindListeners #18523

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions web/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,31 +118,7 @@ class Toolbar {
// Bind the event listeners for click and various other actions.
this.#bindListeners(buttons);

if (options.editorHighlightColorPicker) {
eventBus._on(
"annotationeditoruimanager",
({ uiManager }) => {
this.#setAnnotationEditorUIManager(
uiManager,
options.editorHighlightColorPicker
);
},
// Once the color picker has been added, we don't want to add it again.
{ once: true }
);
}

eventBus._on("showannotationeditorui", ({ mode }) => {
switch (mode) {
case AnnotationEditorType.HIGHLIGHT:
options.editorHighlightButton.click();
break;
}
});

eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));
this.#updateToolbarDensity({ value: toolbarDensity });

this.reset();
}

Expand Down Expand Up @@ -188,7 +164,12 @@ class Toolbar {

#bindListeners(buttons) {
const { eventBus } = this;
const { pageNumber, scaleSelect } = this.#opts;
const {
editorHighlightColorPicker,
editorHighlightButton,
pageNumber,
scaleSelect,
} = this.#opts;
const self = this;

// The buttons within the toolbar.
Expand Down Expand Up @@ -243,6 +224,28 @@ class Toolbar {
"annotationeditormodechanged",
this.#editorModeChanged.bind(this)
);
eventBus._on("showannotationeditorui", ({ mode }) => {
switch (mode) {
case AnnotationEditorType.HIGHLIGHT:
editorHighlightButton.click();
break;
}
});
eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));

if (editorHighlightColorPicker) {
eventBus._on(
"annotationeditoruimanager",
({ uiManager }) => {
this.#setAnnotationEditorUIManager(
uiManager,
editorHighlightColorPicker
);
},
// Once the color picker has been added, we don't want to add it again.
{ once: true }
);
}
}

#editorModeChanged({ mode }) {
Expand Down