aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2014-04-18 20:03:50 +0200
committerHakim El Hattab <hakim.elhattab@gmail.com>2014-04-18 20:03:50 +0200
commita4b09aecda8f70837c44a18c846ab892a2c0800c (patch)
tree0932bda3246ceca04da3d1a13c8294c554a59d80 /js
parent11ea0aa3e13e665dc882a432381c27898c86e569 (diff)
downloadfreenode-live-2017-presentation-a4b09aecda8f70837c44a18c846ab892a2c0800c.tar
freenode-live-2017-presentation-a4b09aecda8f70837c44a18c846ab892a2c0800c.tar.gz
bubble all reveal.js events to parent window through postMessage
Diffstat (limited to 'js')
-rw-r--r--js/reveal.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 57f0872..81cbd16 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -568,10 +568,11 @@ var Reveal = (function(){
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);
+ }, false );
}
@@ -957,13 +958,22 @@ var Reveal = (function(){
* Dispatches an event of the specified type from the
* reveal DOM element.
*/
- function dispatchEvent( type, properties ) {
+ function dispatchEvent( type, args ) {
- var event = document.createEvent( "HTMLEvents", 1, 2 );
+ var event = document.createEvent( 'HTMLEvents', 1, 2 );
event.initEvent( type, true, true );
- extend( event, properties );
+ extend( event, args );
dom.wrapper.dispatchEvent( event );
+ // If we're in an iframe, post each reveal.js event to the
+ // parent window. Used by the notes plugin
+ if( window.parent !== window.self ) {
+ // Remove arguments that can't be stringified (circular structures)
+ if( args && args.currentSlide ) delete args.currentSlide;
+ if( args && args.previousSlide ) delete args.previousSlide;
+ window.parent.postMessage( JSON.stringify({ namespace: 'reveal', eventName: type, eventArgs: args || null }), '*' );
+ }
+
}
/**