|
@@ -720,47 +720,54 @@ exports.SimpleLinkService = exports.PDFLinkService = undefined;
|
|
|
|
|
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
|
|
|
|
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
+
|
|
|
var _dom_events = __w_pdfjs_require__(2);
|
|
|
|
|
|
var _ui_utils = __w_pdfjs_require__(1);
|
|
|
|
|
|
-var PDFLinkService = function PDFLinkServiceClosure() {
|
|
|
- function PDFLinkService(options) {
|
|
|
- options = options || {};
|
|
|
- this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
|
|
|
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
+
|
|
|
+var PDFLinkService = function () {
|
|
|
+ function PDFLinkService() {
|
|
|
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
|
+ eventBus = _ref.eventBus;
|
|
|
+
|
|
|
+ _classCallCheck(this, PDFLinkService);
|
|
|
+
|
|
|
+ this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
|
|
|
this.baseUrl = null;
|
|
|
this.pdfDocument = null;
|
|
|
this.pdfViewer = null;
|
|
|
this.pdfHistory = null;
|
|
|
this._pagesRefCache = null;
|
|
|
}
|
|
|
- PDFLinkService.prototype = {
|
|
|
- setDocument: function PDFLinkService_setDocument(pdfDocument, baseUrl) {
|
|
|
+
|
|
|
+ _createClass(PDFLinkService, [{
|
|
|
+ key: 'setDocument',
|
|
|
+ value: function setDocument(pdfDocument, baseUrl) {
|
|
|
this.baseUrl = baseUrl;
|
|
|
this.pdfDocument = pdfDocument;
|
|
|
this._pagesRefCache = Object.create(null);
|
|
|
- },
|
|
|
- setViewer: function PDFLinkService_setViewer(pdfViewer) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'setViewer',
|
|
|
+ value: function setViewer(pdfViewer) {
|
|
|
this.pdfViewer = pdfViewer;
|
|
|
- },
|
|
|
- setHistory: function PDFLinkService_setHistory(pdfHistory) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'setHistory',
|
|
|
+ value: function setHistory(pdfHistory) {
|
|
|
this.pdfHistory = pdfHistory;
|
|
|
- },
|
|
|
- get pagesCount() {
|
|
|
- return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
|
|
- },
|
|
|
- get page() {
|
|
|
- return this.pdfViewer.currentPageNumber;
|
|
|
- },
|
|
|
- set page(value) {
|
|
|
- this.pdfViewer.currentPageNumber = value;
|
|
|
- },
|
|
|
- navigateTo: function navigateTo(dest) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'navigateTo',
|
|
|
+ value: function navigateTo(dest) {
|
|
|
var _this = this;
|
|
|
|
|
|
- var goToDestination = function goToDestination(_ref) {
|
|
|
- var namedDest = _ref.namedDest,
|
|
|
- explicitDest = _ref.explicitDest;
|
|
|
+ var goToDestination = function goToDestination(_ref2) {
|
|
|
+ var namedDest = _ref2.namedDest,
|
|
|
+ explicitDest = _ref2.explicitDest;
|
|
|
|
|
|
var destRef = explicitDest[0],
|
|
|
pageNumber = void 0;
|
|
@@ -821,8 +828,10 @@ var PDFLinkService = function PDFLinkServiceClosure() {
|
|
|
}
|
|
|
goToDestination(data);
|
|
|
});
|
|
|
- },
|
|
|
- getDestinationHash: function getDestinationHash(dest) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'getDestinationHash',
|
|
|
+ value: function getDestinationHash(dest) {
|
|
|
if (typeof dest === 'string') {
|
|
|
return this.getAnchorUrl('#' + escape(dest));
|
|
|
}
|
|
@@ -831,13 +840,17 @@ var PDFLinkService = function PDFLinkServiceClosure() {
|
|
|
return this.getAnchorUrl('#' + escape(str));
|
|
|
}
|
|
|
return this.getAnchorUrl('');
|
|
|
- },
|
|
|
-
|
|
|
- getAnchorUrl: function PDFLinkService_getAnchorUrl(anchor) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'getAnchorUrl',
|
|
|
+ value: function getAnchorUrl(anchor) {
|
|
|
return (this.baseUrl || '') + anchor;
|
|
|
- },
|
|
|
- setHash: function PDFLinkService_setHash(hash) {
|
|
|
- var pageNumber, dest;
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'setHash',
|
|
|
+ value: function setHash(hash) {
|
|
|
+ var pageNumber = void 0,
|
|
|
+ dest = void 0;
|
|
|
if (hash.indexOf('=') >= 0) {
|
|
|
var params = (0, _ui_utils.parseQueryString)(hash);
|
|
|
if ('search' in params) {
|
|
@@ -870,12 +883,12 @@ var PDFLinkService = function PDFLinkServiceClosure() {
|
|
|
dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
|
|
|
} else if (zoomArg === 'FitR') {
|
|
|
if (zoomArgs.length !== 5) {
|
|
|
- console.error('PDFLinkService_setHash: ' + 'Not enough parameters for \'FitR\'.');
|
|
|
+ console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
|
|
|
} else {
|
|
|
dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
|
|
|
}
|
|
|
} else {
|
|
|
- console.error('PDFLinkService_setHash: \'' + zoomArg + '\' is not a valid zoom value.');
|
|
|
+ console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -896,7 +909,7 @@ var PDFLinkService = function PDFLinkServiceClosure() {
|
|
|
}
|
|
|
} else {
|
|
|
if (/^\d+$/.test(hash) && hash <= this.pagesCount) {
|
|
|
- console.warn('PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + 'please use the "#page=' + hash + '" form instead.');
|
|
|
+ console.warn('PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + ('please use the "#page=' + hash + '" form instead.'));
|
|
|
this.page = hash | 0;
|
|
|
}
|
|
|
dest = unescape(hash);
|
|
@@ -913,10 +926,12 @@ var PDFLinkService = function PDFLinkServiceClosure() {
|
|
|
this.navigateTo(dest);
|
|
|
return;
|
|
|
}
|
|
|
- console.error('PDFLinkService_setHash: \'' + unescape(hash) + '\' is not a valid destination.');
|
|
|
+ console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
|
|
|
}
|
|
|
- },
|
|
|
- executeNamedAction: function PDFLinkService_executeNamedAction(action) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'executeNamedAction',
|
|
|
+ value: function executeNamedAction(action) {
|
|
|
switch (action) {
|
|
|
case 'GoBack':
|
|
|
if (this.pdfHistory) {
|
|
@@ -951,101 +966,148 @@ var PDFLinkService = function PDFLinkServiceClosure() {
|
|
|
source: this,
|
|
|
action: action
|
|
|
});
|
|
|
- },
|
|
|
- onFileAttachmentAnnotation: function onFileAttachmentAnnotation() {
|
|
|
- var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'onFileAttachmentAnnotation',
|
|
|
+ value: function onFileAttachmentAnnotation(_ref3) {
|
|
|
+ var id = _ref3.id,
|
|
|
+ filename = _ref3.filename,
|
|
|
+ content = _ref3.content;
|
|
|
|
|
|
this.eventBus.dispatch('fileattachmentannotation', {
|
|
|
source: this,
|
|
|
- id: params.id,
|
|
|
- filename: params.filename,
|
|
|
- content: params.content
|
|
|
+ id: id,
|
|
|
+ filename: filename,
|
|
|
+ content: content
|
|
|
});
|
|
|
- },
|
|
|
-
|
|
|
- cachePageRef: function PDFLinkService_cachePageRef(pageNum, pageRef) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'cachePageRef',
|
|
|
+ value: function cachePageRef(pageNum, pageRef) {
|
|
|
var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
|
|
|
this._pagesRefCache[refStr] = pageNum;
|
|
|
- },
|
|
|
- _cachedPageNumber: function PDFLinkService_cachedPageNumber(pageRef) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: '_cachedPageNumber',
|
|
|
+ value: function _cachedPageNumber(pageRef) {
|
|
|
var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
|
|
|
return this._pagesRefCache && this._pagesRefCache[refStr] || null;
|
|
|
}
|
|
|
- };
|
|
|
- function isValidExplicitDestination(dest) {
|
|
|
- if (!(dest instanceof Array)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- var destLength = dest.length,
|
|
|
- allowNull = true;
|
|
|
- if (destLength < 2) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- var page = dest[0];
|
|
|
- if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && typeof page.num === 'number' && (page.num | 0) === page.num && typeof page.gen === 'number' && (page.gen | 0) === page.gen) && !(typeof page === 'number' && (page | 0) === page && page >= 0)) {
|
|
|
- return false;
|
|
|
+ }, {
|
|
|
+ key: 'pagesCount',
|
|
|
+ get: function get() {
|
|
|
+ return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
|
|
}
|
|
|
- var zoom = dest[1];
|
|
|
- if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
|
|
|
- return false;
|
|
|
+ }, {
|
|
|
+ key: 'page',
|
|
|
+ get: function get() {
|
|
|
+ return this.pdfViewer.currentPageNumber;
|
|
|
+ },
|
|
|
+ set: function set(value) {
|
|
|
+ this.pdfViewer.currentPageNumber = value;
|
|
|
}
|
|
|
- switch (zoom.name) {
|
|
|
- case 'XYZ':
|
|
|
- if (destLength !== 5) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 'Fit':
|
|
|
- case 'FitB':
|
|
|
- return destLength === 2;
|
|
|
- case 'FitH':
|
|
|
- case 'FitBH':
|
|
|
- case 'FitV':
|
|
|
- case 'FitBV':
|
|
|
- if (destLength !== 3) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 'FitR':
|
|
|
- if (destLength !== 6) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- allowNull = false;
|
|
|
- break;
|
|
|
- default:
|
|
|
+ }]);
|
|
|
+
|
|
|
+ return PDFLinkService;
|
|
|
+}();
|
|
|
+
|
|
|
+function isValidExplicitDestination(dest) {
|
|
|
+ if (!(dest instanceof Array)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var destLength = dest.length,
|
|
|
+ allowNull = true;
|
|
|
+ if (destLength < 2) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var page = dest[0];
|
|
|
+ if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && typeof page.num === 'number' && (page.num | 0) === page.num && typeof page.gen === 'number' && (page.gen | 0) === page.gen) && !(typeof page === 'number' && (page | 0) === page && page >= 0)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var zoom = dest[1];
|
|
|
+ if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ switch (zoom.name) {
|
|
|
+ case 'XYZ':
|
|
|
+ if (destLength !== 5) {
|
|
|
return false;
|
|
|
- }
|
|
|
- for (var i = 2; i < destLength; i++) {
|
|
|
- var param = dest[i];
|
|
|
- if (!(typeof param === 'number' || allowNull && param === null)) {
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'Fit':
|
|
|
+ case 'FitB':
|
|
|
+ return destLength === 2;
|
|
|
+ case 'FitH':
|
|
|
+ case 'FitBH':
|
|
|
+ case 'FitV':
|
|
|
+ case 'FitBV':
|
|
|
+ if (destLength !== 3) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'FitR':
|
|
|
+ if (destLength !== 6) {
|
|
|
return false;
|
|
|
}
|
|
|
+ allowNull = false;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (var i = 2; i < destLength; i++) {
|
|
|
+ var param = dest[i];
|
|
|
+ if (!(typeof param === 'number' || allowNull && param === null)) {
|
|
|
+ return false;
|
|
|
}
|
|
|
- return true;
|
|
|
}
|
|
|
- return PDFLinkService;
|
|
|
-}();
|
|
|
-var SimpleLinkService = function SimpleLinkServiceClosure() {
|
|
|
- function SimpleLinkService() {}
|
|
|
- SimpleLinkService.prototype = {
|
|
|
- get page() {
|
|
|
- return 0;
|
|
|
- },
|
|
|
- set page(value) {},
|
|
|
- navigateTo: function navigateTo(dest) {},
|
|
|
- getDestinationHash: function getDestinationHash(dest) {
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+var SimpleLinkService = function () {
|
|
|
+ function SimpleLinkService() {
|
|
|
+ _classCallCheck(this, SimpleLinkService);
|
|
|
+ }
|
|
|
+
|
|
|
+ _createClass(SimpleLinkService, [{
|
|
|
+ key: 'navigateTo',
|
|
|
+ value: function navigateTo(dest) {}
|
|
|
+ }, {
|
|
|
+ key: 'getDestinationHash',
|
|
|
+ value: function getDestinationHash(dest) {
|
|
|
return '#';
|
|
|
- },
|
|
|
- getAnchorUrl: function getAnchorUrl(hash) {
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'getAnchorUrl',
|
|
|
+ value: function getAnchorUrl(hash) {
|
|
|
return '#';
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'setHash',
|
|
|
+ value: function setHash(hash) {}
|
|
|
+ }, {
|
|
|
+ key: 'executeNamedAction',
|
|
|
+ value: function executeNamedAction(action) {}
|
|
|
+ }, {
|
|
|
+ key: 'onFileAttachmentAnnotation',
|
|
|
+ value: function onFileAttachmentAnnotation(_ref4) {
|
|
|
+ var id = _ref4.id,
|
|
|
+ filename = _ref4.filename,
|
|
|
+ content = _ref4.content;
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ key: 'cachePageRef',
|
|
|
+ value: function cachePageRef(pageNum, pageRef) {}
|
|
|
+ }, {
|
|
|
+ key: 'page',
|
|
|
+ get: function get() {
|
|
|
+ return 0;
|
|
|
},
|
|
|
- setHash: function setHash(hash) {},
|
|
|
- executeNamedAction: function executeNamedAction(action) {},
|
|
|
- onFileAttachmentAnnotation: function onFileAttachmentAnnotation(params) {},
|
|
|
- cachePageRef: function cachePageRef(pageNum, pageRef) {}
|
|
|
- };
|
|
|
+ set: function set(value) {}
|
|
|
+ }]);
|
|
|
+
|
|
|
return SimpleLinkService;
|
|
|
}();
|
|
|
+
|
|
|
exports.PDFLinkService = PDFLinkService;
|
|
|
exports.SimpleLinkService = SimpleLinkService;
|
|
|
|