Skip to content

Commit

Permalink
For mozilla#11838: trigger fallback bar after user clicks in pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
emalysz committed Jun 1, 2020
1 parent fe56897 commit 67e21f0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ class DefaultExternalServices {
const PDFViewerApplication = {
initialBookmark: document.location.hash.substring(1),
_initializedCapability: createPromiseCapability(),
fellback: false,
appConfig: null,
pdfDocument: null,
pdfLoadingTask: null,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -2473,7 +2477,9 @@ function webViewerWheel(evt) {
}

function webViewerClick(evt) {
PDFViewerApplication._hasInteracted = true;
if (!PDFViewerApplication.secondaryToolbar.isOpen) {
PDFViewerApplication.fallback();
return;
}
const appConfig = PDFViewerApplication.appConfig;
Expand Down

0 comments on commit 67e21f0

Please sign in to comment.