Log an error when the value passed to set currentPageNumber
is out of bounds (PR 7502 followup)
With PR 7502 we no longer dispatch an event when the `val` is out of bounds, so to better communicate why nothing happens this patch logs an error in that case (similar to the logging of errors when trying to set an invalid scale). The way that the default viewer is currently implemented, means that e.g. keyboard short-cuts could trigger the new error. Hence this patch also adds the necessary validation code, both to `app.js` and `pdf_link_service.js` to prevent unnecessary errors.
This commit is contained in:
parent
ac7b675603
commit
7706cfa9fe
3 changed files with 46 additions and 37 deletions
|
@ -181,7 +181,7 @@ var PDFViewer = (function pdfViewer() {
|
|||
* @private
|
||||
*/
|
||||
_setCurrentPageNumber:
|
||||
function pdfViewer_setCurrentPageNumber(val, resetCurrentPageView) {
|
||||
function PDFViewer_setCurrentPageNumber(val, resetCurrentPageView) {
|
||||
if (this._currentPageNumber === val) {
|
||||
if (resetCurrentPageView) {
|
||||
this._resetCurrentPageView();
|
||||
|
@ -190,6 +190,8 @@ var PDFViewer = (function pdfViewer() {
|
|||
}
|
||||
|
||||
if (!(0 < val && val <= this.pagesCount)) {
|
||||
console.error('PDFViewer_setCurrentPageNumber: "' + val +
|
||||
'" is out of bounds.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -467,7 +469,7 @@ var PDFViewer = (function pdfViewer() {
|
|||
}
|
||||
},
|
||||
|
||||
_setScale: function pdfViewer_setScale(value, noScroll) {
|
||||
_setScale: function PDFViewer_setScale(value, noScroll) {
|
||||
var scale = parseFloat(value);
|
||||
|
||||
if (scale > 0) {
|
||||
|
@ -507,8 +509,8 @@ var PDFViewer = (function pdfViewer() {
|
|||
scale = Math.min(MAX_AUTO_SCALE, horizontalScale);
|
||||
break;
|
||||
default:
|
||||
console.error('pdfViewSetScale: \'' + value +
|
||||
'\' is an unknown zoom value.');
|
||||
console.error('PDFViewer_setScale: "' + value +
|
||||
'" is an unknown zoom value.');
|
||||
return;
|
||||
}
|
||||
this._setScaleUpdatePages(scale, value, noScroll, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue