|
@@ -1,39 +1,41 @@
|
|
|
|
|
|
-simple postmessage plugin
|
|
|
|
|
|
-Useful when a reveal slideshow is inside an iframe.
|
|
|
-It allows to call reveal methods from outside.
|
|
|
+ simple postmessage plugin
|
|
|
|
|
|
-Example:
|
|
|
- var reveal = window.frames[0];
|
|
|
+ Useful when a reveal slideshow is inside an iframe.
|
|
|
+ It allows to call reveal methods from outside.
|
|
|
|
|
|
-
|
|
|
- reveal.postMessage(JSON.stringify({method: 'prev', args: []}), '*');
|
|
|
-
|
|
|
- reveal.postMessage(JSON.stringify({method: 'next', args: []}), '*');
|
|
|
-
|
|
|
- reveal.postMessage(JSON.stringify({method: 'slide', args: [2,2]}), '*');
|
|
|
+ Example:
|
|
|
+ var reveal = window.frames[0];
|
|
|
|
|
|
-Add to the slideshow:
|
|
|
+
|
|
|
+ reveal.postMessage(JSON.stringify({method: 'prev', args: []}), '*');
|
|
|
+
|
|
|
+ reveal.postMessage(JSON.stringify({method: 'next', args: []}), '*');
|
|
|
+
|
|
|
+ reveal.postMessage(JSON.stringify({method: 'slide', args: [2,2]}), '*');
|
|
|
|
|
|
- dependencies: [
|
|
|
- ...
|
|
|
- { src: 'plugin/postmessage/postmessage.js', async: true, condition: function() { return !!document.body.classList; } }
|
|
|
- ]
|
|
|
+ Add to the slideshow:
|
|
|
|
|
|
+ dependencies: [
|
|
|
+ ...
|
|
|
+ { src: 'plugin/postmessage/postmessage.js', async: true, condition: function() { return !!document.body.classList; } }
|
|
|
+ ]
|
|
|
|
|
|
*/
|
|
|
|
|
|
(function (){
|
|
|
|
|
|
-window.addEventListener("message", function (event){
|
|
|
- var data = JSON.parse(event.data),
|
|
|
- method = data.method,
|
|
|
- args = data.args;
|
|
|
- if (Reveal[method]){
|
|
|
- Reveal[method].apply(Reveal, data.args);
|
|
|
- }
|
|
|
-}, false);
|
|
|
+ window.addEventListener( "message", function ( event ) {
|
|
|
+ var data = JSON.parse( event.data ),
|
|
|
+ method = data.method,
|
|
|
+ args = data.args;
|
|
|
+
|
|
|
+ if( typeof Reveal[method] === 'function' ) {
|
|
|
+ Reveal[method].apply( Reveal, data.args );
|
|
|
+ }
|
|
|
+ }, false);
|
|
|
+
|
|
|
}());
|
|
|
|
|
|
|