Simplify the SimpleLinkService and use it to pass in a linkService instance in DefaultAnnotationsLayerFactory

Considering that most methods of `SimpleLinkService` are complete stubs, or practically "useless" considering what they return, we can actually simplify it even more.

*Note:* This depends on the previous patch, that did a small amount of refactoring of `PDFViewer_scrollPageIntoView`, since `PDFViewer.linkService.page` is no longer accessed.

----------

Currently the `pageviewer` components example doesn't work correctly (an error is printed in the console), since no `linkService` is present when the `AnnotationsLayerBuilder` is created.

*Note:* Given that this uses the `SimpleLinkService`, clicking on e.g. internal links won't actually do anything. However, given that internal links (and similar features) are pretty much useless when only *one* page is loaded the `pageviewer` example, I don't think that really matters.
Also, using the complete `PDFLinkService` would require a `PDFViewer` instance. That would significantly complicate the example, thus making it both less clear and less self contained.
This commit is contained in:
Jonas Jenwald 2015-06-11 22:20:04 +02:00
parent ac3233bfa4
commit 4364b37e55
2 changed files with 8 additions and 10 deletions

View file

@ -81,7 +81,7 @@ var PDFViewer = (function pdfViewer() {
function PDFViewer(options) {
this.container = options.container;
this.viewer = options.viewer || options.container.firstElementChild;
this.linkService = options.linkService || new SimpleLinkService(this);
this.linkService = options.linkService || new SimpleLinkService();
this.removePageBorders = options.removePageBorders || false;
this.defaultRenderingQueue = !options.renderingQueue;
@ -744,22 +744,19 @@ var PDFViewer = (function pdfViewer() {
})();
var SimpleLinkService = (function SimpleLinkServiceClosure() {
function SimpleLinkService(pdfViewer) {
this.pdfViewer = pdfViewer;
}
function SimpleLinkService() {}
SimpleLinkService.prototype = {
/**
* @returns {number}
*/
get page() {
return this.pdfViewer.currentPageNumber;
return 0;
},
/**
* @param {number} value
*/
set page(value) {
this.pdfViewer.currentPageNumber = value;
},
set page(value) {},
/**
* @param dest - The PDF destination object.
*/