Remove the attachDOMEventsToEventBus
functionality, since EventBus
instances are able to re-dispatch events to the DOM (PR 10019, bug 1492849 follow-up)
This also removes the old 'pagechange'/'scalechange'/'documentload' events.
This commit is contained in:
parent
7053b5a146
commit
e2e9657ed0
@ -50,7 +50,7 @@ var pdfViewer = new pdfjsViewer.PDFViewer({
|
|||||||
});
|
});
|
||||||
pdfLinkService.setViewer(pdfViewer);
|
pdfLinkService.setViewer(pdfViewer);
|
||||||
|
|
||||||
container.addEventListener('pagesinit', function () {
|
document.addEventListener('pagesinit', function () {
|
||||||
// We can use pdfViewer now, e.g. let's change default scale.
|
// We can use pdfViewer now, e.g. let's change default scale.
|
||||||
pdfViewer.currentScaleValue = 'page-width';
|
pdfViewer.currentScaleValue = 'page-width';
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ var pdfSinglePageViewer = new pdfjsViewer.PDFSinglePageViewer({
|
|||||||
});
|
});
|
||||||
pdfLinkService.setViewer(pdfSinglePageViewer);
|
pdfLinkService.setViewer(pdfSinglePageViewer);
|
||||||
|
|
||||||
container.addEventListener('pagesinit', function () {
|
document.addEventListener('pagesinit', function () {
|
||||||
// We can use pdfSinglePageViewer now, e.g. let's change default scale.
|
// We can use pdfSinglePageViewer now, e.g. let's change default scale.
|
||||||
pdfSinglePageViewer.currentScaleValue = 'page-width';
|
pdfSinglePageViewer.currentScaleValue = 'page-width';
|
||||||
|
|
||||||
|
@ -346,13 +346,13 @@ var PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
container.addEventListener('pagesinit', function () {
|
document.addEventListener('pagesinit', function () {
|
||||||
// We can use pdfViewer now, e.g. let's change default scale.
|
// We can use pdfViewer now, e.g. let's change default scale.
|
||||||
pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
||||||
});
|
});
|
||||||
|
|
||||||
container.addEventListener('pagechange', function (evt) {
|
document.addEventListener('pagechanging', function (evt) {
|
||||||
var page = evt.pageNumber;
|
var page = evt.detail.pageNumber;
|
||||||
var numPages = PDFViewerApplication.pagesCount;
|
var numPages = PDFViewerApplication.pagesCount;
|
||||||
|
|
||||||
document.getElementById('pageNumber').value = page;
|
document.getElementById('pageNumber').value = page;
|
||||||
|
@ -45,7 +45,7 @@ var pdfViewer = new pdfjsViewer.PDFViewer({
|
|||||||
});
|
});
|
||||||
pdfLinkService.setViewer(pdfViewer);
|
pdfLinkService.setViewer(pdfViewer);
|
||||||
|
|
||||||
container.addEventListener('pagesinit', function () {
|
document.addEventListener('pagesinit', function () {
|
||||||
// We can use pdfViewer now, e.g. let's change default scale.
|
// We can use pdfViewer now, e.g. let's change default scale.
|
||||||
pdfViewer.currentScaleValue = 'page-width';
|
pdfViewer.currentScaleValue = 'page-width';
|
||||||
});
|
});
|
||||||
|
12
web/app.js
12
web/app.js
@ -15,10 +15,10 @@
|
|||||||
/* globals PDFBug, Stats */
|
/* globals PDFBug, Stats */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, isValidRotation,
|
animationStarted, DEFAULT_SCALE_VALUE, getGlobalEventBus,
|
||||||
MAX_SCALE, MIN_SCALE, noContextMenuHandler, normalizeWheelEventDelta,
|
getPDFFileNameFromURL, isValidRotation, MAX_SCALE, MIN_SCALE,
|
||||||
parseQueryString, PresentationModeState, ProgressBar, RendererType,
|
noContextMenuHandler, normalizeWheelEventDelta, parseQueryString,
|
||||||
TextLayerMode
|
PresentationModeState, ProgressBar, RendererType, TextLayerMode
|
||||||
} from './ui_utils';
|
} from './ui_utils';
|
||||||
import {
|
import {
|
||||||
build, createObjectURL, getDocument, getFilenameFromUrl, GlobalWorkerOptions,
|
build, createObjectURL, getDocument, getFilenameFromUrl, GlobalWorkerOptions,
|
||||||
@ -30,7 +30,6 @@ import { CursorTool, PDFCursorTools } from './pdf_cursor_tools';
|
|||||||
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
|
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
|
||||||
import { PDFSidebar, SidebarView } from './pdf_sidebar';
|
import { PDFSidebar, SidebarView } from './pdf_sidebar';
|
||||||
import { AppOptions } from './app_options';
|
import { AppOptions } from './app_options';
|
||||||
import { getGlobalEventBus } from './dom_events';
|
|
||||||
import { OverlayManager } from './overlay_manager';
|
import { OverlayManager } from './overlay_manager';
|
||||||
import { PasswordPrompt } from './password_prompt';
|
import { PasswordPrompt } from './password_prompt';
|
||||||
import { PDFAttachmentViewer } from './pdf_attachment_viewer';
|
import { PDFAttachmentViewer } from './pdf_attachment_viewer';
|
||||||
@ -869,9 +868,6 @@ let PDFViewerApplication = {
|
|||||||
|
|
||||||
firstPagePromise.then(() => {
|
firstPagePromise.then(() => {
|
||||||
this.eventBus.dispatch('documentloaded', { source: this, });
|
this.eventBus.dispatch('documentloaded', { source: this, });
|
||||||
// TODO: Remove the following event, i.e. 'documentload',
|
|
||||||
// once the mozilla-central tests have been updated.
|
|
||||||
this.eventBus.dispatch('documentload', { source: this, });
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,15 +14,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CSS_UNITS, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, isPortraitOrientation,
|
CSS_UNITS, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, getGlobalEventBus,
|
||||||
isValidRotation, MAX_AUTO_SCALE, moveToEndOfArray, NullL10n,
|
isPortraitOrientation, isValidRotation, MAX_AUTO_SCALE, moveToEndOfArray,
|
||||||
PresentationModeState, RendererType, SCROLLBAR_PADDING, TextLayerMode,
|
NullL10n, PresentationModeState, RendererType, SCROLLBAR_PADDING,
|
||||||
UNKNOWN_SCALE, VERTICAL_PADDING, watchScroll
|
TextLayerMode, UNKNOWN_SCALE, VERTICAL_PADDING, watchScroll
|
||||||
} from './ui_utils';
|
} from './ui_utils';
|
||||||
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
|
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
|
||||||
import { AnnotationLayerBuilder } from './annotation_layer_builder';
|
import { AnnotationLayerBuilder } from './annotation_layer_builder';
|
||||||
import { createPromiseCapability } from 'pdfjs-lib';
|
import { createPromiseCapability } from 'pdfjs-lib';
|
||||||
import { getGlobalEventBus } from './dom_events';
|
|
||||||
import { PDFPageView } from './pdf_page_view';
|
import { PDFPageView } from './pdf_page_view';
|
||||||
import { SimpleLinkService } from './pdf_link_service';
|
import { SimpleLinkService } from './pdf_link_service';
|
||||||
import { TextLayerBuilder } from './text_layer_builder';
|
import { TextLayerBuilder } from './text_layer_builder';
|
||||||
@ -232,15 +231,13 @@ class BaseViewer {
|
|||||||
`${this._name}._setCurrentPageNumber: "${val}" is out of bounds.`);
|
`${this._name}._setCurrentPageNumber: "${val}" is out of bounds.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this._currentPageNumber = val;
|
||||||
|
|
||||||
let arg = {
|
this.eventBus.dispatch('pagechanging', {
|
||||||
source: this,
|
source: this,
|
||||||
pageNumber: val,
|
pageNumber: val,
|
||||||
pageLabel: this._pageLabels && this._pageLabels[val - 1],
|
pageLabel: this._pageLabels && this._pageLabels[val - 1],
|
||||||
};
|
});
|
||||||
this._currentPageNumber = val;
|
|
||||||
this.eventBus.dispatch('pagechanging', arg);
|
|
||||||
this.eventBus.dispatch('pagechange', arg);
|
|
||||||
|
|
||||||
if (resetCurrentPageView) {
|
if (resetCurrentPageView) {
|
||||||
this._resetCurrentPageView();
|
this._resetCurrentPageView();
|
||||||
@ -542,13 +539,11 @@ class BaseViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_setScaleDispatchEvent(newScale, newValue, preset = false) {
|
_setScaleDispatchEvent(newScale, newValue, preset = false) {
|
||||||
let arg = {
|
this.eventBus.dispatch('scalechanging', {
|
||||||
source: this,
|
source: this,
|
||||||
scale: newScale,
|
scale: newScale,
|
||||||
presetValue: preset ? newValue : undefined,
|
presetValue: preset ? newValue : undefined,
|
||||||
};
|
});
|
||||||
this.eventBus.dispatch('scalechanging', arg);
|
|
||||||
this.eventBus.dispatch('scalechange', arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_setScaleUpdatePages(newScale, newValue, noScroll = false, preset = false) {
|
_setScaleUpdatePages(newScale, newValue, noScroll = false, preset = false) {
|
||||||
|
@ -1,145 +0,0 @@
|
|||||||
/* Copyright 2016 Mozilla Foundation
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { EventBus } from './ui_utils';
|
|
||||||
|
|
||||||
// Attaching to the application event bus to dispatch events to the DOM for
|
|
||||||
// backwards viewer API compatibility.
|
|
||||||
function attachDOMEventsToEventBus(eventBus) {
|
|
||||||
eventBus.on('documentload', function() {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('documentload', true, true, {});
|
|
||||||
window.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('pagerendered', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('pagerendered', true, true, {
|
|
||||||
pageNumber: evt.pageNumber,
|
|
||||||
cssTransform: evt.cssTransform,
|
|
||||||
});
|
|
||||||
evt.source.div.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('textlayerrendered', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('textlayerrendered', true, true, {
|
|
||||||
pageNumber: evt.pageNumber,
|
|
||||||
});
|
|
||||||
evt.source.textLayerDiv.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('pagechange', function(evt) {
|
|
||||||
let event = document.createEvent('UIEvents');
|
|
||||||
event.initUIEvent('pagechange', true, true, window, 0);
|
|
||||||
event.pageNumber = evt.pageNumber;
|
|
||||||
evt.source.container.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('pagesinit', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('pagesinit', true, true, null);
|
|
||||||
evt.source.container.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('pagesloaded', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('pagesloaded', true, true, {
|
|
||||||
pagesCount: evt.pagesCount,
|
|
||||||
});
|
|
||||||
evt.source.container.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('scalechange', function(evt) {
|
|
||||||
let event = document.createEvent('UIEvents');
|
|
||||||
event.initUIEvent('scalechange', true, true, window, 0);
|
|
||||||
event.scale = evt.scale;
|
|
||||||
event.presetValue = evt.presetValue;
|
|
||||||
evt.source.container.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('updateviewarea', function(evt) {
|
|
||||||
let event = document.createEvent('UIEvents');
|
|
||||||
event.initUIEvent('updateviewarea', true, true, window, 0);
|
|
||||||
event.location = evt.location;
|
|
||||||
evt.source.container.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('find', function(evt) {
|
|
||||||
if (evt.source === window) {
|
|
||||||
return; // event comes from FirefoxCom, no need to replicate
|
|
||||||
}
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('find' + evt.type, true, true, {
|
|
||||||
query: evt.query,
|
|
||||||
phraseSearch: evt.phraseSearch,
|
|
||||||
caseSensitive: evt.caseSensitive,
|
|
||||||
highlightAll: evt.highlightAll,
|
|
||||||
findPrevious: evt.findPrevious,
|
|
||||||
});
|
|
||||||
window.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('attachmentsloaded', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('attachmentsloaded', true, true, {
|
|
||||||
attachmentsCount: evt.attachmentsCount,
|
|
||||||
});
|
|
||||||
evt.source.container.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('sidebarviewchanged', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('sidebarviewchanged', true, true, {
|
|
||||||
view: evt.view,
|
|
||||||
});
|
|
||||||
evt.source.outerContainer.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('pagemode', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('pagemode', true, true, {
|
|
||||||
mode: evt.mode,
|
|
||||||
});
|
|
||||||
evt.source.pdfViewer.container.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('namedaction', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('namedaction', true, true, {
|
|
||||||
action: evt.action,
|
|
||||||
});
|
|
||||||
evt.source.pdfViewer.container.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('presentationmodechanged', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('presentationmodechanged', true, true, {
|
|
||||||
active: evt.active,
|
|
||||||
switchInProgress: evt.switchInProgress,
|
|
||||||
});
|
|
||||||
window.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
eventBus.on('outlineloaded', function(evt) {
|
|
||||||
let event = document.createEvent('CustomEvent');
|
|
||||||
event.initCustomEvent('outlineloaded', true, true, {
|
|
||||||
outlineCount: evt.outlineCount,
|
|
||||||
});
|
|
||||||
evt.source.container.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let globalEventBus = null;
|
|
||||||
function getGlobalEventBus(dispatchToDOM = false) {
|
|
||||||
if (!globalEventBus) {
|
|
||||||
globalEventBus = new EventBus({ dispatchToDOM, });
|
|
||||||
if (!dispatchToDOM) {
|
|
||||||
attachDOMEventsToEventBus(globalEventBus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return globalEventBus;
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
|
||||||
attachDOMEventsToEventBus,
|
|
||||||
getGlobalEventBus,
|
|
||||||
};
|
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import { createPromiseCapability } from 'pdfjs-lib';
|
import { createPromiseCapability } from 'pdfjs-lib';
|
||||||
import { getCharacterType } from './pdf_find_utils';
|
import { getCharacterType } from './pdf_find_utils';
|
||||||
import { getGlobalEventBus } from './dom_events';
|
import { getGlobalEventBus } from './ui_utils';
|
||||||
|
|
||||||
const FindState = {
|
const FindState = {
|
||||||
FOUND: 0,
|
FOUND: 0,
|
||||||
|
@ -14,9 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isValidRotation, parseQueryString, waitOnEventOrTimeout
|
getGlobalEventBus, isValidRotation, parseQueryString, waitOnEventOrTimeout
|
||||||
} from './ui_utils';
|
} from './ui_utils';
|
||||||
import { getGlobalEventBus } from './dom_events';
|
|
||||||
|
|
||||||
// Heuristic value used when force-resetting `this._blockHashChange`.
|
// Heuristic value used when force-resetting `this._blockHashChange`.
|
||||||
const HASH_CHANGE_TIMEOUT = 1000; // milliseconds
|
const HASH_CHANGE_TIMEOUT = 1000; // milliseconds
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getGlobalEventBus } from './dom_events';
|
import { getGlobalEventBus, parseQueryString } from './ui_utils';
|
||||||
import { parseQueryString } from './ui_utils';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFLinkServiceOptions
|
* @typedef {Object} PDFLinkServiceOptions
|
||||||
|
@ -14,13 +14,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
approximateFraction, CSS_UNITS, DEFAULT_SCALE, getOutputScale, NullL10n,
|
approximateFraction, CSS_UNITS, DEFAULT_SCALE, getGlobalEventBus,
|
||||||
RendererType, roundToDivide, TextLayerMode
|
getOutputScale, NullL10n, RendererType, roundToDivide, TextLayerMode
|
||||||
} from './ui_utils';
|
} from './ui_utils';
|
||||||
import {
|
import {
|
||||||
createPromiseCapability, RenderingCancelledException, SVGGraphics
|
createPromiseCapability, RenderingCancelledException, SVGGraphics
|
||||||
} from 'pdfjs-lib';
|
} from 'pdfjs-lib';
|
||||||
import { getGlobalEventBus } from './dom_events';
|
|
||||||
import { RenderingStates } from './pdf_rendering_queue';
|
import { RenderingStates } from './pdf_rendering_queue';
|
||||||
import { viewerCompatibilityParams } from './viewer_compatibility';
|
import { viewerCompatibilityParams } from './viewer_compatibility';
|
||||||
|
|
||||||
|
@ -20,7 +20,9 @@ import {
|
|||||||
import {
|
import {
|
||||||
DefaultTextLayerFactory, TextLayerBuilder
|
DefaultTextLayerFactory, TextLayerBuilder
|
||||||
} from './text_layer_builder.js';
|
} from './text_layer_builder.js';
|
||||||
import { EventBus, NullL10n, ProgressBar } from './ui_utils.js';
|
import {
|
||||||
|
EventBus, getGlobalEventBus, NullL10n, ProgressBar
|
||||||
|
} from './ui_utils.js';
|
||||||
import { PDFLinkService, SimpleLinkService } from './pdf_link_service.js';
|
import { PDFLinkService, SimpleLinkService } from './pdf_link_service.js';
|
||||||
import { DownloadManager } from './download_manager.js';
|
import { DownloadManager } from './download_manager.js';
|
||||||
import { GenericL10n } from './genericl10n.js';
|
import { GenericL10n } from './genericl10n.js';
|
||||||
@ -33,6 +35,9 @@ import { PDFViewer } from './pdf_viewer.js';
|
|||||||
const pdfjsVersion = PDFJSDev.eval('BUNDLE_VERSION');
|
const pdfjsVersion = PDFJSDev.eval('BUNDLE_VERSION');
|
||||||
const pdfjsBuild = PDFJSDev.eval('BUNDLE_BUILD');
|
const pdfjsBuild = PDFJSDev.eval('BUNDLE_BUILD');
|
||||||
|
|
||||||
|
// For backwards compatibility, ensure that events are re-dispatched to the DOM.
|
||||||
|
getGlobalEventBus(/* dispatchToDOM = */ true);
|
||||||
|
|
||||||
export {
|
export {
|
||||||
PDFViewer,
|
PDFViewer,
|
||||||
PDFSinglePageViewer,
|
PDFSinglePageViewer,
|
||||||
|
@ -13,9 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getGlobalEventBus } from './dom_events';
|
import { getGlobalEventBus, scrollIntoView } from './ui_utils';
|
||||||
import { renderTextLayer } from 'pdfjs-lib';
|
import { renderTextLayer } from 'pdfjs-lib';
|
||||||
import { scrollIntoView } from './ui_utils';
|
|
||||||
|
|
||||||
const EXPAND_DIVS_TIMEOUT = 300; // ms
|
const EXPAND_DIVS_TIMEOUT = 300; // ms
|
||||||
const MATCH_SCROLL_OFFSET_TOP = -50;
|
const MATCH_SCROLL_OFFSET_TOP = -50;
|
||||||
|
@ -732,9 +732,6 @@ class EventBus {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_dispatchDOMEvent(eventName, args = null) {
|
_dispatchDOMEvent(eventName, args = null) {
|
||||||
if (!this._dispatchToDOM) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const details = Object.create(null);
|
const details = Object.create(null);
|
||||||
if (args && args.length > 0) {
|
if (args && args.length > 0) {
|
||||||
const obj = args[0];
|
const obj = args[0];
|
||||||
@ -755,6 +752,14 @@ class EventBus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let globalEventBus = null;
|
||||||
|
function getGlobalEventBus(dispatchToDOM = false) {
|
||||||
|
if (!globalEventBus) {
|
||||||
|
globalEventBus = new EventBus({ dispatchToDOM, });
|
||||||
|
}
|
||||||
|
return globalEventBus;
|
||||||
|
}
|
||||||
|
|
||||||
function clamp(v, min, max) {
|
function clamp(v, min, max) {
|
||||||
return Math.min(Math.max(v, min), max);
|
return Math.min(Math.max(v, min), max);
|
||||||
}
|
}
|
||||||
@ -868,6 +873,7 @@ export {
|
|||||||
TextLayerMode,
|
TextLayerMode,
|
||||||
NullL10n,
|
NullL10n,
|
||||||
EventBus,
|
EventBus,
|
||||||
|
getGlobalEventBus,
|
||||||
ProgressBar,
|
ProgressBar,
|
||||||
getPDFFileNameFromURL,
|
getPDFFileNameFromURL,
|
||||||
noContextMenuHandler,
|
noContextMenuHandler,
|
||||||
|
@ -60,7 +60,7 @@ function getViewerConfiguration() {
|
|||||||
appContainer: document.body,
|
appContainer: document.body,
|
||||||
mainContainer: document.getElementById('viewerContainer'),
|
mainContainer: document.getElementById('viewerContainer'),
|
||||||
viewerContainer: document.getElementById('viewer'),
|
viewerContainer: document.getElementById('viewer'),
|
||||||
eventBus: null, // using global event bus with DOM events
|
eventBus: null, // Using global event bus with (optional) DOM events.
|
||||||
toolbar: {
|
toolbar: {
|
||||||
container: document.getElementById('toolbarViewer'),
|
container: document.getElementById('toolbarViewer'),
|
||||||
numPages: document.getElementById('numPages'),
|
numPages: document.getElementById('numPages'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user