From 67e21f03e7ed13502f942ba322bbce7902f8e2d9 Mon Sep 17 00:00:00 2001 From: Emma Malysz Date: Mon, 1 Jun 2020 10:28:30 -0700 Subject: [PATCH] For #11838: trigger fallback bar after user clicks in pdf --- web/app.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/web/app.js b/web/app.js index 1d442f0a189aa7..70428d184ed4d2 100644 --- a/web/app.js +++ b/web/app.js @@ -136,7 +136,6 @@ class DefaultExternalServices { const PDFViewerApplication = { initialBookmark: document.location.hash.substring(1), _initializedCapability: createPromiseCapability(), - fellback: false, appConfig: null, pdfDocument: null, pdfLoadingTask: null, @@ -189,6 +188,8 @@ const PDFViewerApplication = { externalServices: DefaultExternalServices, _boundEvents: {}, contentDispositionFilename: null, + _hasInteracted: false, + _featureId: null, // Called once when the document is loaded. async initialize(appConfig) { @@ -868,14 +869,17 @@ const PDFViewerApplication = { PDFJSDev.test("MOZCENTRAL || GENERIC") ) { // Only trigger the fallback once so we don't spam the user with messages - // for one PDF. - if (this.fellback) { + // for one PDF. It should only be triggered once the user has clicked + // within the PDF. + if (!PDFViewerApplication._hasInteracted) { + if (!this._featureId) { + this._featureId = featureId; + } return; } - this.fellback = true; this.externalServices.fallback( { - featureId, + featureId: this._featureId, url: this.baseUrl, }, function response(download) { @@ -2473,7 +2477,9 @@ function webViewerWheel(evt) { } function webViewerClick(evt) { + PDFViewerApplication._hasInteracted = true; if (!PDFViewerApplication.secondaryToolbar.isOpen) { + PDFViewerApplication.fallback(); return; } const appConfig = PDFViewerApplication.appConfig;