Adds EventBus.

This commit is contained in:
Yury Delendik 2016-04-25 17:57:15 -05:00
parent 55581b162e
commit 7fd3db9977
17 changed files with 510 additions and 151 deletions

View file

@ -35,6 +35,7 @@ var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
* @property {HTMLDivElement} container - The container for the viewer element.
* @property {HTMLDivElement} viewer - (optional) The viewer element.
* @property {PDFViewer} pdfViewer - The document viewer.
* @property {EventBus} eventBus - The application event bus.
* @property {Array} contextMenuItems - (optional) The menuitems that are added
* to the context menu in Presentation Mode.
*/
@ -51,6 +52,7 @@ var PDFPresentationMode = (function PDFPresentationModeClosure() {
this.container = options.container;
this.viewer = options.viewer || options.container.firstElementChild;
this.pdfViewer = options.pdfViewer;
this.eventBus = options.eventBus;
var contextMenuItems = options.contextMenuItems || null;
this.active = false;
@ -163,12 +165,11 @@ var PDFPresentationMode = (function PDFPresentationModeClosure() {
* @private
*/
_notifyStateChange: function PDFPresentationMode_notifyStateChange() {
var event = document.createEvent('CustomEvent');
event.initCustomEvent('presentationmodechanged', true, true, {
this.eventBus.dispatch('presentationmodechanged', {
source: this,
active: this.active,
switchInProgress: !!this.switchInProgress
});
window.dispatchEvent(event);
},
/**