1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Wraps mozL10n to async calls; splits firefox and generic l10n libs.

This commit is contained in:
Yury Delendik 2017-05-03 20:05:53 -05:00
parent 09d46e94c6
commit 5438ce9b98
28 changed files with 463 additions and 260 deletions

View file

@ -14,7 +14,7 @@
*/
import { AnnotationLayer } from 'pdfjs-lib';
import { mozL10n } from './ui_utils';
import { NullL10n } from './ui_utils';
import { SimpleLinkService } from './pdf_link_service';
/**
@ -24,6 +24,7 @@ import { SimpleLinkService } from './pdf_link_service';
* @property {boolean} renderInteractiveForms
* @property {IPDFLinkService} linkService
* @property {DownloadManager} downloadManager
* @property {IL10n} l10n - Localization service.
*/
class AnnotationLayerBuilder {
@ -36,6 +37,7 @@ class AnnotationLayerBuilder {
this.renderInteractiveForms = options.renderInteractiveForms;
this.linkService = options.linkService;
this.downloadManager = options.downloadManager;
this.l10n = options.l10n || NullL10n;
this.div = null;
}
@ -73,9 +75,7 @@ class AnnotationLayerBuilder {
parameters.div = this.div;
AnnotationLayer.render(parameters);
if (typeof mozL10n !== 'undefined') {
mozL10n.translate(this.div);
}
this.l10n.translate(this.div);
}
});
}
@ -96,15 +96,18 @@ class DefaultAnnotationLayerFactory {
* @param {HTMLDivElement} pageDiv
* @param {PDFPage} pdfPage
* @param {boolean} renderInteractiveForms
* @param {IL10n} l10n
* @returns {AnnotationLayerBuilder}
*/
createAnnotationLayerBuilder(pageDiv, pdfPage,
renderInteractiveForms = false) {
renderInteractiveForms = false,
l10n = NullL10n) {
return new AnnotationLayerBuilder({
pageDiv,
pdfPage,
renderInteractiveForms,
linkService: new SimpleLinkService(),
l10n,
});
}
}