Merge pull request #6063 from Snuffleupagus/pdfLinkService-optional-history
Tweak the PDFLinkService a bit
This commit is contained in:
commit
d3fa65e019
@ -65,12 +65,14 @@ var PDFLinkService = (function () {
|
||||
get page() {
|
||||
return this.pdfViewer.currentPageNumber;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
*/
|
||||
set page(value) {
|
||||
this.pdfViewer.currentPageNumber = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param dest - The PDF destination object.
|
||||
*/
|
||||
@ -89,12 +91,14 @@ var PDFLinkService = (function () {
|
||||
}
|
||||
self.pdfViewer.scrollPageIntoView(pageNumber, dest);
|
||||
|
||||
// Update the browsing history.
|
||||
self.pdfHistory.push({
|
||||
dest: dest,
|
||||
hash: destString,
|
||||
page: pageNumber
|
||||
});
|
||||
if (self.pdfHistory) {
|
||||
// Update the browsing history.
|
||||
self.pdfHistory.push({
|
||||
dest: dest,
|
||||
hash: destString,
|
||||
page: pageNumber
|
||||
});
|
||||
}
|
||||
} else {
|
||||
self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
|
||||
var pageNum = pageIndex + 1;
|
||||
@ -173,7 +177,9 @@ var PDFLinkService = (function () {
|
||||
var params = parseQueryString(hash);
|
||||
// borrowing syntax from "Parameters for Opening PDF Files"
|
||||
if ('nameddest' in params) {
|
||||
this.pdfHistory.updateNextHashParam(params.nameddest);
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.updateNextHashParam(params.nameddest);
|
||||
}
|
||||
this.navigateTo(params.nameddest);
|
||||
return;
|
||||
}
|
||||
@ -203,7 +209,7 @@ var PDFLinkService = (function () {
|
||||
zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null];
|
||||
} else if (zoomArg === 'FitR') {
|
||||
if (zoomArgs.length !== 5) {
|
||||
console.error('pdfViewSetHash: ' +
|
||||
console.error('PDFLinkService_setHash: ' +
|
||||
'Not enough parameters for \'FitR\'.');
|
||||
} else {
|
||||
dest = [null, { name: zoomArg },
|
||||
@ -211,7 +217,7 @@ var PDFLinkService = (function () {
|
||||
(zoomArgs[3] | 0), (zoomArgs[4] | 0)];
|
||||
}
|
||||
} else {
|
||||
console.error('pdfViewSetHash: \'' + zoomArg +
|
||||
console.error('PDFLinkService_setHash: \'' + zoomArg +
|
||||
'\' is not a valid zoom value.');
|
||||
}
|
||||
}
|
||||
@ -233,7 +239,9 @@ var PDFLinkService = (function () {
|
||||
} else if (/^\d+$/.test(hash)) { // page number
|
||||
this.page = hash;
|
||||
} else { // named destination
|
||||
this.pdfHistory.updateNextHashParam(unescape(hash));
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.updateNextHashParam(unescape(hash));
|
||||
}
|
||||
this.navigateTo(unescape(hash));
|
||||
}
|
||||
},
|
||||
@ -245,11 +253,15 @@ var PDFLinkService = (function () {
|
||||
// See PDF reference, table 8.45 - Named action
|
||||
switch (action) {
|
||||
case 'GoBack':
|
||||
this.pdfHistory.back();
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.back();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'GoForward':
|
||||
this.pdfHistory.forward();
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.forward();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'NextPage':
|
||||
|
Loading…
x
Reference in New Issue
Block a user