From 73d2133a7e1e7aa86cbd46deb1e27710a39128f7 Mon Sep 17 00:00:00 2001 From: Pdf Bot Date: Tue, 13 Oct 2015 23:21:05 +0100 Subject: [PATCH] PDF.js version 1.1.527 --- bower.json | 2 +- build/pdf.combined.js | 58 +++++++++++++++++++++++++++++++++---- build/pdf.js | 67 +++++++++++++++++++++++++++++++++++++++---- build/pdf.worker.js | 45 +++++++++++++++++++++++++++-- package.json | 2 +- 5 files changed, 158 insertions(+), 16 deletions(-) diff --git a/bower.json b/bower.json index 7bdebcf90..b787949bc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.1.523", + "version": "1.1.527", "main": [ "build/pdf.js", "build/pdf.worker.js" diff --git a/build/pdf.combined.js b/build/pdf.combined.js index 16b1e70c6..39b195191 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.1.523'; -PDFJS.build = 'd89fde0'; +PDFJS.version = '1.1.527'; +PDFJS.build = '2096a2a'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -340,6 +340,38 @@ function shadow(obj, prop, value) { } PDFJS.shadow = shadow; +var LinkTarget = PDFJS.LinkTarget = { + NONE: 0, // Default value. + SELF: 1, + BLANK: 2, + PARENT: 3, + TOP: 4, +}; +var LinkTargetStringMap = [ + '', + '_self', + '_blank', + '_parent', + '_top' +]; + +function isExternalLinkTargetSet() { + switch (PDFJS.externalLinkTarget) { + case LinkTarget.NONE: + return false; + case LinkTarget.SELF: + case LinkTarget.BLANK: + case LinkTarget.PARENT: + case LinkTarget.TOP: + return true; + } + warn('PDFJS.externalLinkTarget is invalid: ' + PDFJS.externalLinkTarget); + // Reset the external link target, to suppress further warnings. + PDFJS.externalLinkTarget = LinkTarget.NONE; + return false; +} +PDFJS.isExternalLinkTargetSet = isExternalLinkTargetSet; + var PasswordResponses = PDFJS.PasswordResponses = { NEED_PASSWORD: 1, INCORRECT_PASSWORD: 2 @@ -1747,14 +1779,27 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? 16777216 : PDFJS.maxCanvasPixels); /** - * Opens external links in a new window if enabled. The default behavior opens - * external links in the PDF.js window. + * (Deprecated) Opens external links in a new window if enabled. + * The default behavior opens external links in the PDF.js window. * @var {boolean} */ PDFJS.openExternalLinksInNewWindow = ( PDFJS.openExternalLinksInNewWindow === undefined ? false : PDFJS.openExternalLinksInNewWindow); +/** + * Specifies the |target| attribute for external links. + * The constants from PDFJS.LinkTarget should be used: + * - NONE [default] + * - SELF + * - BLANK + * - PARENT + * - TOP + * @var {number} + */ +PDFJS.externalLinkTarget = (PDFJS.externalLinkTarget === undefined ? + PDFJS.LinkTarget.NONE : PDFJS.externalLinkTarget); + /** * Determines if we can eval strings as JS. Primarily used to improve * performance for font rendering. @@ -6850,8 +6895,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() { var link = document.createElement('a'); link.href = link.title = item.url || ''; - if (item.url && PDFJS.openExternalLinksInNewWindow) { - link.target = '_blank'; + + if (item.url && isExternalLinkTargetSet()) { + link.target = LinkTargetStringMap[PDFJS.externalLinkTarget]; } container.appendChild(link); diff --git a/build/pdf.js b/build/pdf.js index 469d9aa0d..3bd3471c1 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.1.523'; -PDFJS.build = 'd89fde0'; +PDFJS.version = '1.1.527'; +PDFJS.build = '2096a2a'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -340,6 +340,47 @@ function shadow(obj, prop, value) { } PDFJS.shadow = shadow; +var LinkTarget = PDFJS.LinkTarget = { + NONE: 0, // Default value. + SELF: 1, + BLANK: 2, + PARENT: 3, + TOP: 4, +}; +var LinkTargetStringMap = [ + '', + '_self', + '_blank', + '_parent', + '_top' +]; + +function isExternalLinkTargetSet() { + if (PDFJS.openExternalLinksInNewWindow) { + warn('PDFJS.openExternalLinksInNewWindow is deprecated, ' + + 'use PDFJS.externalLinkTarget instead.'); + if (PDFJS.externalLinkTarget === LinkTarget.NONE) { + PDFJS.externalLinkTarget = LinkTarget.BLANK; + } + // Reset the deprecated parameter, to suppress further warnings. + PDFJS.openExternalLinksInNewWindow = false; + } + switch (PDFJS.externalLinkTarget) { + case LinkTarget.NONE: + return false; + case LinkTarget.SELF: + case LinkTarget.BLANK: + case LinkTarget.PARENT: + case LinkTarget.TOP: + return true; + } + warn('PDFJS.externalLinkTarget is invalid: ' + PDFJS.externalLinkTarget); + // Reset the external link target, to suppress further warnings. + PDFJS.externalLinkTarget = LinkTarget.NONE; + return false; +} +PDFJS.isExternalLinkTargetSet = isExternalLinkTargetSet; + var PasswordResponses = PDFJS.PasswordResponses = { NEED_PASSWORD: 1, INCORRECT_PASSWORD: 2 @@ -1747,14 +1788,27 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? 16777216 : PDFJS.maxCanvasPixels); /** - * Opens external links in a new window if enabled. The default behavior opens - * external links in the PDF.js window. + * (Deprecated) Opens external links in a new window if enabled. + * The default behavior opens external links in the PDF.js window. * @var {boolean} */ PDFJS.openExternalLinksInNewWindow = ( PDFJS.openExternalLinksInNewWindow === undefined ? false : PDFJS.openExternalLinksInNewWindow); +/** + * Specifies the |target| attribute for external links. + * The constants from PDFJS.LinkTarget should be used: + * - NONE [default] + * - SELF + * - BLANK + * - PARENT + * - TOP + * @var {number} + */ +PDFJS.externalLinkTarget = (PDFJS.externalLinkTarget === undefined ? + PDFJS.LinkTarget.NONE : PDFJS.externalLinkTarget); + /** * Determines if we can eval strings as JS. Primarily used to improve * performance for font rendering. @@ -6894,8 +6948,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() { var link = document.createElement('a'); link.href = link.title = item.url || ''; - if (item.url && PDFJS.openExternalLinksInNewWindow) { - link.target = '_blank'; + + if (item.url && isExternalLinkTargetSet()) { + link.target = LinkTargetStringMap[PDFJS.externalLinkTarget]; } container.appendChild(link); diff --git a/build/pdf.worker.js b/build/pdf.worker.js index 0197663fb..8c48ad457 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.1.523'; -PDFJS.build = 'd89fde0'; +PDFJS.version = '1.1.527'; +PDFJS.build = '2096a2a'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -340,6 +340,47 @@ function shadow(obj, prop, value) { } PDFJS.shadow = shadow; +var LinkTarget = PDFJS.LinkTarget = { + NONE: 0, // Default value. + SELF: 1, + BLANK: 2, + PARENT: 3, + TOP: 4, +}; +var LinkTargetStringMap = [ + '', + '_self', + '_blank', + '_parent', + '_top' +]; + +function isExternalLinkTargetSet() { + if (PDFJS.openExternalLinksInNewWindow) { + warn('PDFJS.openExternalLinksInNewWindow is deprecated, ' + + 'use PDFJS.externalLinkTarget instead.'); + if (PDFJS.externalLinkTarget === LinkTarget.NONE) { + PDFJS.externalLinkTarget = LinkTarget.BLANK; + } + // Reset the deprecated parameter, to suppress further warnings. + PDFJS.openExternalLinksInNewWindow = false; + } + switch (PDFJS.externalLinkTarget) { + case LinkTarget.NONE: + return false; + case LinkTarget.SELF: + case LinkTarget.BLANK: + case LinkTarget.PARENT: + case LinkTarget.TOP: + return true; + } + warn('PDFJS.externalLinkTarget is invalid: ' + PDFJS.externalLinkTarget); + // Reset the external link target, to suppress further warnings. + PDFJS.externalLinkTarget = LinkTarget.NONE; + return false; +} +PDFJS.isExternalLinkTargetSet = isExternalLinkTargetSet; + var PasswordResponses = PDFJS.PasswordResponses = { NEED_PASSWORD: 1, INCORRECT_PASSWORD: 2 diff --git a/package.json b/package.json index ca7ac4316..4c4d1e24b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.1.523", + "version": "1.1.527", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla",