Skip to content

Commit

Permalink
Prevent external links from "replacing" the viewer when it's embedded…
Browse files Browse the repository at this point in the history
… (bug 976541)

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=976541.

This patch also adds a `externalLinkTarget` preference, to make the behaviour user configurable.
  • Loading branch information
Snuffleupagus committed Oct 13, 2015
1 parent 39b962e commit 610df45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion web/default_preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ var DEFAULT_PREFERENCES = {
disableAutoFetch: false,
disableFontFace: false,
disableTextLayer: false,
useOnlyCssZoom: false
useOnlyCssZoom: false,
externalLinkTarget: 0,
};
16 changes: 14 additions & 2 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,24 @@ var PDFViewerApplication = {
}),
Preferences.get('useOnlyCssZoom').then(function resolved(value) {
PDFJS.useOnlyCssZoom = value;
})
}),
Preferences.get('externalLinkTarget').then(function resolved(value) {
if (PDFJS.isExternalLinkTargetSet()) {
return;
}
PDFJS.externalLinkTarget = value;
}),
// TODO move more preferences and other async stuff here
]).catch(function (reason) { });

return initializedPromise.then(function () {
PDFViewerApplication.initialized = true;
if (self.isViewerEmbedded && !PDFJS.isExternalLinkTargetSet()) {
// Prevent external links from "replacing" the viewer,
// when it's embedded in e.g. an iframe or an object.
PDFJS.externalLinkTarget = PDFJS.LinkTarget.TOP;
}

self.initialized = true;
});
},

Expand Down

0 comments on commit 610df45

Please sign in to comment.