Attempt to simplify the signature of the PDFFindBar constructor, by moving the eventBus parameter from the options object

This is similar to the format used by a number of other viewer components, and should simplify the `PDFFindBar` initialization slightly.
This commit is contained in:
Jonas Jenwald 2018-10-02 12:57:07 +02:00
parent 25446dbd8d
commit 3f3ddaf541
2 changed files with 5 additions and 8 deletions

View File

@ -286,7 +286,7 @@ let PDFViewerApplication = {
this.overlayManager = new OverlayManager(); this.overlayManager = new OverlayManager();
const dispatchToDOM = AppOptions.get('eventBusDispatchToDOM'); const dispatchToDOM = AppOptions.get('eventBusDispatchToDOM');
let eventBus = appConfig.eventBus || getGlobalEventBus(dispatchToDOM); const eventBus = appConfig.eventBus || getGlobalEventBus(dispatchToDOM);
this.eventBus = eventBus; this.eventBus = eventBus;
let pdfRenderingQueue = new PDFRenderingQueue(); let pdfRenderingQueue = new PDFRenderingQueue();
@ -349,10 +349,7 @@ let PDFViewerApplication = {
}); });
pdfLinkService.setHistory(this.pdfHistory); pdfLinkService.setHistory(this.pdfHistory);
// TODO: improve `PDFFindBar` constructor parameter passing this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);
let findBarConfig = Object.create(appConfig.findBar);
findBarConfig.eventBus = eventBus;
this.findBar = new PDFFindBar(findBarConfig, this.l10n);
this.pdfDocumentProperties = this.pdfDocumentProperties =
new PDFDocumentProperties(appConfig.documentProperties, new PDFDocumentProperties(appConfig.documentProperties,

View File

@ -13,8 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { getGlobalEventBus, NullL10n } from './ui_utils';
import { FindState } from './pdf_find_controller'; import { FindState } from './pdf_find_controller';
import { NullL10n } from './ui_utils';
const MATCHES_COUNT_LIMIT = 1000; const MATCHES_COUNT_LIMIT = 1000;
@ -25,7 +25,7 @@ const MATCHES_COUNT_LIMIT = 1000;
* is done by PDFFindController. * is done by PDFFindController.
*/ */
class PDFFindBar { class PDFFindBar {
constructor(options, l10n = NullL10n) { constructor(options, eventBus = getGlobalEventBus(), l10n = NullL10n) {
this.opened = false; this.opened = false;
this.bar = options.bar || null; this.bar = options.bar || null;
@ -38,7 +38,7 @@ class PDFFindBar {
this.findResultsCount = options.findResultsCount || null; this.findResultsCount = options.findResultsCount || null;
this.findPreviousButton = options.findPreviousButton || null; this.findPreviousButton = options.findPreviousButton || null;
this.findNextButton = options.findNextButton || null; this.findNextButton = options.findNextButton || null;
this.eventBus = options.eventBus; this.eventBus = eventBus;
this.l10n = l10n; this.l10n = l10n;
// Add event listeners to the DOM elements. // Add event listeners to the DOM elements.