diff options
Diffstat (limited to 'js/reveal.js')
-rw-r--r-- | js/reveal.js | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/js/reveal.js b/js/reveal.js index a06ce55..5cb72eb 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1430,13 +1430,13 @@ var Reveal = (function(){ /** * Toggles the paused mode on and off. */ - function togglePause() { + function togglePause( override ) { - if( isPaused() ) { - resume(); + if( typeof override === 'boolean' ) { + override ? pause() : resume(); } else { - pause(); + isPaused() ? resume() : pause(); } } @@ -2326,6 +2326,40 @@ var Reveal = (function(){ } /** + * Retrieves the current state of the presentation as + * an object. This state can then be restored at any + * time. + */ + function getState() { + + var indices = getIndices(); + + return { + indexh: indices.h, + indexv: indices.v, + indexf: indices.f, + paused: isPaused(), + overview: isOverview() + }; + + } + + /** + * Restores the presentation to the given state. + * + * @param {Object} state As generated by getState() + */ + function setState( state ) { + + if( typeof state === 'object' ) { + slide( state.indexh, state.indexv, state.indexf ); + togglePause( state.paused ); + toggleOverview( state.overview ); + } + + } + + /** * Return a sorted fragments list, ordered by an increasing * "data-fragment-index" attribute. * @@ -3345,6 +3379,10 @@ var Reveal = (function(){ addEventListeners: addEventListeners, removeEventListeners: removeEventListeners, + // Facility for persisting and restoring the presentation state + getState: getState, + setState: setState, + // Returns the indices of the current, or specified, slide getIndices: getIndices, |