Reduce some duplication when toggling "expanded" buttons in the viewer toolbars
This is very similar to PR 16281, but for buttons that use the "aria-expanded" attribute.
This commit is contained in:
parent
d520754bcf
commit
362be760e3
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { FindState } from "./pdf_find_controller.js";
|
import { FindState } from "./pdf_find_controller.js";
|
||||||
|
import { toggleExpandedBtn } from "./ui_utils.js";
|
||||||
|
|
||||||
const MATCHES_COUNT_LIMIT = 1000;
|
const MATCHES_COUNT_LIMIT = 1000;
|
||||||
|
|
||||||
@ -173,9 +174,7 @@ class PDFFindBar {
|
|||||||
open() {
|
open() {
|
||||||
if (!this.opened) {
|
if (!this.opened) {
|
||||||
this.opened = true;
|
this.opened = true;
|
||||||
this.toggleButton.classList.add("toggled");
|
toggleExpandedBtn(this.toggleButton, true, this.bar);
|
||||||
this.toggleButton.setAttribute("aria-expanded", "true");
|
|
||||||
this.bar.classList.remove("hidden");
|
|
||||||
}
|
}
|
||||||
this.findField.select();
|
this.findField.select();
|
||||||
this.findField.focus();
|
this.findField.focus();
|
||||||
@ -188,9 +187,7 @@ class PDFFindBar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
this.toggleButton.classList.remove("toggled");
|
toggleExpandedBtn(this.toggleButton, false, this.bar);
|
||||||
this.toggleButton.setAttribute("aria-expanded", "false");
|
|
||||||
this.bar.classList.add("hidden");
|
|
||||||
|
|
||||||
this.eventBus.dispatch("findbarclose", { source: this });
|
this.eventBus.dispatch("findbarclose", { source: this });
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import {
|
|||||||
RenderingStates,
|
RenderingStates,
|
||||||
SidebarView,
|
SidebarView,
|
||||||
toggleCheckedBtn,
|
toggleCheckedBtn,
|
||||||
|
toggleExpandedBtn,
|
||||||
} from "./ui_utils.js";
|
} from "./ui_utils.js";
|
||||||
|
|
||||||
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
||||||
@ -238,8 +239,7 @@ class PDFSidebar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isOpen = true;
|
this.isOpen = true;
|
||||||
this.toggleButton.classList.add("toggled");
|
toggleExpandedBtn(this.toggleButton, true);
|
||||||
this.toggleButton.setAttribute("aria-expanded", "true");
|
|
||||||
|
|
||||||
this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
|
this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
|
||||||
|
|
||||||
@ -257,8 +257,7 @@ class PDFSidebar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
this.toggleButton.classList.remove("toggled");
|
toggleExpandedBtn(this.toggleButton, false);
|
||||||
this.toggleButton.setAttribute("aria-expanded", "false");
|
|
||||||
|
|
||||||
this.outerContainer.classList.add("sidebarMoving");
|
this.outerContainer.classList.add("sidebarMoving");
|
||||||
this.outerContainer.classList.remove("sidebarOpen");
|
this.outerContainer.classList.remove("sidebarOpen");
|
||||||
|
@ -18,6 +18,7 @@ import {
|
|||||||
ScrollMode,
|
ScrollMode,
|
||||||
SpreadMode,
|
SpreadMode,
|
||||||
toggleCheckedBtn,
|
toggleCheckedBtn,
|
||||||
|
toggleExpandedBtn,
|
||||||
} from "./ui_utils.js";
|
} from "./ui_utils.js";
|
||||||
import { PagesCountLimit } from "./pdf_viewer.js";
|
import { PagesCountLimit } from "./pdf_viewer.js";
|
||||||
|
|
||||||
@ -292,9 +293,7 @@ class SecondaryToolbar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.opened = true;
|
this.opened = true;
|
||||||
this.toggleButton.classList.add("toggled");
|
toggleExpandedBtn(this.toggleButton, true, this.toolbar);
|
||||||
this.toggleButton.setAttribute("aria-expanded", "true");
|
|
||||||
this.toolbar.classList.remove("hidden");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
@ -302,9 +301,7 @@ class SecondaryToolbar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
this.toolbar.classList.add("hidden");
|
toggleExpandedBtn(this.toggleButton, false, this.toolbar);
|
||||||
this.toggleButton.classList.remove("toggled");
|
|
||||||
this.toggleButton.setAttribute("aria-expanded", "false");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
|
@ -851,6 +851,13 @@ function toggleCheckedBtn(button, toggle, view = null) {
|
|||||||
view?.classList.toggle("hidden", !toggle);
|
view?.classList.toggle("hidden", !toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleExpandedBtn(button, toggle, view = null) {
|
||||||
|
button.classList.toggle("toggled", toggle);
|
||||||
|
button.setAttribute("aria-expanded", toggle);
|
||||||
|
|
||||||
|
view?.classList.toggle("hidden", !toggle);
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
animationStarted,
|
animationStarted,
|
||||||
apiPageLayoutToViewerModes,
|
apiPageLayoutToViewerModes,
|
||||||
@ -891,6 +898,7 @@ export {
|
|||||||
SpreadMode,
|
SpreadMode,
|
||||||
TextLayerMode,
|
TextLayerMode,
|
||||||
toggleCheckedBtn,
|
toggleCheckedBtn,
|
||||||
|
toggleExpandedBtn,
|
||||||
UNKNOWN_SCALE,
|
UNKNOWN_SCALE,
|
||||||
VERTICAL_PADDING,
|
VERTICAL_PADDING,
|
||||||
watchScroll,
|
watchScroll,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user