|
@@ -14,65 +14,55 @@
|
|
*/
|
|
*/
|
|
'use strict';
|
|
'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 DEFAULT_SCALE_DELTA = 1.1;
|
|
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
|
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
|
function configure(PDFJS) {
|
|
function configure(PDFJS) {
|
|
@@ -81,13 +71,13 @@ function configure(PDFJS) {
|
|
PDFJS.cMapUrl = '../web/cmaps/';
|
|
PDFJS.cMapUrl = '../web/cmaps/';
|
|
PDFJS.cMapPacked = true;
|
|
PDFJS.cMapPacked = true;
|
|
}
|
|
}
|
|
-var DefaultExernalServices = {
|
|
|
|
|
|
+var DefaultExternalServices = {
|
|
updateFindControlState: function (data) {},
|
|
updateFindControlState: function (data) {},
|
|
initPassiveLoading: function (callbacks) {},
|
|
initPassiveLoading: function (callbacks) {},
|
|
fallback: function (data, callback) {},
|
|
fallback: function (data, callback) {},
|
|
reportTelemetry: function (data) {},
|
|
reportTelemetry: function (data) {},
|
|
createDownloadManager: function () {
|
|
createDownloadManager: function () {
|
|
- return new downloadManagerLib.DownloadManager();
|
|
|
|
|
|
+ throw new Error('Not implemented: createDownloadManager');
|
|
},
|
|
},
|
|
supportsIntegratedFind: false,
|
|
supportsIntegratedFind: false,
|
|
supportsDocumentFonts: true,
|
|
supportsDocumentFonts: true,
|
|
@@ -124,7 +114,7 @@ var PDFViewerApplication = {
|
|
pageRotation: 0,
|
|
pageRotation: 0,
|
|
isInitialViewSet: false,
|
|
isInitialViewSet: false,
|
|
viewerPrefs: {
|
|
viewerPrefs: {
|
|
- sidebarViewOnLoad: SidebarView.NONE,
|
|
|
|
|
|
+ sidebarViewOnLoad: _pdf_sidebar.SidebarView.NONE,
|
|
pdfBugEnabled: false,
|
|
pdfBugEnabled: false,
|
|
showPreviousViewOnLoad: true,
|
|
showPreviousViewOnLoad: true,
|
|
defaultZoomValue: '',
|
|
defaultZoomValue: '',
|
|
@@ -137,79 +127,77 @@ var PDFViewerApplication = {
|
|
isViewerEmbedded: window.parent !== window,
|
|
isViewerEmbedded: window.parent !== window,
|
|
url: '',
|
|
url: '',
|
|
baseUrl: '',
|
|
baseUrl: '',
|
|
- externalServices: DefaultExernalServices,
|
|
|
|
|
|
+ externalServices: DefaultExternalServices,
|
|
initialize: function pdfViewInitialize(appConfig) {
|
|
initialize: function pdfViewInitialize(appConfig) {
|
|
var self = this;
|
|
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;
|
|
this.appConfig = appConfig;
|
|
return this._readPreferences().then(function () {
|
|
return this._readPreferences().then(function () {
|
|
return self._initializeViewerComponents();
|
|
return self._initializeViewerComponents();
|
|
}).then(function () {
|
|
}).then(function () {
|
|
self.bindEvents();
|
|
self.bindEvents();
|
|
self.bindWindowEvents();
|
|
self.bindWindowEvents();
|
|
- localized.then(function () {
|
|
|
|
|
|
+ _ui_utils.localized.then(function () {
|
|
self.eventBus.dispatch('localized');
|
|
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;
|
|
self.initialized = true;
|
|
});
|
|
});
|
|
},
|
|
},
|
|
_readPreferences: function () {
|
|
_readPreferences: function () {
|
|
var self = this;
|
|
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;
|
|
self.viewerPrefs['sidebarViewOnLoad'] = value;
|
|
- }), Preferences.get('pdfBugEnabled').then(function resolved(value) {
|
|
|
|
|
|
+ }), _preferences.Preferences.get('pdfBugEnabled').then(function resolved(value) {
|
|
self.viewerPrefs['pdfBugEnabled'] = value;
|
|
self.viewerPrefs['pdfBugEnabled'] = value;
|
|
- }), Preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
|
|
|
|
|
|
+ }), _preferences.Preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
|
|
self.viewerPrefs['showPreviousViewOnLoad'] = value;
|
|
self.viewerPrefs['showPreviousViewOnLoad'] = value;
|
|
- }), Preferences.get('defaultZoomValue').then(function resolved(value) {
|
|
|
|
|
|
+ }), _preferences.Preferences.get('defaultZoomValue').then(function resolved(value) {
|
|
self.viewerPrefs['defaultZoomValue'] = value;
|
|
self.viewerPrefs['defaultZoomValue'] = value;
|
|
- }), Preferences.get('enhanceTextSelection').then(function resolved(value) {
|
|
|
|
|
|
+ }), _preferences.Preferences.get('enhanceTextSelection').then(function resolved(value) {
|
|
self.viewerPrefs['enhanceTextSelection'] = 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;
|
|
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;
|
|
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;
|
|
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;
|
|
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;
|
|
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;
|
|
self.viewerPrefs['renderer'] = value;
|
|
- }), Preferences.get('renderInteractiveForms').then(function resolved(value) {
|
|
|
|
|
|
+ }), _preferences.Preferences.get('renderInteractiveForms').then(function resolved(value) {
|
|
self.viewerPrefs['renderInteractiveForms'] = value;
|
|
self.viewerPrefs['renderInteractiveForms'] = value;
|
|
- }), Preferences.get('disablePageLabels').then(function resolved(value) {
|
|
|
|
|
|
+ }), _preferences.Preferences.get('disablePageLabels').then(function resolved(value) {
|
|
self.viewerPrefs['disablePageLabels'] = value;
|
|
self.viewerPrefs['disablePageLabels'] = value;
|
|
- }), Preferences.get('enablePrintAutoRotate').then(function resolved(value) {
|
|
|
|
|
|
+ }), _preferences.Preferences.get('enablePrintAutoRotate').then(function resolved(value) {
|
|
self.viewerPrefs['enablePrintAutoRotate'] = value;
|
|
self.viewerPrefs['enablePrintAutoRotate'] = value;
|
|
})]).catch(function (reason) {});
|
|
})]).catch(function (reason) {});
|
|
},
|
|
},
|
|
@@ -217,18 +205,18 @@ var PDFViewerApplication = {
|
|
var self = this;
|
|
var self = this;
|
|
var appConfig = this.appConfig;
|
|
var appConfig = this.appConfig;
|
|
return new Promise(function (resolve, reject) {
|
|
return new Promise(function (resolve, reject) {
|
|
- var eventBus = appConfig.eventBus || getGlobalEventBus();
|
|
|
|
|
|
+ var eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)();
|
|
self.eventBus = eventBus;
|
|
self.eventBus = eventBus;
|
|
- var pdfRenderingQueue = new PDFRenderingQueue();
|
|
|
|
|
|
+ var pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
|
|
pdfRenderingQueue.onIdle = self.cleanup.bind(self);
|
|
pdfRenderingQueue.onIdle = self.cleanup.bind(self);
|
|
self.pdfRenderingQueue = pdfRenderingQueue;
|
|
self.pdfRenderingQueue = pdfRenderingQueue;
|
|
- var pdfLinkService = new PDFLinkService({ eventBus: eventBus });
|
|
|
|
|
|
+ var pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus: eventBus });
|
|
self.pdfLinkService = pdfLinkService;
|
|
self.pdfLinkService = pdfLinkService;
|
|
var downloadManager = self.externalServices.createDownloadManager();
|
|
var downloadManager = self.externalServices.createDownloadManager();
|
|
self.downloadManager = downloadManager;
|
|
self.downloadManager = downloadManager;
|
|
var container = appConfig.mainContainer;
|
|
var container = appConfig.mainContainer;
|
|
var viewer = appConfig.viewerContainer;
|
|
var viewer = appConfig.viewerContainer;
|
|
- self.pdfViewer = new PDFViewer({
|
|
|
|
|
|
+ self.pdfViewer = new _pdf_viewer.PDFViewer({
|
|
container: container,
|
|
container: container,
|
|
viewer: viewer,
|
|
viewer: viewer,
|
|
eventBus: eventBus,
|
|
eventBus: eventBus,
|
|
@@ -243,18 +231,18 @@ var PDFViewerApplication = {
|
|
pdfRenderingQueue.setViewer(self.pdfViewer);
|
|
pdfRenderingQueue.setViewer(self.pdfViewer);
|
|
pdfLinkService.setViewer(self.pdfViewer);
|
|
pdfLinkService.setViewer(self.pdfViewer);
|
|
var thumbnailContainer = appConfig.sidebar.thumbnailView;
|
|
var thumbnailContainer = appConfig.sidebar.thumbnailView;
|
|
- self.pdfThumbnailViewer = new PDFThumbnailViewer({
|
|
|
|
|
|
+ self.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
|
|
container: thumbnailContainer,
|
|
container: thumbnailContainer,
|
|
renderingQueue: pdfRenderingQueue,
|
|
renderingQueue: pdfRenderingQueue,
|
|
linkService: pdfLinkService
|
|
linkService: pdfLinkService
|
|
});
|
|
});
|
|
pdfRenderingQueue.setThumbnailViewer(self.pdfThumbnailViewer);
|
|
pdfRenderingQueue.setThumbnailViewer(self.pdfThumbnailViewer);
|
|
- self.pdfHistory = new PDFHistory({
|
|
|
|
|
|
+ self.pdfHistory = new _pdf_history.PDFHistory({
|
|
linkService: pdfLinkService,
|
|
linkService: pdfLinkService,
|
|
eventBus: eventBus
|
|
eventBus: eventBus
|
|
});
|
|
});
|
|
pdfLinkService.setHistory(self.pdfHistory);
|
|
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) {
|
|
self.findController.onUpdateResultsCount = function (matchCount) {
|
|
if (self.supportsIntegratedFind) {
|
|
if (self.supportsIntegratedFind) {
|
|
return;
|
|
return;
|
|
@@ -275,17 +263,17 @@ var PDFViewerApplication = {
|
|
var findBarConfig = Object.create(appConfig.findBar);
|
|
var findBarConfig = Object.create(appConfig.findBar);
|
|
findBarConfig.findController = self.findController;
|
|
findBarConfig.findController = self.findController;
|
|
findBarConfig.eventBus = eventBus;
|
|
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,
|
|
container: container,
|
|
eventBus: eventBus
|
|
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) {
|
|
if (self.supportsFullscreen) {
|
|
- self.pdfPresentationMode = new PDFPresentationMode({
|
|
|
|
|
|
+ self.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
|
|
container: container,
|
|
container: container,
|
|
viewer: viewer,
|
|
viewer: viewer,
|
|
pdfViewer: self.pdfViewer,
|
|
pdfViewer: self.pdfViewer,
|
|
@@ -293,13 +281,13 @@ var PDFViewerApplication = {
|
|
contextMenuItems: appConfig.fullscreen
|
|
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,
|
|
container: appConfig.sidebar.outlineView,
|
|
eventBus: eventBus,
|
|
eventBus: eventBus,
|
|
linkService: pdfLinkService
|
|
linkService: pdfLinkService
|
|
});
|
|
});
|
|
- self.pdfAttachmentViewer = new PDFAttachmentViewer({
|
|
|
|
|
|
+ self.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
|
|
container: appConfig.sidebar.attachmentsView,
|
|
container: appConfig.sidebar.attachmentsView,
|
|
eventBus: eventBus,
|
|
eventBus: eventBus,
|
|
downloadManager: downloadManager
|
|
downloadManager: downloadManager
|
|
@@ -309,7 +297,7 @@ var PDFViewerApplication = {
|
|
sidebarConfig.pdfThumbnailViewer = self.pdfThumbnailViewer;
|
|
sidebarConfig.pdfThumbnailViewer = self.pdfThumbnailViewer;
|
|
sidebarConfig.pdfOutlineViewer = self.pdfOutlineViewer;
|
|
sidebarConfig.pdfOutlineViewer = self.pdfOutlineViewer;
|
|
sidebarConfig.eventBus = eventBus;
|
|
sidebarConfig.eventBus = eventBus;
|
|
- self.pdfSidebar = new PDFSidebar(sidebarConfig);
|
|
|
|
|
|
+ self.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig);
|
|
self.pdfSidebar.onToggled = self.forceRendering.bind(self);
|
|
self.pdfSidebar.onToggled = self.forceRendering.bind(self);
|
|
resolve(undefined);
|
|
resolve(undefined);
|
|
});
|
|
});
|
|
@@ -322,8 +310,8 @@ var PDFViewerApplication = {
|
|
do {
|
|
do {
|
|
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
|
|
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
|
|
newScale = Math.ceil(newScale * 10) / 10;
|
|
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;
|
|
this.pdfViewer.currentScaleValue = newScale;
|
|
},
|
|
},
|
|
zoomOut: function pdfViewZoomOut(ticks) {
|
|
zoomOut: function pdfViewZoomOut(ticks) {
|
|
@@ -331,8 +319,8 @@ var PDFViewerApplication = {
|
|
do {
|
|
do {
|
|
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
|
|
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
|
|
newScale = Math.floor(newScale * 10) / 10;
|
|
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;
|
|
this.pdfViewer.currentScaleValue = newScale;
|
|
},
|
|
},
|
|
get pagesCount() {
|
|
get pagesCount() {
|
|
@@ -357,10 +345,10 @@ var PDFViewerApplication = {
|
|
if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
|
|
if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
|
|
support = false;
|
|
support = false;
|
|
}
|
|
}
|
|
- if (support && pdfjsLib.PDFJS.disableFullscreen === true) {
|
|
|
|
|
|
+ if (support && _pdfjs.PDFJS.disableFullscreen === true) {
|
|
support = false;
|
|
support = false;
|
|
}
|
|
}
|
|
- return pdfjsLib.shadow(this, 'supportsFullscreen', support);
|
|
|
|
|
|
+ return (0, _pdfjs.shadow)(this, 'supportsFullscreen', support);
|
|
},
|
|
},
|
|
get supportsIntegratedFind() {
|
|
get supportsIntegratedFind() {
|
|
return this.externalServices.supportsIntegratedFind;
|
|
return this.externalServices.supportsIntegratedFind;
|
|
@@ -372,8 +360,8 @@ var PDFViewerApplication = {
|
|
return this.externalServices.supportsDocumentColors;
|
|
return this.externalServices.supportsDocumentColors;
|
|
},
|
|
},
|
|
get loadingBar() {
|
|
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() {
|
|
get supportedMouseWheelZoomModifierKeys() {
|
|
return this.externalServices.supportedMouseWheelZoomModifierKeys;
|
|
return this.externalServices.supportedMouseWheelZoomModifierKeys;
|
|
@@ -384,10 +372,10 @@ var PDFViewerApplication = {
|
|
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
|
|
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
|
|
this.url = url;
|
|
this.url = url;
|
|
this.baseUrl = url.split('#')[0];
|
|
this.baseUrl = url.split('#')[0];
|
|
- var title = getPDFFileNameFromURL(url, '');
|
|
|
|
|
|
+ var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
|
|
if (!title) {
|
|
if (!title) {
|
|
try {
|
|
try {
|
|
- title = decodeURIComponent(pdfjsLib.getFilenameFromUrl(url)) || url;
|
|
|
|
|
|
+ title = decodeURIComponent((0, _pdfjs.getFilenameFromUrl)(url)) || url;
|
|
} catch (e) {
|
|
} catch (e) {
|
|
title = url;
|
|
title = url;
|
|
}
|
|
}
|
|
@@ -434,7 +422,7 @@ var PDFViewerApplication = {
|
|
}
|
|
}
|
|
if (this.pdfLoadingTask) {
|
|
if (this.pdfLoadingTask) {
|
|
return this.close().then(function () {
|
|
return this.close().then(function () {
|
|
- Preferences.reload();
|
|
|
|
|
|
+ _preferences.Preferences.reload();
|
|
return this.open(file, args);
|
|
return this.open(file, args);
|
|
}.bind(this));
|
|
}.bind(this));
|
|
}
|
|
}
|
|
@@ -462,7 +450,7 @@ var PDFViewerApplication = {
|
|
}
|
|
}
|
|
var self = this;
|
|
var self = this;
|
|
self.downloadComplete = false;
|
|
self.downloadComplete = false;
|
|
- var loadingTask = pdfjsLib.getDocument(parameters);
|
|
|
|
|
|
+ var loadingTask = (0, _pdfjs.getDocument)(parameters);
|
|
this.pdfLoadingTask = loadingTask;
|
|
this.pdfLoadingTask = loadingTask;
|
|
loadingTask.onPassword = function passwordNeeded(updateCallback, reason) {
|
|
loadingTask.onPassword = function passwordNeeded(updateCallback, reason) {
|
|
self.passwordPrompt.setUpdateCallback(updateCallback, reason);
|
|
self.passwordPrompt.setUpdateCallback(updateCallback, reason);
|
|
@@ -476,13 +464,13 @@ var PDFViewerApplication = {
|
|
self.load(pdfDocument, scale);
|
|
self.load(pdfDocument, scale);
|
|
}, function getDocumentError(exception) {
|
|
}, function getDocumentError(exception) {
|
|
var message = exception && exception.message;
|
|
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 };
|
|
var moreInfo = { message: message };
|
|
self.error(loadingErrorMessage, moreInfo);
|
|
self.error(loadingErrorMessage, moreInfo);
|
|
@@ -494,7 +482,7 @@ var PDFViewerApplication = {
|
|
downloadManager.downloadUrl(url, filename);
|
|
downloadManager.downloadUrl(url, filename);
|
|
}
|
|
}
|
|
var url = this.baseUrl;
|
|
var url = this.baseUrl;
|
|
- var filename = getPDFFileNameFromURL(this.url);
|
|
|
|
|
|
+ var filename = (0, _ui_utils.getPDFFileNameFromURL)(this.url);
|
|
var downloadManager = this.downloadManager;
|
|
var downloadManager = this.downloadManager;
|
|
downloadManager.onerror = function (err) {
|
|
downloadManager.onerror = function (err) {
|
|
PDFViewerApplication.error('PDF failed to download.');
|
|
PDFViewerApplication.error('PDF failed to download.');
|
|
@@ -508,26 +496,26 @@ var PDFViewerApplication = {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.pdfDocument.getData().then(function getDataSuccess(data) {
|
|
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);
|
|
downloadManager.download(blob, url, filename);
|
|
}, downloadByUrl).then(null, downloadByUrl);
|
|
}, downloadByUrl).then(null, downloadByUrl);
|
|
},
|
|
},
|
|
fallback: function pdfViewFallback(featureId) {},
|
|
fallback: function pdfViewFallback(featureId) {},
|
|
error: function pdfViewError(message, moreInfo) {
|
|
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';
|
|
}, 'PDF.js v{{version}} (build: {{build}})') + '\n';
|
|
if (moreInfo) {
|
|
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) {
|
|
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 {
|
|
} else {
|
|
if (moreInfo.filename) {
|
|
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) {
|
|
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 = {
|
|
moreInfoButton.removeAttribute('hidden');
|
|
moreInfoButton.removeAttribute('hidden');
|
|
lessInfoButton.setAttribute('hidden', 'true');
|
|
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');
|
|
moreInfoButton.removeAttribute('hidden');
|
|
lessInfoButton.setAttribute('hidden', 'true');
|
|
lessInfoButton.setAttribute('hidden', 'true');
|
|
errorMoreInfo.value = moreInfoText;
|
|
errorMoreInfo.value = moreInfoText;
|
|
@@ -565,7 +553,7 @@ var PDFViewerApplication = {
|
|
var percent = Math.round(level * 100);
|
|
var percent = Math.round(level * 100);
|
|
if (percent > this.loadingBar.percent || isNaN(percent)) {
|
|
if (percent > this.loadingBar.percent || isNaN(percent)) {
|
|
this.loadingBar.percent = percent;
|
|
this.loadingBar.percent = percent;
|
|
- if (pdfjsLib.PDFJS.disableAutoFetch && percent) {
|
|
|
|
|
|
+ if (_pdfjs.PDFJS.disableAutoFetch && percent) {
|
|
if (this.disableAutoFetchLoadingBarTimeout) {
|
|
if (this.disableAutoFetchLoadingBarTimeout) {
|
|
clearTimeout(this.disableAutoFetchLoadingBarTimeout);
|
|
clearTimeout(this.disableAutoFetchLoadingBarTimeout);
|
|
this.disableAutoFetchLoadingBarTimeout = null;
|
|
this.disableAutoFetchLoadingBarTimeout = null;
|
|
@@ -580,7 +568,7 @@ var PDFViewerApplication = {
|
|
},
|
|
},
|
|
load: function pdfViewLoad(pdfDocument, scale) {
|
|
load: function pdfViewLoad(pdfDocument, scale) {
|
|
var self = this;
|
|
var self = this;
|
|
- scale = scale || UNKNOWN_SCALE;
|
|
|
|
|
|
+ scale = scale || _ui_utils.UNKNOWN_SCALE;
|
|
this.pdfDocument = pdfDocument;
|
|
this.pdfDocument = pdfDocument;
|
|
this.pdfDocumentProperties.setDocumentAndUrl(pdfDocument, this.url);
|
|
this.pdfDocumentProperties.setDocumentAndUrl(pdfDocument, this.url);
|
|
var downloadedPromise = pdfDocument.getDownloadInfo().then(function () {
|
|
var downloadedPromise = pdfDocument.getDownloadInfo().then(function () {
|
|
@@ -590,7 +578,7 @@ var PDFViewerApplication = {
|
|
this.toolbar.setPagesCount(pdfDocument.numPages, false);
|
|
this.toolbar.setPagesCount(pdfDocument.numPages, false);
|
|
this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
|
|
this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
|
|
var id = this.documentFingerprint = pdfDocument.fingerprint;
|
|
var id = this.documentFingerprint = pdfDocument.fingerprint;
|
|
- var store = this.store = new ViewHistory(id);
|
|
|
|
|
|
+ var store = this.store = new _view_history.ViewHistory(id);
|
|
var baseDocumentUrl;
|
|
var baseDocumentUrl;
|
|
baseDocumentUrl = null;
|
|
baseDocumentUrl = null;
|
|
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
|
|
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
|
|
@@ -608,7 +596,7 @@ var PDFViewerApplication = {
|
|
self.eventBus.dispatch('documentload', { source: self });
|
|
self.eventBus.dispatch('documentload', { source: self });
|
|
});
|
|
});
|
|
self.loadingBar.setWidth(self.appConfig.viewerContainer);
|
|
self.loadingBar.setWidth(self.appConfig.viewerContainer);
|
|
- if (!pdfjsLib.PDFJS.disableHistory && !self.isViewerEmbedded) {
|
|
|
|
|
|
+ if (!_pdfjs.PDFJS.disableHistory && !self.isViewerEmbedded) {
|
|
if (!self.viewerPrefs['showPreviousViewOnLoad']) {
|
|
if (!self.viewerPrefs['showPreviousViewOnLoad']) {
|
|
self.pdfHistory.clearHistoryState();
|
|
self.pdfHistory.clearHistoryState();
|
|
}
|
|
}
|
|
@@ -629,11 +617,11 @@ var PDFViewerApplication = {
|
|
sidebarView = null;
|
|
sidebarView = null;
|
|
if (self.viewerPrefs['showPreviousViewOnLoad'] && store.get('exists', false)) {
|
|
if (self.viewerPrefs['showPreviousViewOnLoad'] && store.get('exists', false)) {
|
|
var pageNum = store.get('page', '1');
|
|
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 left = store.get('scrollLeft', '0');
|
|
var top = store.get('scrollTop', '0');
|
|
var top = store.get('scrollTop', '0');
|
|
storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' + left + ',' + top;
|
|
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']) {
|
|
} else if (self.viewerPrefs['defaultZoomValue']) {
|
|
storedHash = 'page=1&zoom=' + self.viewerPrefs['defaultZoomValue'];
|
|
storedHash = 'page=1&zoom=' + self.viewerPrefs['defaultZoomValue'];
|
|
}
|
|
}
|
|
@@ -688,7 +676,7 @@ var PDFViewerApplication = {
|
|
pdfDocument.getJavaScript().then(function (javaScript) {
|
|
pdfDocument.getJavaScript().then(function (javaScript) {
|
|
if (javaScript.length) {
|
|
if (javaScript.length) {
|
|
console.warn('Warning: JavaScript is not supported');
|
|
console.warn('Warning: JavaScript is not supported');
|
|
- self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
|
|
|
|
|
|
+ self.fallback(_pdfjs.UNSUPPORTED_FEATURES.javaScript);
|
|
}
|
|
}
|
|
var regex = /\bprint\s*\(/;
|
|
var regex = /\bprint\s*\(/;
|
|
for (var i = 0, ii = javaScript.length; i < ii; i++) {
|
|
for (var i = 0, ii = javaScript.length; i < ii; i++) {
|
|
@@ -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) {
|
|
pdfDocument.getOutline().then(function (outline) {
|
|
self.pdfOutlineViewer.render({ outline: outline });
|
|
self.pdfOutlineViewer.render({ outline: outline });
|
|
});
|
|
});
|
|
@@ -716,7 +704,7 @@ var PDFViewerApplication = {
|
|
metadata = data.metadata;
|
|
metadata = data.metadata;
|
|
self.documentInfo = info;
|
|
self.documentInfo = info;
|
|
self.metadata = metadata;
|
|
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;
|
|
var pdfTitle;
|
|
if (metadata && metadata.has('dc:title')) {
|
|
if (metadata && metadata.has('dc:title')) {
|
|
var title = metadata.get('dc:title');
|
|
var title = metadata.get('dc:title');
|
|
@@ -732,7 +720,7 @@ var PDFViewerApplication = {
|
|
}
|
|
}
|
|
if (info.IsAcroFormPresent) {
|
|
if (info.IsAcroFormPresent) {
|
|
console.warn('Warning: AcroForm/XFA is not supported');
|
|
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 = {
|
|
this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
|
|
this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
|
|
this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
|
|
this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
|
|
if (!this.pdfViewer.currentScaleValue) {
|
|
if (!this.pdfViewer.currentScaleValue) {
|
|
- this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
|
|
|
|
|
+ this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
cleanup: function pdfViewCleanup() {
|
|
cleanup: function pdfViewCleanup() {
|
|
@@ -766,7 +754,7 @@ var PDFViewerApplication = {
|
|
}
|
|
}
|
|
this.pdfViewer.cleanup();
|
|
this.pdfViewer.cleanup();
|
|
this.pdfThumbnailViewer.cleanup();
|
|
this.pdfThumbnailViewer.cleanup();
|
|
- if (this.pdfViewer.renderer !== RendererType.SVG) {
|
|
|
|
|
|
+ if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
|
|
this.pdfDocument.cleanup();
|
|
this.pdfDocument.cleanup();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -780,12 +768,12 @@ var PDFViewerApplication = {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (!this.supportsPrinting) {
|
|
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);
|
|
this.error(printMessage);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (!this.pdfViewer.pageViewsReady) {
|
|
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);
|
|
window.alert(notReadyMessage);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -888,25 +876,27 @@ var PDFViewerApplication = {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var validateFileURL;
|
|
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) {
|
|
function loadAndEnablePDFBug(enabledTabs) {
|
|
return new Promise(function (resolve, reject) {
|
|
return new Promise(function (resolve, reject) {
|
|
var appConfig = PDFViewerApplication.appConfig;
|
|
var appConfig = PDFViewerApplication.appConfig;
|
|
@@ -914,7 +904,10 @@ function loadAndEnablePDFBug(enabledTabs) {
|
|
script.src = appConfig.debuggerScriptPath;
|
|
script.src = appConfig.debuggerScriptPath;
|
|
script.onload = function () {
|
|
script.onload = function () {
|
|
PDFBug.enable(enabledTabs);
|
|
PDFBug.enable(enabledTabs);
|
|
- PDFBug.init(pdfjsLib, appConfig.mainContainer);
|
|
|
|
|
|
+ PDFBug.init({
|
|
|
|
+ PDFJS: _pdfjs.PDFJS,
|
|
|
|
+ OPS: _pdfjs.OPS
|
|
|
|
+ }, appConfig.mainContainer);
|
|
resolve();
|
|
resolve();
|
|
};
|
|
};
|
|
script.onerror = function () {
|
|
script.onerror = function () {
|
|
@@ -927,7 +920,7 @@ function webViewerInitialized() {
|
|
var appConfig = PDFViewerApplication.appConfig;
|
|
var appConfig = PDFViewerApplication.appConfig;
|
|
var file;
|
|
var file;
|
|
var queryString = document.location.search.substring(1);
|
|
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;
|
|
file = 'file' in params ? params.file : appConfig.defaultUrl;
|
|
validateFileURL(file);
|
|
validateFileURL(file);
|
|
var waitForBeforeOpening = [];
|
|
var waitForBeforeOpening = [];
|
|
@@ -935,7 +928,7 @@ function webViewerInitialized() {
|
|
fileInput.id = appConfig.openFileInputName;
|
|
fileInput.id = appConfig.openFileInputName;
|
|
fileInput.className = 'fileInput';
|
|
fileInput.className = 'fileInput';
|
|
fileInput.setAttribute('type', 'file');
|
|
fileInput.setAttribute('type', 'file');
|
|
- fileInput.oncontextmenu = noContextMenuHandler;
|
|
|
|
|
|
+ fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
|
|
document.body.appendChild(fileInput);
|
|
document.body.appendChild(fileInput);
|
|
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
|
|
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
|
|
appConfig.toolbar.openFile.setAttribute('hidden', 'true');
|
|
appConfig.toolbar.openFile.setAttribute('hidden', 'true');
|
|
@@ -943,47 +936,46 @@ function webViewerInitialized() {
|
|
} else {
|
|
} else {
|
|
fileInput.value = null;
|
|
fileInput.value = null;
|
|
}
|
|
}
|
|
- var PDFJS = pdfjsLib.PDFJS;
|
|
|
|
if (PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
|
|
if (PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
|
|
var hash = document.location.hash.substring(1);
|
|
var hash = document.location.hash.substring(1);
|
|
- var hashParams = parseQueryString(hash);
|
|
|
|
|
|
+ var hashParams = (0, _ui_utils.parseQueryString)(hash);
|
|
if ('disableworker' in hashParams) {
|
|
if ('disableworker' in hashParams) {
|
|
- PDFJS.disableWorker = hashParams['disableworker'] === 'true';
|
|
|
|
|
|
+ _pdfjs.PDFJS.disableWorker = hashParams['disableworker'] === 'true';
|
|
}
|
|
}
|
|
if ('disablerange' in hashParams) {
|
|
if ('disablerange' in hashParams) {
|
|
- PDFJS.disableRange = hashParams['disablerange'] === 'true';
|
|
|
|
|
|
+ _pdfjs.PDFJS.disableRange = hashParams['disablerange'] === 'true';
|
|
}
|
|
}
|
|
if ('disablestream' in hashParams) {
|
|
if ('disablestream' in hashParams) {
|
|
- PDFJS.disableStream = hashParams['disablestream'] === 'true';
|
|
|
|
|
|
+ _pdfjs.PDFJS.disableStream = hashParams['disablestream'] === 'true';
|
|
}
|
|
}
|
|
if ('disableautofetch' in hashParams) {
|
|
if ('disableautofetch' in hashParams) {
|
|
- PDFJS.disableAutoFetch = hashParams['disableautofetch'] === 'true';
|
|
|
|
|
|
+ _pdfjs.PDFJS.disableAutoFetch = hashParams['disableautofetch'] === 'true';
|
|
}
|
|
}
|
|
if ('disablefontface' in hashParams) {
|
|
if ('disablefontface' in hashParams) {
|
|
- PDFJS.disableFontFace = hashParams['disablefontface'] === 'true';
|
|
|
|
|
|
+ _pdfjs.PDFJS.disableFontFace = hashParams['disablefontface'] === 'true';
|
|
}
|
|
}
|
|
if ('disablehistory' in hashParams) {
|
|
if ('disablehistory' in hashParams) {
|
|
- PDFJS.disableHistory = hashParams['disablehistory'] === 'true';
|
|
|
|
|
|
+ _pdfjs.PDFJS.disableHistory = hashParams['disablehistory'] === 'true';
|
|
}
|
|
}
|
|
if ('webgl' in hashParams) {
|
|
if ('webgl' in hashParams) {
|
|
- PDFJS.disableWebGL = hashParams['webgl'] !== 'true';
|
|
|
|
|
|
+ _pdfjs.PDFJS.disableWebGL = hashParams['webgl'] !== 'true';
|
|
}
|
|
}
|
|
if ('useonlycsszoom' in hashParams) {
|
|
if ('useonlycsszoom' in hashParams) {
|
|
- PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true';
|
|
|
|
|
|
+ _pdfjs.PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true';
|
|
}
|
|
}
|
|
if ('verbosity' in hashParams) {
|
|
if ('verbosity' in hashParams) {
|
|
- PDFJS.verbosity = hashParams['verbosity'] | 0;
|
|
|
|
|
|
+ _pdfjs.PDFJS.verbosity = hashParams['verbosity'] | 0;
|
|
}
|
|
}
|
|
if ('ignorecurrentpositiononzoom' in hashParams) {
|
|
if ('ignorecurrentpositiononzoom' in hashParams) {
|
|
- PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
|
|
|
|
|
|
+ _pdfjs.PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
|
|
}
|
|
}
|
|
if ('locale' in hashParams) {
|
|
if ('locale' in hashParams) {
|
|
- PDFJS.locale = hashParams['locale'];
|
|
|
|
|
|
+ _pdfjs.PDFJS.locale = hashParams['locale'];
|
|
}
|
|
}
|
|
if ('textlayer' in hashParams) {
|
|
if ('textlayer' in hashParams) {
|
|
switch (hashParams['textlayer']) {
|
|
switch (hashParams['textlayer']) {
|
|
case 'off':
|
|
case 'off':
|
|
- PDFJS.disableTextLayer = true;
|
|
|
|
|
|
+ _pdfjs.PDFJS.disableTextLayer = true;
|
|
break;
|
|
break;
|
|
case 'visible':
|
|
case 'visible':
|
|
case 'shadow':
|
|
case 'shadow':
|
|
@@ -994,13 +986,13 @@ function webViewerInitialized() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ('pdfbug' in hashParams) {
|
|
if ('pdfbug' in hashParams) {
|
|
- PDFJS.pdfBug = true;
|
|
|
|
|
|
+ _pdfjs.PDFJS.pdfBug = true;
|
|
var pdfBug = hashParams['pdfbug'];
|
|
var pdfBug = hashParams['pdfbug'];
|
|
var enabled = pdfBug.split(',');
|
|
var enabled = pdfBug.split(',');
|
|
waitForBeforeOpening.push(loadAndEnablePDFBug(enabled));
|
|
waitForBeforeOpening.push(loadAndEnablePDFBug(enabled));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- mozL10n.setLanguage(PDFJS.locale);
|
|
|
|
|
|
+ _ui_utils.mozL10n.setLanguage(_pdfjs.PDFJS.locale);
|
|
if (!PDFViewerApplication.supportsPrinting) {
|
|
if (!PDFViewerApplication.supportsPrinting) {
|
|
appConfig.toolbar.print.classList.add('hidden');
|
|
appConfig.toolbar.print.classList.add('hidden');
|
|
appConfig.secondaryToolbar.printButton.classList.add('hidden');
|
|
appConfig.secondaryToolbar.printButton.classList.add('hidden');
|
|
@@ -1023,30 +1015,32 @@ function webViewerInitialized() {
|
|
Promise.all(waitForBeforeOpening).then(function () {
|
|
Promise.all(waitForBeforeOpening).then(function () {
|
|
webViewerOpenFileViaURL(file);
|
|
webViewerOpenFileViaURL(file);
|
|
}).catch(function (reason) {
|
|
}).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;
|
|
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) {
|
|
function webViewerPageRendered(e) {
|
|
var pageNumber = e.pageNumber;
|
|
var pageNumber = e.pageNumber;
|
|
var pageIndex = pageNumber - 1;
|
|
var pageIndex = pageNumber - 1;
|
|
@@ -1061,11 +1055,11 @@ function webViewerPageRendered(e) {
|
|
var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
|
|
var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
|
|
thumbnailView.setImage(pageView);
|
|
thumbnailView.setImage(pageView);
|
|
}
|
|
}
|
|
- if (pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
|
|
|
|
|
|
+ if (_pdfjs.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
|
|
Stats.add(pageNumber, pageView.stats);
|
|
Stats.add(pageNumber, pageView.stats);
|
|
}
|
|
}
|
|
if (pageView.error) {
|
|
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) {}
|
|
function webViewerTextLayerRendered(e) {}
|
|
@@ -1074,17 +1068,17 @@ function webViewerPageMode(e) {
|
|
view;
|
|
view;
|
|
switch (mode) {
|
|
switch (mode) {
|
|
case 'thumbs':
|
|
case 'thumbs':
|
|
- view = SidebarView.THUMBS;
|
|
|
|
|
|
+ view = _pdf_sidebar.SidebarView.THUMBS;
|
|
break;
|
|
break;
|
|
case 'bookmarks':
|
|
case 'bookmarks':
|
|
case 'outline':
|
|
case 'outline':
|
|
- view = SidebarView.OUTLINE;
|
|
|
|
|
|
+ view = _pdf_sidebar.SidebarView.OUTLINE;
|
|
break;
|
|
break;
|
|
case 'attachments':
|
|
case 'attachments':
|
|
- view = SidebarView.ATTACHMENTS;
|
|
|
|
|
|
+ view = _pdf_sidebar.SidebarView.ATTACHMENTS;
|
|
break;
|
|
break;
|
|
case 'none':
|
|
case 'none':
|
|
- view = SidebarView.NONE;
|
|
|
|
|
|
+ view = _pdf_sidebar.SidebarView.NONE;
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
console.error('Invalid "pagemode" hash parameter: ' + mode);
|
|
console.error('Invalid "pagemode" hash parameter: ' + mode);
|
|
@@ -1108,7 +1102,7 @@ function webViewerNamedAction(e) {
|
|
function webViewerPresentationModeChanged(e) {
|
|
function webViewerPresentationModeChanged(e) {
|
|
var active = e.active;
|
|
var active = e.active;
|
|
var switchInProgress = e.switchInProgress;
|
|
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) {
|
|
function webViewerSidebarViewChanged(e) {
|
|
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
|
|
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
|
|
@@ -1139,7 +1133,7 @@ function webViewerUpdateViewarea(e) {
|
|
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
|
|
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
|
|
PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams, location.pageNumber);
|
|
PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams, location.pageNumber);
|
|
var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
|
|
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);
|
|
PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
|
|
}
|
|
}
|
|
function webViewerResize() {
|
|
function webViewerResize() {
|
|
@@ -1147,7 +1141,7 @@ function webViewerResize() {
|
|
if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
|
|
if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
|
|
PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
|
|
PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
|
|
} else if (!currentScaleValue) {
|
|
} else if (!currentScaleValue) {
|
|
- PDFViewerApplication.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
|
|
|
|
|
+ PDFViewerApplication.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
|
|
}
|
|
}
|
|
PDFViewerApplication.pdfViewer.update();
|
|
PDFViewerApplication.pdfViewer.update();
|
|
}
|
|
}
|
|
@@ -1165,26 +1159,28 @@ function webViewerHashchange(e) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var webViewerFileInputChange;
|
|
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() {
|
|
function webViewerPresentationMode() {
|
|
PDFViewerApplication.requestPresentationMode();
|
|
PDFViewerApplication.requestPresentationMode();
|
|
}
|
|
}
|
|
@@ -1268,7 +1264,7 @@ function webViewerPageChanging(e) {
|
|
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
|
|
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
|
|
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
|
|
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
|
|
}
|
|
}
|
|
- if (pdfjsLib.PDFJS.pdfBug && Stats.enabled) {
|
|
|
|
|
|
+ if (_pdfjs.PDFJS.pdfBug && Stats.enabled) {
|
|
var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
|
|
var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
|
|
if (pageView.stats) {
|
|
if (pageView.stats) {
|
|
Stats.add(page, pageView.stats);
|
|
Stats.add(page, pageView.stats);
|
|
@@ -1292,7 +1288,7 @@ function webViewerWheel(evt) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var previousScale = pdfViewer.currentScale;
|
|
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 MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
|
|
var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
|
|
var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
|
|
if (ticks < 0) {
|
|
if (ticks < 0) {
|
|
@@ -1327,7 +1323,7 @@ function webViewerClick(evt) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function webViewerKeyDown(evt) {
|
|
function webViewerKeyDown(evt) {
|
|
- if (OverlayManager.active) {
|
|
|
|
|
|
+ if (_overlay_manager.OverlayManager.active) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var handled = false,
|
|
var handled = false,
|
|
@@ -1379,7 +1375,7 @@ function webViewerKeyDown(evt) {
|
|
case 96:
|
|
case 96:
|
|
if (!isViewerInPresentationMode) {
|
|
if (!isViewerInPresentationMode) {
|
|
setTimeout(function () {
|
|
setTimeout(function () {
|
|
- pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
|
|
|
|
|
+ pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
|
|
});
|
|
});
|
|
handled = false;
|
|
handled = false;
|
|
}
|
|
}
|
|
@@ -1548,8 +1544,8 @@ function webViewerKeyDown(evt) {
|
|
evt.preventDefault();
|
|
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 = {
|
|
var PDFPrintServiceFactory = {
|
|
instance: {
|
|
instance: {
|
|
@@ -1560,5 +1556,5 @@ var PDFPrintServiceFactory = {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
exports.PDFViewerApplication = PDFViewerApplication;
|
|
exports.PDFViewerApplication = PDFViewerApplication;
|
|
-exports.DefaultExernalServices = DefaultExernalServices;
|
|
|
|
|
|
+exports.DefaultExternalServices = DefaultExternalServices;
|
|
exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
|
|
exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
|