Browse Source

PDF.js version 1.8.199 - See mozilla/pdf.js@74b31ab18f1a368963f7337e2b7313a5f335e618

master v1.8.199
pdfjsbot 8 years ago
parent
commit
6e6bd7ea0e
  1. 2
      bower.json
  2. 12
      build/pdf.combined.js
  3. 12
      build/pdf.js
  4. 4
      build/pdf.min.js
  5. 4
      build/pdf.worker.js
  6. 4
      lib/display/api.js
  7. 4
      lib/display/global.js
  8. 4
      lib/pdf.js
  9. 4
      lib/pdf.worker.js
  10. 26
      lib/web/annotation_layer_builder.js
  11. 510
      lib/web/app.js
  12. 265
      lib/web/chromecom.js
  13. 11
      lib/web/dom_events.js
  14. 22
      lib/web/download_manager.js
  15. 24
      lib/web/firefox_print_service.js
  16. 216
      lib/web/firefoxcom.js
  17. 3
      lib/web/grab_to_pan.js
  18. 21
      lib/web/hand_tool.js
  19. 3
      lib/web/overlay_manager.js
  20. 28
      lib/web/password_prompt.js
  21. 17
      lib/web/pdf_attachment_viewer.js
  22. 30
      lib/web/pdf_document_properties.js
  23. 27
      lib/web/pdf_find_bar.js
  24. 11
      lib/web/pdf_find_controller.js
  25. 10
      lib/web/pdf_history.js
  26. 16
      lib/web/pdf_link_service.js
  27. 15
      lib/web/pdf_outline_viewer.js
  28. 98
      lib/web/pdf_page_view.js
  29. 11
      lib/web/pdf_presentation_mode.js
  30. 43
      lib/web/pdf_print_service.js
  31. 5
      lib/web/pdf_rendering_queue.js
  32. 19
      lib/web/pdf_sidebar.js
  33. 46
      lib/web/pdf_thumbnail_view.js
  34. 27
      lib/web/pdf_thumbnail_viewer.js
  35. 110
      lib/web/pdf_viewer.js
  36. 31
      lib/web/preferences.js
  37. 20
      lib/web/secondary_toolbar.js
  38. 15
      lib/web/text_layer_builder.js
  39. 36
      lib/web/toolbar.js
  40. 25
      lib/web/ui_utils.js
  41. 3
      lib/web/view_history.js
  42. 2
      package.json
  43. 7922
      web/pdf_viewer.js

2
bower.json

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

12
build/pdf.combined.js

@ -12778,8 +12778,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -12778,8 +12778,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}
};
}();
exports.version = '1.8.195';
exports.build = 'c4c44c1b';
exports.version = '1.8.199';
exports.build = '74b31ab1';
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;
exports.PDFWorker = PDFWorker;
@ -28040,8 +28040,8 @@ if (!globalScope.PDFJS) { @@ -28040,8 +28040,8 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS = {};
}
var PDFJS = globalScope.PDFJS;
PDFJS.version = '1.8.195';
PDFJS.build = 'c4c44c1b';
PDFJS.version = '1.8.199';
PDFJS.build = '74b31ab1';
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
sharedUtil.setVerbosityLevel(PDFJS.verbosity);
@ -43578,8 +43578,8 @@ exports.TilingPattern = TilingPattern; @@ -43578,8 +43578,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.195';
var pdfjsBuild = 'c4c44c1b';
var pdfjsVersion = '1.8.199';
var pdfjsBuild = '74b31ab1';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
var pdfjsDisplayAPI = __w_pdfjs_require__(10);

12
build/pdf.js

@ -3492,8 +3492,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -3492,8 +3492,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}
};
}();
exports.version = '1.8.195';
exports.build = 'c4c44c1b';
exports.version = '1.8.199';
exports.build = '74b31ab1';
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;
exports.PDFWorker = PDFWorker;
@ -5432,8 +5432,8 @@ if (!globalScope.PDFJS) { @@ -5432,8 +5432,8 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS = {};
}
var PDFJS = globalScope.PDFJS;
PDFJS.version = '1.8.195';
PDFJS.build = 'c4c44c1b';
PDFJS.version = '1.8.199';
PDFJS.build = '74b31ab1';
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
sharedUtil.setVerbosityLevel(PDFJS.verbosity);
@ -7934,8 +7934,8 @@ exports.TilingPattern = TilingPattern; @@ -7934,8 +7934,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.195';
var pdfjsBuild = 'c4c44c1b';
var pdfjsVersion = '1.8.199';
var pdfjsBuild = '74b31ab1';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
var pdfjsDisplayAPI = __w_pdfjs_require__(3);

4
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

4
build/pdf.worker.js vendored

@ -36985,8 +36985,8 @@ exports.Type1Parser = Type1Parser; @@ -36985,8 +36985,8 @@ exports.Type1Parser = Type1Parser;
"use strict";
var pdfjsVersion = '1.8.195';
var pdfjsBuild = 'c4c44c1b';
var pdfjsVersion = '1.8.199';
var pdfjsBuild = '74b31ab1';
var pdfjsCoreWorker = __w_pdfjs_require__(8);
{
__w_pdfjs_require__(19);

4
lib/display/api.js

@ -1379,8 +1379,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -1379,8 +1379,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}
};
}();
exports.version = '1.8.195';
exports.build = 'c4c44c1b';
exports.version = '1.8.199';
exports.build = '74b31ab1';
exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport;
exports.PDFWorker = PDFWorker;

4
lib/display/global.js

@ -31,8 +31,8 @@ if (!globalScope.PDFJS) { @@ -31,8 +31,8 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS = {};
}
var PDFJS = globalScope.PDFJS;
PDFJS.version = '1.8.195';
PDFJS.build = 'c4c44c1b';
PDFJS.version = '1.8.199';
PDFJS.build = '74b31ab1';
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
sharedUtil.setVerbosityLevel(PDFJS.verbosity);

4
lib/pdf.js

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.8.195';
var pdfjsBuild = 'c4c44c1b';
var pdfjsVersion = '1.8.199';
var pdfjsBuild = '74b31ab1';
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.195';
var pdfjsBuild = 'c4c44c1b';
var pdfjsVersion = '1.8.199';
var pdfjsBuild = '74b31ab1';
var pdfjsCoreWorker = require('./core/worker.js');
{
require('./core/network.js');

26
lib/web/annotation_layer_builder.js

@ -14,11 +14,17 @@ @@ -14,11 +14,17 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var pdfLinkService = require('./pdf_link_service.js');
var pdfjsLib = require('./pdfjs.js');
var mozL10n = uiUtils.mozL10n;
var SimpleLinkService = pdfLinkService.SimpleLinkService;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
var _pdfjs = require('pdfjs-web/pdfjs');
var _ui_utils = require('pdfjs-web/ui_utils');
var _pdf_link_service = require('pdfjs-web/pdf_link_service');
var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() {
function AnnotationLayerBuilder(options) {
this.pageDiv = options.pageDiv;
@ -44,7 +50,7 @@ var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() { @@ -44,7 +50,7 @@ var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() {
downloadManager: self.downloadManager
};
if (self.div) {
pdfjsLib.AnnotationLayer.update(parameters);
_pdfjs.AnnotationLayer.update(parameters);
} else {
if (annotations.length === 0) {
return;
@ -53,9 +59,9 @@ var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() { @@ -53,9 +59,9 @@ var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() {
self.div.className = 'annotationLayer';
self.pageDiv.appendChild(self.div);
parameters.div = self.div;
pdfjsLib.AnnotationLayer.render(parameters);
if (typeof mozL10n !== 'undefined') {
mozL10n.translate(self.div);
_pdfjs.AnnotationLayer.render(parameters);
if (typeof _ui_utils.mozL10n !== 'undefined') {
_ui_utils.mozL10n.translate(self.div);
}
}
});
@ -76,7 +82,7 @@ DefaultAnnotationLayerFactory.prototype = { @@ -76,7 +82,7 @@ DefaultAnnotationLayerFactory.prototype = {
pageDiv: pageDiv,
pdfPage: pdfPage,
renderInteractiveForms: renderInteractiveForms,
linkService: new SimpleLinkService()
linkService: new _pdf_link_service.SimpleLinkService()
});
}
};

510
lib/web/app.js

@ -14,65 +14,55 @@ @@ -14,65 +14,55 @@
*/
'use strict';
var uiUtilsLib = require('./ui_utils.js');
var downloadManagerLib = require('./download_manager.js');
var pdfHistoryLib = require('./pdf_history.js');
var preferencesLib = require('./preferences.js');
var pdfSidebarLib = require('./pdf_sidebar.js');
var viewHistoryLib = require('./view_history.js');
var pdfThumbnailViewerLib = require('./pdf_thumbnail_viewer.js');
var toolbarLib = require('./toolbar.js');
var secondaryToolbarLib = require('./secondary_toolbar.js');
var passwordPromptLib = require('./password_prompt.js');
var pdfPresentationModeLib = require('./pdf_presentation_mode.js');
var pdfDocumentPropertiesLib = require('./pdf_document_properties.js');
var handToolLib = require('./hand_tool.js');
var pdfViewerLib = require('./pdf_viewer.js');
var pdfRenderingQueueLib = require('./pdf_rendering_queue.js');
var pdfLinkServiceLib = require('./pdf_link_service.js');
var pdfOutlineViewerLib = require('./pdf_outline_viewer.js');
var overlayManagerLib = require('./overlay_manager.js');
var pdfAttachmentViewerLib = require('./pdf_attachment_viewer.js');
var pdfFindControllerLib = require('./pdf_find_controller.js');
var pdfFindBarLib = require('./pdf_find_bar.js');
var domEventsLib = require('./dom_events.js');
var pdfjsLib = require('./pdfjs.js');
var UNKNOWN_SCALE = uiUtilsLib.UNKNOWN_SCALE;
var DEFAULT_SCALE_VALUE = uiUtilsLib.DEFAULT_SCALE_VALUE;
var MIN_SCALE = uiUtilsLib.MIN_SCALE;
var MAX_SCALE = uiUtilsLib.MAX_SCALE;
var ProgressBar = uiUtilsLib.ProgressBar;
var getPDFFileNameFromURL = uiUtilsLib.getPDFFileNameFromURL;
var noContextMenuHandler = uiUtilsLib.noContextMenuHandler;
var mozL10n = uiUtilsLib.mozL10n;
var parseQueryString = uiUtilsLib.parseQueryString;
var PDFHistory = pdfHistoryLib.PDFHistory;
var Preferences = preferencesLib.Preferences;
var SidebarView = pdfSidebarLib.SidebarView;
var PDFSidebar = pdfSidebarLib.PDFSidebar;
var ViewHistory = viewHistoryLib.ViewHistory;
var PDFThumbnailViewer = pdfThumbnailViewerLib.PDFThumbnailViewer;
var Toolbar = toolbarLib.Toolbar;
var SecondaryToolbar = secondaryToolbarLib.SecondaryToolbar;
var PasswordPrompt = passwordPromptLib.PasswordPrompt;
var PDFPresentationMode = pdfPresentationModeLib.PDFPresentationMode;
var PDFDocumentProperties = pdfDocumentPropertiesLib.PDFDocumentProperties;
var HandTool = handToolLib.HandTool;
var PresentationModeState = pdfViewerLib.PresentationModeState;
var PDFViewer = pdfViewerLib.PDFViewer;
var RenderingStates = pdfRenderingQueueLib.RenderingStates;
var PDFRenderingQueue = pdfRenderingQueueLib.PDFRenderingQueue;
var PDFLinkService = pdfLinkServiceLib.PDFLinkService;
var PDFOutlineViewer = pdfOutlineViewerLib.PDFOutlineViewer;
var OverlayManager = overlayManagerLib.OverlayManager;
var PDFAttachmentViewer = pdfAttachmentViewerLib.PDFAttachmentViewer;
var PDFFindController = pdfFindControllerLib.PDFFindController;
var PDFFindBar = pdfFindBarLib.PDFFindBar;
var getGlobalEventBus = domEventsLib.getGlobalEventBus;
var normalizeWheelEventDelta = uiUtilsLib.normalizeWheelEventDelta;
var animationStarted = uiUtilsLib.animationStarted;
var localized = uiUtilsLib.localized;
var RendererType = uiUtilsLib.RendererType;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _pdfjs = require('pdfjs-web/pdfjs');
var _pdf_rendering_queue = require('pdfjs-web/pdf_rendering_queue');
var _pdf_sidebar = require('pdfjs-web/pdf_sidebar');
var _pdf_viewer = require('pdfjs-web/pdf_viewer');
var _dom_events = require('pdfjs-web/dom_events');
var _hand_tool = require('pdfjs-web/hand_tool');
var _overlay_manager = require('pdfjs-web/overlay_manager');
var _password_prompt = require('pdfjs-web/password_prompt');
var _pdf_attachment_viewer = require('pdfjs-web/pdf_attachment_viewer');
var _pdf_document_properties = require('pdfjs-web/pdf_document_properties');
var _pdf_find_bar = require('pdfjs-web/pdf_find_bar');
var _pdf_find_controller = require('pdfjs-web/pdf_find_controller');
var _pdf_history = require('pdfjs-web/pdf_history');
var _pdf_link_service = require('pdfjs-web/pdf_link_service');
var _pdf_outline_viewer = require('pdfjs-web/pdf_outline_viewer');
var _pdf_presentation_mode = require('pdfjs-web/pdf_presentation_mode');
var _pdf_thumbnail_viewer = require('pdfjs-web/pdf_thumbnail_viewer');
var _preferences = require('pdfjs-web/preferences');
var _secondary_toolbar = require('pdfjs-web/secondary_toolbar');
var _toolbar = require('pdfjs-web/toolbar');
var _view_history = require('pdfjs-web/view_history');
var DEFAULT_SCALE_DELTA = 1.1;
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
function configure(PDFJS) {
@ -81,13 +71,13 @@ function configure(PDFJS) { @@ -81,13 +71,13 @@ function configure(PDFJS) {
PDFJS.cMapUrl = '../web/cmaps/';
PDFJS.cMapPacked = true;
}
var DefaultExernalServices = {
var DefaultExternalServices = {
updateFindControlState: function (data) {},
initPassiveLoading: function (callbacks) {},
fallback: function (data, callback) {},
reportTelemetry: function (data) {},
createDownloadManager: function () {
return new downloadManagerLib.DownloadManager();
throw new Error('Not implemented: createDownloadManager');
},
supportsIntegratedFind: false,
supportsDocumentFonts: true,
@ -124,7 +114,7 @@ var PDFViewerApplication = { @@ -124,7 +114,7 @@ var PDFViewerApplication = {
pageRotation: 0,
isInitialViewSet: false,
viewerPrefs: {
sidebarViewOnLoad: SidebarView.NONE,
sidebarViewOnLoad: _pdf_sidebar.SidebarView.NONE,
pdfBugEnabled: false,
showPreviousViewOnLoad: true,
defaultZoomValue: '',
@ -137,79 +127,77 @@ var PDFViewerApplication = { @@ -137,79 +127,77 @@ var PDFViewerApplication = {
isViewerEmbedded: window.parent !== window,
url: '',
baseUrl: '',
externalServices: DefaultExernalServices,
externalServices: DefaultExternalServices,
initialize: function pdfViewInitialize(appConfig) {
var self = this;
var PDFJS = pdfjsLib.PDFJS;
Preferences.initialize();
this.preferences = Preferences;
configure(PDFJS);
_preferences.Preferences.initialize();
this.preferences = _preferences.Preferences;
configure(_pdfjs.PDFJS);
this.appConfig = appConfig;
return this._readPreferences().then(function () {
return self._initializeViewerComponents();
}).then(function () {
self.bindEvents();
self.bindWindowEvents();
localized.then(function () {
_ui_utils.localized.then(function () {
self.eventBus.dispatch('localized');
});
if (self.isViewerEmbedded && !PDFJS.isExternalLinkTargetSet()) {
PDFJS.externalLinkTarget = PDFJS.LinkTarget.TOP;
if (self.isViewerEmbedded && !_pdfjs.PDFJS.isExternalLinkTargetSet()) {
_pdfjs.PDFJS.externalLinkTarget = _pdfjs.PDFJS.LinkTarget.TOP;
}
self.initialized = true;
});
},
_readPreferences: function () {
var self = this;
var PDFJS = pdfjsLib.PDFJS;
return Promise.all([Preferences.get('enableWebGL').then(function resolved(value) {
PDFJS.disableWebGL = !value;
}), Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
return Promise.all([_preferences.Preferences.get('enableWebGL').then(function resolved(value) {
_pdfjs.PDFJS.disableWebGL = !value;
}), _preferences.Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
self.viewerPrefs['sidebarViewOnLoad'] = value;
}), Preferences.get('pdfBugEnabled').then(function resolved(value) {
}), _preferences.Preferences.get('pdfBugEnabled').then(function resolved(value) {
self.viewerPrefs['pdfBugEnabled'] = value;
}), Preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
}), _preferences.Preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
self.viewerPrefs['showPreviousViewOnLoad'] = value;
}), Preferences.get('defaultZoomValue').then(function resolved(value) {
}), _preferences.Preferences.get('defaultZoomValue').then(function resolved(value) {
self.viewerPrefs['defaultZoomValue'] = value;
}), Preferences.get('enhanceTextSelection').then(function resolved(value) {
}), _preferences.Preferences.get('enhanceTextSelection').then(function resolved(value) {
self.viewerPrefs['enhanceTextSelection'] = value;
}), Preferences.get('disableTextLayer').then(function resolved(value) {
if (PDFJS.disableTextLayer === true) {
}), _preferences.Preferences.get('disableTextLayer').then(function resolved(value) {
if (_pdfjs.PDFJS.disableTextLayer === true) {
return;
}
PDFJS.disableTextLayer = value;
}), Preferences.get('disableRange').then(function resolved(value) {
if (PDFJS.disableRange === true) {
_pdfjs.PDFJS.disableTextLayer = value;
}), _preferences.Preferences.get('disableRange').then(function resolved(value) {
if (_pdfjs.PDFJS.disableRange === true) {
return;
}
PDFJS.disableRange = value;
}), Preferences.get('disableStream').then(function resolved(value) {
if (PDFJS.disableStream === true) {
_pdfjs.PDFJS.disableRange = value;
}), _preferences.Preferences.get('disableStream').then(function resolved(value) {
if (_pdfjs.PDFJS.disableStream === true) {
return;
}
PDFJS.disableStream = value;
}), Preferences.get('disableAutoFetch').then(function resolved(value) {
PDFJS.disableAutoFetch = value;
}), Preferences.get('disableFontFace').then(function resolved(value) {
if (PDFJS.disableFontFace === true) {
_pdfjs.PDFJS.disableStream = value;
}), _preferences.Preferences.get('disableAutoFetch').then(function resolved(value) {
_pdfjs.PDFJS.disableAutoFetch = value;
}), _preferences.Preferences.get('disableFontFace').then(function resolved(value) {
if (_pdfjs.PDFJS.disableFontFace === true) {
return;
}
PDFJS.disableFontFace = value;
}), Preferences.get('useOnlyCssZoom').then(function resolved(value) {
PDFJS.useOnlyCssZoom = value;
}), Preferences.get('externalLinkTarget').then(function resolved(value) {
if (PDFJS.isExternalLinkTargetSet()) {
_pdfjs.PDFJS.disableFontFace = value;
}), _preferences.Preferences.get('useOnlyCssZoom').then(function resolved(value) {
_pdfjs.PDFJS.useOnlyCssZoom = value;
}), _preferences.Preferences.get('externalLinkTarget').then(function resolved(value) {
if (_pdfjs.PDFJS.isExternalLinkTargetSet()) {
return;
}
PDFJS.externalLinkTarget = value;
}), Preferences.get('renderer').then(function resolved(value) {
_pdfjs.PDFJS.externalLinkTarget = value;
}), _preferences.Preferences.get('renderer').then(function resolved(value) {
self.viewerPrefs['renderer'] = value;
}), Preferences.get('renderInteractiveForms').then(function resolved(value) {
}), _preferences.Preferences.get('renderInteractiveForms').then(function resolved(value) {
self.viewerPrefs['renderInteractiveForms'] = value;
}), Preferences.get('disablePageLabels').then(function resolved(value) {
}), _preferences.Preferences.get('disablePageLabels').then(function resolved(value) {
self.viewerPrefs['disablePageLabels'] = value;
}), Preferences.get('enablePrintAutoRotate').then(function resolved(value) {
}), _preferences.Preferences.get('enablePrintAutoRotate').then(function resolved(value) {
self.viewerPrefs['enablePrintAutoRotate'] = value;
})]).catch(function (reason) {});
},
@ -217,18 +205,18 @@ var PDFViewerApplication = { @@ -217,18 +205,18 @@ var PDFViewerApplication = {
var self = this;
var appConfig = this.appConfig;
return new Promise(function (resolve, reject) {
var eventBus = appConfig.eventBus || getGlobalEventBus();
var eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)();
self.eventBus = eventBus;
var pdfRenderingQueue = new PDFRenderingQueue();
var pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
pdfRenderingQueue.onIdle = self.cleanup.bind(self);
self.pdfRenderingQueue = pdfRenderingQueue;
var pdfLinkService = new PDFLinkService({ eventBus: eventBus });
var pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus: eventBus });
self.pdfLinkService = pdfLinkService;
var downloadManager = self.externalServices.createDownloadManager();
self.downloadManager = downloadManager;
var container = appConfig.mainContainer;
var viewer = appConfig.viewerContainer;
self.pdfViewer = new PDFViewer({
self.pdfViewer = new _pdf_viewer.PDFViewer({
container: container,
viewer: viewer,
eventBus: eventBus,
@ -243,18 +231,18 @@ var PDFViewerApplication = { @@ -243,18 +231,18 @@ var PDFViewerApplication = {
pdfRenderingQueue.setViewer(self.pdfViewer);
pdfLinkService.setViewer(self.pdfViewer);
var thumbnailContainer = appConfig.sidebar.thumbnailView;
self.pdfThumbnailViewer = new PDFThumbnailViewer({
self.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
container: thumbnailContainer,
renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService
});
pdfRenderingQueue.setThumbnailViewer(self.pdfThumbnailViewer);
self.pdfHistory = new PDFHistory({
self.pdfHistory = new _pdf_history.PDFHistory({
linkService: pdfLinkService,
eventBus: eventBus
});
pdfLinkService.setHistory(self.pdfHistory);
self.findController = new PDFFindController({ pdfViewer: self.pdfViewer });
self.findController = new _pdf_find_controller.PDFFindController({ pdfViewer: self.pdfViewer });
self.findController.onUpdateResultsCount = function (matchCount) {
if (self.supportsIntegratedFind) {
return;
@ -275,17 +263,17 @@ var PDFViewerApplication = { @@ -275,17 +263,17 @@ var PDFViewerApplication = {
var findBarConfig = Object.create(appConfig.findBar);
findBarConfig.findController = self.findController;
findBarConfig.eventBus = eventBus;
self.findBar = new PDFFindBar(findBarConfig);
self.overlayManager = OverlayManager;
self.handTool = new HandTool({
self.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig);
self.overlayManager = _overlay_manager.OverlayManager;
self.handTool = new _hand_tool.HandTool({
container: container,
eventBus: eventBus
});
self.pdfDocumentProperties = new PDFDocumentProperties(appConfig.documentProperties);
self.toolbar = new Toolbar(appConfig.toolbar, container, eventBus);
self.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
self.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties);
self.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus);
self.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
if (self.supportsFullscreen) {
self.pdfPresentationMode = new PDFPresentationMode({
self.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
container: container,
viewer: viewer,
pdfViewer: self.pdfViewer,
@ -293,13 +281,13 @@ var PDFViewerApplication = { @@ -293,13 +281,13 @@ var PDFViewerApplication = {
contextMenuItems: appConfig.fullscreen
});
}
self.passwordPrompt = new PasswordPrompt(appConfig.passwordOverlay);
self.pdfOutlineViewer = new PDFOutlineViewer({
self.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay);
self.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
container: appConfig.sidebar.outlineView,
eventBus: eventBus,
linkService: pdfLinkService
});
self.pdfAttachmentViewer = new PDFAttachmentViewer({
self.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
container: appConfig.sidebar.attachmentsView,
eventBus: eventBus,
downloadManager: downloadManager
@ -309,7 +297,7 @@ var PDFViewerApplication = { @@ -309,7 +297,7 @@ var PDFViewerApplication = {
sidebarConfig.pdfThumbnailViewer = self.pdfThumbnailViewer;
sidebarConfig.pdfOutlineViewer = self.pdfOutlineViewer;
sidebarConfig.eventBus = eventBus;
self.pdfSidebar = new PDFSidebar(sidebarConfig);
self.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig);
self.pdfSidebar.onToggled = self.forceRendering.bind(self);
resolve(undefined);
});
@ -322,8 +310,8 @@ var PDFViewerApplication = { @@ -322,8 +310,8 @@ var PDFViewerApplication = {
do {
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
newScale = Math.ceil(newScale * 10) / 10;
newScale = Math.min(MAX_SCALE, newScale);
} while (--ticks > 0 && newScale < MAX_SCALE);
newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
} while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
this.pdfViewer.currentScaleValue = newScale;
},
zoomOut: function pdfViewZoomOut(ticks) {
@ -331,8 +319,8 @@ var PDFViewerApplication = { @@ -331,8 +319,8 @@ var PDFViewerApplication = {
do {
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
newScale = Math.floor(newScale * 10) / 10;
newScale = Math.max(MIN_SCALE, newScale);
} while (--ticks > 0 && newScale > MIN_SCALE);
newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
} while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
this.pdfViewer.currentScaleValue = newScale;
},
get pagesCount() {
@ -357,10 +345,10 @@ var PDFViewerApplication = { @@ -357,10 +345,10 @@ var PDFViewerApplication = {
if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
support = false;
}
if (support && pdfjsLib.PDFJS.disableFullscreen === true) {
if (support && _pdfjs.PDFJS.disableFullscreen === true) {
support = false;
}
return pdfjsLib.shadow(this, 'supportsFullscreen', support);
return (0, _pdfjs.shadow)(this, 'supportsFullscreen', support);
},
get supportsIntegratedFind() {
return this.externalServices.supportsIntegratedFind;
@ -372,8 +360,8 @@ var PDFViewerApplication = { @@ -372,8 +360,8 @@ var PDFViewerApplication = {
return this.externalServices.supportsDocumentColors;
},
get loadingBar() {
var bar = new ProgressBar('#loadingBar', {});
return pdfjsLib.shadow(this, 'loadingBar', bar);
var bar = new _ui_utils.ProgressBar('#loadingBar', {});
return (0, _pdfjs.shadow)(this, 'loadingBar', bar);
},
get supportedMouseWheelZoomModifierKeys() {
return this.externalServices.supportedMouseWheelZoomModifierKeys;
@ -384,10 +372,10 @@ var PDFViewerApplication = { @@ -384,10 +372,10 @@ var PDFViewerApplication = {
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
this.url = url;
this.baseUrl = url.split('#')[0];
var title = getPDFFileNameFromURL(url, '');
var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
if (!title) {
try {
title = decodeURIComponent(pdfjsLib.getFilenameFromUrl(url)) || url;
title = decodeURIComponent((0, _pdfjs.getFilenameFromUrl)(url)) || url;
} catch (e) {
title = url;
}
@ -434,7 +422,7 @@ var PDFViewerApplication = { @@ -434,7 +422,7 @@ var PDFViewerApplication = {
}
if (this.pdfLoadingTask) {
return this.close().then(function () {
Preferences.reload();
_preferences.Preferences.reload();
return this.open(file, args);
}.bind(this));
}
@ -462,7 +450,7 @@ var PDFViewerApplication = { @@ -462,7 +450,7 @@ var PDFViewerApplication = {
}
var self = this;
self.downloadComplete = false;
var loadingTask = pdfjsLib.getDocument(parameters);
var loadingTask = (0, _pdfjs.getDocument)(parameters);
this.pdfLoadingTask = loadingTask;
loadingTask.onPassword = function passwordNeeded(updateCallback, reason) {
self.passwordPrompt.setUpdateCallback(updateCallback, reason);
@ -476,13 +464,13 @@ var PDFViewerApplication = { @@ -476,13 +464,13 @@ var PDFViewerApplication = {
self.load(pdfDocument, scale);
}, function getDocumentError(exception) {
var message = exception && exception.message;
var loadingErrorMessage = mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
if (exception instanceof pdfjsLib.InvalidPDFException) {
loadingErrorMessage = mozL10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
} else if (exception instanceof pdfjsLib.MissingPDFException) {
loadingErrorMessage = mozL10n.get('missing_file_error', null, 'Missing PDF file.');
} else if (exception instanceof pdfjsLib.UnexpectedResponseException) {
loadingErrorMessage = mozL10n.get('unexpected_response_error', null, 'Unexpected server response.');
var loadingErrorMessage = _ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
if (exception instanceof _pdfjs.InvalidPDFException) {
loadingErrorMessage = _ui_utils.mozL10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
} else if (exception instanceof _pdfjs.MissingPDFException) {
loadingErrorMessage = _ui_utils.mozL10n.get('missing_file_error', null, 'Missing PDF file.');
} else if (exception instanceof _pdfjs.UnexpectedResponseException) {
loadingErrorMessage = _ui_utils.mozL10n.get('unexpected_response_error', null, 'Unexpected server response.');
}
var moreInfo = { message: message };
self.error(loadingErrorMessage, moreInfo);
@ -494,7 +482,7 @@ var PDFViewerApplication = { @@ -494,7 +482,7 @@ var PDFViewerApplication = {
downloadManager.downloadUrl(url, filename);
}
var url = this.baseUrl;
var filename = getPDFFileNameFromURL(this.url);
var filename = (0, _ui_utils.getPDFFileNameFromURL)(this.url);
var downloadManager = this.downloadManager;
downloadManager.onerror = function (err) {
PDFViewerApplication.error('PDF failed to download.');
@ -508,26 +496,26 @@ var PDFViewerApplication = { @@ -508,26 +496,26 @@ var PDFViewerApplication = {
return;
}
this.pdfDocument.getData().then(function getDataSuccess(data) {
var blob = pdfjsLib.createBlob(data, 'application/pdf');
var blob = (0, _pdfjs.createBlob)(data, 'application/pdf');
downloadManager.download(blob, url, filename);
}, downloadByUrl).then(null, downloadByUrl);
},
fallback: function pdfViewFallback(featureId) {},
error: function pdfViewError(message, moreInfo) {
var moreInfoText = mozL10n.get('error_version_info', {
version: pdfjsLib.version || '?',
build: pdfjsLib.build || '?'
var moreInfoText = _ui_utils.mozL10n.get('error_version_info', {
version: _pdfjs.version || '?',
build: _pdfjs.build || '?'
}, 'PDF.js v{{version}} (build: {{build}})') + '\n';
if (moreInfo) {
moreInfoText += mozL10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}');
moreInfoText += _ui_utils.mozL10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}');
if (moreInfo.stack) {
moreInfoText += '\n' + mozL10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}');
moreInfoText += '\n' + _ui_utils.mozL10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}');
} else {
if (moreInfo.filename) {
moreInfoText += '\n' + mozL10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}');
moreInfoText += '\n' + _ui_utils.mozL10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}');
}
if (moreInfo.lineNumber) {
moreInfoText += '\n' + mozL10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}');
moreInfoText += '\n' + _ui_utils.mozL10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}');
}
}
}
@ -554,9 +542,9 @@ var PDFViewerApplication = { @@ -554,9 +542,9 @@ var PDFViewerApplication = {
moreInfoButton.removeAttribute('hidden');
lessInfoButton.setAttribute('hidden', 'true');
};
moreInfoButton.oncontextmenu = noContextMenuHandler;
lessInfoButton.oncontextmenu = noContextMenuHandler;
closeButton.oncontextmenu = noContextMenuHandler;
moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
moreInfoButton.removeAttribute('hidden');
lessInfoButton.setAttribute('hidden', 'true');
errorMoreInfo.value = moreInfoText;
@ -565,7 +553,7 @@ var PDFViewerApplication = { @@ -565,7 +553,7 @@ var PDFViewerApplication = {
var percent = Math.round(level * 100);
if (percent > this.loadingBar.percent || isNaN(percent)) {
this.loadingBar.percent = percent;
if (pdfjsLib.PDFJS.disableAutoFetch && percent) {
if (_pdfjs.PDFJS.disableAutoFetch && percent) {
if (this.disableAutoFetchLoadingBarTimeout) {
clearTimeout(this.disableAutoFetchLoadingBarTimeout);
this.disableAutoFetchLoadingBarTimeout = null;
@ -580,7 +568,7 @@ var PDFViewerApplication = { @@ -580,7 +568,7 @@ var PDFViewerApplication = {
},
load: function pdfViewLoad(pdfDocument, scale) {
var self = this;
scale = scale || UNKNOWN_SCALE;
scale = scale || _ui_utils.UNKNOWN_SCALE;
this.pdfDocument = pdfDocument;
this.pdfDocumentProperties.setDocumentAndUrl(pdfDocument, this.url);
var downloadedPromise = pdfDocument.getDownloadInfo().then(function () {
@ -590,7 +578,7 @@ var PDFViewerApplication = { @@ -590,7 +578,7 @@ var PDFViewerApplication = {
this.toolbar.setPagesCount(pdfDocument.numPages, false);
this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
var id = this.documentFingerprint = pdfDocument.fingerprint;
var store = this.store = new ViewHistory(id);
var store = this.store = new _view_history.ViewHistory(id);
var baseDocumentUrl;
baseDocumentUrl = null;
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
@ -608,7 +596,7 @@ var PDFViewerApplication = { @@ -608,7 +596,7 @@ var PDFViewerApplication = {
self.eventBus.dispatch('documentload', { source: self });
});
self.loadingBar.setWidth(self.appConfig.viewerContainer);
if (!pdfjsLib.PDFJS.disableHistory && !self.isViewerEmbedded) {
if (!_pdfjs.PDFJS.disableHistory && !self.isViewerEmbedded) {
if (!self.viewerPrefs['showPreviousViewOnLoad']) {
self.pdfHistory.clearHistoryState();
}
@ -629,11 +617,11 @@ var PDFViewerApplication = { @@ -629,11 +617,11 @@ var PDFViewerApplication = {
sidebarView = null;
if (self.viewerPrefs['showPreviousViewOnLoad'] && store.get('exists', false)) {
var pageNum = store.get('page', '1');
var zoom = self.viewerPrefs['defaultZoomValue'] || store.get('zoom', DEFAULT_SCALE_VALUE);
var zoom = self.viewerPrefs['defaultZoomValue'] || store.get('zoom', _ui_utils.DEFAULT_SCALE_VALUE);
var left = store.get('scrollLeft', '0');
var top = store.get('scrollTop', '0');
storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' + left + ',' + top;
sidebarView = store.get('sidebarView', SidebarView.NONE);
sidebarView = store.get('sidebarView', _pdf_sidebar.SidebarView.NONE);
} else if (self.viewerPrefs['defaultZoomValue']) {
storedHash = 'page=1&zoom=' + self.viewerPrefs['defaultZoomValue'];
}
@ -688,7 +676,7 @@ var PDFViewerApplication = { @@ -688,7 +676,7 @@ var PDFViewerApplication = {
pdfDocument.getJavaScript().then(function (javaScript) {
if (javaScript.length) {
console.warn('Warning: JavaScript is not supported');
self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
self.fallback(_pdfjs.UNSUPPORTED_FEATURES.javaScript);
}
var regex = /\bprint\s*\(/;
for (var i = 0, ii = javaScript.length; i < ii; i++) {
@ -703,7 +691,7 @@ var PDFViewerApplication = { @@ -703,7 +691,7 @@ var PDFViewerApplication = {
});
}
});
Promise.all([onePageRendered, animationStarted]).then(function () {
Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () {
pdfDocument.getOutline().then(function (outline) {
self.pdfOutlineViewer.render({ outline: outline });
});
@ -716,7 +704,7 @@ var PDFViewerApplication = { @@ -716,7 +704,7 @@ var PDFViewerApplication = {
metadata = data.metadata;
self.documentInfo = info;
self.metadata = metadata;
console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (pdfjsLib.version || '-') + (!pdfjsLib.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjs.version || '-') + (!_pdfjs.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
var pdfTitle;
if (metadata && metadata.has('dc:title')) {
var title = metadata.get('dc:title');
@ -732,7 +720,7 @@ var PDFViewerApplication = { @@ -732,7 +720,7 @@ var PDFViewerApplication = {
}
if (info.IsAcroFormPresent) {
console.warn('Warning: AcroForm/XFA is not supported');
self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.forms);
self.fallback(_pdfjs.UNSUPPORTED_FEATURES.forms);
}
});
},
@ -757,7 +745,7 @@ var PDFViewerApplication = { @@ -757,7 +745,7 @@ var PDFViewerApplication = {
this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
if (!this.pdfViewer.currentScaleValue) {
this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
}
},
cleanup: function pdfViewCleanup() {
@ -766,7 +754,7 @@ var PDFViewerApplication = { @@ -766,7 +754,7 @@ var PDFViewerApplication = {
}
this.pdfViewer.cleanup();
this.pdfThumbnailViewer.cleanup();
if (this.pdfViewer.renderer !== RendererType.SVG) {
if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
this.pdfDocument.cleanup();
}
},
@ -780,12 +768,12 @@ var PDFViewerApplication = { @@ -780,12 +768,12 @@ var PDFViewerApplication = {
return;
}
if (!this.supportsPrinting) {
var printMessage = mozL10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by this browser.');
var printMessage = _ui_utils.mozL10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by this browser.');
this.error(printMessage);
return;
}
if (!this.pdfViewer.pageViewsReady) {
var notReadyMessage = mozL10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.');
var notReadyMessage = _ui_utils.mozL10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.');
window.alert(notReadyMessage);
return;
}
@ -888,25 +876,27 @@ var PDFViewerApplication = { @@ -888,25 +876,27 @@ var PDFViewerApplication = {
}
};
var validateFileURL;
var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
validateFileURL = function validateFileURL(file) {
try {
var viewerOrigin = new URL(window.location.href).origin || 'null';
if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) {
return;
}
var fileOrigin = new URL(file, window.location.href).origin;
if (fileOrigin !== viewerOrigin) {
throw new Error('file origin does not match viewer\'s');
{
var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
validateFileURL = function validateFileURL(file) {
try {
var viewerOrigin = new URL(window.location.href).origin || 'null';
if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) {
return;
}
var fileOrigin = new URL(file, window.location.href).origin;
if (fileOrigin !== viewerOrigin) {
throw new Error('file origin does not match viewer\'s');
}
} 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);
throw e;
}
} catch (e) {
var message = e && e.message;
var loadingErrorMessage = mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
var moreInfo = { message: message };
PDFViewerApplication.error(loadingErrorMessage, moreInfo);
throw e;
}
};
};
}
function loadAndEnablePDFBug(enabledTabs) {
return new Promise(function (resolve, reject) {
var appConfig = PDFViewerApplication.appConfig;
@ -914,7 +904,10 @@ function loadAndEnablePDFBug(enabledTabs) { @@ -914,7 +904,10 @@ function loadAndEnablePDFBug(enabledTabs) {
script.src = appConfig.debuggerScriptPath;
script.onload = function () {
PDFBug.enable(enabledTabs);
PDFBug.init(pdfjsLib, appConfig.mainContainer);
PDFBug.init({
PDFJS: _pdfjs.PDFJS,
OPS: _pdfjs.OPS
}, appConfig.mainContainer);
resolve();
};
script.onerror = function () {
@ -927,7 +920,7 @@ function webViewerInitialized() { @@ -927,7 +920,7 @@ function webViewerInitialized() {
var appConfig = PDFViewerApplication.appConfig;
var file;
var queryString = document.location.search.substring(1);
var params = parseQueryString(queryString);
var params = (0, _ui_utils.parseQueryString)(queryString);
file = 'file' in params ? params.file : appConfig.defaultUrl;
validateFileURL(file);
var waitForBeforeOpening = [];
@ -935,7 +928,7 @@ function webViewerInitialized() { @@ -935,7 +928,7 @@ function webViewerInitialized() {
fileInput.id = appConfig.openFileInputName;
fileInput.className = 'fileInput';
fileInput.setAttribute('type', 'file');
fileInput.oncontextmenu = noContextMenuHandler;
fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
document.body.appendChild(fileInput);
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
appConfig.toolbar.openFile.setAttribute('hidden', 'true');
@ -943,47 +936,46 @@ function webViewerInitialized() { @@ -943,47 +936,46 @@ function webViewerInitialized() {
} else {
fileInput.value = null;
}
var PDFJS = pdfjsLib.PDFJS;
if (PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
var hash = document.location.hash.substring(1);
var hashParams = parseQueryString(hash);
var hashParams = (0, _ui_utils.parseQueryString)(hash);
if ('disableworker' in hashParams) {
PDFJS.disableWorker = hashParams['disableworker'] === 'true';
_pdfjs.PDFJS.disableWorker = hashParams['disableworker'] === 'true';
}
if ('disablerange' in hashParams) {
PDFJS.disableRange = hashParams['disablerange'] === 'true';
_pdfjs.PDFJS.disableRange = hashParams['disablerange'] === 'true';
}
if ('disablestream' in hashParams) {
PDFJS.disableStream = hashParams['disablestream'] === 'true';
_pdfjs.PDFJS.disableStream = hashParams['disablestream'] === 'true';
}
if ('disableautofetch' in hashParams) {
PDFJS.disableAutoFetch = hashParams['disableautofetch'] === 'true';
_pdfjs.PDFJS.disableAutoFetch = hashParams['disableautofetch'] === 'true';
}
if ('disablefontface' in hashParams) {
PDFJS.disableFontFace = hashParams['disablefontface'] === 'true';
_pdfjs.PDFJS.disableFontFace = hashParams['disablefontface'] === 'true';
}
if ('disablehistory' in hashParams) {
PDFJS.disableHistory = hashParams['disablehistory'] === 'true';
_pdfjs.PDFJS.disableHistory = hashParams['disablehistory'] === 'true';
}
if ('webgl' in hashParams) {
PDFJS.disableWebGL = hashParams['webgl'] !== 'true';
_pdfjs.PDFJS.disableWebGL = hashParams['webgl'] !== 'true';
}
if ('useonlycsszoom' in hashParams) {
PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true';
_pdfjs.PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true';
}
if ('verbosity' in hashParams) {
PDFJS.verbosity = hashParams['verbosity'] | 0;
_pdfjs.PDFJS.verbosity = hashParams['verbosity'] | 0;
}
if ('ignorecurrentpositiononzoom' in hashParams) {
PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
_pdfjs.PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
}
if ('locale' in hashParams) {
PDFJS.locale = hashParams['locale'];
_pdfjs.PDFJS.locale = hashParams['locale'];
}
if ('textlayer' in hashParams) {
switch (hashParams['textlayer']) {
case 'off':
PDFJS.disableTextLayer = true;
_pdfjs.PDFJS.disableTextLayer = true;
break;
case 'visible':
case 'shadow':
@ -994,13 +986,13 @@ function webViewerInitialized() { @@ -994,13 +986,13 @@ function webViewerInitialized() {
}
}
if ('pdfbug' in hashParams) {
PDFJS.pdfBug = true;
_pdfjs.PDFJS.pdfBug = true;
var pdfBug = hashParams['pdfbug'];
var enabled = pdfBug.split(',');
waitForBeforeOpening.push(loadAndEnablePDFBug(enabled));
}
}
mozL10n.setLanguage(PDFJS.locale);
_ui_utils.mozL10n.setLanguage(_pdfjs.PDFJS.locale);
if (!PDFViewerApplication.supportsPrinting) {
appConfig.toolbar.print.classList.add('hidden');
appConfig.secondaryToolbar.printButton.classList.add('hidden');
@ -1023,30 +1015,32 @@ function webViewerInitialized() { @@ -1023,30 +1015,32 @@ function webViewerInitialized() {
Promise.all(waitForBeforeOpening).then(function () {
webViewerOpenFileViaURL(file);
}).catch(function (reason) {
PDFViewerApplication.error(mozL10n.get('loading_error', null, 'An error occurred while opening.'), reason);
PDFViewerApplication.error(_ui_utils.mozL10n.get('loading_error', null, 'An error occurred while opening.'), reason);
});
}
var webViewerOpenFileViaURL;
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
if (file && file.lastIndexOf('file:', 0) === 0) {
PDFViewerApplication.setTitleUsingUrl(file);
var xhr = new XMLHttpRequest();
xhr.onload = function () {
PDFViewerApplication.open(new Uint8Array(xhr.response));
};
try {
xhr.open('GET', file);
xhr.responseType = 'arraybuffer';
xhr.send();
} catch (e) {
PDFViewerApplication.error(mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.'), e);
{
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
if (file && file.lastIndexOf('file:', 0) === 0) {
PDFViewerApplication.setTitleUsingUrl(file);
var xhr = new XMLHttpRequest();
xhr.onload = function () {
PDFViewerApplication.open(new Uint8Array(xhr.response));
};
try {
xhr.open('GET', file);
xhr.responseType = 'arraybuffer';
xhr.send();
} catch (e) {
PDFViewerApplication.error(_ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.'), e);
}
return;
}
return;
}
if (file) {
PDFViewerApplication.open(file);
}
};
if (file) {
PDFViewerApplication.open(file);
}
};
}
function webViewerPageRendered(e) {
var pageNumber = e.pageNumber;
var pageIndex = pageNumber - 1;
@ -1061,11 +1055,11 @@ function webViewerPageRendered(e) { @@ -1061,11 +1055,11 @@ function webViewerPageRendered(e) {
var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
thumbnailView.setImage(pageView);
}
if (pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
if (_pdfjs.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
Stats.add(pageNumber, pageView.stats);
}
if (pageView.error) {
PDFViewerApplication.error(mozL10n.get('rendering_error', null, 'An error occurred while rendering the page.'), pageView.error);
PDFViewerApplication.error(_ui_utils.mozL10n.get('rendering_error', null, 'An error occurred while rendering the page.'), pageView.error);
}
}
function webViewerTextLayerRendered(e) {}
@ -1074,17 +1068,17 @@ function webViewerPageMode(e) { @@ -1074,17 +1068,17 @@ function webViewerPageMode(e) {
view;
switch (mode) {
case 'thumbs':
view = SidebarView.THUMBS;
view = _pdf_sidebar.SidebarView.THUMBS;
break;
case 'bookmarks':
case 'outline':
view = SidebarView.OUTLINE;
view = _pdf_sidebar.SidebarView.OUTLINE;
break;
case 'attachments':
view = SidebarView.ATTACHMENTS;
view = _pdf_sidebar.SidebarView.ATTACHMENTS;
break;
case 'none':
view = SidebarView.NONE;
view = _pdf_sidebar.SidebarView.NONE;
break;
default:
console.error('Invalid "pagemode" hash parameter: ' + mode);
@ -1108,7 +1102,7 @@ function webViewerNamedAction(e) { @@ -1108,7 +1102,7 @@ function webViewerNamedAction(e) {
function webViewerPresentationModeChanged(e) {
var active = e.active;
var switchInProgress = e.switchInProgress;
PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? PresentationModeState.CHANGING : active ? PresentationModeState.FULLSCREEN : PresentationModeState.NORMAL;
PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _pdf_viewer.PresentationModeState.CHANGING : active ? _pdf_viewer.PresentationModeState.FULLSCREEN : _pdf_viewer.PresentationModeState.NORMAL;
}
function webViewerSidebarViewChanged(e) {
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
@ -1139,7 +1133,7 @@ function webViewerUpdateViewarea(e) { @@ -1139,7 +1133,7 @@ function webViewerUpdateViewarea(e) {
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams, location.pageNumber);
var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
var loading = currentPage.renderingState !== RenderingStates.FINISHED;
var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
}
function webViewerResize() {
@ -1147,7 +1141,7 @@ function webViewerResize() { @@ -1147,7 +1141,7 @@ function webViewerResize() {
if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
} else if (!currentScaleValue) {
PDFViewerApplication.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
PDFViewerApplication.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
}
PDFViewerApplication.pdfViewer.update();
}
@ -1165,26 +1159,28 @@ function webViewerHashchange(e) { @@ -1165,26 +1159,28 @@ function webViewerHashchange(e) {
}
}
var webViewerFileInputChange;
webViewerFileInputChange = function webViewerFileInputChange(e) {
var file = e.fileInput.files[0];
if (!pdfjsLib.PDFJS.disableCreateObjectURL && typeof URL !== 'undefined' && URL.createObjectURL) {
PDFViewerApplication.open(URL.createObjectURL(file));
} else {
var fileReader = new FileReader();
fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
var buffer = evt.target.result;
var uint8Array = new Uint8Array(buffer);
PDFViewerApplication.open(uint8Array);
};
fileReader.readAsArrayBuffer(file);
}
PDFViewerApplication.setTitleUsingUrl(file.name);
var appConfig = PDFViewerApplication.appConfig;
appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
appConfig.toolbar.download.setAttribute('hidden', 'true');
appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
};
{
webViewerFileInputChange = function webViewerFileInputChange(e) {
var file = e.fileInput.files[0];
if (!_pdfjs.PDFJS.disableCreateObjectURL && typeof URL !== 'undefined' && URL.createObjectURL) {
PDFViewerApplication.open(URL.createObjectURL(file));
} else {
var fileReader = new FileReader();
fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
var buffer = evt.target.result;
var uint8Array = new Uint8Array(buffer);
PDFViewerApplication.open(uint8Array);
};
fileReader.readAsArrayBuffer(file);
}
PDFViewerApplication.setTitleUsingUrl(file.name);
var appConfig = PDFViewerApplication.appConfig;
appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
appConfig.toolbar.download.setAttribute('hidden', 'true');
appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
};
}
function webViewerPresentationMode() {
PDFViewerApplication.requestPresentationMode();
}
@ -1268,7 +1264,7 @@ function webViewerPageChanging(e) { @@ -1268,7 +1264,7 @@ function webViewerPageChanging(e) {
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
}
if (pdfjsLib.PDFJS.pdfBug && Stats.enabled) {
if (_pdfjs.PDFJS.pdfBug && Stats.enabled) {
var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
if (pageView.stats) {
Stats.add(page, pageView.stats);
@ -1292,7 +1288,7 @@ function webViewerWheel(evt) { @@ -1292,7 +1288,7 @@ function webViewerWheel(evt) {
return;
}
var previousScale = pdfViewer.currentScale;
var delta = normalizeWheelEventDelta(evt);
var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
if (ticks < 0) {
@ -1327,7 +1323,7 @@ function webViewerClick(evt) { @@ -1327,7 +1323,7 @@ function webViewerClick(evt) {
}
}
function webViewerKeyDown(evt) {
if (OverlayManager.active) {
if (_overlay_manager.OverlayManager.active) {
return;
}
var handled = false,
@ -1379,7 +1375,7 @@ function webViewerKeyDown(evt) { @@ -1379,7 +1375,7 @@ function webViewerKeyDown(evt) {
case 96:
if (!isViewerInPresentationMode) {
setTimeout(function () {
pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
});
handled = false;
}
@ -1548,8 +1544,8 @@ function webViewerKeyDown(evt) { @@ -1548,8 +1544,8 @@ function webViewerKeyDown(evt) {
evt.preventDefault();
}
}
localized.then(function webViewerLocalized() {
document.getElementsByTagName('html')[0].dir = mozL10n.getDirection();
_ui_utils.localized.then(function webViewerLocalized() {
document.getElementsByTagName('html')[0].dir = _ui_utils.mozL10n.getDirection();
});
var PDFPrintServiceFactory = {
instance: {
@ -1560,5 +1556,5 @@ var PDFPrintServiceFactory = { @@ -1560,5 +1556,5 @@ var PDFPrintServiceFactory = {
}
};
exports.PDFViewerApplication = PDFViewerApplication;
exports.DefaultExernalServices = DefaultExernalServices;
exports.DefaultExternalServices = DefaultExternalServices;
exports.PDFPrintServiceFactory = PDFPrintServiceFactory;

265
lib/web/chromecom.js

@ -14,8 +14,263 @@ @@ -14,8 +14,263 @@
*/
'use strict';
var app = require('./app.js');
var overlayManager = require('./overlay_manager.js');
var preferences = require('./preferences.js');
var pdfjsLib = require('./pdfjs.js');
throw new Error('Module "pdfjs-web/chromecom" shall not be used outside ' + 'CHROME build.');
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ChromeCom = undefined;
var _app = require('pdfjs-web/app');
var _overlay_manager = require('pdfjs-web/overlay_manager');
var _pdfjs = require('pdfjs-web/pdfjs');
var _preferences = require('pdfjs-web/preferences');
{
throw new Error('Module "pdfjs-web/chromecom" shall not be used outside ' + 'CHROME build.');
}
var ChromeCom = {};
ChromeCom.request = function ChromeCom_request(action, data, callback) {
var message = {
action: action,
data: data
};
if (!chrome.runtime) {
console.error('chrome.runtime is undefined.');
if (callback) {
callback();
}
} else if (callback) {
chrome.runtime.sendMessage(message, callback);
} else {
chrome.runtime.sendMessage(message);
}
};
ChromeCom.resolvePDFFile = function ChromeCom_resolvePDFFile(file, callback) {
file = file.replace(/^drive:/i, 'filesystem:' + location.origin + '/external/');
if (/^filesystem:/.test(file) && !_pdfjs.PDFJS.disableWorker) {
var resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;
resolveLocalFileSystemURL(file, function onResolvedFSURL(fileEntry) {
fileEntry.file(function (fileObject) {
var blobUrl = URL.createObjectURL(fileObject);
callback(blobUrl, fileObject.size);
});
}, function onFileSystemError(error) {
console.warn('Cannot resolve file ' + file + ', ' + error.name + ' ' + error.message);
callback(file);
});
return;
}
if (/^https?:/.test(file)) {
setReferer(file, function () {
callback(file);
});
return;
}
if (/^file?:/.test(file)) {
getEmbedderOrigin(function (origin) {
if (origin && !/^file:|^chrome-extension:/.test(origin)) {
_app.PDFViewerApplication.error('Blocked ' + origin + ' from loading ' + file + '. Refused to load a local file in a non-local page ' + 'for security reasons.');
return;
}
isAllowedFileSchemeAccess(function (isAllowedAccess) {
if (isAllowedAccess) {
callback(file);
} else {
requestAccessToLocalFile(file);
}
});
});
return;
}
callback(file);
};
function getEmbedderOrigin(callback) {
var origin = window === top ? location.origin : location.ancestorOrigins[0];
if (origin === 'null') {
getParentOrigin(callback);
} else {
callback(origin);
}
}
function getParentOrigin(callback) {
ChromeCom.request('getParentOrigin', null, callback);
}
function isAllowedFileSchemeAccess(callback) {
ChromeCom.request('isAllowedFileSchemeAccess', null, callback);
}
function isRuntimeAvailable() {
try {
if (chrome.runtime && chrome.runtime.getManifest()) {
return true;
}
} catch (e) {}
return false;
}
function reloadIfRuntimeIsUnavailable() {
if (!isRuntimeAvailable()) {
location.reload();
}
}
var chromeFileAccessOverlayPromise;
function requestAccessToLocalFile(fileUrl) {
var onCloseOverlay = null;
if (top !== window) {
window.addEventListener('focus', reloadIfRuntimeIsUnavailable);
onCloseOverlay = function () {
window.removeEventListener('focus', reloadIfRuntimeIsUnavailable);
reloadIfRuntimeIsUnavailable();
_overlay_manager.OverlayManager.close('chromeFileAccessOverlay');
};
}
if (!chromeFileAccessOverlayPromise) {
chromeFileAccessOverlayPromise = _overlay_manager.OverlayManager.register('chromeFileAccessOverlay', document.getElementById('chromeFileAccessOverlay'), onCloseOverlay, true);
}
chromeFileAccessOverlayPromise.then(function () {
var iconPath = chrome.runtime.getManifest().icons[48];
document.getElementById('chrome-pdfjs-logo-bg').style.backgroundImage = 'url(' + chrome.runtime.getURL(iconPath) + ')';
var i18nFileAccessLabel = {
"am": "\u1208\u134b\u12ed\u120d \u12e9\u12a0\u122d\u12a4\u120d\u12ce\u127d \u1218\u12f3\u1228\u123b \u134d\u1240\u12f5",
"ar": "\u200f\u0627\u0644\u0633\u0645\u0627\u062d \u0628\u0627\u0644\u062f\u062e\u0648\u0644 \u0625\u0644\u0649 \u0639\u0646\u0627\u0648\u064a\u0646 URL \u0644\u0644\u0645\u0644\u0641\u0627\u062a",
"bg": "\u0414\u0430 \u0441\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0438 \u0434\u043e\u0441\u0442\u044a\u043f \u0434\u043e URL \u0430\u0434\u0440\u0435\u0441\u0438\u0442\u0435 \u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u0435\u0442\u0435",
"bn": "\u09ab\u09be\u0987\u09b2 URL\u0997\u09c1\u09b2\u09bf\u09a4\u09c7 \u0985\u09cd\u09af\u09be\u0995\u09cd\u09b8\u09c7\u09b8 \u09ae\u099e\u09cd\u099c\u09c1\u09b0 \u0995\u09b0\u09c1\u09a8",
"ca": "Permet l'acc\u00e9s als URL de fitxer",
"cs": "Umo\u017enit p\u0159\u00edstup k adres\u00e1m URL soubor\u016f",
"da": "Tillad adgang til webadresser p\u00e5 filer",
"de": "Zugriff auf Datei-URLs zulassen",
"el": "\u039d\u03b1 \u03b5\u03c0\u03b9\u03c4\u03c1\u03ad\u03c0\u03b5\u03c4\u03b1\u03b9 \u03b7 \u03c0\u03c1\u03cc\u03c3\u03b2\u03b1\u03c3\u03b7 \u03c3\u03b5 \u03b4\u03b9\u03b5\u03c5\u03b8\u03cd\u03bd\u03c3\u03b5\u03b9\u03c2 URL \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd",
"en-GB": "Allow access to file URLs",
"es": "Permitir acceso a URL de archivo",
"es-419": "Permitir el acceso a las URL del archivo",
"et": "Luba juurdep\u00e4\u00e4s failide URL-idele",
"fa": "\u200f\u0627\u062c\u0627\u0632\u0647\u0654 \u062f\u0633\u062a\u0631\u0633\u06cc \u0628\u0647 URL \u0647\u0627\u06cc \u0641\u0627\u06cc\u0644",
"fi": "Salli tiedostojen URL-osoitteiden k\u00e4ytt\u00f6",
"fil": "Payagan ang access na mag-file ng mga URL",
"fr": "Autoriser l'acc\u00e8s aux URL de fichier",
"gu": "URL \u0aab\u0abe\u0a87\u0ab2 \u0a95\u0ab0\u0ab5\u0abe \u0a8d\u0a95\u0acd\u0ab8\u0ac7\u0ab8\u0aa8\u0ac0 \u0aae\u0a82\u0a9c\u0ac2\u0ab0\u0ac0 \u0a86\u0aaa\u0acb",
"hi": "\u092b\u093c\u093e\u0907\u0932 URL \u0924\u0915 \u092a\u0939\u0941\u0902\u091a\u0928\u0947 \u0915\u0940 \u0905\u0928\u0941\u092e\u0924\u093f \u0926\u0947\u0902",
"hr": "Dozvoli pristup URL-ovima datoteke",
"hu": "F\u00e1jl URL-ekhez val\u00f3 hozz\u00e1f\u00e9r\u00e9s enged\u00e9lyez\u00e9se",
"id": "Izinkan akses ke URL file",
"it": "Consenti l'accesso agli URL dei file",
"iw": "\u05d0\u05e4\u05e9\u05e8 \u05d2\u05d9\u05e9\u05d4 \u05dc\u05db\u05ea\u05d5\u05d1\u05d5\u05ea \u05d0\u05ea\u05e8\u05d9\u05dd \u05e9\u05dc \u05e7\u05d1\u05e6\u05d9\u05dd",
"ja": "\u30d5\u30a1\u30a4\u30eb\u306e URL \u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3059\u308b",
"kn": "URL \u0c97\u0cb3\u0ca8\u0ccd\u0ca8\u0cc1 \u0cab\u0cc8\u0cb2\u0ccd\u200c\u0c97\u0cb3\u0cbf\u0c97\u0cc6 \u0caa\u0ccd\u0cb0\u0cb5\u0cc7\u0cb6\u0cbf\u0cb8\u0cb2\u0cc1 \u0c85\u0ca8\u0cc1\u0cae\u0ca4\u0cbf\u0cb8\u0cbf",
"ko": "\ud30c\uc77c URL\uc5d0 \ub300\ud55c \uc561\uc138\uc2a4 \ud5c8\uc6a9",
"lt": "Leisti pasiekti failo URL",
"lv": "At\u013caut piek\u013cuvi faila vietr\u0101\u017eiem URL",
"ml": "URL \u0d15\u0d33\u0d4d\u200d\u200c \u0d2b\u0d2f\u0d32\u0d4d\u200d\u200c \u0d1a\u0d46\u0d2f\u0d4d\u0d2f\u0d41\u0d28\u0d4d\u0d28\u0d24\u0d3f\u0d28\u0d4d \u0d06\u0d15\u0d4d\u200d\u0d38\u0d38\u0d4d\u0d38\u0d4d \u0d05\u0d28\u0d41\u0d35\u0d26\u0d3f\u0d15\u0d4d\u0d15\u0d41\u0d15",
"mr": "\u092b\u093e\u0907\u0932 URL \u092e\u0927\u094d\u092f\u0947 \u092a\u094d\u0930\u0935\u0947\u0936\u093e\u0938 \u0905\u0928\u0941\u092e\u0924\u0940 \u0926\u094d\u092f\u093e",
"ms": "Membenarkan akses ke URL fail",
"nl": "Toegang tot bestand-URL's toestaan",
"no": "Tillat tilgang til filnettadresser",
"pl": "Zezwalaj na dost\u0119p do adres\u00f3w URL plik\u00f3w",
"pt-BR": "Permitir acesso aos URLs do arquivo",
"pt-PT": "Permitir acesso a URLs de ficheiro",
"ro": "Permite accesul la adresele URL de fi\u0219iere",
"ru": "\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c",
"sk": "Povoli\u0165 pr\u00edstup k webov\u00fdm adres\u00e1m s\u00faboru",
"sl": "Dovoli dostop do URL-jev datoteke",
"sr": "\u0414\u043e\u0437\u0432\u043e\u043b\u0438 \u043f\u0440\u0438\u0441\u0442\u0443\u043f URL \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0430 \u0434\u0430\u0442\u043e\u0442\u0435\u043a\u0430",
"sv": "Till\u00e5t \u00e5tkomst till webbadresser i filen",
"sw": "Ruhusu kufikia URL za faili",
"ta": "\u0b95\u0bcb\u0baa\u0bcd\u0baa\u0bc1 URL\u0b95\u0bb3\u0bc1\u0b95\u0bcd\u0b95\u0bc1 \u0b85\u0ba3\u0bc1\u0b95\u0bb2\u0bc8 \u0b85\u0ba9\u0bc1\u0bae\u0ba4\u0bbf",
"te": "\u0c2b\u0c48\u0c32\u0c4d URL\u0c32\u0c15\u0c41 \u0c2a\u0c4d\u0c30\u0c3e\u0c2a\u0c4d\u0c24\u0c3f\u0c28\u0c3f \u0c05\u0c28\u0c41\u0c2e\u0c24\u0c3f\u0c02\u0c1a\u0c41",
"th": "\u0e2d\u0e19\u0e38\u0e0d\u0e32\u0e15\u0e43\u0e2b\u0e49\u0e40\u0e02\u0e49\u0e32\u0e16\u0e36\u0e07\u0e44\u0e1f\u0e25\u0e4c URL",
"tr": "Dosya URL'lerine eri\u015fime izin ver",
"uk": "\u041d\u0430\u0434\u0430\u0432\u0430\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043e URL-\u0430\u0434\u0440\u0435\u0441 \u0444\u0430\u0439\u043b\u0443",
"vi": "Cho ph\u00e9p truy c\u1eadp v\u00e0o c\u00e1c URL c\u1ee7a t\u1ec7p",
"zh-CN": "\u5141\u8bb8\u8bbf\u95ee\u6587\u4ef6\u7f51\u5740",
"zh-TW": "\u5141\u8a31\u5b58\u53d6\u6a94\u6848\u7db2\u5740"
}[chrome.i18n.getUILanguage && chrome.i18n.getUILanguage()];
if (i18nFileAccessLabel) {
document.getElementById('chrome-file-access-label').textContent = i18nFileAccessLabel;
}
var link = document.getElementById('chrome-link-to-extensions-page');
link.href = 'chrome://extensions/?id=' + chrome.runtime.id;
link.onclick = function (e) {
e.preventDefault();
ChromeCom.request('openExtensionsPageForFileAccess', { newTab: e.ctrlKey || e.metaKey || e.button === 1 || window !== top });
};
document.getElementById('chrome-url-of-local-file').textContent = fileUrl;
_overlay_manager.OverlayManager.open('chromeFileAccessOverlay');
});
}
if (window === top) {
addEventListener('unload', function () {
if (!isRuntimeAvailable()) {
localStorage.setItem('unload-' + Date.now() + '-' + document.hidden + '-' + location.href, JSON.stringify(history.state));
}
});
}
var port;
function setReferer(url, callback) {
if (!port) {
port = chrome.runtime.connect({ name: 'chromecom-referrer' });
}
port.onDisconnect.addListener(onDisconnect);
port.onMessage.addListener(onMessage);
port.postMessage({
referer: window.history.state && window.history.state.chromecomState,
requestUrl: url
});
function onMessage(referer) {
if (referer) {
var state = window.history.state || {};
state.chromecomState = referer;
window.history.replaceState(state, '');
}
onCompleted();
}
function onDisconnect() {
port = null;
callback();
}
function onCompleted() {
port.onDisconnect.removeListener(onDisconnect);
port.onMessage.removeListener(onMessage);
callback();
}
}
var storageArea = chrome.storage.sync || chrome.storage.local;
_preferences.Preferences._writeToStorage = function (prefObj) {
return new Promise(function (resolve) {
if (prefObj === _preferences.Preferences.defaults) {
var keysToRemove = Object.keys(_preferences.Preferences.defaults);
storageArea.remove(keysToRemove, function () {
resolve();
});
} else {
storageArea.set(prefObj, function () {
resolve();
});
}
});
};
_preferences.Preferences._readFromStorage = function (prefObj) {
return new Promise(function (resolve) {
if (chrome.storage.managed) {
chrome.storage.managed.get(_preferences.Preferences.defaults, getPreferences);
} else {
getPreferences(_preferences.Preferences.defaults);
}
function getPreferences(defaultPrefs) {
if (chrome.runtime.lastError) {
defaultPrefs = _preferences.Preferences.defaults;
}
storageArea.get(defaultPrefs, function (readPrefs) {
resolve(readPrefs);
});
}
});
};
var ChromeExternalServices = Object.create(_app.DefaultExternalServices);
ChromeExternalServices.initPassiveLoading = function (callbacks) {
var appConfig = _app.PDFViewerApplication.appConfig;
ChromeCom.resolvePDFFile(appConfig.defaultUrl, function (url, length, originalURL) {
callbacks.onOpenWithURL(url, length, originalURL);
});
};
_app.PDFViewerApplication.externalServices = ChromeExternalServices;
exports.ChromeCom = ChromeCom;

11
lib/web/dom_events.js

@ -14,8 +14,13 @@ @@ -14,8 +14,13 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var EventBus = uiUtils.EventBus;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
function attachDOMEventsToEventBus(eventBus) {
eventBus.on('documentload', function () {
var event = document.createEvent('CustomEvent');
@ -117,7 +122,7 @@ function getGlobalEventBus() { @@ -117,7 +122,7 @@ function getGlobalEventBus() {
if (globalEventBus) {
return globalEventBus;
}
globalEventBus = new EventBus();
globalEventBus = new _ui_utils.EventBus();
attachDOMEventsToEventBus(globalEventBus);
return globalEventBus;
}

22
lib/web/download_manager.js

@ -14,7 +14,16 @@ @@ -14,7 +14,16 @@
*/
'use strict';
var pdfjsLib = require('./pdfjs.js');
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DownloadManager = undefined;
var _pdfjs = require('pdfjs-web/pdfjs');
var _app = require('pdfjs-web/app');
;
function download(blobUrl, filename) {
var a = document.createElement('a');
if (a.click) {
@ -37,7 +46,7 @@ function download(blobUrl, filename) { @@ -37,7 +46,7 @@ function download(blobUrl, filename) {
function DownloadManager() {}
DownloadManager.prototype = {
downloadUrl: function DownloadManager_downloadUrl(url, filename) {
if (!pdfjsLib.createValidAbsoluteUrl(url, 'http://example.com')) {
if (!(0, _pdfjs.createValidAbsoluteUrl)(url, 'http://example.com')) {
return;
}
download(url + '#pdfjs.action=download', filename);
@ -46,7 +55,7 @@ DownloadManager.prototype = { @@ -46,7 +55,7 @@ DownloadManager.prototype = {
if (navigator.msSaveBlob) {
return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
}
var blobUrl = pdfjsLib.createObjectURL(data, contentType, pdfjsLib.PDFJS.disableCreateObjectURL);
var blobUrl = (0, _pdfjs.createObjectURL)(data, contentType, _pdfjs.PDFJS.disableCreateObjectURL);
download(blobUrl, filename);
},
download: function DownloadManager_download(blob, url, filename) {
@ -56,7 +65,7 @@ DownloadManager.prototype = { @@ -56,7 +65,7 @@ DownloadManager.prototype = {
}
return;
}
if (pdfjsLib.PDFJS.disableCreateObjectURL) {
if (_pdfjs.PDFJS.disableCreateObjectURL) {
this.downloadUrl(url, filename);
return;
}
@ -64,4 +73,9 @@ DownloadManager.prototype = { @@ -64,4 +73,9 @@ DownloadManager.prototype = {
download(blobUrl, filename);
}
};
var GenericExternalServices = Object.create(_app.DefaultExternalServices);
GenericExternalServices.createDownloadManager = function () {
return new DownloadManager();
};
_app.PDFViewerApplication.externalServices = GenericExternalServices;
exports.DownloadManager = DownloadManager;

24
lib/web/firefox_print_service.js

@ -14,19 +14,25 @@ @@ -14,19 +14,25 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var app = require('./app.js');
var pdfjsLib = require('./pdfjs.js');
var CSS_UNITS = uiUtils.CSS_UNITS;
var PDFPrintServiceFactory = app.PDFPrintServiceFactory;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FirefoxPrintService = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _app = require('pdfjs-web/app');
var _pdfjs = require('pdfjs-web/pdfjs');
function composePage(pdfDocument, pageNumber, size, printContainer) {
var canvas = document.createElement('canvas');
var PRINT_RESOLUTION = 150;
var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
canvas.width = Math.floor(size.width * PRINT_UNITS);
canvas.height = Math.floor(size.height * PRINT_UNITS);
canvas.style.width = Math.floor(size.width * CSS_UNITS) + 'px';
canvas.style.height = Math.floor(size.height * CSS_UNITS) + 'px';
canvas.style.width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
canvas.style.height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
var canvasWrapper = document.createElement('div');
canvasWrapper.appendChild(canvas);
printContainer.appendChild(canvasWrapper);
@ -75,11 +81,11 @@ FirefoxPrintService.prototype = { @@ -75,11 +81,11 @@ FirefoxPrintService.prototype = {
this.printContainer.textContent = '';
}
};
PDFPrintServiceFactory.instance = {
_app.PDFPrintServiceFactory.instance = {
get supportsPrinting() {
var canvas = document.createElement('canvas');
var value = 'mozPrintCallback' in canvas;
return pdfjsLib.shadow(this, 'supportsPrinting', value);
return (0, _pdfjs.shadow)(this, 'supportsPrinting', value);
},
createPrintService: function (pdfDocument, pagesOverview, printContainer) {
return new FirefoxPrintService(pdfDocument, pagesOverview, printContainer);

216
lib/web/firefoxcom.js

@ -14,7 +14,215 @@ @@ -14,7 +14,215 @@
*/
'use strict';
var preferences = require('./preferences.js');
var app = require('./app.js');
var pdfjsLib = require('./pdfjs.js');
throw new Error('Module "pdfjs-web/firefoxcom" shall not be used outside ' + 'FIREFOX and MOZCENTRAL builds.');
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FirefoxCom = exports.DownloadManager = undefined;
var _pdfjs = require('pdfjs-web/pdfjs');
var _app = require('pdfjs-web/app');
var _preferences = require('pdfjs-web/preferences');
{
throw new Error('Module "pdfjs-web/firefoxcom" shall not be used outside ' + 'FIREFOX and MOZCENTRAL builds.');
}
var FirefoxCom = function FirefoxComClosure() {
return {
requestSync: function (action, data) {
var request = document.createTextNode('');
document.documentElement.appendChild(request);
var sender = document.createEvent('CustomEvent');
sender.initCustomEvent('pdf.js.message', true, false, {
action: action,
data: data,
sync: true
});
request.dispatchEvent(sender);
var response = sender.detail.response;
document.documentElement.removeChild(request);
return response;
},
request: function (action, data, callback) {
var request = document.createTextNode('');
if (callback) {
document.addEventListener('pdf.js.response', function listener(event) {
var node = event.target;
var response = event.detail.response;
document.documentElement.removeChild(node);
document.removeEventListener('pdf.js.response', listener);
return callback(response);
});
}
document.documentElement.appendChild(request);
var sender = document.createEvent('CustomEvent');
sender.initCustomEvent('pdf.js.message', true, false, {
action: action,
data: data,
sync: false,
responseExpected: !!callback
});
return request.dispatchEvent(sender);
}
};
}();
var DownloadManager = function DownloadManagerClosure() {
function DownloadManager() {}
DownloadManager.prototype = {
downloadUrl: function DownloadManager_downloadUrl(url, filename) {
FirefoxCom.request('download', {
originalUrl: url,
filename: filename
});
},
downloadData: function DownloadManager_downloadData(data, filename, contentType) {
var blobUrl = (0, _pdfjs.createObjectURL)(data, contentType, false);
FirefoxCom.request('download', {
blobUrl: blobUrl,
originalUrl: blobUrl,
filename: filename,
isAttachment: true
});
},
download: function DownloadManager_download(blob, url, filename) {
var blobUrl = window.URL.createObjectURL(blob);
FirefoxCom.request('download', {
blobUrl: blobUrl,
originalUrl: url,
filename: filename
}, function response(err) {
if (err && this.onerror) {
this.onerror(err);
}
window.URL.revokeObjectURL(blobUrl);
}.bind(this));
}
};
return DownloadManager;
}();
_preferences.Preferences._writeToStorage = function (prefObj) {
return new Promise(function (resolve) {
FirefoxCom.request('setPreferences', prefObj, resolve);
});
};
_preferences.Preferences._readFromStorage = function (prefObj) {
return new Promise(function (resolve) {
FirefoxCom.request('getPreferences', prefObj, function (prefStr) {
var readPrefs = JSON.parse(prefStr);
resolve(readPrefs);
});
});
};
(function listenFindEvents() {
var events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange'];
var handleEvent = function (evt) {
if (!_app.PDFViewerApplication.initialized) {
return;
}
_app.PDFViewerApplication.eventBus.dispatch('find', {
source: window,
type: evt.type.substring('find'.length),
query: evt.detail.query,
phraseSearch: true,
caseSensitive: !!evt.detail.caseSensitive,
highlightAll: !!evt.detail.highlightAll,
findPrevious: !!evt.detail.findPrevious
});
};
for (var i = 0, len = events.length; i < len; i++) {
window.addEventListener(events[i], handleEvent);
}
})();
function FirefoxComDataRangeTransport(length, initialData) {
_pdfjs.PDFDataRangeTransport.call(this, length, initialData);
}
FirefoxComDataRangeTransport.prototype = Object.create(_pdfjs.PDFDataRangeTransport.prototype);
FirefoxComDataRangeTransport.prototype.requestDataRange = function FirefoxComDataRangeTransport_requestDataRange(begin, end) {
FirefoxCom.request('requestDataRange', {
begin: begin,
end: end
});
};
FirefoxComDataRangeTransport.prototype.abort = function FirefoxComDataRangeTransport_abort() {
FirefoxCom.requestSync('abortLoading', null);
};
_app.PDFViewerApplication.externalServices = {
updateFindControlState: function (data) {
FirefoxCom.request('updateFindControlState', data);
},
initPassiveLoading: function (callbacks) {
var pdfDataRangeTransport;
window.addEventListener('message', function windowMessage(e) {
if (e.source !== null) {
console.warn('Rejected untrusted message from ' + e.origin);
return;
}
var args = e.data;
if (typeof args !== 'object' || !('pdfjsLoadAction' in args)) {
return;
}
switch (args.pdfjsLoadAction) {
case 'supportsRangedLoading':
pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data);
callbacks.onOpenWithTransport(args.pdfUrl, args.length, pdfDataRangeTransport);
break;
case 'range':
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
break;
case 'rangeProgress':
pdfDataRangeTransport.onDataProgress(args.loaded);
break;
case 'progressiveRead':
pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
break;
case 'progress':
callbacks.onProgress(args.loaded, args.total);
break;
case 'complete':
if (!args.data) {
callbacks.onError(args.errorCode);
break;
}
callbacks.onOpenWithData(args.data);
break;
}
});
FirefoxCom.requestSync('initPassiveLoading', null);
},
fallback: function (data, callback) {
FirefoxCom.request('fallback', data, callback);
},
reportTelemetry: function (data) {
FirefoxCom.request('reportTelemetry', JSON.stringify(data));
},
createDownloadManager: function () {
return new DownloadManager();
},
get supportsIntegratedFind() {
var support = FirefoxCom.requestSync('supportsIntegratedFind');
return (0, _pdfjs.shadow)(this, 'supportsIntegratedFind', support);
},
get supportsDocumentFonts() {
var support = FirefoxCom.requestSync('supportsDocumentFonts');
return (0, _pdfjs.shadow)(this, 'supportsDocumentFonts', support);
},
get supportsDocumentColors() {
var support = FirefoxCom.requestSync('supportsDocumentColors');
return (0, _pdfjs.shadow)(this, 'supportsDocumentColors', support);
},
get supportedMouseWheelZoomModifierKeys() {
var support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
return (0, _pdfjs.shadow)(this, 'supportedMouseWheelZoomModifierKeys', support);
}
};
document.mozL10n.setExternalLocalizerServices({
getLocale: function () {
return FirefoxCom.requestSync('getLocale', null);
},
getStrings: function (key) {
return FirefoxCom.requestSync('getStrings', key);
}
});
exports.DownloadManager = DownloadManager;
exports.FirefoxCom = FirefoxCom;

3
lib/web/grab_to_pan.js

@ -14,6 +14,9 @@ @@ -14,6 +14,9 @@
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
function GrabToPan(options) {
this.element = options.element;
this.document = options.element.ownerDocument;

21
lib/web/hand_tool.js

@ -14,25 +14,30 @@ @@ -14,25 +14,30 @@
*/
'use strict';
var grabToPan = require('./grab_to_pan.js');
var preferences = require('./preferences.js');
var uiUtils = require('./ui_utils.js');
var GrabToPan = grabToPan.GrabToPan;
var Preferences = preferences.Preferences;
var localized = uiUtils.localized;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.HandTool = undefined;
var _grab_to_pan = require('pdfjs-web/grab_to_pan');
var _ui_utils = require('pdfjs-web/ui_utils');
var _preferences = require('pdfjs-web/preferences');
var HandTool = function HandToolClosure() {
function HandTool(options) {
this.container = options.container;
this.eventBus = options.eventBus;
this.wasActive = false;
this.handTool = new GrabToPan({
this.handTool = new _grab_to_pan.GrabToPan({
element: this.container,
onActiveChanged: function (isActive) {
this.eventBus.dispatch('handtoolchanged', { isActive: isActive });
}.bind(this)
});
this.eventBus.on('togglehandtool', this.toggle.bind(this));
Promise.all([localized, Preferences.get('enableHandToolOnLoad')]).then(function resolved(values) {
Promise.all([_ui_utils.localized, _preferences.Preferences.get('enableHandToolOnLoad')]).then(function resolved(values) {
if (values[1] === true) {
this.handTool.activate();
}

3
lib/web/overlay_manager.js

@ -14,6 +14,9 @@ @@ -14,6 +14,9 @@
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var OverlayManager = {
overlays: {},
active: null,

28
lib/web/password_prompt.js

@ -14,11 +14,17 @@ @@ -14,11 +14,17 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var overlayManager = require('./overlay_manager.js');
var pdfjsLib = require('./pdfjs.js');
var mozL10n = uiUtils.mozL10n;
var OverlayManager = overlayManager.OverlayManager;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PasswordPrompt = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _overlay_manager = require('pdfjs-web/overlay_manager');
var _pdfjs = require('pdfjs-web/pdfjs');
var PasswordPrompt = function PasswordPromptClosure() {
function PasswordPrompt(options) {
this.overlayName = options.overlayName;
@ -36,22 +42,22 @@ var PasswordPrompt = function PasswordPromptClosure() { @@ -36,22 +42,22 @@ var PasswordPrompt = function PasswordPromptClosure() {
this.verify();
}
}.bind(this));
OverlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
_overlay_manager.OverlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
}
PasswordPrompt.prototype = {
open: function PasswordPrompt_open() {
OverlayManager.open(this.overlayName).then(function () {
_overlay_manager.OverlayManager.open(this.overlayName).then(function () {
this.input.type = 'password';
this.input.focus();
var promptString = mozL10n.get('password_label', null, 'Enter the password to open this PDF file.');
if (this.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
promptString = mozL10n.get('password_invalid', null, 'Invalid password. Please try again.');
var promptString = _ui_utils.mozL10n.get('password_label', null, 'Enter the password to open this PDF file.');
if (this.reason === _pdfjs.PasswordResponses.INCORRECT_PASSWORD) {
promptString = _ui_utils.mozL10n.get('password_invalid', null, 'Invalid password. Please try again.');
}
this.label.textContent = promptString;
}.bind(this));
},
close: function PasswordPrompt_close() {
OverlayManager.close(this.overlayName).then(function () {
_overlay_manager.OverlayManager.close(this.overlayName).then(function () {
this.input.value = '';
this.input.type = '';
}.bind(this));

17
lib/web/pdf_attachment_viewer.js

@ -14,14 +14,20 @@ @@ -14,14 +14,20 @@
*/
'use strict';
var pdfjsLib = require('./pdfjs.js');
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFAttachmentViewer = undefined;
var _pdfjs = require('pdfjs-web/pdfjs');
var PDFAttachmentViewer = function PDFAttachmentViewerClosure() {
function PDFAttachmentViewer(options) {
this.attachments = null;
this.container = options.container;
this.eventBus = options.eventBus;
this.downloadManager = options.downloadManager;
this._renderedCapability = pdfjsLib.createPromiseCapability();
this._renderedCapability = (0, _pdfjs.createPromiseCapability)();
this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
}
PDFAttachmentViewer.prototype = {
@ -29,7 +35,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() { @@ -29,7 +35,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() {
this.attachments = null;
this.container.textContent = '';
if (!keepRenderedCapability) {
this._renderedCapability = pdfjsLib.createPromiseCapability();
this._renderedCapability = (0, _pdfjs.createPromiseCapability)();
}
},
_dispatchEvent: function PDFAttachmentViewer_dispatchEvent(attachmentsCount) {
@ -43,7 +49,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() { @@ -43,7 +49,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() {
var blobUrl;
button.onclick = function () {
if (!blobUrl) {
blobUrl = pdfjsLib.createObjectURL(content, 'application/pdf', pdfjsLib.PDFJS.disableCreateObjectURL);
blobUrl = (0, _pdfjs.createObjectURL)(content, 'application/pdf', _pdfjs.PDFJS.disableCreateObjectURL);
}
var viewerUrl;
viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
@ -76,8 +82,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() { @@ -76,8 +82,7 @@ var PDFAttachmentViewer = function PDFAttachmentViewerClosure() {
attachmentsCount = names.length;
for (var i = 0; i < attachmentsCount; i++) {
var item = attachments[names[i]];
var filename = pdfjsLib.getFilenameFromUrl(item.filename);
filename = pdfjsLib.removeNullCharacters(filename);
var filename = (0, _pdfjs.removeNullCharacters)((0, _pdfjs.getFilenameFromUrl)(item.filename));
var div = document.createElement('div');
div.className = 'attachmentsItem';
var button = document.createElement('button');

30
lib/web/pdf_document_properties.js

@ -14,11 +14,15 @@ @@ -14,11 +14,15 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var overlayManager = require('./overlay_manager.js');
var getPDFFileNameFromURL = uiUtils.getPDFFileNameFromURL;
var mozL10n = uiUtils.mozL10n;
var OverlayManager = overlayManager.OverlayManager;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFDocumentProperties = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _overlay_manager = require('pdfjs-web/overlay_manager');
var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
function PDFDocumentProperties(options) {
this.fields = options.fields;
@ -33,16 +37,16 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() { @@ -33,16 +37,16 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
this.dataAvailablePromise = new Promise(function (resolve) {
this.resolveDataAvailable = resolve;
}.bind(this));
OverlayManager.register(this.overlayName, this.container, this.close.bind(this));
_overlay_manager.OverlayManager.register(this.overlayName, this.container, this.close.bind(this));
}
PDFDocumentProperties.prototype = {
open: function PDFDocumentProperties_open() {
Promise.all([OverlayManager.open(this.overlayName), this.dataAvailablePromise]).then(function () {
Promise.all([_overlay_manager.OverlayManager.open(this.overlayName), this.dataAvailablePromise]).then(function () {
this._getProperties();
}.bind(this));
},
close: function PDFDocumentProperties_close() {
OverlayManager.close(this.overlayName);
_overlay_manager.OverlayManager.close(this.overlayName);
},
setFileSize: function PDFDocumentProperties_setFileSize(fileSize) {
if (fileSize > 0) {
@ -55,7 +59,7 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() { @@ -55,7 +59,7 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
this.resolveDataAvailable();
},
_getProperties: function PDFDocumentProperties_getProperties() {
if (!OverlayManager.active) {
if (!_overlay_manager.OverlayManager.active) {
return;
}
this.pdfDocument.getDownloadInfo().then(function (data) {
@ -67,7 +71,7 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() { @@ -67,7 +71,7 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
}.bind(this));
this.pdfDocument.getMetadata().then(function (data) {
var content = {
'fileName': getPDFFileNameFromURL(this.url),
'fileName': (0, _ui_utils.getPDFFileNameFromURL)(this.url),
'fileSize': this._parseFileSize(),
'title': data.info.Title,
'author': data.info.Author,
@ -96,12 +100,12 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() { @@ -96,12 +100,12 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
if (!kb) {
return;
} else if (kb < 1024) {
return mozL10n.get('document_properties_kb', {
return _ui_utils.mozL10n.get('document_properties_kb', {
size_kb: (+kb.toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_kb}} KB ({{size_b}} bytes)');
}
return mozL10n.get('document_properties_mb', {
return _ui_utils.mozL10n.get('document_properties_mb', {
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_mb}} MB ({{size_b}} bytes)');
@ -133,7 +137,7 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() { @@ -133,7 +137,7 @@ var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
var dateString = date.toLocaleDateString();
var timeString = date.toLocaleTimeString();
return mozL10n.get('document_properties_date_string', {
return _ui_utils.mozL10n.get('document_properties_date_string', {
date: dateString,
time: timeString
}, '{{date}}, {{time}}');

27
lib/web/pdf_find_bar.js

@ -14,10 +14,15 @@ @@ -14,10 +14,15 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var pdfFindController = require('./pdf_find_controller.js');
var mozL10n = uiUtils.mozL10n;
var FindStates = pdfFindController.FindStates;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFFindBar = undefined;
var _pdf_find_controller = require('pdfjs-web/pdf_find_controller');
var _ui_utils = require('pdfjs-web/ui_utils');
var PDFFindBar = function PDFFindBarClosure() {
function PDFFindBar(options) {
this.opened = false;
@ -89,20 +94,20 @@ var PDFFindBar = function PDFFindBarClosure() { @@ -89,20 +94,20 @@ var PDFFindBar = function PDFFindBarClosure() {
var findMsg = '';
var status = '';
switch (state) {
case FindStates.FIND_FOUND:
case _pdf_find_controller.FindStates.FIND_FOUND:
break;
case FindStates.FIND_PENDING:
case _pdf_find_controller.FindStates.FIND_PENDING:
status = 'pending';
break;
case FindStates.FIND_NOTFOUND:
findMsg = mozL10n.get('find_not_found', null, 'Phrase not found');
case _pdf_find_controller.FindStates.FIND_NOTFOUND:
findMsg = _ui_utils.mozL10n.get('find_not_found', null, 'Phrase not found');
notFound = true;
break;
case FindStates.FIND_WRAPPED:
case _pdf_find_controller.FindStates.FIND_WRAPPED:
if (previous) {
findMsg = mozL10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
findMsg = _ui_utils.mozL10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
} else {
findMsg = mozL10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
findMsg = _ui_utils.mozL10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
}
break;
}

11
lib/web/pdf_find_controller.js

@ -14,8 +14,13 @@ @@ -14,8 +14,13 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var scrollIntoView = uiUtils.scrollIntoView;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFFindController = exports.FindStates = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var FindStates = {
FIND_FOUND: 0,
FIND_NOTFOUND: 1,
@ -311,7 +316,7 @@ var PDFFindController = function PDFFindControllerClosure() { @@ -311,7 +316,7 @@ var PDFFindController = function PDFFindControllerClosure() {
top: FIND_SCROLL_OFFSET_TOP,
left: FIND_SCROLL_OFFSET_LEFT
};
scrollIntoView(elements[beginIdx], spot, true);
(0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
}
},
nextPageMatch: function PDFFindController_nextPageMatch() {

10
lib/web/pdf_history.js

@ -14,10 +14,16 @@ @@ -14,10 +14,16 @@
*/
'use strict';
var domEvents = require('./dom_events.js');
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFHistory = undefined;
var _dom_events = require('pdfjs-web/dom_events');
function PDFHistory(options) {
this.linkService = options.linkService;
this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.initialized = false;
this.initialDestination = null;
this.initialBookmark = null;

16
lib/web/pdf_link_service.js

@ -14,9 +14,15 @@ @@ -14,9 +14,15 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var domEvents = require('./dom_events.js');
var parseQueryString = uiUtils.parseQueryString;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SimpleLinkService = exports.PDFLinkService = undefined;
var _dom_events = require('pdfjs-web/dom_events');
var _ui_utils = require('pdfjs-web/ui_utils');
var PageNumberRegExp = /^\d+$/;
function isPageNumber(str) {
return PageNumberRegExp.test(str);
@ -24,7 +30,7 @@ function isPageNumber(str) { @@ -24,7 +30,7 @@ function isPageNumber(str) {
var PDFLinkService = function PDFLinkServiceClosure() {
function PDFLinkService(options) {
options = options || {};
this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.baseUrl = null;
this.pdfDocument = null;
this.pdfViewer = null;
@ -122,7 +128,7 @@ var PDFLinkService = function PDFLinkServiceClosure() { @@ -122,7 +128,7 @@ var PDFLinkService = function PDFLinkServiceClosure() {
setHash: function PDFLinkService_setHash(hash) {
var pageNumber, dest;
if (hash.indexOf('=') >= 0) {
var params = parseQueryString(hash);
var params = (0, _ui_utils.parseQueryString)(hash);
if ('search' in params) {
this.eventBus.dispatch('findfromurlhash', {
source: this,

15
lib/web/pdf_outline_viewer.js

@ -14,8 +14,13 @@ @@ -14,8 +14,13 @@
*/
'use strict';
var pdfjsLib = require('./pdfjs.js');
var PDFJS = pdfjsLib.PDFJS;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFOutlineViewer = undefined;
var _pdfjs = require('pdfjs-web/pdfjs');
var DEFAULT_TITLE = '\u2013';
var PDFOutlineViewer = function PDFOutlineViewerClosure() {
function PDFOutlineViewer(options) {
@ -40,9 +45,9 @@ var PDFOutlineViewer = function PDFOutlineViewerClosure() { @@ -40,9 +45,9 @@ var PDFOutlineViewer = function PDFOutlineViewerClosure() {
},
_bindLink: function PDFOutlineViewer_bindLink(element, item) {
if (item.url) {
pdfjsLib.addLinkAttributes(element, {
(0, _pdfjs.addLinkAttributes)(element, {
url: item.url,
target: item.newWindow ? PDFJS.LinkTarget.BLANK : undefined
target: item.newWindow ? _pdfjs.PDFJS.LinkTarget.BLANK : undefined
});
return;
}
@ -120,7 +125,7 @@ var PDFOutlineViewer = function PDFOutlineViewerClosure() { @@ -120,7 +125,7 @@ var PDFOutlineViewer = function PDFOutlineViewerClosure() {
var element = document.createElement('a');
this._bindLink(element, item);
this._setStyles(element, item);
element.textContent = pdfjsLib.removeNullCharacters(item.title) || DEFAULT_TITLE;
element.textContent = (0, _pdfjs.removeNullCharacters)(item.title) || DEFAULT_TITLE;
div.appendChild(element);
if (item.items.length > 0) {
hasAnyNesting = true;

98
lib/web/pdf_page_view.js

@ -14,17 +14,19 @@ @@ -14,17 +14,19 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var pdfRenderingQueue = require('./pdf_rendering_queue.js');
var domEvents = require('./dom_events.js');
var pdfjsLib = require('./pdfjs.js');
var CSS_UNITS = uiUtils.CSS_UNITS;
var DEFAULT_SCALE = uiUtils.DEFAULT_SCALE;
var getOutputScale = uiUtils.getOutputScale;
var approximateFraction = uiUtils.approximateFraction;
var roundToDivide = uiUtils.roundToDivide;
var RendererType = uiUtils.RendererType;
var RenderingStates = pdfRenderingQueue.RenderingStates;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFPageView = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _pdfjs = require('pdfjs-web/pdfjs');
var _dom_events = require('pdfjs-web/dom_events');
var _pdf_rendering_queue = require('pdfjs-web/pdf_rendering_queue');
var TEXT_LAYER_RENDER_DELAY = 200;
var PDFPageView = function PDFPageViewClosure() {
function PDFPageView(options) {
@ -41,20 +43,20 @@ var PDFPageView = function PDFPageViewClosure() { @@ -41,20 +43,20 @@ var PDFPageView = function PDFPageViewClosure() {
this.renderingId = 'page' + id;
this.pageLabel = null;
this.rotation = 0;
this.scale = scale || DEFAULT_SCALE;
this.scale = scale || _ui_utils.DEFAULT_SCALE;
this.viewport = defaultViewport;
this.pdfPageRotate = defaultViewport.rotation;
this.hasRestrictedScaling = false;
this.enhanceTextSelection = enhanceTextSelection;
this.renderInteractiveForms = renderInteractiveForms;
this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.renderingQueue = renderingQueue;
this.textLayerFactory = textLayerFactory;
this.annotationLayerFactory = annotationLayerFactory;
this.renderer = options.renderer || RendererType.CANVAS;
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
this.paintTask = null;
this.paintedViewportMap = new WeakMap();
this.renderingState = RenderingStates.INITIAL;
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
this.resume = null;
this.error = null;
this.onBeforeDraw = null;
@ -75,7 +77,7 @@ var PDFPageView = function PDFPageViewClosure() { @@ -75,7 +77,7 @@ var PDFPageView = function PDFPageViewClosure() {
this.pdfPage = pdfPage;
this.pdfPageRotate = pdfPage.rotate;
var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
this.viewport = pdfPage.getViewport(this.scale * CSS_UNITS, totalRotation);
this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
this.stats = pdfPage.stats;
this.reset();
},
@ -143,7 +145,7 @@ var PDFPageView = function PDFPageViewClosure() { @@ -143,7 +145,7 @@ var PDFPageView = function PDFPageViewClosure() {
}
var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
this.viewport = this.viewport.clone({
scale: this.scale * CSS_UNITS,
scale: this.scale * _ui_utils.CSS_UNITS,
rotation: totalRotation
});
if (this.svg) {
@ -156,14 +158,14 @@ var PDFPageView = function PDFPageViewClosure() { @@ -156,14 +158,14 @@ var PDFPageView = function PDFPageViewClosure() {
return;
}
var isScalingRestricted = false;
if (this.canvas && pdfjsLib.PDFJS.maxCanvasPixels > 0) {
if (this.canvas && _pdfjs.PDFJS.maxCanvasPixels > 0) {
var outputScale = this.outputScale;
if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > pdfjsLib.PDFJS.maxCanvasPixels) {
if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > _pdfjs.PDFJS.maxCanvasPixels) {
isScalingRestricted = true;
}
}
if (this.canvas) {
if (pdfjsLib.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
if (_pdfjs.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
this.cssTransform(this.canvas, true);
this.eventBus.dispatch('pagerendered', {
source: this,
@ -187,7 +189,7 @@ var PDFPageView = function PDFPageViewClosure() { @@ -187,7 +189,7 @@ var PDFPageView = function PDFPageViewClosure() {
this.paintTask.cancel();
this.paintTask = null;
}
this.renderingState = RenderingStates.INITIAL;
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
this.resume = null;
if (this.textLayer) {
this.textLayer.cancel();
@ -200,7 +202,6 @@ var PDFPageView = function PDFPageViewClosure() { @@ -200,7 +202,6 @@ var PDFPageView = function PDFPageViewClosure() {
}
},
cssTransform: function PDFPageView_transform(target, redrawAnnotations) {
var CustomStyle = pdfjsLib.CustomStyle;
var width = this.viewport.width;
var height = this.viewport.height;
var div = this.div;
@ -215,7 +216,7 @@ var PDFPageView = function PDFPageViewClosure() { @@ -215,7 +216,7 @@ var PDFPageView = function PDFPageViewClosure() {
scaleY = width / height;
}
var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
CustomStyle.setProp('transform', target, cssTransform);
_pdfjs.CustomStyle.setProp('transform', target, cssTransform);
if (this.textLayer) {
var textLayerViewport = this.textLayer.viewport;
var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
@ -246,8 +247,8 @@ var PDFPageView = function PDFPageViewClosure() { @@ -246,8 +247,8 @@ var PDFPageView = function PDFPageViewClosure() {
console.error('Bad rotation value.');
break;
}
CustomStyle.setProp('transform', textLayerDiv, 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')');
CustomStyle.setProp('transformOrigin', textLayerDiv, '0% 0%');
_pdfjs.CustomStyle.setProp('transform', textLayerDiv, 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')');
_pdfjs.CustomStyle.setProp('transformOrigin', textLayerDiv, '0% 0%');
}
if (redrawAnnotations && this.annotationLayer) {
this.annotationLayer.render(this.viewport, 'display');
@ -263,11 +264,11 @@ var PDFPageView = function PDFPageViewClosure() { @@ -263,11 +264,11 @@ var PDFPageView = function PDFPageViewClosure() {
return this.viewport.convertToPdfPoint(x, y);
},
draw: function PDFPageView_draw() {
if (this.renderingState !== RenderingStates.INITIAL) {
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
this.reset();
}
this.renderingState = RenderingStates.RUNNING;
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
var self = this;
var pdfPage = this.pdfPage;
var div = this.div;
@ -299,9 +300,9 @@ var PDFPageView = function PDFPageViewClosure() { @@ -299,9 +300,9 @@ var PDFPageView = function PDFPageViewClosure() {
if (this.renderingQueue) {
renderContinueCallback = function renderContinueCallback(cont) {
if (!self.renderingQueue.isHighestPriority(self)) {
self.renderingState = RenderingStates.PAUSED;
self.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
self.resume = function resumeCallback() {
self.renderingState = RenderingStates.RUNNING;
self.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
cont();
};
return;
@ -313,11 +314,11 @@ var PDFPageView = function PDFPageViewClosure() { @@ -313,11 +314,11 @@ var PDFPageView = function PDFPageViewClosure() {
if (paintTask === self.paintTask) {
self.paintTask = null;
}
if (error === 'cancelled' || error instanceof pdfjsLib.RenderingCancelledException) {
if (error === 'cancelled' || error instanceof _pdfjs.RenderingCancelledException) {
self.error = null;
return Promise.resolve(undefined);
}
self.renderingState = RenderingStates.FINISHED;
self.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
if (self.loadingIconDiv) {
div.removeChild(self.loadingIconDiv);
delete self.loadingIconDiv;
@ -338,7 +339,7 @@ var PDFPageView = function PDFPageViewClosure() { @@ -338,7 +339,7 @@ var PDFPageView = function PDFPageViewClosure() {
}
return Promise.resolve(undefined);
};
var paintTask = this.renderer === RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
paintTask.onRenderContinue = renderContinueCallback;
this.paintTask = paintTask;
var resultPromise = paintTask.promise.then(function () {
@ -395,17 +396,17 @@ var PDFPageView = function PDFPageViewClosure() { @@ -395,17 +396,17 @@ var PDFPageView = function PDFPageViewClosure() {
this.canvas = canvas;
canvas.mozOpaque = true;
var ctx = canvas.getContext('2d', { alpha: false });
var outputScale = getOutputScale(ctx);
var outputScale = (0, _ui_utils.getOutputScale)(ctx);
this.outputScale = outputScale;
if (pdfjsLib.PDFJS.useOnlyCssZoom) {
var actualSizeViewport = viewport.clone({ scale: CSS_UNITS });
if (_pdfjs.PDFJS.useOnlyCssZoom) {
var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
outputScale.sx *= actualSizeViewport.width / viewport.width;
outputScale.sy *= actualSizeViewport.height / viewport.height;
outputScale.scaled = true;
}
if (pdfjsLib.PDFJS.maxCanvasPixels > 0) {
if (_pdfjs.PDFJS.maxCanvasPixels > 0) {
var pixelsInViewport = viewport.width * viewport.height;
var maxScale = Math.sqrt(pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
var maxScale = Math.sqrt(_pdfjs.PDFJS.maxCanvasPixels / pixelsInViewport);
if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
outputScale.sx = maxScale;
outputScale.sy = maxScale;
@ -415,12 +416,12 @@ var PDFPageView = function PDFPageViewClosure() { @@ -415,12 +416,12 @@ var PDFPageView = function PDFPageViewClosure() {
this.hasRestrictedScaling = false;
}
}
var sfx = approximateFraction(outputScale.sx);
var sfy = approximateFraction(outputScale.sy);
canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);
canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);
canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
canvas.style.height = roundToDivide(viewport.height, sfy[1]) + 'px';
var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
this.paintedViewportMap.set(canvas, viewport);
var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
var renderContext = {
@ -451,8 +452,8 @@ var PDFPageView = function PDFPageViewClosure() { @@ -451,8 +452,8 @@ var PDFPageView = function PDFPageViewClosure() {
var cancelled = false;
var ensureNotCancelled = function () {
if (cancelled) {
if (pdfjsLib.PDFJS.pdfjsNext) {
throw new pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + self.id, 'svg');
if (_pdfjs.PDFJS.pdfjsNext) {
throw new _pdfjs.RenderingCancelledException('Rendering cancelled, page ' + self.id, 'svg');
} else {
throw 'cancelled';
}
@ -460,18 +461,17 @@ var PDFPageView = function PDFPageViewClosure() { @@ -460,18 +461,17 @@ var PDFPageView = function PDFPageViewClosure() {
};
var self = this;
var pdfPage = this.pdfPage;
var SVGGraphics = pdfjsLib.SVGGraphics;
var actualSizeViewport = this.viewport.clone({ scale: CSS_UNITS });
var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
var promise = pdfPage.getOperatorList().then(function (opList) {
ensureNotCancelled();
var svgGfx = new SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
var svgGfx = new _pdfjs.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
ensureNotCancelled();
self.svg = svg;
self.paintedViewportMap.set(svg, actualSizeViewport);
svg.style.width = wrapper.style.width;
svg.style.height = wrapper.style.height;
self.renderingState = RenderingStates.FINISHED;
self.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
wrapper.appendChild(svg);
});
});

11
lib/web/pdf_presentation_mode.js

@ -14,8 +14,13 @@ @@ -14,8 +14,13 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var normalizeWheelEventDelta = uiUtils.normalizeWheelEventDelta;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFPresentationMode = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
var DELAY_BEFORE_HIDING_CONTROLS = 3000;
var ACTIVE_SELECTOR = 'pdfPresentationMode';
@ -82,7 +87,7 @@ var PDFPresentationMode = function PDFPresentationModeClosure() { @@ -82,7 +87,7 @@ var PDFPresentationMode = function PDFPresentationModeClosure() {
return;
}
evt.preventDefault();
var delta = normalizeWheelEventDelta(evt);
var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
var MOUSE_SCROLL_COOLDOWN_TIME = 50;
var PAGE_SWITCH_THRESHOLD = 0.1;
var currentTime = new Date().getTime();

43
lib/web/pdf_print_service.js

@ -14,14 +14,19 @@ @@ -14,14 +14,19 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var overlayManager = require('./overlay_manager.js');
var app = require('./app.js');
var pdfjsLib = require('./pdfjs.js');
var mozL10n = uiUtils.mozL10n;
var CSS_UNITS = uiUtils.CSS_UNITS;
var PDFPrintServiceFactory = app.PDFPrintServiceFactory;
var OverlayManager = overlayManager.OverlayManager;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFPrintService = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _overlay_manager = require('pdfjs-web/overlay_manager');
var _pdfjs = require('pdfjs-web/pdfjs');
var _app = require('pdfjs-web/app');
var activeService = null;
function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
var scratchCanvas = activeService.scratchCanvas;
@ -29,8 +34,8 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) { @@ -29,8 +34,8 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
var width = Math.floor(size.width * CSS_UNITS) + 'px';
var height = Math.floor(size.height * CSS_UNITS) + 'px';
var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
var ctx = scratchCanvas.getContext('2d');
ctx.save();
ctx.fillStyle = 'rgb(255, 255, 255)';
@ -87,10 +92,10 @@ PDFPrintService.prototype = { @@ -87,10 +92,10 @@ PDFPrintService.prototype = {
this.scratchCanvas = null;
activeService = null;
ensureOverlay().then(function () {
if (OverlayManager.active !== 'printServiceOverlay') {
if (_overlay_manager.OverlayManager.active !== 'printServiceOverlay') {
return;
}
OverlayManager.close('printServiceOverlay');
_overlay_manager.OverlayManager.close('printServiceOverlay');
});
},
renderPages: function () {
@ -116,7 +121,7 @@ PDFPrintService.prototype = { @@ -116,7 +121,7 @@ PDFPrintService.prototype = {
img.style.width = printItem.width;
img.style.height = printItem.height;
var scratchCanvas = this.scratchCanvas;
if ('toBlob' in scratchCanvas && !pdfjsLib.PDFJS.disableCreateObjectURL) {
if ('toBlob' in scratchCanvas && !_pdfjs.PDFJS.disableCreateObjectURL) {
scratchCanvas.toBlob(function (blob) {
img.src = URL.createObjectURL(blob);
});
@ -161,7 +166,7 @@ window.print = function print() { @@ -161,7 +166,7 @@ window.print = function print() {
}
ensureOverlay().then(function () {
if (activeService) {
OverlayManager.open('printServiceOverlay');
_overlay_manager.OverlayManager.open('printServiceOverlay');
}
});
try {
@ -169,8 +174,8 @@ window.print = function print() { @@ -169,8 +174,8 @@ window.print = function print() {
} finally {
if (!activeService) {
console.error('Expected print service to be initialized.');
if (OverlayManager.active === 'printServiceOverlay') {
OverlayManager.close('printServiceOverlay');
if (_overlay_manager.OverlayManager.active === 'printServiceOverlay') {
_overlay_manager.OverlayManager.close('printServiceOverlay');
}
return;
}
@ -201,7 +206,7 @@ function renderProgress(index, total) { @@ -201,7 +206,7 @@ function renderProgress(index, total) {
var progressBar = progressContainer.querySelector('progress');
var progressPerc = progressContainer.querySelector('.relative-progress');
progressBar.value = progress;
progressPerc.textContent = mozL10n.get('print_progress_percent', { progress: progress }, progress + '%');
progressPerc.textContent = _ui_utils.mozL10n.get('print_progress_percent', { progress: progress }, progress + '%');
}
var hasAttachEvent = !!document.attachEvent;
window.addEventListener('keydown', function (event) {
@ -240,12 +245,12 @@ if ('onbeforeprint' in window) { @@ -240,12 +245,12 @@ if ('onbeforeprint' in window) {
var overlayPromise;
function ensureOverlay() {
if (!overlayPromise) {
overlayPromise = OverlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
overlayPromise = _overlay_manager.OverlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
document.getElementById('printCancel').onclick = abort;
}
return overlayPromise;
}
PDFPrintServiceFactory.instance = {
_app.PDFPrintServiceFactory.instance = {
supportsPrinting: true,
createPrintService: function (pdfDocument, pagesOverview, printContainer) {
if (activeService) {

5
lib/web/pdf_rendering_queue.js

@ -12,8 +12,11 @@ @@ -12,8 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var CLEANUP_TIMEOUT = 30000;
var RenderingStates = {
INITIAL: 0,

19
lib/web/pdf_sidebar.js

@ -14,10 +14,15 @@ @@ -14,10 +14,15 @@
*/
'use strict';
var pdfRenderingQueue = require('./pdf_rendering_queue.js');
var uiUtils = require('./ui_utils.js');
var RenderingStates = pdfRenderingQueue.RenderingStates;
var mozL10n = uiUtils.mozL10n;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFSidebar = exports.SidebarView = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _pdf_rendering_queue = require('pdfjs-web/pdf_rendering_queue');
var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
var SidebarView = {
NONE: 0,
@ -194,7 +199,7 @@ var PDFSidebar = function PDFSidebarClosure() { @@ -194,7 +199,7 @@ var PDFSidebar = function PDFSidebarClosure() {
var pagesCount = pdfViewer.pagesCount;
for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
var pageView = pdfViewer.getPageView(pageIndex);
if (pageView && pageView.renderingState === RenderingStates.FINISHED) {
if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
var thumbnailView = thumbnailViewer.getThumbnail(pageIndex);
thumbnailView.setImage(pageView);
}
@ -205,7 +210,7 @@ var PDFSidebar = function PDFSidebarClosure() { @@ -205,7 +210,7 @@ var PDFSidebar = function PDFSidebarClosure() {
if (this.disableNotification) {
return;
}
this.toggleButton.title = mozL10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)');
this.toggleButton.title = _ui_utils.mozL10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)');
if (!this.isOpen) {
this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
} else if (view === this.active) {
@ -245,7 +250,7 @@ var PDFSidebar = function PDFSidebarClosure() { @@ -245,7 +250,7 @@ var PDFSidebar = function PDFSidebarClosure() {
for (view in SidebarView) {
removeNotification(SidebarView[view]);
}
this.toggleButton.title = mozL10n.get('toggle_sidebar.title', null, 'Toggle Sidebar');
this.toggleButton.title = _ui_utils.mozL10n.get('toggle_sidebar.title', null, 'Toggle Sidebar');
},
_addEventListeners: function PDFSidebar_addEventListeners() {
var self = this;

46
lib/web/pdf_thumbnail_view.js

@ -14,11 +14,15 @@ @@ -14,11 +14,15 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var pdfRenderingQueue = require('./pdf_rendering_queue.js');
var mozL10n = uiUtils.mozL10n;
var getOutputScale = uiUtils.getOutputScale;
var RenderingStates = pdfRenderingQueue.RenderingStates;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFThumbnailView = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _pdf_rendering_queue = require('pdfjs-web/pdf_rendering_queue');
var THUMBNAIL_WIDTH = 98;
var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
var PDFThumbnailView = function PDFThumbnailViewClosure() {
@ -55,7 +59,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -55,7 +59,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
this.linkService = linkService;
this.renderingQueue = renderingQueue;
this.renderTask = null;
this.renderingState = RenderingStates.INITIAL;
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
this.resume = null;
this.disableCanvasToImageConversion = disableCanvasToImageConversion;
this.pageWidth = this.viewport.width;
@ -66,7 +70,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -66,7 +70,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
this.scale = this.canvasWidth / this.pageWidth;
var anchor = document.createElement('a');
anchor.href = linkService.getAnchorUrl('#page=' + id);
anchor.title = mozL10n.get('thumb_page_title', { page: id }, 'Page {{page}}');
anchor.title = _ui_utils.mozL10n.get('thumb_page_title', { page: id }, 'Page {{page}}');
anchor.onclick = function stopNavigation() {
linkService.page = id;
return false;
@ -139,7 +143,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -139,7 +143,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
this.renderTask.cancel();
this.renderTask = null;
}
this.renderingState = RenderingStates.INITIAL;
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
this.resume = null;
},
_getPageDrawContext: function PDFThumbnailView_getPageDrawContext(noCtxScale) {
@ -147,7 +151,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -147,7 +151,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
this.canvas = canvas;
canvas.mozOpaque = true;
var ctx = canvas.getContext('2d', { alpha: false });
var outputScale = getOutputScale(ctx);
var outputScale = (0, _ui_utils.getOutputScale)(ctx);
canvas.width = this.canvasWidth * outputScale.sx | 0;
canvas.height = this.canvasHeight * outputScale.sy | 0;
canvas.style.width = this.canvasWidth + 'px';
@ -161,12 +165,12 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -161,12 +165,12 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
if (!this.canvas) {
return;
}
if (this.renderingState !== RenderingStates.FINISHED) {
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
return;
}
var id = this.renderingId;
var className = 'thumbnailImage';
var ariaLabel = mozL10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}');
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;
@ -190,11 +194,11 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -190,11 +194,11 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
delete this.canvas;
},
draw: function PDFThumbnailView_draw() {
if (this.renderingState !== RenderingStates.INITIAL) {
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
return Promise.resolve(undefined);
}
this.renderingState = RenderingStates.RUNNING;
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
var resolveRenderPromise, rejectRenderPromise;
var promise = new Promise(function (resolve, reject) {
resolveRenderPromise = resolve;
@ -209,7 +213,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -209,7 +213,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
rejectRenderPromise(error);
return;
}
self.renderingState = RenderingStates.FINISHED;
self.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
self._convertCanvasToImage();
if (!error) {
resolveRenderPromise(undefined);
@ -221,9 +225,9 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -221,9 +225,9 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
var drawViewport = this.viewport.clone({ scale: this.scale });
var renderContinueCallback = function renderContinueCallback(cont) {
if (!self.renderingQueue.isHighestPriority(self)) {
self.renderingState = RenderingStates.PAUSED;
self.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
self.resume = function resumeCallback() {
self.renderingState = RenderingStates.RUNNING;
self.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
cont();
};
return;
@ -244,7 +248,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -244,7 +248,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
return promise;
},
setImage: function PDFThumbnailView_setImage(pageView) {
if (this.renderingState !== RenderingStates.INITIAL) {
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
return;
}
var img = pageView.canvas;
@ -254,7 +258,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -254,7 +258,7 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
if (!this.pdfPage) {
this.setPdfPage(pageView.pdfPage);
}
this.renderingState = RenderingStates.FINISHED;
this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
var ctx = this._getPageDrawContext(true);
var canvas = ctx.canvas;
if (img.width <= 2 * canvas.width) {
@ -285,11 +289,11 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() { @@ -285,11 +289,11 @@ var PDFThumbnailView = function PDFThumbnailViewClosure() {
},
setPageLabel: function PDFThumbnailView_setPageLabel(label) {
this.pageLabel = typeof label === 'string' ? label : null;
this.anchor.title = mozL10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}');
if (this.renderingState !== RenderingStates.FINISHED) {
this.anchor.title = _ui_utils.mozL10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}');
if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
return;
}
var ariaLabel = mozL10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}');
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) {

27
lib/web/pdf_thumbnail_viewer.js

@ -14,19 +14,22 @@ @@ -14,19 +14,22 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var pdfThumbnailView = require('./pdf_thumbnail_view.js');
var watchScroll = uiUtils.watchScroll;
var getVisibleElements = uiUtils.getVisibleElements;
var scrollIntoView = uiUtils.scrollIntoView;
var PDFThumbnailView = pdfThumbnailView.PDFThumbnailView;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFThumbnailViewer = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _pdf_thumbnail_view = require('pdfjs-web/pdf_thumbnail_view');
var THUMBNAIL_SCROLL_MARGIN = -19;
var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
function PDFThumbnailViewer(options) {
this.container = options.container;
this.renderingQueue = options.renderingQueue;
this.linkService = options.linkService;
this.scroll = watchScroll(this.container, this._scrollUpdated.bind(this));
this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
this._resetView();
}
PDFThumbnailViewer.prototype = {
@ -37,7 +40,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() { @@ -37,7 +40,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
return this.thumbnails[index];
},
_getVisibleThumbs: function PDFThumbnailViewer_getVisibleThumbs() {
return getVisibleElements(this.container, this.thumbnails);
return (0, _ui_utils.getVisibleElements)(this.container, this.thumbnails);
},
scrollThumbnailIntoView: function PDFThumbnailViewer_scrollThumbnailIntoView(page) {
var selected = document.querySelector('.thumbnail.selected');
@ -54,7 +57,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() { @@ -54,7 +57,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
var first = visibleThumbs.first.id;
var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
if (page <= first || page >= last) {
scrollIntoView(thumbnail, { top: THUMBNAIL_SCROLL_MARGIN });
(0, _ui_utils.scrollIntoView)(thumbnail, { top: THUMBNAIL_SCROLL_MARGIN });
}
}
},
@ -69,12 +72,12 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() { @@ -69,12 +72,12 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
}
},
cleanup: function PDFThumbnailViewer_cleanup() {
var tempCanvas = PDFThumbnailView.tempImageCache;
var tempCanvas = _pdf_thumbnail_view.PDFThumbnailView.tempImageCache;
if (tempCanvas) {
tempCanvas.width = 0;
tempCanvas.height = 0;
}
PDFThumbnailView.tempImageCache = null;
_pdf_thumbnail_view.PDFThumbnailView.tempImageCache = null;
},
_resetView: function PDFThumbnailViewer_resetView() {
this.thumbnails = [];
@ -96,7 +99,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() { @@ -96,7 +99,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
var pagesCount = pdfDocument.numPages;
var viewport = firstPage.getViewport(1.0);
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
var thumbnail = new PDFThumbnailView({
var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
container: this.container,
id: pageNum,
defaultViewport: viewport.clone(),

110
lib/web/pdf_viewer.js

@ -14,31 +14,27 @@ @@ -14,31 +14,27 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var pdfPageView = require('./pdf_page_view.js');
var pdfRenderingQueue = require('./pdf_rendering_queue.js');
var textLayerBuilder = require('./text_layer_builder.js');
var annotationLayerBuilder = require('./annotation_layer_builder.js');
var pdfLinkService = require('./pdf_link_service.js');
var domEvents = require('./dom_events.js');
var pdfjsLib = require('./pdfjs.js');
var UNKNOWN_SCALE = uiUtils.UNKNOWN_SCALE;
var SCROLLBAR_PADDING = uiUtils.SCROLLBAR_PADDING;
var VERTICAL_PADDING = uiUtils.VERTICAL_PADDING;
var MAX_AUTO_SCALE = uiUtils.MAX_AUTO_SCALE;
var CSS_UNITS = uiUtils.CSS_UNITS;
var DEFAULT_SCALE = uiUtils.DEFAULT_SCALE;
var DEFAULT_SCALE_VALUE = uiUtils.DEFAULT_SCALE_VALUE;
var RendererType = uiUtils.RendererType;
var scrollIntoView = uiUtils.scrollIntoView;
var watchScroll = uiUtils.watchScroll;
var getVisibleElements = uiUtils.getVisibleElements;
var PDFPageView = pdfPageView.PDFPageView;
var RenderingStates = pdfRenderingQueue.RenderingStates;
var PDFRenderingQueue = pdfRenderingQueue.PDFRenderingQueue;
var TextLayerBuilder = textLayerBuilder.TextLayerBuilder;
var AnnotationLayerBuilder = annotationLayerBuilder.AnnotationLayerBuilder;
var SimpleLinkService = pdfLinkService.SimpleLinkService;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFViewer = exports.PresentationModeState = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var _pdf_rendering_queue = require('pdfjs-web/pdf_rendering_queue');
var _annotation_layer_builder = require('pdfjs-web/annotation_layer_builder');
var _dom_events = require('pdfjs-web/dom_events');
var _pdfjs = require('pdfjs-web/pdfjs');
var _pdf_page_view = require('pdfjs-web/pdf_page_view');
var _pdf_link_service = require('pdfjs-web/pdf_link_service');
var _text_layer_builder = require('pdfjs-web/text_layer_builder');
var PresentationModeState = {
UNKNOWN: 0,
NORMAL: 1,
@ -81,22 +77,22 @@ var PDFViewer = function pdfViewer() { @@ -81,22 +77,22 @@ var PDFViewer = function pdfViewer() {
function PDFViewer(options) {
this.container = options.container;
this.viewer = options.viewer || options.container.firstElementChild;
this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
this.linkService = options.linkService || new SimpleLinkService();
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
this.downloadManager = options.downloadManager || null;
this.removePageBorders = options.removePageBorders || false;
this.enhanceTextSelection = options.enhanceTextSelection || false;
this.renderInteractiveForms = options.renderInteractiveForms || false;
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
this.renderer = options.renderer || RendererType.CANVAS;
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) {
this.renderingQueue = new PDFRenderingQueue();
this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
this.renderingQueue.setViewer(this);
} else {
this.renderingQueue = options.renderingQueue;
}
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this));
this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
this.presentationModeState = PresentationModeState.UNKNOWN;
this._resetView();
if (this.removePageBorders) {
@ -163,7 +159,7 @@ var PDFViewer = function pdfViewer() { @@ -163,7 +159,7 @@ var PDFViewer = function pdfViewer() {
this.currentPageNumber = pageNumber;
},
get currentScale() {
return this._currentScale !== UNKNOWN_SCALE ? this._currentScale : DEFAULT_SCALE;
return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
},
set currentScale(val) {
if (isNaN(val)) {
@ -171,7 +167,7 @@ var PDFViewer = function pdfViewer() { @@ -171,7 +167,7 @@ var PDFViewer = function pdfViewer() {
}
if (!this.pdfDocument) {
this._currentScale = val;
this._currentScaleValue = val !== UNKNOWN_SCALE ? val.toString() : null;
this._currentScaleValue = val !== _ui_utils.UNKNOWN_SCALE ? val.toString() : null;
return;
}
this._setScale(val, false);
@ -181,7 +177,7 @@ var PDFViewer = function pdfViewer() { @@ -181,7 +177,7 @@ var PDFViewer = function pdfViewer() {
},
set currentScaleValue(val) {
if (!this.pdfDocument) {
this._currentScale = isNaN(val) ? UNKNOWN_SCALE : val;
this._currentScale = isNaN(val) ? _ui_utils.UNKNOWN_SCALE : val;
this._currentScaleValue = val.toString();
return;
}
@ -251,13 +247,13 @@ var PDFViewer = function pdfViewer() { @@ -251,13 +247,13 @@ var PDFViewer = function pdfViewer() {
this.firstPagePromise = firstPagePromise;
return firstPagePromise.then(function (pdfPage) {
var scale = this.currentScale;
var viewport = pdfPage.getViewport(scale * CSS_UNITS);
var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
var textLayerFactory = null;
if (!pdfjsLib.PDFJS.disableTextLayer) {
if (!_pdfjs.PDFJS.disableTextLayer) {
textLayerFactory = this;
}
var pageView = new PDFPageView({
var pageView = new _pdf_page_view.PDFPageView({
container: this.viewer,
eventBus: this.eventBus,
id: pageNum,
@ -275,7 +271,7 @@ var PDFViewer = function pdfViewer() { @@ -275,7 +271,7 @@ var PDFViewer = function pdfViewer() {
}
var linkService = this.linkService;
onePageRendered.then(function () {
if (!pdfjsLib.PDFJS.disableAutoFetch) {
if (!_pdfjs.PDFJS.disableAutoFetch) {
var getPagesLeft = pagesCount;
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) {
@ -324,7 +320,7 @@ var PDFViewer = function pdfViewer() { @@ -324,7 +320,7 @@ var PDFViewer = function pdfViewer() {
_resetView: function () {
this._pages = [];
this._currentPageNumber = 1;
this._currentScale = UNKNOWN_SCALE;
this._currentScale = _ui_utils.UNKNOWN_SCALE;
this._currentScaleValue = null;
this._pageLabels = null;
this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
@ -367,7 +363,7 @@ var PDFViewer = function pdfViewer() { @@ -367,7 +363,7 @@ var PDFViewer = function pdfViewer() {
if (!noScroll) {
var page = this._currentPageNumber,
dest;
if (this._location && !pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
if (this._location && !_pdfjs.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
page = this._location.pageNumber;
dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
}
@ -391,8 +387,8 @@ var PDFViewer = function pdfViewer() { @@ -391,8 +387,8 @@ var PDFViewer = function pdfViewer() {
if (!currentPage) {
return;
}
var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : SCROLLBAR_PADDING;
var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : VERTICAL_PADDING;
var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
switch (value) {
@ -411,7 +407,7 @@ var PDFViewer = function pdfViewer() { @@ -411,7 +407,7 @@ var PDFViewer = function pdfViewer() {
case 'auto':
var isLandscape = currentPage.width > currentPage.height;
var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
scale = Math.min(MAX_AUTO_SCALE, horizontalScale);
scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
break;
default:
console.error('PDFViewer_setScale: "' + value + '" is an unknown zoom value.');
@ -425,7 +421,7 @@ var PDFViewer = function pdfViewer() { @@ -425,7 +421,7 @@ var PDFViewer = function pdfViewer() {
this._setScale(this._currentScaleValue, true);
}
var pageView = this._pages[this._currentPageNumber - 1];
scrollIntoView(pageView.div);
(0, _ui_utils.scrollIntoView)(pageView.div);
},
scrollPageIntoView: function PDFViewer_scrollPageIntoView(params) {
if (!this.pdfDocument) {
@ -461,8 +457,8 @@ var PDFViewer = function pdfViewer() { @@ -461,8 +457,8 @@ var PDFViewer = function pdfViewer() {
widthScale,
heightScale;
var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / CSS_UNITS;
var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / CSS_UNITS;
var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
var scale = 0;
switch (dest[1].name) {
case 'XYZ':
@ -497,10 +493,10 @@ var PDFViewer = function pdfViewer() { @@ -497,10 +493,10 @@ var PDFViewer = function pdfViewer() {
y = dest[3];
width = dest[4] - x;
height = dest[5] - y;
var hPadding = this.removePageBorders ? 0 : SCROLLBAR_PADDING;
var vPadding = this.removePageBorders ? 0 : VERTICAL_PADDING;
widthScale = (this.container.clientWidth - hPadding) / width / CSS_UNITS;
heightScale = (this.container.clientHeight - vPadding) / height / CSS_UNITS;
var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
break;
default:
@ -509,11 +505,11 @@ var PDFViewer = function pdfViewer() { @@ -509,11 +505,11 @@ var PDFViewer = function pdfViewer() {
}
if (scale && scale !== this._currentScale) {
this.currentScaleValue = scale;
} else if (this._currentScale === UNKNOWN_SCALE) {
this.currentScaleValue = DEFAULT_SCALE_VALUE;
} else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
}
if (scale === 'page-fit' && !dest[4]) {
scrollIntoView(pageView.div);
(0, _ui_utils.scrollIntoView)(pageView.div);
return;
}
var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
@ -523,7 +519,7 @@ var PDFViewer = function pdfViewer() { @@ -523,7 +519,7 @@ var PDFViewer = function pdfViewer() {
left = Math.max(left, 0);
top = Math.max(top, 0);
}
scrollIntoView(pageView.div, {
(0, _ui_utils.scrollIntoView)(pageView.div, {
left: left,
top: top
});
@ -599,7 +595,7 @@ var PDFViewer = function pdfViewer() { @@ -599,7 +595,7 @@ var PDFViewer = function pdfViewer() {
},
_getVisiblePages: function () {
if (!this.isInPresentationMode) {
return getVisibleElements(this.container, this._pages, true);
return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);
}
var visible = [];
var currentPage = this._pages[this._currentPageNumber - 1];
@ -615,7 +611,7 @@ var PDFViewer = function pdfViewer() { @@ -615,7 +611,7 @@ var PDFViewer = function pdfViewer() {
},
cleanup: function () {
for (var i = 0, ii = this._pages.length; i < ii; i++) {
if (this._pages[i] && this._pages[i].renderingState !== RenderingStates.FINISHED) {
if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
this._pages[i].reset();
}
}
@ -660,7 +656,7 @@ var PDFViewer = function pdfViewer() { @@ -660,7 +656,7 @@ var PDFViewer = function pdfViewer() {
});
},
createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport, enhanceTextSelection) {
return new TextLayerBuilder({
return new _text_layer_builder.TextLayerBuilder({
textLayerDiv: textLayerDiv,
eventBus: this.eventBus,
pageIndex: pageIndex,
@ -670,7 +666,7 @@ var PDFViewer = function pdfViewer() { @@ -670,7 +666,7 @@ var PDFViewer = function pdfViewer() {
});
},
createAnnotationLayerBuilder: function (pageDiv, pdfPage, renderInteractiveForms) {
return new AnnotationLayerBuilder({
return new _annotation_layer_builder.AnnotationLayerBuilder({
pageDiv: pageDiv,
pdfPage: pdfPage,
renderInteractiveForms: renderInteractiveForms,

31
lib/web/preferences.js

@ -12,8 +12,11 @@ @@ -12,8 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var defaultPreferences = null;
function getDefaultPreferences() {
if (!defaultPreferences) {
@ -130,16 +133,18 @@ var Preferences = { @@ -130,16 +133,18 @@ var Preferences = {
}.bind(this));
}
};
Preferences._writeToStorage = function (prefObj) {
return new Promise(function (resolve) {
localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
resolve();
});
};
Preferences._readFromStorage = function (prefObj) {
return new Promise(function (resolve) {
var readPrefs = JSON.parse(localStorage.getItem('pdfjs.preferences'));
resolve(readPrefs);
});
};
{
Preferences._writeToStorage = function (prefObj) {
return new Promise(function (resolve) {
localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
resolve();
});
};
Preferences._readFromStorage = function (prefObj) {
return new Promise(function (resolve) {
var readPrefs = JSON.parse(localStorage.getItem('pdfjs.preferences'));
resolve(readPrefs);
});
};
}
exports.Preferences = Preferences;

20
lib/web/secondary_toolbar.js

@ -14,9 +14,13 @@ @@ -14,9 +14,13 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var SCROLLBAR_PADDING = uiUtils.SCROLLBAR_PADDING;
var mozL10n = uiUtils.mozL10n;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SecondaryToolbar = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var SecondaryToolbar = function SecondaryToolbarClosure() {
function SecondaryToolbar(options, mainContainer, eventBus) {
this.toolbar = options.toolbar;
@ -131,11 +135,11 @@ var SecondaryToolbar = function SecondaryToolbarClosure() { @@ -131,11 +135,11 @@ var SecondaryToolbar = function SecondaryToolbarClosure() {
}
isHandToolActive = e.isActive;
if (isHandToolActive) {
toggleHandToolButton.title = mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
toggleHandToolButton.firstElementChild.textContent = mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
toggleHandToolButton.title = _ui_utils.mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
toggleHandToolButton.firstElementChild.textContent = _ui_utils.mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
} else {
toggleHandToolButton.title = mozL10n.get('hand_tool_enable.title', null, 'Enable hand tool');
toggleHandToolButton.firstElementChild.textContent = mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
toggleHandToolButton.title = _ui_utils.mozL10n.get('hand_tool_enable.title', null, 'Enable hand tool');
toggleHandToolButton.firstElementChild.textContent = _ui_utils.mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
}
});
},
@ -171,7 +175,7 @@ var SecondaryToolbar = function SecondaryToolbarClosure() { @@ -171,7 +175,7 @@ var SecondaryToolbar = function SecondaryToolbarClosure() {
if (this.containerHeight === this.previousContainerHeight) {
return;
}
this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - SCROLLBAR_PADDING) + 'px;');
this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
this.previousContainerHeight = this.containerHeight;
}
};

15
lib/web/text_layer_builder.js

@ -14,13 +14,20 @@ @@ -14,13 +14,20 @@
*/
'use strict';
var domEvents = require('./dom_events.js');
var pdfjsLib = require('./pdfjs.js');
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
var _dom_events = require('pdfjs-web/dom_events');
var _pdfjs = require('pdfjs-web/pdfjs');
var EXPAND_DIVS_TIMEOUT = 300;
var TextLayerBuilder = function TextLayerBuilderClosure() {
function TextLayerBuilder(options) {
this.textLayerDiv = options.textLayerDiv;
this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
this.eventBus = options.eventBus || _dom_events.domEvents.getGlobalEventBus();
this.textContent = null;
this.renderingDone = false;
this.pageIdx = options.pageIndex;
@ -54,7 +61,7 @@ var TextLayerBuilder = function TextLayerBuilderClosure() { @@ -54,7 +61,7 @@ var TextLayerBuilder = function TextLayerBuilderClosure() {
this.cancel();
this.textDivs = [];
var textLayerFrag = document.createDocumentFragment();
this.textLayerRenderTask = pdfjsLib.renderTextLayer({
this.textLayerRenderTask = (0, _pdfjs.renderTextLayer)({
textContent: this.textContent,
container: textLayerFrag,
viewport: this.viewport,

36
lib/web/toolbar.js

@ -14,15 +14,13 @@ @@ -14,15 +14,13 @@
*/
'use strict';
var uiUtils = require('./ui_utils.js');
var mozL10n = uiUtils.mozL10n;
var noContextMenuHandler = uiUtils.noContextMenuHandler;
var animationStarted = uiUtils.animationStarted;
var localized = uiUtils.localized;
var DEFAULT_SCALE_VALUE = uiUtils.DEFAULT_SCALE_VALUE;
var DEFAULT_SCALE = uiUtils.DEFAULT_SCALE;
var MIN_SCALE = uiUtils.MIN_SCALE;
var MAX_SCALE = uiUtils.MAX_SCALE;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Toolbar = undefined;
var _ui_utils = require('pdfjs-web/ui_utils');
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
var SCALE_SELECT_CONTAINER_PADDING = 8;
var SCALE_SELECT_PADDING = 22;
@ -57,8 +55,8 @@ var Toolbar = function ToolbarClosure() { @@ -57,8 +55,8 @@ var Toolbar = function ToolbarClosure() {
this.pageLabel = null;
this.hasPageLabels = false;
this.pagesCount = 0;
this.pageScaleValue = DEFAULT_SCALE_VALUE;
this.pageScale = DEFAULT_SCALE;
this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
this.pageScale = _ui_utils.DEFAULT_SCALE;
this._updateUIState(true);
},
_bindListeners: function Toolbar_bindClickListeners() {
@ -107,8 +105,8 @@ var Toolbar = function ToolbarClosure() { @@ -107,8 +105,8 @@ var Toolbar = function ToolbarClosure() {
items.download.addEventListener('click', function (e) {
eventBus.dispatch('download');
});
items.scaleSelect.oncontextmenu = noContextMenuHandler;
localized.then(this._localized.bind(this));
items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
_ui_utils.localized.then(this._localized.bind(this));
},
_localized: function Toolbar_localized() {
this._wasLocalized = true;
@ -130,7 +128,7 @@ var Toolbar = function ToolbarClosure() { @@ -130,7 +128,7 @@ var Toolbar = function ToolbarClosure() {
}
if (!predefinedValueFound) {
var customScale = Math.round(scale * 10000) / 100;
items.customScaleOption.textContent = mozL10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%');
items.customScaleOption.textContent = _ui_utils.mozL10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%');
items.customScaleOption.selected = true;
}
}
@ -147,13 +145,13 @@ var Toolbar = function ToolbarClosure() { @@ -147,13 +145,13 @@ var Toolbar = function ToolbarClosure() {
items.pageNumber.type = 'text';
} else {
items.pageNumber.type = 'number';
items.numPages.textContent = mozL10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}');
items.numPages.textContent = _ui_utils.mozL10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}');
}
items.pageNumber.max = pagesCount;
}
if (this.hasPageLabels) {
items.pageNumber.value = this.pageLabel;
items.numPages.textContent = mozL10n.get('page_of_pages', {
items.numPages.textContent = _ui_utils.mozL10n.get('page_of_pages', {
pageNumber: pageNumber,
pagesCount: pagesCount
}, '({{pageNumber}} of {{pagesCount}})');
@ -162,8 +160,8 @@ var Toolbar = function ToolbarClosure() { @@ -162,8 +160,8 @@ var Toolbar = function ToolbarClosure() {
}
items.previous.disabled = pageNumber <= 1;
items.next.disabled = pageNumber >= pagesCount;
items.zoomOut.disabled = scale <= MIN_SCALE;
items.zoomIn.disabled = scale >= MAX_SCALE;
items.zoomOut.disabled = scale <= _ui_utils.MIN_SCALE;
items.zoomIn.disabled = scale >= _ui_utils.MAX_SCALE;
selectScaleOption(scaleValue, scale);
},
updateLoadingIndicatorState: function Toolbar_updateLoadingIndicatorState(loading) {
@ -177,7 +175,7 @@ var Toolbar = function ToolbarClosure() { @@ -177,7 +175,7 @@ var Toolbar = function ToolbarClosure() {
_adjustScaleWidth: function Toolbar_adjustScaleWidth() {
var container = this.items.scaleSelectContainer;
var select = this.items.scaleSelect;
animationStarted.then(function () {
_ui_utils.animationStarted.then(function () {
if (container.clientWidth === 0) {
container.setAttribute('style', 'display: inherit;');
}

25
lib/web/ui_utils.js

@ -14,7 +14,13 @@ @@ -14,7 +14,13 @@
*/
'use strict';
var pdfjsLib = require('./pdfjs.js');
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.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 _pdfjs = require('pdfjs-web/pdfjs');
var CSS_UNITS = 96.0 / 72.0;
var DEFAULT_SCALE_VALUE = 'auto';
var DEFAULT_SCALE = 1.0;
@ -29,14 +35,15 @@ var RendererType = { @@ -29,14 +35,15 @@ var RendererType = {
SVG: 'svg'
};
var mozL10n = document.mozL10n || document.webL10n;
var PDFJS = pdfjsLib.PDFJS;
PDFJS.disableFullscreen = PDFJS.disableFullscreen === undefined ? false : PDFJS.disableFullscreen;
PDFJS.useOnlyCssZoom = PDFJS.useOnlyCssZoom === undefined ? false : PDFJS.useOnlyCssZoom;
PDFJS.maxCanvasPixels = PDFJS.maxCanvasPixels === undefined ? 16777216 : PDFJS.maxCanvasPixels;
PDFJS.disableHistory = PDFJS.disableHistory === undefined ? false : PDFJS.disableHistory;
PDFJS.disableTextLayer = PDFJS.disableTextLayer === undefined ? false : PDFJS.disableTextLayer;
PDFJS.ignoreCurrentPositionOnZoom = PDFJS.ignoreCurrentPositionOnZoom === undefined ? false : PDFJS.ignoreCurrentPositionOnZoom;
PDFJS.locale = PDFJS.locale === undefined ? navigator.language : PDFJS.locale;
_pdfjs.PDFJS.disableFullscreen = _pdfjs.PDFJS.disableFullscreen === undefined ? false : _pdfjs.PDFJS.disableFullscreen;
_pdfjs.PDFJS.useOnlyCssZoom = _pdfjs.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjs.PDFJS.useOnlyCssZoom;
_pdfjs.PDFJS.maxCanvasPixels = _pdfjs.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjs.PDFJS.maxCanvasPixels;
_pdfjs.PDFJS.disableHistory = _pdfjs.PDFJS.disableHistory === undefined ? false : _pdfjs.PDFJS.disableHistory;
_pdfjs.PDFJS.disableTextLayer = _pdfjs.PDFJS.disableTextLayer === undefined ? false : _pdfjs.PDFJS.disableTextLayer;
_pdfjs.PDFJS.ignoreCurrentPositionOnZoom = _pdfjs.PDFJS.ignoreCurrentPositionOnZoom === undefined ? false : _pdfjs.PDFJS.ignoreCurrentPositionOnZoom;
{
_pdfjs.PDFJS.locale = _pdfjs.PDFJS.locale === undefined ? navigator.language : _pdfjs.PDFJS.locale;
}
function getOutputScale(ctx) {
var devicePixelRatio = window.devicePixelRatio || 1;
var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;

3
lib/web/view_history.js

@ -14,6 +14,9 @@ @@ -14,6 +14,9 @@
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
var ViewHistory = function ViewHistoryClosure() {
function ViewHistory(fingerprint, cacheSize) {

2
package.json

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

7922
web/pdf_viewer.js

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save