aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2014-04-18 13:56:51 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2014-04-18 13:56:51 +0200
commit11ea0aa3e13e665dc882a432381c27898c86e569 (patch)
treec33ff0584ba26a0e5257a88ed1f1a8a94545e4df /js
parent38af788a65bcb18e644ae63f83410710c80ae97b (diff)
downloadfosdem-2018-presentation-11ea0aa3e13e665dc882a432381c27898c86e569.tar
fosdem-2018-presentation-11ea0aa3e13e665dc882a432381c27898c86e569.tar.gz
postmessage plugin is now part of reveal.js core
Diffstat (limited to 'js')
-rw-r--r--js/reveal.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/js/reveal.js b/js/reveal.js
index fe499ea..57f0872 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -239,7 +239,6 @@ var Reveal = (function(){
}
-
/**
* Loads the dependencies of reveal.js. Dependencies are
* defined via the configuration option 'dependencies'
@@ -313,6 +312,9 @@ var Reveal = (function(){
// Make sure we've got all the DOM elements we need
setupDOM();
+ // Listen to messages posted to this window
+ setupPostMessage();
+
// Resets all vertical slides so that only the first is visible
resetVerticalSlides();
@@ -552,6 +554,28 @@ var Reveal = (function(){
}
/**
+ * Registers a listener to postMessage events, this makes it
+ * possible to call all reveal.js API methods from another
+ * window. For example:
+ *
+ * revealWindow.postMessage( JSON.stringify({
+ * method: 'slide',
+ * args: [ 2 ]
+ * }), '*' );
+ */
+ function setupPostMessage() {
+
+ window.addEventListener( 'message', function ( event ) {
+ var data = JSON.parse( event.data );
+ var method = Reveal[data.method];
+ if( typeof method === 'function' ) {
+ method.apply( Reveal, data.args );
+ }
+ }, false);
+
+ }
+
+ /**
* Applies the configuration settings from the config
* object. May be called multiple times.
*/