mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
Merge pull request #19487 from Snuffleupagus/OverlayManager-closeIfActive
Add a new `closeIfActive` method in the `OverlayManager` class
This commit is contained in:
commit
c69282a64f
6 changed files with 19 additions and 24 deletions
|
@ -245,9 +245,7 @@ class AltTextManager {
|
|||
}
|
||||
|
||||
#finish() {
|
||||
if (this.#overlayManager.active === this.#dialog) {
|
||||
this.#overlayManager.close(this.#dialog);
|
||||
}
|
||||
this.#overlayManager.closeIfActive(this.#dialog);
|
||||
}
|
||||
|
||||
#close() {
|
||||
|
|
|
@ -440,9 +440,7 @@ class NewAltTextManager {
|
|||
}
|
||||
|
||||
#finish() {
|
||||
if (this.#overlayManager.active === this.#dialog) {
|
||||
this.#overlayManager.close(this.#dialog);
|
||||
}
|
||||
this.#overlayManager.closeIfActive(this.#dialog);
|
||||
}
|
||||
|
||||
#close() {
|
||||
|
@ -696,9 +694,7 @@ class ImageAltTextSettings {
|
|||
}
|
||||
|
||||
#finish() {
|
||||
if (this.#overlayManager.active === this.#dialog) {
|
||||
this.#overlayManager.close(this.#dialog);
|
||||
}
|
||||
this.#overlayManager.closeIfActive(this.#dialog);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,17 @@ class OverlayManager {
|
|||
dialog.close();
|
||||
this.#active = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLDialogElement} dialog - The overlay's DOM element.
|
||||
* @returns {Promise} A promise that is resolved when the overlay has been
|
||||
* closed.
|
||||
*/
|
||||
async closeIfActive(dialog) {
|
||||
if (this.#active === dialog) {
|
||||
await this.close(dialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { OverlayManager };
|
||||
|
|
|
@ -89,9 +89,7 @@ class PasswordPrompt {
|
|||
}
|
||||
|
||||
async close() {
|
||||
if (this.overlayManager.active === this.dialog) {
|
||||
this.overlayManager.close(this.dialog);
|
||||
}
|
||||
this.overlayManager.closeIfActive(this.dialog);
|
||||
}
|
||||
|
||||
#verify() {
|
||||
|
|
|
@ -148,9 +148,7 @@ class PDFPrintService {
|
|||
this.scratchCanvas = null;
|
||||
activeService = null;
|
||||
ensureOverlay().then(function () {
|
||||
if (overlayManager.active === dialog) {
|
||||
overlayManager.close(dialog);
|
||||
}
|
||||
overlayManager.closeIfActive(dialog);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -260,9 +258,7 @@ window.print = function () {
|
|||
if (!activeService) {
|
||||
console.error("Expected print service to be initialized.");
|
||||
ensureOverlay().then(function () {
|
||||
if (overlayManager.active === dialog) {
|
||||
overlayManager.close(dialog);
|
||||
}
|
||||
overlayManager.closeIfActive(dialog);
|
||||
});
|
||||
return; // eslint-disable-line no-unsafe-finally
|
||||
}
|
||||
|
|
|
@ -826,9 +826,7 @@ class SignatureManager {
|
|||
}
|
||||
|
||||
#finish() {
|
||||
if (this.#overlayManager.active === this.#dialog) {
|
||||
this.#overlayManager.close(this.#dialog);
|
||||
}
|
||||
this.#overlayManager.closeIfActive(this.#dialog);
|
||||
}
|
||||
|
||||
#close() {
|
||||
|
@ -993,9 +991,7 @@ class EditDescriptionDialog {
|
|||
}
|
||||
|
||||
#finish() {
|
||||
if (this.#overlayManager.active === this.#dialog) {
|
||||
this.#overlayManager.close(this.#dialog);
|
||||
}
|
||||
this.#overlayManager.closeIfActive(this.#dialog);
|
||||
}
|
||||
|
||||
#close() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue