2020-05-19 18:27:45 +00:00
|
|
|
import Deck, { VERSION } from './reveal.js'
|
2020-03-07 09:44:02 +00:00
|
|
|
|
2020-04-07 07:40:11 +00: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-04-27 09:44:33 +00:00
|
|
|
let Reveal = Deck;
|
2020-03-31 11:06:58 +00:00
|
|
|
|
2020-04-07 07:40:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The below is a thin shell that mimics the pre 4.0
|
|
|
|
* reveal.js API and ensures backwards compatibility.
|
2020-05-18 13:59:18 +00:00
|
|
|
* This API only allows for one Reveal instance per
|
2020-04-07 07:40:11 +00:00
|
|
|
* 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-04-17 08:59:55 +00:00
|
|
|
Reveal.initialize = options => {
|
2020-04-07 07:40:11 +00:00
|
|
|
|
|
|
|
// Create our singleton reveal.js instance
|
2020-04-17 08:59:55 +00:00
|
|
|
Object.assign( Reveal, new Deck( document.querySelector( '.reveal' ), options ) );
|
2020-04-07 07:40:11 +00:00
|
|
|
|
|
|
|
// Invoke any enqueued API calls
|
2020-04-17 08:59:55 +00:00
|
|
|
enqueuedAPICalls.map( method => method( Reveal ) );
|
2020-04-07 07:40:11 +00:00
|
|
|
|
2020-04-17 08:59:55 +00:00
|
|
|
return Reveal.initialize();
|
2020-04-07 07:40:11 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The pre 4.0 API let you add event listener before
|
|
|
|
* initializing. We maintain the same behavior by
|
2020-04-27 09:44:33 +00:00
|
|
|
* queuing up premature API calls and invoking all
|
|
|
|
* of them when Reveal.initialize is called.
|
2020-04-07 07:40:11 +00:00
|
|
|
*/
|
2020-04-16 13:45:25 +00:00
|
|
|
[ 'on', 'off', 'addEventListener', 'removeEventListener', 'registerPlugin' ].forEach( method => {
|
2020-04-17 08:59:55 +00:00
|
|
|
Reveal[method] = ( ...args ) => {
|
2020-04-07 07:40:11 +00:00
|
|
|
enqueuedAPICalls.push( deck => deck[method].call( null, ...args ) );
|
|
|
|
}
|
2020-04-17 08:59:55 +00:00
|
|
|
} );
|
|
|
|
|
2020-05-27 11:15:26 +00:00
|
|
|
Reveal.isReady = () => false;
|
|
|
|
|
2020-05-19 18:27:45 +00:00
|
|
|
Reveal.VERSION = VERSION;
|
|
|
|
|
2020-04-17 08:59:55 +00:00
|
|
|
export default Reveal;
|