From 5ae936eb87771d64e896f38a3ed5ef5463a58f4b Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Thu, 13 Jun 2024 22:03:18 +0200 Subject: [PATCH] Display a wait cursor when saving When the document is a bit long to save (for example in modifying a large document) we must have something indicating that pdf.js is doing something. --- web/app.js | 19 +++++++++++++------ web/viewer.css | 9 +++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/web/app.js b/web/app.js index 16a81300e..3ba91c25e 100644 --- a/web/app.js +++ b/web/app.js @@ -1133,12 +1133,19 @@ const PDFViewerApplication = { } }, - downloadOrSave(options = {}) { - if (this.pdfDocument?.annotationStorage.size > 0) { - this.save(options); - } else { - this.download(options); - } + async downloadOrSave(options = {}) { + // In the Firefox case, this method MUST always trigger a download. + // When the user is closing a modified and unsaved document, we display a + // prompt asking for saving or not. In case they save, we must wait for + // saving to complete before closing the tab. + // So in case this function does not trigger a download, we must trigger a + // a message and change PdfjsChild.sys.mjs to take it into account. + const { classList } = this.appConfig.appContainer; + classList.add("wait"); + await (this.pdfDocument?.annotationStorage.size > 0 + ? this.save(options) + : this.download(options)); + classList.remove("wait"); }, /** diff --git a/web/viewer.css b/web/viewer.css index 56a32ad65..6706ac5cd 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -223,6 +223,15 @@ body { body { background-color: var(--body-bg-color); scrollbar-color: var(--scrollbar-color) var(--scrollbar-bg-color); + + &.wait::before { + content: ""; + position: fixed; + width: 100%; + height: 100%; + z-index: 100000; + cursor: wait; + } } .hidden,