Browse Source

PDF.js version 1.8.406 - See mozilla/pdf.js@45933545f15056b13eec0f2babfe0cdbf4b6385f

master v1.8.406
pdfjsbot 8 years ago
parent
commit
c9a004b903
  1. 2
      bower.json
  2. 12
      build/pdf.combined.js
  3. 2
      build/pdf.combined.js.map
  4. 12
      build/pdf.js
  5. 2
      build/pdf.js.map
  6. 4
      build/pdf.min.js
  7. 4
      build/pdf.worker.js
  8. 2
      build/pdf.worker.js.map
  9. 4
      lib/display/api.js
  10. 4
      lib/display/global.js
  11. 4
      lib/pdf.js
  12. 4
      lib/pdf.worker.js
  13. 9
      lib/web/annotation_layer_builder.js
  14. 104
      lib/web/app.js
  15. 5
      lib/web/chromecom.js
  16. 34
      lib/web/firefoxcom.js
  17. 7
      lib/web/genericcom.js
  18. 68
      lib/web/genericl10n.js
  19. 20
      lib/web/interfaces.js
  20. 13
      lib/web/password_prompt.js
  21. 35
      lib/web/pdf_document_properties.js
  22. 15
      lib/web/pdf_find_bar.js
  23. 3
      lib/web/pdf_page_view.js
  24. 17
      lib/web/pdf_print_service.js
  25. 53
      lib/web/pdf_sidebar.js
  26. 53
      lib/web/pdf_thumbnail_view.js
  27. 4
      lib/web/pdf_thumbnail_viewer.js
  28. 3
      lib/web/pdf_viewer.component.js
  29. 8
      lib/web/pdf_viewer.js
  30. 35
      lib/web/toolbar.js
  31. 35
      lib/web/ui_utils.js
  32. 2
      package.json
  33. 866
      web/pdf_viewer.js
  34. 2
      web/pdf_viewer.js.map

2
bower.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "1.8.404",
"version": "1.8.406",
"main": [
"build/pdf.js",
"build/pdf.worker.js"

12
build/pdf.combined.js

@ -12809,8 +12809,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -12809,8 +12809,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.8.404';
exports.build = build = 'bd288df9';
exports.version = version = '1.8.406';
exports.build = build = '45933545';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;
@ -28147,8 +28147,8 @@ if (!_util.globalScope.PDFJS) { @@ -28147,8 +28147,8 @@ if (!_util.globalScope.PDFJS) {
}
var PDFJS = _util.globalScope.PDFJS;
{
PDFJS.version = '1.8.404';
PDFJS.build = 'bd288df9';
PDFJS.version = '1.8.406';
PDFJS.build = '45933545';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
@ -46762,8 +46762,8 @@ exports.TilingPattern = TilingPattern; @@ -46762,8 +46762,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.404';
var pdfjsBuild = 'bd288df9';
var pdfjsVersion = '1.8.406';
var pdfjsBuild = '45933545';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
var pdfjsDisplayAPI = __w_pdfjs_require__(10);

2
build/pdf.combined.js.map

File diff suppressed because one or more lines are too long

12
build/pdf.js

@ -3538,8 +3538,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -3538,8 +3538,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.8.404';
exports.build = build = 'bd288df9';
exports.version = version = '1.8.406';
exports.build = build = '45933545';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;
@ -5512,8 +5512,8 @@ if (!_util.globalScope.PDFJS) { @@ -5512,8 +5512,8 @@ if (!_util.globalScope.PDFJS) {
}
var PDFJS = _util.globalScope.PDFJS;
{
PDFJS.version = '1.8.404';
PDFJS.build = 'bd288df9';
PDFJS.version = '1.8.406';
PDFJS.build = '45933545';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
@ -11052,8 +11052,8 @@ exports.TilingPattern = TilingPattern; @@ -11052,8 +11052,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.404';
var pdfjsBuild = 'bd288df9';
var pdfjsVersion = '1.8.406';
var pdfjsBuild = '45933545';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
var pdfjsDisplayAPI = __w_pdfjs_require__(3);

2
build/pdf.js.map

File diff suppressed because one or more lines are too long

4
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

4
build/pdf.worker.js vendored

@ -40061,8 +40061,8 @@ exports.Type1Parser = Type1Parser; @@ -40061,8 +40061,8 @@ exports.Type1Parser = Type1Parser;
"use strict";
var pdfjsVersion = '1.8.404';
var pdfjsBuild = 'bd288df9';
var pdfjsVersion = '1.8.406';
var pdfjsBuild = '45933545';
var pdfjsCoreWorker = __w_pdfjs_require__(8);
{
__w_pdfjs_require__(19);

2
build/pdf.worker.js.map vendored

File diff suppressed because one or more lines are too long

4
lib/display/api.js

@ -1418,8 +1418,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -1418,8 +1418,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.8.404';
exports.build = build = 'bd288df9';
exports.version = version = '1.8.406';
exports.build = build = '45933545';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;

4
lib/display/global.js

@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) { @@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
}
var PDFJS = _util.globalScope.PDFJS;
{
PDFJS.version = '1.8.404';
PDFJS.build = 'bd288df9';
PDFJS.version = '1.8.406';
PDFJS.build = '45933545';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {

4
lib/pdf.js

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.8.404';
var pdfjsBuild = 'bd288df9';
var pdfjsVersion = '1.8.406';
var pdfjsBuild = '45933545';
var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js');

4
lib/pdf.worker.js vendored

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.8.404';
var pdfjsBuild = 'bd288df9';
var pdfjsVersion = '1.8.406';
var pdfjsBuild = '45933545';
var pdfjsCoreWorker = require('./core/worker.js');
{
require('./core/network.js');

9
lib/web/annotation_layer_builder.js

@ -38,6 +38,7 @@ var AnnotationLayerBuilder = function () { @@ -38,6 +38,7 @@ var AnnotationLayerBuilder = function () {
this.renderInteractiveForms = options.renderInteractiveForms;
this.linkService = options.linkService;
this.downloadManager = options.downloadManager;
this.l10n = options.l10n || _ui_utils.NullL10n;
this.div = null;
}
@ -69,9 +70,7 @@ var AnnotationLayerBuilder = function () { @@ -69,9 +70,7 @@ var AnnotationLayerBuilder = function () {
_this.pageDiv.appendChild(_this.div);
parameters.div = _this.div;
_pdf.AnnotationLayer.render(parameters);
if (typeof _ui_utils.mozL10n !== 'undefined') {
_ui_utils.mozL10n.translate(_this.div);
}
_this.l10n.translate(_this.div);
}
});
}
@ -97,12 +96,14 @@ var DefaultAnnotationLayerFactory = function () { @@ -97,12 +96,14 @@ var DefaultAnnotationLayerFactory = function () {
key: 'createAnnotationLayerBuilder',
value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
return new AnnotationLayerBuilder({
pageDiv: pageDiv,
pdfPage: pdfPage,
renderInteractiveForms: renderInteractiveForms,
linkService: new _pdf_link_service.SimpleLinkService()
linkService: new _pdf_link_service.SimpleLinkService(),
l10n: l10n
});
}
}]);

104
lib/web/app.js

@ -116,6 +116,7 @@ var PDFViewerApplication = { @@ -116,6 +116,7 @@ var PDFViewerApplication = {
toolbar: null,
secondaryToolbar: null,
eventBus: null,
l10n: null,
pageRotation: 0,
isInitialViewSet: false,
viewerPrefs: {
@ -140,11 +141,14 @@ var PDFViewerApplication = { @@ -140,11 +141,14 @@ var PDFViewerApplication = {
configure(_pdf.PDFJS);
this.appConfig = appConfig;
return this._readPreferences().then(function () {
return _this._initializeL10n();
}).then(function () {
return _this._initializeViewerComponents();
}).then(function () {
_this.bindEvents();
_this.bindWindowEvents();
_ui_utils.localized.then(function () {
var appContainer = appConfig.appContainer || document.documentElement;
_this.l10n.translate(appContainer).then(function () {
_this.eventBus.dispatch('localized');
});
if (_this.isViewerEmbedded && !_pdf.PDFJS.isExternalLinkTargetSet()) {
@ -208,6 +212,19 @@ var PDFViewerApplication = { @@ -208,6 +212,19 @@ var PDFViewerApplication = {
viewerPrefs['enablePrintAutoRotate'] = value;
})]).catch(function (reason) {});
},
_initializeL10n: function _initializeL10n() {
if (this.viewerPrefs['pdfBugEnabled']) {
var hash = document.location.hash.substring(1);
var hashParams = (0, _ui_utils.parseQueryString)(hash);
if ('locale' in hashParams) {
_pdf.PDFJS.locale = hashParams['locale'];
}
}
this.l10n = this.externalServices.createL10n();
return this.l10n.getDirection().then(function (dir) {
document.getElementsByTagName('html')[0].dir = dir;
});
},
_initializeViewerComponents: function _initializeViewerComponents() {
var _this2 = this;
@ -233,6 +250,7 @@ var PDFViewerApplication = { @@ -233,6 +250,7 @@ var PDFViewerApplication = {
linkService: pdfLinkService,
downloadManager: downloadManager,
renderer: _this2.viewerPrefs['renderer'],
l10n: _this2.l10n,
enhanceTextSelection: _this2.viewerPrefs['enhanceTextSelection'],
renderInteractiveForms: _this2.viewerPrefs['renderInteractiveForms'],
enablePrintAutoRotate: _this2.viewerPrefs['enablePrintAutoRotate']
@ -243,7 +261,8 @@ var PDFViewerApplication = { @@ -243,7 +261,8 @@ var PDFViewerApplication = {
_this2.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
container: thumbnailContainer,
renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService
linkService: pdfLinkService,
l10n: _this2.l10n
});
pdfRenderingQueue.setThumbnailViewer(_this2.pdfThumbnailViewer);
_this2.pdfHistory = new _pdf_history.PDFHistory({
@ -272,14 +291,14 @@ var PDFViewerApplication = { @@ -272,14 +291,14 @@ var PDFViewerApplication = {
var findBarConfig = Object.create(appConfig.findBar);
findBarConfig.findController = _this2.findController;
findBarConfig.eventBus = eventBus;
_this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig);
_this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this2.overlayManager);
_this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, _this2.l10n);
_this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this2.overlayManager, _this2.l10n);
_this2.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
container: container,
eventBus: eventBus,
preferences: _this2.preferences
});
_this2.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus);
_this2.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus, _this2.l10n);
_this2.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
if (_this2.supportsFullscreen) {
_this2.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
@ -290,7 +309,7 @@ var PDFViewerApplication = { @@ -290,7 +309,7 @@ var PDFViewerApplication = {
contextMenuItems: appConfig.fullscreen
});
}
_this2.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this2.overlayManager);
_this2.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this2.overlayManager, _this2.l10n);
_this2.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
container: appConfig.sidebar.outlineView,
eventBus: eventBus,
@ -306,7 +325,7 @@ var PDFViewerApplication = { @@ -306,7 +325,7 @@ var PDFViewerApplication = {
sidebarConfig.pdfThumbnailViewer = _this2.pdfThumbnailViewer;
sidebarConfig.pdfOutlineViewer = _this2.pdfOutlineViewer;
sidebarConfig.eventBus = eventBus;
_this2.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig);
_this2.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, _this2.l10n);
_this2.pdfSidebar.onToggled = _this2.forceRendering.bind(_this2);
resolve(undefined);
});
@ -479,16 +498,20 @@ var PDFViewerApplication = { @@ -479,16 +498,20 @@ var PDFViewerApplication = {
_this3.load(pdfDocument, scale);
}, function (exception) {
var message = exception && exception.message;
var loadingErrorMessage = _ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
var loadingErrorMessage = void 0;
if (exception instanceof _pdf.InvalidPDFException) {
loadingErrorMessage = _ui_utils.mozL10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
loadingErrorMessage = _this3.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
} else if (exception instanceof _pdf.MissingPDFException) {
loadingErrorMessage = _ui_utils.mozL10n.get('missing_file_error', null, 'Missing PDF file.');
loadingErrorMessage = _this3.l10n.get('missing_file_error', null, 'Missing PDF file.');
} else if (exception instanceof _pdf.UnexpectedResponseException) {
loadingErrorMessage = _ui_utils.mozL10n.get('unexpected_response_error', null, 'Unexpected server response.');
loadingErrorMessage = _this3.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
} else {
loadingErrorMessage = _this3.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
}
_this3.error(loadingErrorMessage, { message: message });
throw new Error(loadingErrorMessage);
return loadingErrorMessage.then(function (msg) {
_this3.error(msg, { message: message });
throw new Error(msg);
});
});
},
@ -517,20 +540,20 @@ var PDFViewerApplication = { @@ -517,20 +540,20 @@ var PDFViewerApplication = {
},
fallback: function pdfViewFallback(featureId) {},
error: function pdfViewError(message, moreInfo) {
var moreInfoText = _ui_utils.mozL10n.get('error_version_info', {
var moreInfoText = [this.l10n.get('error_version_info', {
version: _pdf.version || '?',
build: _pdf.build || '?'
}, 'PDF.js v{{version}} (build: {{build}})') + '\n';
}, 'PDF.js v{{version}} (build: {{build}})')];
if (moreInfo) {
moreInfoText += _ui_utils.mozL10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}');
moreInfoText.push(this.l10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}'));
if (moreInfo.stack) {
moreInfoText += '\n' + _ui_utils.mozL10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}');
moreInfoText.push(this.l10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}'));
} else {
if (moreInfo.filename) {
moreInfoText += '\n' + _ui_utils.mozL10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}');
moreInfoText.push(this.l10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}'));
}
if (moreInfo.lineNumber) {
moreInfoText += '\n' + _ui_utils.mozL10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}');
moreInfoText.push(this.l10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}'));
}
}
}
@ -562,7 +585,9 @@ var PDFViewerApplication = { @@ -562,7 +585,9 @@ var PDFViewerApplication = {
closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
moreInfoButton.removeAttribute('hidden');
lessInfoButton.setAttribute('hidden', 'true');
errorMoreInfo.value = moreInfoText;
Promise.all(moreInfoText).then(function (parts) {
errorMoreInfo.value = parts.join('\n');
});
},
progress: function pdfViewProgress(level) {
var _this4 = this;
@ -799,22 +824,26 @@ var PDFViewerApplication = { @@ -799,22 +824,26 @@ var PDFViewerApplication = {
this.pdfRenderingQueue.renderHighestPriority();
},
beforePrint: function pdfViewSetupBeforePrint() {
var _this6 = this;
if (this.printService) {
return;
}
if (!this.supportsPrinting) {
var printMessage = _ui_utils.mozL10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by this browser.');
this.error(printMessage);
this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
_this6.error(printMessage);
});
return;
}
if (!this.pdfViewer.pageViewsReady) {
var notReadyMessage = _ui_utils.mozL10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.');
window.alert(notReadyMessage);
this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
window.alert(notReadyMessage);
});
return;
}
var pagesOverview = this.pdfViewer.getPagesOverview();
var printContainer = this.appConfig.printContainer;
var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer);
var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
this.printService = printService;
this.forceRendering();
printService.layout();
@ -925,9 +954,9 @@ var validateFileURL; @@ -925,9 +954,9 @@ var validateFileURL;
}
} catch (e) {
var message = e && e.message;
var loadingErrorMessage = _ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
var moreInfo = { message: message };
PDFViewerApplication.error(loadingErrorMessage, moreInfo);
PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
PDFViewerApplication.error(loadingErrorMessage, { message: message });
});
throw e;
}
};
@ -1004,9 +1033,6 @@ function webViewerInitialized() { @@ -1004,9 +1033,6 @@ function webViewerInitialized() {
if ('ignorecurrentpositiononzoom' in hashParams) {
_pdf.PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
}
if ('locale' in hashParams) {
_pdf.PDFJS.locale = hashParams['locale'];
}
if ('textlayer' in hashParams) {
switch (hashParams['textlayer']) {
case 'off':
@ -1027,7 +1053,6 @@ function webViewerInitialized() { @@ -1027,7 +1053,6 @@ function webViewerInitialized() {
waitForBeforeOpening.push(loadAndEnablePDFBug(enabled));
}
}
_ui_utils.mozL10n.setLanguage(_pdf.PDFJS.locale);
if (!PDFViewerApplication.supportsPrinting) {
appConfig.toolbar.print.classList.add('hidden');
appConfig.secondaryToolbar.printButton.classList.add('hidden');
@ -1050,7 +1075,9 @@ function webViewerInitialized() { @@ -1050,7 +1075,9 @@ function webViewerInitialized() {
Promise.all(waitForBeforeOpening).then(function () {
webViewerOpenFileViaURL(file);
}).catch(function (reason) {
PDFViewerApplication.error(_ui_utils.mozL10n.get('loading_error', null, 'An error occurred while opening.'), reason);
PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while opening.').then(function (msg) {
PDFViewerApplication.error(msg, reason);
});
});
}
var webViewerOpenFileViaURL;
@ -1067,7 +1094,9 @@ var webViewerOpenFileViaURL; @@ -1067,7 +1094,9 @@ var webViewerOpenFileViaURL;
xhr.responseType = 'arraybuffer';
xhr.send();
} catch (e) {
PDFViewerApplication.error(_ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.'), e);
PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
PDFViewerApplication.error(msg, e);
});
}
return;
}
@ -1094,7 +1123,9 @@ function webViewerPageRendered(e) { @@ -1094,7 +1123,9 @@ function webViewerPageRendered(e) {
Stats.add(pageNumber, pageView.stats);
}
if (pageView.error) {
PDFViewerApplication.error(_ui_utils.mozL10n.get('rendering_error', null, 'An error occurred while rendering the page.'), pageView.error);
PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
PDFViewerApplication.error(msg, pageView.error);
});
}
}
function webViewerTextLayerRendered(e) {}
@ -1575,9 +1606,6 @@ function webViewerKeyDown(evt) { @@ -1575,9 +1606,6 @@ function webViewerKeyDown(evt) {
evt.preventDefault();
}
}
_ui_utils.localized.then(function webViewerLocalized() {
document.getElementsByTagName('html')[0].dir = _ui_utils.mozL10n.getDirection();
});
var PDFPrintServiceFactory = {
instance: {
supportsPrinting: false,

5
lib/web/chromecom.js

@ -27,6 +27,8 @@ var _preferences = require('./preferences'); @@ -27,6 +27,8 @@ var _preferences = require('./preferences');
var _download_manager = require('./download_manager');
var _genericl10n = require('./genericl10n');
var _pdf = require('../pdf');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@ -311,5 +313,8 @@ ChromeExternalServices.createDownloadManager = function () { @@ -311,5 +313,8 @@ ChromeExternalServices.createDownloadManager = function () {
ChromeExternalServices.createPreferences = function () {
return new ChromePreferences();
};
ChromeExternalServices.createL10n = function () {
return new _genericl10n.GenericL10n(navigator.language);
};
_app.PDFViewerApplication.externalServices = ChromeExternalServices;
exports.ChromeCom = ChromeCom;

34
lib/web/firefoxcom.js

@ -23,6 +23,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol @@ -23,6 +23,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
require('../extensions/firefox/tools/l10n');
var _pdf = require('../pdf');
var _preferences = require('./preferences');
@ -146,6 +148,34 @@ var FirefoxPreferences = function (_BasePreferences) { @@ -146,6 +148,34 @@ var FirefoxPreferences = function (_BasePreferences) {
return FirefoxPreferences;
}(_preferences.BasePreferences);
var MozL10n = function () {
function MozL10n(mozL10n) {
_classCallCheck(this, MozL10n);
this.mozL10n = mozL10n;
}
_createClass(MozL10n, [{
key: 'getDirection',
value: function getDirection() {
return Promise.resolve(this.mozL10n.getDirection());
}
}, {
key: 'get',
value: function get(property, args, fallback) {
return Promise.resolve(this.mozL10n.get(property, args, fallback));
}
}, {
key: 'translate',
value: function translate(element) {
this.mozL10n.translate(element);
return Promise.resolve();
}
}]);
return MozL10n;
}();
(function listenFindEvents() {
var events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange'];
var handleEvent = function handleEvent(evt) {
@ -234,6 +264,10 @@ _app.PDFViewerApplication.externalServices = { @@ -234,6 +264,10 @@ _app.PDFViewerApplication.externalServices = {
createPreferences: function createPreferences() {
return new FirefoxPreferences();
},
createL10n: function createL10n() {
var mozL10n = document.mozL10n;
return new MozL10n(mozL10n);
},
get supportsIntegratedFind() {
var support = FirefoxCom.requestSync('supportsIntegratedFind');

7
lib/web/genericcom.js

@ -27,6 +27,10 @@ var _preferences = require('./preferences'); @@ -27,6 +27,10 @@ var _preferences = require('./preferences');
var _download_manager = require('./download_manager');
var _genericl10n = require('./genericl10n');
var _pdf = require('../pdf');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@ -73,5 +77,8 @@ GenericExternalServices.createDownloadManager = function () { @@ -73,5 +77,8 @@ GenericExternalServices.createDownloadManager = function () {
GenericExternalServices.createPreferences = function () {
return new GenericPreferences();
};
GenericExternalServices.createL10n = function () {
return new _genericl10n.GenericL10n(_pdf.PDFJS.locale);
};
_app.PDFViewerApplication.externalServices = GenericExternalServices;
exports.GenericCom = GenericCom;

68
lib/web/genericl10n.js

@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
/* Copyright 2017 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GenericL10n = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
require('../external/webL10n/l10n');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var webL10n = document.webL10n;
var GenericL10n = function () {
function GenericL10n(lang) {
_classCallCheck(this, GenericL10n);
this._lang = lang;
this._ready = new Promise(function (resolve, reject) {
webL10n.setLanguage(lang, function () {
resolve(webL10n);
});
});
}
_createClass(GenericL10n, [{
key: 'getDirection',
value: function getDirection() {
return this._ready.then(function (l10n) {
return l10n.getDirection();
});
}
}, {
key: 'get',
value: function get(property, args, fallback) {
return this._ready.then(function (l10n) {
return l10n.get(property, args, fallback);
});
}
}, {
key: 'translate',
value: function translate(element) {
return this._ready.then(function (l10n) {
return l10n.translate(element);
});
}
}]);
return GenericL10n;
}();
exports.GenericL10n = GenericL10n;

20
lib/web/interfaces.js

@ -118,8 +118,28 @@ var IPDFAnnotationLayerFactory = function () { @@ -118,8 +118,28 @@ var IPDFAnnotationLayerFactory = function () {
key: 'createAnnotationLayerBuilder',
value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
}
}]);
return IPDFAnnotationLayerFactory;
}();
var IL10n = function () {
function IL10n() {
_classCallCheck(this, IL10n);
}
_createClass(IL10n, [{
key: 'getDirection',
value: function getDirection() {}
}, {
key: 'get',
value: function get(key, args, fallback) {}
}, {
key: 'translate',
value: function translate(element) {}
}]);
return IL10n;
}();

13
lib/web/password_prompt.js

@ -31,6 +31,8 @@ var PasswordPrompt = function () { @@ -31,6 +31,8 @@ var PasswordPrompt = function () {
function PasswordPrompt(options, overlayManager) {
var _this = this;
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
_classCallCheck(this, PasswordPrompt);
this.overlayName = options.overlayName;
@ -40,6 +42,7 @@ var PasswordPrompt = function () { @@ -40,6 +42,7 @@ var PasswordPrompt = function () {
this.submitButton = options.submitButton;
this.cancelButton = options.cancelButton;
this.overlayManager = overlayManager;
this.l10n = l10n;
this.updateCallback = null;
this.reason = null;
this.submitButton.addEventListener('click', this.verify.bind(this));
@ -59,11 +62,15 @@ var PasswordPrompt = function () { @@ -59,11 +62,15 @@ var PasswordPrompt = function () {
this.overlayManager.open(this.overlayName).then(function () {
_this2.input.focus();
var promptString = _ui_utils.mozL10n.get('password_label', null, 'Enter the password to open this PDF file.');
var promptString = void 0;
if (_this2.reason === _pdf.PasswordResponses.INCORRECT_PASSWORD) {
promptString = _ui_utils.mozL10n.get('password_invalid', null, 'Invalid password. Please try again.');
promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
} else {
promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
}
_this2.label.textContent = promptString;
promptString.then(function (msg) {
_this2.label.textContent = msg;
});
});
}
}, {

35
lib/web/pdf_document_properties.js

@ -19,6 +19,8 @@ Object.defineProperty(exports, "__esModule", { @@ -19,6 +19,8 @@ Object.defineProperty(exports, "__esModule", {
});
exports.PDFDocumentProperties = undefined;
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _ui_utils = require('./ui_utils');
@ -35,6 +37,7 @@ var PDFDocumentProperties = function () { @@ -35,6 +37,7 @@ var PDFDocumentProperties = function () {
fields = _ref.fields,
container = _ref.container,
closeButton = _ref.closeButton;
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
_classCallCheck(this, PDFDocumentProperties);
@ -42,6 +45,7 @@ var PDFDocumentProperties = function () { @@ -42,6 +45,7 @@ var PDFDocumentProperties = function () {
this.fields = fields;
this.container = container;
this.overlayManager = overlayManager;
this.l10n = l10n;
this._reset();
if (closeButton) {
closeButton.addEventListener('click', this.close.bind(this));
@ -71,15 +75,24 @@ var PDFDocumentProperties = function () { @@ -71,15 +75,24 @@ var PDFDocumentProperties = function () {
var info = _ref2.info,
metadata = _ref2.metadata;
return Promise.all([info, metadata, _this._parseFileSize(_this.maybeFileSize), _this._parseDate(info.CreationDate), _this._parseDate(info.ModDate)]);
}).then(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 5),
info = _ref4[0],
metadata = _ref4[1],
fileSize = _ref4[2],
creationDate = _ref4[3],
modificationDate = _ref4[4];
freezeFieldData({
'fileName': (0, _ui_utils.getPDFFileNameFromURL)(_this.url),
'fileSize': _this._parseFileSize(_this.maybeFileSize),
'fileSize': fileSize,
'title': info.Title,
'author': info.Author,
'subject': info.Subject,
'keywords': info.Keywords,
'creationDate': _this._parseDate(info.CreationDate),
'modificationDate': _this._parseDate(info.ModDate),
'creationDate': creationDate,
'modificationDate': modificationDate,
'creator': info.Creator,
'producer': info.Producer,
'version': info.PDFFormatVersion,
@ -87,11 +100,13 @@ var PDFDocumentProperties = function () { @@ -87,11 +100,13 @@ var PDFDocumentProperties = function () {
});
_this._updateUI();
return _this.pdfDocument.getDownloadInfo();
}).then(function (_ref3) {
var length = _ref3.length;
}).then(function (_ref5) {
var length = _ref5.length;
return _this._parseFileSize(length);
}).then(function (fileSize) {
var data = (0, _ui_utils.cloneObj)(_this.fieldData);
data['fileSize'] = _this._parseFileSize(length);
data['fileSize'] = fileSize;
freezeFieldData(data);
_this._updateUI();
});
@ -158,14 +173,14 @@ var PDFDocumentProperties = function () { @@ -158,14 +173,14 @@ var PDFDocumentProperties = function () {
var kb = fileSize / 1024;
if (!kb) {
return;
return Promise.resolve(undefined);
} else if (kb < 1024) {
return _ui_utils.mozL10n.get('document_properties_kb', {
return this.l10n.get('document_properties_kb', {
size_kb: (+kb.toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_kb}} KB ({{size_b}} bytes)');
}
return _ui_utils.mozL10n.get('document_properties_mb', {
return this.l10n.get('document_properties_mb', {
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_mb}} MB ({{size_b}} bytes)');
@ -199,7 +214,7 @@ var PDFDocumentProperties = function () { @@ -199,7 +214,7 @@ var PDFDocumentProperties = function () {
var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
var dateString = date.toLocaleDateString();
var timeString = date.toLocaleTimeString();
return _ui_utils.mozL10n.get('document_properties_date_string', {
return this.l10n.get('document_properties_date_string', {
date: dateString,
time: timeString
}, '{{date}}, {{time}}');

15
lib/web/pdf_find_bar.js

@ -31,6 +31,8 @@ var PDFFindBar = function () { @@ -31,6 +31,8 @@ var PDFFindBar = function () {
function PDFFindBar(options) {
var _this = this;
var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
_classCallCheck(this, PDFFindBar);
this.opened = false;
@ -46,6 +48,7 @@ var PDFFindBar = function () { @@ -46,6 +48,7 @@ var PDFFindBar = function () {
this.findNextButton = options.findNextButton || null;
this.findController = options.findController || null;
this.eventBus = options.eventBus;
this.l10n = l10n;
if (this.findController === null) {
throw new Error('PDFFindBar cannot be used without a ' + 'PDFFindController instance.');
}
@ -103,6 +106,8 @@ var PDFFindBar = function () { @@ -103,6 +106,8 @@ var PDFFindBar = function () {
}, {
key: 'updateUIState',
value: function updateUIState(state, previous, matchCount) {
var _this2 = this;
var notFound = false;
var findMsg = '';
var status = '';
@ -113,14 +118,14 @@ var PDFFindBar = function () { @@ -113,14 +118,14 @@ var PDFFindBar = function () {
status = 'pending';
break;
case _pdf_find_controller.FindStates.FIND_NOTFOUND:
findMsg = _ui_utils.mozL10n.get('find_not_found', null, 'Phrase not found');
findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
notFound = true;
break;
case _pdf_find_controller.FindStates.FIND_WRAPPED:
if (previous) {
findMsg = _ui_utils.mozL10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
} else {
findMsg = _ui_utils.mozL10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
}
break;
}
@ -130,7 +135,9 @@ var PDFFindBar = function () { @@ -130,7 +135,9 @@ var PDFFindBar = function () {
this.findField.classList.remove('notFound');
}
this.findField.setAttribute('data-status', status);
this.findMsg.textContent = findMsg;
Promise.resolve(findMsg).then(function (msg) {
_this2.findMsg.textContent = msg;
});
this.updateResultsCount(matchCount);
this._adjustWidth();
}

3
lib/web/pdf_page_view.js

@ -54,6 +54,7 @@ var PDFPageView = function () { @@ -54,6 +54,7 @@ var PDFPageView = function () {
this.textLayerFactory = options.textLayerFactory;
this.annotationLayerFactory = options.annotationLayerFactory;
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
this.l10n = options.l10n || _ui_utils.NullL10n;
this.paintTask = null;
this.paintedViewportMap = new WeakMap();
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
@ -378,7 +379,7 @@ var PDFPageView = function () { @@ -378,7 +379,7 @@ var PDFPageView = function () {
});
if (this.annotationLayerFactory) {
if (!this.annotationLayer) {
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms);
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n);
}
this.annotationLayer.render(this.viewport, 'display');
}

17
lib/web/pdf_print_service.js

@ -55,10 +55,11 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) { @@ -55,10 +55,11 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
};
});
}
function PDFPrintService(pdfDocument, pagesOverview, printContainer) {
function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
this.pdfDocument = pdfDocument;
this.pagesOverview = pagesOverview;
this.printContainer = printContainer;
this.l10n = l10n || _ui_utils.NullL10n;
this.currentPage = -1;
this.scratchCanvas = document.createElement('canvas');
}
@ -104,12 +105,12 @@ PDFPrintService.prototype = { @@ -104,12 +105,12 @@ PDFPrintService.prototype = {
var renderNextPage = function renderNextPage(resolve, reject) {
_this.throwIfInactive();
if (++_this.currentPage >= pageCount) {
renderProgress(pageCount, pageCount);
renderProgress(pageCount, pageCount, _this.l10n);
resolve();
return;
}
var index = _this.currentPage;
renderProgress(index, pageCount);
renderProgress(index, pageCount, _this.l10n);
renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
renderNextPage(resolve, reject);
}, reject);
@ -206,13 +207,15 @@ function abort() { @@ -206,13 +207,15 @@ function abort() {
dispatchEvent('afterprint');
}
}
function renderProgress(index, total) {
function renderProgress(index, total, l10n) {
var progressContainer = document.getElementById('printServiceOverlay');
var progress = Math.round(100 * index / total);
var progressBar = progressContainer.querySelector('progress');
var progressPerc = progressContainer.querySelector('.relative-progress');
progressBar.value = progress;
progressPerc.textContent = _ui_utils.mozL10n.get('print_progress_percent', { progress: progress }, progress + '%');
l10n.get('print_progress_percent', { progress: progress }, progress + '%').then(function (msg) {
progressPerc.textContent = msg;
});
}
var hasAttachEvent = !!document.attachEvent;
window.addEventListener('keydown', function (event) {
@ -262,11 +265,11 @@ function ensureOverlay() { @@ -262,11 +265,11 @@ function ensureOverlay() {
}
_app.PDFPrintServiceFactory.instance = {
supportsPrinting: true,
createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer) {
createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
if (activeService) {
throw new Error('The print service is created and active.');
}
activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer);
activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
return activeService;
}
};

53
lib/web/pdf_sidebar.js

@ -37,6 +37,8 @@ var SidebarView = { @@ -37,6 +37,8 @@ var SidebarView = {
var PDFSidebar = function () {
function PDFSidebar(options) {
var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
_classCallCheck(this, PDFSidebar);
this.isOpen = false;
@ -57,6 +59,7 @@ var PDFSidebar = function () { @@ -57,6 +59,7 @@ var PDFSidebar = function () {
this.outlineView = options.outlineView;
this.attachmentsView = options.attachmentsView;
this.disableNotification = options.disableNotification || false;
this.l10n = l10n;
this._addEventListeners();
}
@ -224,10 +227,14 @@ var PDFSidebar = function () { @@ -224,10 +227,14 @@ var PDFSidebar = function () {
}, {
key: '_showUINotification',
value: function _showUINotification(view) {
var _this = this;
if (this.disableNotification) {
return;
}
this.toggleButton.title = _ui_utils.mozL10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)');
this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
_this.toggleButton.title = msg;
});
if (!this.isOpen) {
this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
} else if (view === this.active) {
@ -245,7 +252,7 @@ var PDFSidebar = function () { @@ -245,7 +252,7 @@ var PDFSidebar = function () {
}, {
key: '_hideUINotification',
value: function _hideUINotification(view) {
var _this = this;
var _this2 = this;
if (this.disableNotification) {
return;
@ -253,10 +260,10 @@ var PDFSidebar = function () { @@ -253,10 +260,10 @@ var PDFSidebar = function () {
var removeNotification = function removeNotification(view) {
switch (view) {
case SidebarView.OUTLINE:
_this.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
_this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
break;
case SidebarView.ATTACHMENTS:
_this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
_this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
break;
}
};
@ -271,51 +278,53 @@ var PDFSidebar = function () { @@ -271,51 +278,53 @@ var PDFSidebar = function () {
for (view in SidebarView) {
removeNotification(SidebarView[view]);
}
this.toggleButton.title = _ui_utils.mozL10n.get('toggle_sidebar.title', null, 'Toggle Sidebar');
this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
_this2.toggleButton.title = msg;
});
}
}, {
key: '_addEventListeners',
value: function _addEventListeners() {
var _this2 = this;
var _this3 = this;
this.mainContainer.addEventListener('transitionend', function (evt) {
if (evt.target === _this2.mainContainer) {
_this2.outerContainer.classList.remove('sidebarMoving');
if (evt.target === _this3.mainContainer) {
_this3.outerContainer.classList.remove('sidebarMoving');
}
});
this.thumbnailButton.addEventListener('click', function () {
_this2.switchView(SidebarView.THUMBS);
_this3.switchView(SidebarView.THUMBS);
});
this.outlineButton.addEventListener('click', function () {
_this2.switchView(SidebarView.OUTLINE);
_this3.switchView(SidebarView.OUTLINE);
});
this.outlineButton.addEventListener('dblclick', function () {
_this2.pdfOutlineViewer.toggleOutlineTree();
_this3.pdfOutlineViewer.toggleOutlineTree();
});
this.attachmentsButton.addEventListener('click', function () {
_this2.switchView(SidebarView.ATTACHMENTS);
_this3.switchView(SidebarView.ATTACHMENTS);
});
this.eventBus.on('outlineloaded', function (evt) {
var outlineCount = evt.outlineCount;
_this2.outlineButton.disabled = !outlineCount;
_this3.outlineButton.disabled = !outlineCount;
if (outlineCount) {
_this2._showUINotification(SidebarView.OUTLINE);
} else if (_this2.active === SidebarView.OUTLINE) {
_this2.switchView(SidebarView.THUMBS);
_this3._showUINotification(SidebarView.OUTLINE);
} else if (_this3.active === SidebarView.OUTLINE) {
_this3.switchView(SidebarView.THUMBS);
}
});
this.eventBus.on('attachmentsloaded', function (evt) {
var attachmentsCount = evt.attachmentsCount;
_this2.attachmentsButton.disabled = !attachmentsCount;
_this3.attachmentsButton.disabled = !attachmentsCount;
if (attachmentsCount) {
_this2._showUINotification(SidebarView.ATTACHMENTS);
} else if (_this2.active === SidebarView.ATTACHMENTS) {
_this2.switchView(SidebarView.THUMBS);
_this3._showUINotification(SidebarView.ATTACHMENTS);
} else if (_this3.active === SidebarView.ATTACHMENTS) {
_this3.switchView(SidebarView.THUMBS);
}
});
this.eventBus.on('presentationmodechanged', function (evt) {
if (!evt.active && !evt.switchInProgress && _this2.isThumbnailViewVisible) {
_this2._updateThumbnailViewer();
if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
_this3._updateThumbnailViewer();
}
});
}

53
lib/web/pdf_thumbnail_view.js

@ -83,9 +83,12 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -83,9 +83,12 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
this.canvasWidth = THUMBNAIL_WIDTH;
this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
this.scale = this.canvasWidth / this.pageWidth;
this.l10n = options.l10n || _ui_utils.NullL10n;
var anchor = document.createElement('a');
anchor.href = linkService.getAnchorUrl('#page=' + id);
anchor.title = _ui_utils.mozL10n.get('thumb_page_title', { page: id }, 'Page {{page}}');
this.l10n.get('thumb_page_title', { page: id }, 'Page {{page}}').then(function (msg) {
anchor.title = msg;
});
anchor.onclick = function stopNavigation() {
linkService.page = id;
return false;
@ -177,6 +180,8 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -177,6 +180,8 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
return ctx;
},
_convertCanvasToImage: function PDFThumbnailView_convertCanvasToImage() {
var _this = this;
if (!this.canvas) {
return;
}
@ -185,11 +190,12 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -185,11 +190,12 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
}
var id = this.renderingId;
var className = 'thumbnailImage';
var ariaLabel = _ui_utils.mozL10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}');
if (this.disableCanvasToImageConversion) {
this.canvas.id = id;
this.canvas.className = className;
this.canvas.setAttribute('aria-label', ariaLabel);
this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
_this.canvas.setAttribute('aria-label', msg);
});
this.div.setAttribute('data-loaded', true);
this.ring.appendChild(this.canvas);
return;
@ -197,7 +203,9 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -197,7 +203,9 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
var image = document.createElement('img');
image.id = id;
image.className = className;
image.setAttribute('aria-label', ariaLabel);
this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
image.setAttribute('aria-label', msg);
});
image.style.width = this.canvasWidth + 'px';
image.style.height = this.canvasHeight + 'px';
image.src = this.canvas.toDataURL();
@ -209,7 +217,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -209,7 +217,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
delete this.canvas;
},
draw: function draw() {
var _this = this;
var _this2 = this;
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
@ -218,15 +226,15 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -218,15 +226,15 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
var renderCapability = (0, _pdf.createPromiseCapability)();
var finishRenderTask = function finishRenderTask(error) {
if (renderTask === _this.renderTask) {
_this.renderTask = null;
if (renderTask === _this2.renderTask) {
_this2.renderTask = null;
}
if (error === 'cancelled' || error instanceof _pdf.RenderingCancelledException) {
renderCapability.resolve(undefined);
return;
}
_this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
_this._convertCanvasToImage();
_this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
_this2._convertCanvasToImage();
if (!error) {
renderCapability.resolve(undefined);
} else {
@ -236,10 +244,10 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -236,10 +244,10 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
var ctx = this._getPageDrawContext();
var drawViewport = this.viewport.clone({ scale: this.scale });
var renderContinueCallback = function renderContinueCallback(cont) {
if (!_this.renderingQueue.isHighestPriority(_this)) {
_this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
_this.resume = function () {
_this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
if (!_this2.renderingQueue.isHighestPriority(_this2)) {
_this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
_this2.resume = function () {
_this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
cont();
};
return;
@ -301,17 +309,22 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -301,17 +309,22 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
return this.pageLabel !== null ? this.pageLabel : this.id;
},
setPageLabel: function PDFThumbnailView_setPageLabel(label) {
var _this3 = this;
this.pageLabel = typeof label === 'string' ? label : null;
this.anchor.title = _ui_utils.mozL10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}');
this.l10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}').then(function (msg) {
_this3.anchor.title = msg;
});
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
return;
}
var ariaLabel = _ui_utils.mozL10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}');
if (this.image) {
this.image.setAttribute('aria-label', ariaLabel);
} else if (this.disableCanvasToImageConversion && this.canvas) {
this.canvas.setAttribute('aria-label', ariaLabel);
}
this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
if (_this3.image) {
_this3.image.setAttribute('aria-label', ariaLabel);
} else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
_this3.canvas.setAttribute('aria-label', ariaLabel);
}
});
}
};
PDFThumbnailView.cleanup = function () {

4
lib/web/pdf_thumbnail_viewer.js

@ -29,6 +29,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() { @@ -29,6 +29,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
this.container = options.container;
this.renderingQueue = options.renderingQueue;
this.linkService = options.linkService;
this.l10n = options.l10n || _ui_utils.NullL10n;
this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
this._resetView();
}
@ -102,7 +103,8 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() { @@ -102,7 +103,8 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
defaultViewport: viewport.clone(),
linkService: _this.linkService,
renderingQueue: _this.renderingQueue,
disableCanvasToImageConversion: false
disableCanvasToImageConversion: false,
l10n: _this.l10n
});
_this.thumbnails.push(thumbnail);
}

3
lib/web/pdf_viewer.component.js

@ -24,6 +24,7 @@ var pdfjsWebPDFHistory = require('./pdf_history.js'); @@ -24,6 +24,7 @@ var pdfjsWebPDFHistory = require('./pdf_history.js');
var pdfjsWebPDFFindController = require('./pdf_find_controller.js');
var pdfjsWebUIUtils = require('./ui_utils.js');
var pdfjsWebDownloadManager = require('./download_manager.js');
var pdfjsWebGenericL10n = require('./genericl10n.js');
var PDFJS = pdfjsLib.PDFJS;
PDFJS.PDFViewer = pdfjsWebPDFViewer.PDFViewer;
PDFJS.PDFPageView = pdfjsWebPDFPageView.PDFPageView;
@ -37,4 +38,6 @@ PDFJS.PDFFindController = pdfjsWebPDFFindController.PDFFindController; @@ -37,4 +38,6 @@ PDFJS.PDFFindController = pdfjsWebPDFFindController.PDFFindController;
PDFJS.EventBus = pdfjsWebUIUtils.EventBus;
PDFJS.DownloadManager = pdfjsWebDownloadManager.DownloadManager;
PDFJS.ProgressBar = pdfjsWebUIUtils.ProgressBar;
PDFJS.GenericL10n = pdfjsWebGenericL10n.GenericL10n;
PDFJS.NullL10n = pdfjsWebUIUtils.NullL10n;
exports.PDFJS = PDFJS;

8
lib/web/pdf_viewer.js

@ -85,6 +85,7 @@ var PDFViewer = function pdfViewer() { @@ -85,6 +85,7 @@ var PDFViewer = function pdfViewer() {
this.renderInteractiveForms = options.renderInteractiveForms || false;
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
this.l10n = options.l10n || _ui_utils.NullL10n;
this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) {
this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
@ -260,7 +261,8 @@ var PDFViewer = function pdfViewer() { @@ -260,7 +261,8 @@ var PDFViewer = function pdfViewer() {
annotationLayerFactory: _this,
enhanceTextSelection: _this.enhanceTextSelection,
renderInteractiveForms: _this.renderInteractiveForms,
renderer: _this.renderer
renderer: _this.renderer,
l10n: _this.l10n
});
bindOnAfterAndBeforeDraw(pageView);
_this._pages.push(pageView);
@ -680,13 +682,15 @@ var PDFViewer = function pdfViewer() { @@ -680,13 +682,15 @@ var PDFViewer = function pdfViewer() {
},
createAnnotationLayerBuilder: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
return new _annotation_layer_builder.AnnotationLayerBuilder({
pageDiv: pageDiv,
pdfPage: pdfPage,
renderInteractiveForms: renderInteractiveForms,
linkService: this.linkService,
downloadManager: this.downloadManager
downloadManager: this.downloadManager,
l10n: l10n
});
},
setFindController: function setFindController(findController) {

35
lib/web/toolbar.js

@ -26,9 +26,12 @@ var SCALE_SELECT_CONTAINER_PADDING = 8; @@ -26,9 +26,12 @@ var SCALE_SELECT_CONTAINER_PADDING = 8;
var SCALE_SELECT_PADDING = 22;
var Toolbar = function ToolbarClosure() {
function Toolbar(options, mainContainer, eventBus) {
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
this.toolbar = options.container;
this.mainContainer = mainContainer;
this.eventBus = eventBus;
this.l10n = l10n;
this.items = options;
this._wasLocalized = false;
this.reset();
@ -61,6 +64,8 @@ var Toolbar = function ToolbarClosure() { @@ -61,6 +64,8 @@ var Toolbar = function ToolbarClosure() {
},
_bindListeners: function Toolbar_bindClickListeners() {
var _this = this;
var eventBus = this.eventBus;
var self = this;
var items = this.items;
@ -107,7 +112,9 @@ var Toolbar = function ToolbarClosure() { @@ -107,7 +112,9 @@ var Toolbar = function ToolbarClosure() {
eventBus.dispatch('download');
});
items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
_ui_utils.localized.then(this._localized.bind(this));
eventBus.on('localized', function (evt) {
_this._localized();
});
},
_localized: function Toolbar_localized() {
this._wasLocalized = true;
@ -115,7 +122,12 @@ var Toolbar = function ToolbarClosure() { @@ -115,7 +122,12 @@ var Toolbar = function ToolbarClosure() {
this._updateUIState(true);
},
_updateUIState: function Toolbar_updateUIState(resetNumPages) {
function selectScaleOption(value, scale) {
var _this2 = this;
if (!this._wasLocalized) {
return;
}
var selectScaleOption = function selectScaleOption(value, scale) {
var options = items.scaleSelect.options;
var predefinedValueFound = false;
for (var i = 0, ii = options.length; i < ii; i++) {
@ -129,13 +141,12 @@ var Toolbar = function ToolbarClosure() { @@ -129,13 +141,12 @@ var Toolbar = function ToolbarClosure() {
}
if (!predefinedValueFound) {
var customScale = Math.round(scale * 10000) / 100;
items.customScaleOption.textContent = _ui_utils.mozL10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%');
_this2.l10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%').then(function (msg) {
items.customScaleOption.textContent = msg;
});
items.customScaleOption.selected = true;
}
}
if (!this._wasLocalized) {
return;
}
};
var pageNumber = this.pageNumber;
var scaleValue = (this.pageScaleValue || this.pageScale).toString();
var scale = this.pageScale;
@ -146,16 +157,20 @@ var Toolbar = function ToolbarClosure() { @@ -146,16 +157,20 @@ var Toolbar = function ToolbarClosure() {
items.pageNumber.type = 'text';
} else {
items.pageNumber.type = 'number';
items.numPages.textContent = _ui_utils.mozL10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}');
this.l10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}').then(function (msg) {
items.numPages.textContent = msg;
});
}
items.pageNumber.max = pagesCount;
}
if (this.hasPageLabels) {
items.pageNumber.value = this.pageLabel;
items.numPages.textContent = _ui_utils.mozL10n.get('page_of_pages', {
this.l10n.get('page_of_pages', {
pageNumber: pageNumber,
pagesCount: pagesCount
}, '({{pageNumber}} of {{pagesCount}})');
}, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
items.numPages.textContent = msg;
});
} else {
items.pageNumber.value = pageNumber;
}

35
lib/web/ui_utils.js

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
var _pdf = require('../pdf');
@ -34,7 +34,22 @@ var RendererType = { @@ -34,7 +34,22 @@ var RendererType = {
CANVAS: 'canvas',
SVG: 'svg'
};
var mozL10n = typeof document !== 'undefined' ? document.mozL10n || document.webL10n : undefined;
function formatL10nValue(text, args) {
if (!args) {
return text;
}
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
return name in args ? args[name] : '{{' + name + '}}';
});
}
var NullL10n = {
get: function get(property, args, fallback) {
return Promise.resolve(formatL10nValue(fallback, args));
},
translate: function translate(element) {
return Promise.resolve();
}
};
_pdf.PDFJS.disableFullscreen = _pdf.PDFJS.disableFullscreen === undefined ? false : _pdf.PDFJS.disableFullscreen;
_pdf.PDFJS.useOnlyCssZoom = _pdf.PDFJS.useOnlyCssZoom === undefined ? false : _pdf.PDFJS.useOnlyCssZoom;
_pdf.PDFJS.maxCanvasPixels = _pdf.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdf.PDFJS.maxCanvasPixels;
@ -301,19 +316,8 @@ function cloneObj(obj) { @@ -301,19 +316,8 @@ function cloneObj(obj) {
var animationStarted = new Promise(function (resolve) {
window.requestAnimationFrame(resolve);
});
var localized = new Promise(function (resolve, reject) {
if (!mozL10n) {
resolve();
return;
}
if (mozL10n.getReadyState() !== 'loading') {
resolve();
return;
}
window.addEventListener('localized', function localized(evt) {
resolve();
});
});
var mozL10n;
var localized = Promise.resolve();
var EventBus = function EventBusClosure() {
function EventBus() {
this._listeners = Object.create(null);
@ -421,6 +425,7 @@ exports.VERTICAL_PADDING = VERTICAL_PADDING; @@ -421,6 +425,7 @@ exports.VERTICAL_PADDING = VERTICAL_PADDING;
exports.cloneObj = cloneObj;
exports.RendererType = RendererType;
exports.mozL10n = mozL10n;
exports.NullL10n = NullL10n;
exports.EventBus = EventBus;
exports.ProgressBar = ProgressBar;
exports.getPDFFileNameFromURL = getPDFFileNameFromURL;

2
package.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "1.8.404",
"version": "1.8.406",
"main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.",
"keywords": [

866
web/pdf_viewer.js

@ -88,7 +88,7 @@ return /******/ (function(modules) { // webpackBootstrap @@ -88,7 +88,7 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ __w_pdfjs_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 12);
/******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 14);
/******/ })
/************************************************************************/
/******/ ([
@ -120,7 +120,7 @@ module.exports = pdfjsLib; @@ -120,7 +120,7 @@ module.exports = pdfjsLib;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
var _pdfjsLib = __w_pdfjs_require__(0);
@ -137,7 +137,22 @@ var RendererType = { @@ -137,7 +137,22 @@ var RendererType = {
CANVAS: 'canvas',
SVG: 'svg'
};
var mozL10n = typeof document !== 'undefined' ? document.mozL10n || document.webL10n : undefined;
function formatL10nValue(text, args) {
if (!args) {
return text;
}
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
return name in args ? args[name] : '{{' + name + '}}';
});
}
var NullL10n = {
get: function get(property, args, fallback) {
return Promise.resolve(formatL10nValue(fallback, args));
},
translate: function translate(element) {
return Promise.resolve();
}
};
_pdfjsLib.PDFJS.disableFullscreen = _pdfjsLib.PDFJS.disableFullscreen === undefined ? false : _pdfjsLib.PDFJS.disableFullscreen;
_pdfjsLib.PDFJS.useOnlyCssZoom = _pdfjsLib.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjsLib.PDFJS.useOnlyCssZoom;
_pdfjsLib.PDFJS.maxCanvasPixels = _pdfjsLib.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjsLib.PDFJS.maxCanvasPixels;
@ -404,19 +419,8 @@ function cloneObj(obj) { @@ -404,19 +419,8 @@ function cloneObj(obj) {
var animationStarted = new Promise(function (resolve) {
window.requestAnimationFrame(resolve);
});
var localized = new Promise(function (resolve, reject) {
if (!mozL10n) {
resolve();
return;
}
if (mozL10n.getReadyState() !== 'loading') {
resolve();
return;
}
window.addEventListener('localized', function localized(evt) {
resolve();
});
});
var mozL10n;
var localized = Promise.resolve();
var EventBus = function EventBusClosure() {
function EventBus() {
this._listeners = Object.create(null);
@ -524,6 +528,7 @@ exports.VERTICAL_PADDING = VERTICAL_PADDING; @@ -524,6 +528,7 @@ exports.VERTICAL_PADDING = VERTICAL_PADDING;
exports.cloneObj = cloneObj;
exports.RendererType = RendererType;
exports.mozL10n = mozL10n;
exports.NullL10n = NullL10n;
exports.EventBus = EventBus;
exports.ProgressBar = ProgressBar;
exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
@ -1036,6 +1041,7 @@ var AnnotationLayerBuilder = function () { @@ -1036,6 +1041,7 @@ var AnnotationLayerBuilder = function () {
this.renderInteractiveForms = options.renderInteractiveForms;
this.linkService = options.linkService;
this.downloadManager = options.downloadManager;
this.l10n = options.l10n || _ui_utils.NullL10n;
this.div = null;
}
@ -1067,9 +1073,7 @@ var AnnotationLayerBuilder = function () { @@ -1067,9 +1073,7 @@ var AnnotationLayerBuilder = function () {
_this.pageDiv.appendChild(_this.div);
parameters.div = _this.div;
_pdfjsLib.AnnotationLayer.render(parameters);
if (typeof _ui_utils.mozL10n !== 'undefined') {
_ui_utils.mozL10n.translate(_this.div);
}
_this.l10n.translate(_this.div);
}
});
}
@ -1095,12 +1099,14 @@ var DefaultAnnotationLayerFactory = function () { @@ -1095,12 +1099,14 @@ var DefaultAnnotationLayerFactory = function () {
key: 'createAnnotationLayerBuilder',
value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
return new AnnotationLayerBuilder({
pageDiv: pageDiv,
pdfPage: pdfPage,
renderInteractiveForms: renderInteractiveForms,
linkService: new _pdf_link_service.SimpleLinkService()
linkService: new _pdf_link_service.SimpleLinkService(),
l10n: l10n
});
}
}]);
@ -1158,6 +1164,7 @@ var PDFPageView = function () { @@ -1158,6 +1164,7 @@ var PDFPageView = function () {
this.textLayerFactory = options.textLayerFactory;
this.annotationLayerFactory = options.annotationLayerFactory;
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
this.l10n = options.l10n || _ui_utils.NullL10n;
this.paintTask = null;
this.paintedViewportMap = new WeakMap();
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
@ -1482,7 +1489,7 @@ var PDFPageView = function () { @@ -1482,7 +1489,7 @@ var PDFPageView = function () {
});
if (this.annotationLayerFactory) {
if (!this.annotationLayer) {
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms);
this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n);
}
this.annotationLayer.render(this.viewport, 'display');
}
@ -2137,6 +2144,66 @@ exports.DownloadManager = DownloadManager; @@ -2137,6 +2144,66 @@ exports.DownloadManager = DownloadManager;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GenericL10n = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
__w_pdfjs_require__(13);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var webL10n = document.webL10n;
var GenericL10n = function () {
function GenericL10n(lang) {
_classCallCheck(this, GenericL10n);
this._lang = lang;
this._ready = new Promise(function (resolve, reject) {
webL10n.setLanguage(lang, function () {
resolve(webL10n);
});
});
}
_createClass(GenericL10n, [{
key: 'getDirection',
value: function getDirection() {
return this._ready.then(function (l10n) {
return l10n.getDirection();
});
}
}, {
key: 'get',
value: function get(property, args, fallback) {
return this._ready.then(function (l10n) {
return l10n.get(property, args, fallback);
});
}
}, {
key: 'translate',
value: function translate(element) {
return this._ready.then(function (l10n) {
return l10n.translate(element);
});
}
}]);
return GenericL10n;
}();
exports.GenericL10n = GenericL10n;
/***/ }),
/* 10 */
/***/ (function(module, exports, __w_pdfjs_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
@ -2509,7 +2576,7 @@ exports.FindStates = FindStates; @@ -2509,7 +2576,7 @@ exports.FindStates = FindStates;
exports.PDFFindController = PDFFindController;
/***/ }),
/* 10 */
/* 11 */
/***/ (function(module, exports, __w_pdfjs_require__) {
"use strict";
@ -2816,7 +2883,7 @@ PDFHistory.prototype = { @@ -2816,7 +2883,7 @@ PDFHistory.prototype = {
exports.PDFHistory = PDFHistory;
/***/ }),
/* 11 */
/* 12 */
/***/ (function(module, exports, __w_pdfjs_require__) {
"use strict";
@ -2893,6 +2960,7 @@ var PDFViewer = function pdfViewer() { @@ -2893,6 +2960,7 @@ var PDFViewer = function pdfViewer() {
this.renderInteractiveForms = options.renderInteractiveForms || false;
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
this.l10n = options.l10n || _ui_utils.NullL10n;
this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) {
this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
@ -3068,7 +3136,8 @@ var PDFViewer = function pdfViewer() { @@ -3068,7 +3136,8 @@ var PDFViewer = function pdfViewer() {
annotationLayerFactory: _this,
enhanceTextSelection: _this.enhanceTextSelection,
renderInteractiveForms: _this.renderInteractiveForms,
renderer: _this.renderer
renderer: _this.renderer,
l10n: _this.l10n
});
bindOnAfterAndBeforeDraw(pageView);
_this._pages.push(pageView);
@ -3488,13 +3557,15 @@ var PDFViewer = function pdfViewer() { @@ -3488,13 +3557,15 @@ var PDFViewer = function pdfViewer() {
},
createAnnotationLayerBuilder: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
return new _annotation_layer_builder.AnnotationLayerBuilder({
pageDiv: pageDiv,
pdfPage: pdfPage,
renderInteractiveForms: renderInteractiveForms,
linkService: this.linkService,
downloadManager: this.downloadManager
downloadManager: this.downloadManager,
l10n: l10n
});
},
setFindController: function setFindController(findController) {
@ -3531,22 +3602,757 @@ exports.PresentationModeState = PresentationModeState; @@ -3531,22 +3602,757 @@ exports.PresentationModeState = PresentationModeState;
exports.PDFViewer = PDFViewer;
/***/ }),
/* 12 */
/* 13 */
/***/ (function(module, exports, __w_pdfjs_require__) {
"use strict";
document.webL10n = function (window, document, undefined) {
var gL10nData = {};
var gTextData = '';
var gTextProp = 'textContent';
var gLanguage = '';
var gMacros = {};
var gReadyState = 'loading';
var gAsyncResourceLoading = true;
function getL10nResourceLinks() {
return document.querySelectorAll('link[type="application/l10n"]');
}
function getL10nDictionary() {
var script = document.querySelector('script[type="application/l10n"]');
return script ? JSON.parse(script.innerHTML) : null;
}
function getTranslatableChildren(element) {
return element ? element.querySelectorAll('*[data-l10n-id]') : [];
}
function getL10nAttributes(element) {
if (!element) return {};
var l10nId = element.getAttribute('data-l10n-id');
var l10nArgs = element.getAttribute('data-l10n-args');
var args = {};
if (l10nArgs) {
try {
args = JSON.parse(l10nArgs);
} catch (e) {
console.warn('could not parse arguments for #' + l10nId);
}
}
return {
id: l10nId,
args: args
};
}
function fireL10nReadyEvent(lang) {
var evtObject = document.createEvent('Event');
evtObject.initEvent('localized', true, false);
evtObject.language = lang;
document.dispatchEvent(evtObject);
}
function xhrLoadText(url, onSuccess, onFailure) {
onSuccess = onSuccess || function _onSuccess(data) {};
onFailure = onFailure || function _onFailure() {};
var xhr = new XMLHttpRequest();
xhr.open('GET', url, gAsyncResourceLoading);
if (xhr.overrideMimeType) {
xhr.overrideMimeType('text/plain; charset=utf-8');
}
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200 || xhr.status === 0) {
onSuccess(xhr.responseText);
} else {
onFailure();
}
}
};
xhr.onerror = onFailure;
xhr.ontimeout = onFailure;
try {
xhr.send(null);
} catch (e) {
onFailure();
}
}
function parseResource(href, lang, successCallback, failureCallback) {
var baseURL = href.replace(/[^\/]*$/, '') || './';
function evalString(text) {
if (text.lastIndexOf('\\') < 0) return text;
return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
}
function parseProperties(text, parsedPropertiesCallback) {
var dictionary = {};
var reBlank = /^\s*|\s*$/;
var reComment = /^\s*#|^\s*$/;
var reSection = /^\s*\[(.*)\]\s*$/;
var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
var currentLang = '*';
var genericLang = lang.split('-', 1)[0];
var skipLang = false;
var match = '';
function nextEntry() {
while (true) {
if (!entries.length) {
parsedRawLinesCallback();
return;
}
var line = entries.shift();
if (reComment.test(line)) continue;
if (extendedSyntax) {
match = reSection.exec(line);
if (match) {
currentLang = match[1].toLowerCase();
skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
continue;
} else if (skipLang) {
continue;
}
match = reImport.exec(line);
if (match) {
loadImport(baseURL + match[1], nextEntry);
return;
}
}
var tmp = line.match(reSplit);
if (tmp && tmp.length == 3) {
dictionary[tmp[1]] = evalString(tmp[2]);
}
}
}
nextEntry();
}
function loadImport(url, callback) {
xhrLoadText(url, function (content) {
parseRawLines(content, false, callback);
}, function () {
console.warn(url + ' not found.');
callback();
});
}
parseRawLines(text, true, function () {
parsedPropertiesCallback(dictionary);
});
}
xhrLoadText(href, function (response) {
gTextData += response;
parseProperties(response, function (data) {
for (var key in data) {
var id,
prop,
index = key.lastIndexOf('.');
if (index > 0) {
id = key.substring(0, index);
prop = key.substr(index + 1);
} else {
id = key;
prop = gTextProp;
}
if (!gL10nData[id]) {
gL10nData[id] = {};
}
gL10nData[id][prop] = data[key];
}
if (successCallback) {
successCallback();
}
});
}, failureCallback);
}
function loadLocale(lang, callback) {
if (lang) {
lang = lang.toLowerCase();
}
callback = callback || function _callback() {};
clear();
gLanguage = lang;
var langLinks = getL10nResourceLinks();
var langCount = langLinks.length;
if (langCount === 0) {
var dict = getL10nDictionary();
if (dict && dict.locales && dict.default_locale) {
console.log('using the embedded JSON directory, early way out');
gL10nData = dict.locales[lang];
if (!gL10nData) {
var defaultLocale = dict.default_locale.toLowerCase();
for (var anyCaseLang in dict.locales) {
anyCaseLang = anyCaseLang.toLowerCase();
if (anyCaseLang === lang) {
gL10nData = dict.locales[lang];
break;
} else if (anyCaseLang === defaultLocale) {
gL10nData = dict.locales[defaultLocale];
}
}
}
callback();
} else {
console.log('no resource to load, early way out');
}
fireL10nReadyEvent(lang);
gReadyState = 'complete';
return;
}
var onResourceLoaded = null;
var gResourceCount = 0;
onResourceLoaded = function onResourceLoaded() {
gResourceCount++;
if (gResourceCount >= langCount) {
callback();
fireL10nReadyEvent(lang);
gReadyState = 'complete';
}
};
function L10nResourceLink(link) {
var href = link.href;
this.load = function (lang, callback) {
parseResource(href, lang, callback, function () {
console.warn(href + ' not found.');
console.warn('"' + lang + '" resource not found');
gLanguage = '';
callback();
});
};
}
for (var i = 0; i < langCount; i++) {
var resource = new L10nResourceLink(langLinks[i]);
resource.load(lang, onResourceLoaded);
}
}
function clear() {
gL10nData = {};
gTextData = '';
gLanguage = '';
}
function getPluralRules(lang) {
var locales2rules = {
'af': 3,
'ak': 4,
'am': 4,
'ar': 1,
'asa': 3,
'az': 0,
'be': 11,
'bem': 3,
'bez': 3,
'bg': 3,
'bh': 4,
'bm': 0,
'bn': 3,
'bo': 0,
'br': 20,
'brx': 3,
'bs': 11,
'ca': 3,
'cgg': 3,
'chr': 3,
'cs': 12,
'cy': 17,
'da': 3,
'de': 3,
'dv': 3,
'dz': 0,
'ee': 3,
'el': 3,
'en': 3,
'eo': 3,
'es': 3,
'et': 3,
'eu': 3,
'fa': 0,
'ff': 5,
'fi': 3,
'fil': 4,
'fo': 3,
'fr': 5,
'fur': 3,
'fy': 3,
'ga': 8,
'gd': 24,
'gl': 3,
'gsw': 3,
'gu': 3,
'guw': 4,
'gv': 23,
'ha': 3,
'haw': 3,
'he': 2,
'hi': 4,
'hr': 11,
'hu': 0,
'id': 0,
'ig': 0,
'ii': 0,
'is': 3,
'it': 3,
'iu': 7,
'ja': 0,
'jmc': 3,
'jv': 0,
'ka': 0,
'kab': 5,
'kaj': 3,
'kcg': 3,
'kde': 0,
'kea': 0,
'kk': 3,
'kl': 3,
'km': 0,
'kn': 0,
'ko': 0,
'ksb': 3,
'ksh': 21,
'ku': 3,
'kw': 7,
'lag': 18,
'lb': 3,
'lg': 3,
'ln': 4,
'lo': 0,
'lt': 10,
'lv': 6,
'mas': 3,
'mg': 4,
'mk': 16,
'ml': 3,
'mn': 3,
'mo': 9,
'mr': 3,
'ms': 0,
'mt': 15,
'my': 0,
'nah': 3,
'naq': 7,
'nb': 3,
'nd': 3,
'ne': 3,
'nl': 3,
'nn': 3,
'no': 3,
'nr': 3,
'nso': 4,
'ny': 3,
'nyn': 3,
'om': 3,
'or': 3,
'pa': 3,
'pap': 3,
'pl': 13,
'ps': 3,
'pt': 3,
'rm': 3,
'ro': 9,
'rof': 3,
'ru': 11,
'rwk': 3,
'sah': 0,
'saq': 3,
'se': 7,
'seh': 3,
'ses': 0,
'sg': 0,
'sh': 11,
'shi': 19,
'sk': 12,
'sl': 14,
'sma': 7,
'smi': 7,
'smj': 7,
'smn': 7,
'sms': 7,
'sn': 3,
'so': 3,
'sq': 3,
'sr': 11,
'ss': 3,
'ssy': 3,
'st': 3,
'sv': 3,
'sw': 3,
'syr': 3,
'ta': 3,
'te': 3,
'teo': 3,
'th': 0,
'ti': 4,
'tig': 3,
'tk': 3,
'tl': 4,
'tn': 3,
'to': 0,
'tr': 0,
'ts': 3,
'tzm': 22,
'uk': 11,
'ur': 3,
've': 3,
'vi': 0,
'vun': 3,
'wa': 4,
'wae': 3,
'wo': 0,
'xh': 3,
'xog': 3,
'yo': 0,
'zh': 0,
'zu': 3
};
function isIn(n, list) {
return list.indexOf(n) !== -1;
}
function isBetween(n, start, end) {
return start <= n && n <= end;
}
var pluralRules = {
'0': function _(n) {
return 'other';
},
'1': function _(n) {
if (isBetween(n % 100, 3, 10)) return 'few';
if (n === 0) return 'zero';
if (isBetween(n % 100, 11, 99)) return 'many';
if (n == 2) return 'two';
if (n == 1) return 'one';
return 'other';
},
'2': function _(n) {
if (n !== 0 && n % 10 === 0) return 'many';
if (n == 2) return 'two';
if (n == 1) return 'one';
return 'other';
},
'3': function _(n) {
if (n == 1) return 'one';
return 'other';
},
'4': function _(n) {
if (isBetween(n, 0, 1)) return 'one';
return 'other';
},
'5': function _(n) {
if (isBetween(n, 0, 2) && n != 2) return 'one';
return 'other';
},
'6': function _(n) {
if (n === 0) return 'zero';
if (n % 10 == 1 && n % 100 != 11) return 'one';
return 'other';
},
'7': function _(n) {
if (n == 2) return 'two';
if (n == 1) return 'one';
return 'other';
},
'8': function _(n) {
if (isBetween(n, 3, 6)) return 'few';
if (isBetween(n, 7, 10)) return 'many';
if (n == 2) return 'two';
if (n == 1) return 'one';
return 'other';
},
'9': function _(n) {
if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
if (n == 1) return 'one';
return 'other';
},
'10': function _(n) {
if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
return 'other';
},
'11': function _(n) {
if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
if (n % 10 == 1 && n % 100 != 11) return 'one';
return 'other';
},
'12': function _(n) {
if (isBetween(n, 2, 4)) return 'few';
if (n == 1) return 'one';
return 'other';
},
'13': function _(n) {
if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
if (n == 1) return 'one';
return 'other';
},
'14': function _(n) {
if (isBetween(n % 100, 3, 4)) return 'few';
if (n % 100 == 2) return 'two';
if (n % 100 == 1) return 'one';
return 'other';
},
'15': function _(n) {
if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
if (isBetween(n % 100, 11, 19)) return 'many';
if (n == 1) return 'one';
return 'other';
},
'16': function _(n) {
if (n % 10 == 1 && n != 11) return 'one';
return 'other';
},
'17': function _(n) {
if (n == 3) return 'few';
if (n === 0) return 'zero';
if (n == 6) return 'many';
if (n == 2) return 'two';
if (n == 1) return 'one';
return 'other';
},
'18': function _(n) {
if (n === 0) return 'zero';
if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
return 'other';
},
'19': function _(n) {
if (isBetween(n, 2, 10)) return 'few';
if (isBetween(n, 0, 1)) return 'one';
return 'other';
},
'20': function _(n) {
if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
if (n % 1000000 === 0 && n !== 0) return 'many';
if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
return 'other';
},
'21': function _(n) {
if (n === 0) return 'zero';
if (n == 1) return 'one';
return 'other';
},
'22': function _(n) {
if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
return 'other';
},
'23': function _(n) {
if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
return 'other';
},
'24': function _(n) {
if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
if (isIn(n, [2, 12])) return 'two';
if (isIn(n, [1, 11])) return 'one';
return 'other';
}
};
var index = locales2rules[lang.replace(/-.*$/, '')];
if (!(index in pluralRules)) {
console.warn('plural form unknown for [' + lang + ']');
return function () {
return 'other';
};
}
return pluralRules[index];
}
gMacros.plural = function (str, param, key, prop) {
var n = parseFloat(param);
if (isNaN(n)) return str;
if (prop != gTextProp) return str;
if (!gMacros._pluralRules) {
gMacros._pluralRules = getPluralRules(gLanguage);
}
var index = '[' + gMacros._pluralRules(n) + ']';
if (n === 0 && key + '[zero]' in gL10nData) {
str = gL10nData[key + '[zero]'][prop];
} else if (n == 1 && key + '[one]' in gL10nData) {
str = gL10nData[key + '[one]'][prop];
} else if (n == 2 && key + '[two]' in gL10nData) {
str = gL10nData[key + '[two]'][prop];
} else if (key + index in gL10nData) {
str = gL10nData[key + index][prop];
} else if (key + '[other]' in gL10nData) {
str = gL10nData[key + '[other]'][prop];
}
return str;
};
function getL10nData(key, args, fallback) {
var data = gL10nData[key];
if (!data) {
console.warn('#' + key + ' is undefined.');
if (!fallback) {
return null;
}
data = fallback;
}
var rv = {};
for (var prop in data) {
var str = data[prop];
str = substIndexes(str, args, key, prop);
str = substArguments(str, args, key);
rv[prop] = str;
}
return rv;
}
function substIndexes(str, args, key, prop) {
var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
var reMatch = reIndex.exec(str);
if (!reMatch || !reMatch.length) return str;
var macroName = reMatch[1];
var paramName = reMatch[2];
var param;
if (args && paramName in args) {
param = args[paramName];
} else if (paramName in gL10nData) {
param = gL10nData[paramName];
}
if (macroName in gMacros) {
var macro = gMacros[macroName];
str = macro(str, param, key, prop);
}
return str;
}
function substArguments(str, args, key) {
var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
return str.replace(reArgs, function (matched_text, arg) {
if (args && arg in args) {
return args[arg];
}
if (arg in gL10nData) {
return gL10nData[arg];
}
console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
return matched_text;
});
}
function translateElement(element) {
var l10n = getL10nAttributes(element);
if (!l10n.id) return;
var data = getL10nData(l10n.id, l10n.args);
if (!data) {
console.warn('#' + l10n.id + ' is undefined.');
return;
}
if (data[gTextProp]) {
if (getChildElementCount(element) === 0) {
element[gTextProp] = data[gTextProp];
} else {
var children = element.childNodes;
var found = false;
for (var i = 0, l = children.length; i < l; i++) {
if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
if (found) {
children[i].nodeValue = '';
} else {
children[i].nodeValue = data[gTextProp];
found = true;
}
}
}
if (!found) {
var textNode = document.createTextNode(data[gTextProp]);
element.insertBefore(textNode, element.firstChild);
}
}
delete data[gTextProp];
}
for (var k in data) {
element[k] = data[k];
}
}
function getChildElementCount(element) {
if (element.children) {
return element.children.length;
}
if (typeof element.childElementCount !== 'undefined') {
return element.childElementCount;
}
var count = 0;
for (var i = 0; i < element.childNodes.length; i++) {
count += element.nodeType === 1 ? 1 : 0;
}
return count;
}
function translateFragment(element) {
element = element || document.documentElement;
var children = getTranslatableChildren(element);
var elementCount = children.length;
for (var i = 0; i < elementCount; i++) {
translateElement(children[i]);
}
translateElement(element);
}
return {
get: function get(key, args, fallbackString) {
var index = key.lastIndexOf('.');
var prop = gTextProp;
if (index > 0) {
prop = key.substr(index + 1);
key = key.substring(0, index);
}
var fallback;
if (fallbackString) {
fallback = {};
fallback[prop] = fallbackString;
}
var data = getL10nData(key, args, fallback);
if (data && prop in data) {
return data[prop];
}
return '{{' + key + '}}';
},
getData: function getData() {
return gL10nData;
},
getText: function getText() {
return gTextData;
},
getLanguage: function getLanguage() {
return gLanguage;
},
setLanguage: function setLanguage(lang, callback) {
loadLocale(lang, function () {
if (callback) callback();
});
},
getDirection: function getDirection() {
var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
var shortCode = gLanguage.split('-', 1)[0];
return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
},
translate: translateFragment,
getReadyState: function getReadyState() {
return gReadyState;
},
ready: function ready(callback) {
if (!callback) {
return;
} else if (gReadyState == 'complete' || gReadyState == 'interactive') {
window.setTimeout(function () {
callback();
});
} else if (document.addEventListener) {
document.addEventListener('localized', function once() {
document.removeEventListener('localized', once);
callback();
});
}
}
};
}(window, document);
/***/ }),
/* 14 */
/***/ (function(module, exports, __w_pdfjs_require__) {
"use strict";
var pdfjsLib = __w_pdfjs_require__(0);
var pdfjsWebPDFViewer = __w_pdfjs_require__(11);
var pdfjsWebPDFViewer = __w_pdfjs_require__(12);
var pdfjsWebPDFPageView = __w_pdfjs_require__(5);
var pdfjsWebPDFLinkService = __w_pdfjs_require__(3);
var pdfjsWebTextLayerBuilder = __w_pdfjs_require__(6);
var pdfjsWebAnnotationLayerBuilder = __w_pdfjs_require__(4);
var pdfjsWebPDFHistory = __w_pdfjs_require__(10);
var pdfjsWebPDFFindController = __w_pdfjs_require__(9);
var pdfjsWebPDFHistory = __w_pdfjs_require__(11);
var pdfjsWebPDFFindController = __w_pdfjs_require__(10);
var pdfjsWebUIUtils = __w_pdfjs_require__(1);
var pdfjsWebDownloadManager = __w_pdfjs_require__(8);
var pdfjsWebGenericL10n = __w_pdfjs_require__(9);
var PDFJS = pdfjsLib.PDFJS;
PDFJS.PDFViewer = pdfjsWebPDFViewer.PDFViewer;
PDFJS.PDFPageView = pdfjsWebPDFPageView.PDFPageView;
@ -3560,6 +4366,8 @@ PDFJS.PDFFindController = pdfjsWebPDFFindController.PDFFindController; @@ -3560,6 +4366,8 @@ PDFJS.PDFFindController = pdfjsWebPDFFindController.PDFFindController;
PDFJS.EventBus = pdfjsWebUIUtils.EventBus;
PDFJS.DownloadManager = pdfjsWebDownloadManager.DownloadManager;
PDFJS.ProgressBar = pdfjsWebUIUtils.ProgressBar;
PDFJS.GenericL10n = pdfjsWebGenericL10n.GenericL10n;
PDFJS.NullL10n = pdfjsWebUIUtils.NullL10n;
exports.PDFJS = PDFJS;
/***/ })

2
web/pdf_viewer.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save