mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Reduce some duplication when toggling buttons in the viewer toolbars
Currently we repeat the same code in lots of places, to update the "toggled" class and "aria-checked" attribute, when various toolbar buttons are clicked. For the MOZCENTRAL build-target this patch reduces the size of the *built* `web/viewer.js` file by just over `1.2` kilo-bytes.
This commit is contained in:
parent
b3932f70ed
commit
2a195beb30
4 changed files with 69 additions and 82 deletions
|
@ -841,6 +841,13 @@ function apiPageModeToSidebarView(mode) {
|
|||
return SidebarView.NONE; // Default value.
|
||||
}
|
||||
|
||||
function toggleCheckedBtn(button, toggle, view = null) {
|
||||
button.classList.toggle("toggled", toggle);
|
||||
button.setAttribute("aria-checked", toggle);
|
||||
|
||||
view?.classList.toggle("hidden", !toggle);
|
||||
}
|
||||
|
||||
export {
|
||||
animationStarted,
|
||||
apiPageLayoutToViewerModes,
|
||||
|
@ -880,6 +887,7 @@ export {
|
|||
SidebarView,
|
||||
SpreadMode,
|
||||
TextLayerMode,
|
||||
toggleCheckedBtn,
|
||||
UNKNOWN_SCALE,
|
||||
VERTICAL_PADDING,
|
||||
watchScroll,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue