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:
parent
ac3233bfa4
commit
4364b37e55
@ -14,7 +14,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*globals PDFJS, CustomStyle, mozL10n */
|
||||
/*globals PDFJS, CustomStyle, mozL10n, SimpleLinkService */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -171,7 +171,8 @@ DefaultAnnotationsLayerFactory.prototype = {
|
||||
createAnnotationsLayerBuilder: function (pageDiv, pdfPage) {
|
||||
return new AnnotationsLayerBuilder({
|
||||
pageDiv: pageDiv,
|
||||
pdfPage: pdfPage
|
||||
pdfPage: pdfPage,
|
||||
linkService: new SimpleLinkService(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user