2020-03-07 18:22:19 +01:00
|
|
|
import Presentation from './reveal.js'
|
2020-03-07 10:44:02 +01:00
|
|
|
|
2020-04-07 09:40:11 +02:00
|
|
|
/**
|
|
|
|
* Expose the Reveal class to the window. To create a
|
|
|
|
* new instance:
|
|
|
|
* let deck = new Reveal( document.querySelector( '.reveal' ), {
|
|
|
|
* controls: false
|
|
|
|
* } );
|
|
|
|
* deck.initialize().then(() => {
|
|
|
|
* // reveal.js is ready
|
|
|
|
* });
|
|
|
|
*/
|
2020-03-31 13:06:58 +02:00
|
|
|
window.Reveal = Presentation;
|
|
|
|
|
2020-04-07 09:40:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The below is a thin shell that mimics the pre 4.0
|
|
|
|
* reveal.js API and ensures backwards compatibility.
|
|
|
|
* This API only allows for once Reveal instance per
|
|
|
|
* page, whereas the new API above lets you run many
|
|
|
|
* presentations on the same page.
|
|
|
|
*
|
|
|
|
* Reveal.initialize( { controls: false } ).then(() => {
|
|
|
|
* // reveal.js is ready
|
|
|
|
* });
|
|
|
|
*/
|
|
|
|
|
|
|
|
let enqueuedAPICalls = [];
|
|
|
|
|
2020-03-31 13:06:58 +02:00
|
|
|
window.Reveal.initialize = options => {
|
2020-04-07 09:40:11 +02:00
|
|
|
|
|
|
|
// Create our singleton reveal.js instance
|
2020-03-31 13:06:58 +02:00
|
|
|
window.Reveal = new Presentation( document.querySelector( '.reveal' ), options );
|
2020-04-07 09:40:11 +02:00
|
|
|
|
|
|
|
// Invoke any enqueued API calls
|
|
|
|
enqueuedAPICalls.map( method => method( window.Reveal ) );
|
|
|
|
|
2020-03-31 13:06:58 +02:00
|
|
|
return window.Reveal.initialize();
|
2020-04-07 09:40:11 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The pre 4.0 API let you add event listener before
|
|
|
|
* initializing. We maintain the same behavior by
|
|
|
|
* queuing up early API calls and invoking all of them
|
|
|
|
* when Reveal.initialize is called.
|
|
|
|
*/
|
2020-04-16 15:45:25 +02:00
|
|
|
[ 'on', 'off', 'addEventListener', 'removeEventListener', 'registerPlugin' ].forEach( method => {
|
2020-04-07 09:40:11 +02:00
|
|
|
window.Reveal[method] = ( ...args ) => {
|
|
|
|
enqueuedAPICalls.push( deck => deck[method].call( null, ...args ) );
|
|
|
|
}
|
|
|
|
} );
|