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.
This commit is contained in:
Jonas Jenwald 2015-11-23 12:57:53 +01:00
parent aa75c4fe4e
commit 27c8e1e22f
2 changed files with 6 additions and 3 deletions

View File

@ -173,6 +173,9 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
/** /**
* (Deprecated) Opens external links in a new window if enabled. * (Deprecated) Opens external links in a new window if enabled.
* The default behavior opens external links in the PDF.js window. * 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} * @var {boolean}
*/ */
PDFJS.openExternalLinksInNewWindow = ( PDFJS.openExternalLinksInNewWindow = (

View File

@ -360,10 +360,10 @@ var LinkTargetStringMap = [
]; ];
function isExternalLinkTargetSet() { function isExternalLinkTargetSet() {
//#if GENERIC //#if !MOZCENTRAL
if (PDFJS.openExternalLinksInNewWindow) { if (PDFJS.openExternalLinksInNewWindow) {
warn('PDFJS.openExternalLinksInNewWindow is deprecated, ' + deprecated('PDFJS.openExternalLinksInNewWindow, please use ' +
'use PDFJS.externalLinkTarget instead.'); '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
if (PDFJS.externalLinkTarget === LinkTarget.NONE) { if (PDFJS.externalLinkTarget === LinkTarget.NONE) {
PDFJS.externalLinkTarget = LinkTarget.BLANK; PDFJS.externalLinkTarget = LinkTarget.BLANK;
} }