From 27c8e1e22fc930b8424bafdaa744a6f283c516f3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 23 Nov 2015 12:57:53 +0100 Subject: [PATCH] Improve the comment and deprecation warning for `PDFJS.openExternalLinksInNewWindow` This patch: - Updates the JSDoc comment in `api.js`, to more clearly point out that `PDFJS.openExternalLinksInNewWindow` is deprecated, and explains what to use instead. - Changes the `warn`, in `isExternalLinkTargetSet()`, to use the new `deprecated` function instead. Also updates the message with more detailed information about what to use instead. - Changes the pre-processor tag to ensure the deprecation warning is seen in all build types where it could possibly matter (in case people are using `PDFJS.openExternalLinksInNewWindow` in e.g. custom-built extensions). These changes were prompted by seeing http://stackoverflow.com/questions/33813373/pdf-js-how-to-open-hyperlinks-in-a-new-tab-window, since it seems to me that the current comments/warnings might not be worded well enough. --- src/display/api.js | 3 +++ src/shared/util.js | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index 450483e58..a4a4713fd 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -173,6 +173,9 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? /** * (Deprecated) Opens external links in a new window if enabled. * The default behavior opens external links in the PDF.js window. + * + * NOTE: This property has been deprecated, please use + * `PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK` instead. * @var {boolean} */ PDFJS.openExternalLinksInNewWindow = ( diff --git a/src/shared/util.js b/src/shared/util.js index 6845a5fd4..9f5c071b0 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -360,10 +360,10 @@ var LinkTargetStringMap = [ ]; function isExternalLinkTargetSet() { -//#if GENERIC +//#if !MOZCENTRAL if (PDFJS.openExternalLinksInNewWindow) { - warn('PDFJS.openExternalLinksInNewWindow is deprecated, ' + - 'use PDFJS.externalLinkTarget instead.'); + deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.'); if (PDFJS.externalLinkTarget === LinkTarget.NONE) { PDFJS.externalLinkTarget = LinkTarget.BLANK; }