Skip to content

Commit fea11d2

Browse files
committed
add config option for postMessage features
1 parent a4b09ae commit fea11d2

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

js/reveal.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ var Reveal = (function(){
8989
// Opens links in an iframe preview overlay
9090
previewLinks: false,
9191

92+
// Flags if we should listen to and dispatch events through window.postMessage
93+
postMessage: true,
94+
9295
// Focuses body when page changes visiblity to ensure keyboard shortcuts work
9396
focusBodyOnPageVisiblityChange: true,
9497

@@ -565,14 +568,16 @@ var Reveal = (function(){
565568
*/
566569
function setupPostMessage() {
567570

568-
window.addEventListener( 'message', function ( event ) {
569-
var data = JSON.parse( event.data );
570-
var method = Reveal[data.method];
571+
if( config.postMessage ) {
572+
window.addEventListener( 'message', function ( event ) {
573+
var data = JSON.parse( event.data );
574+
var method = Reveal[data.method];
571575

572-
if( typeof method === 'function' ) {
573-
method.apply( Reveal, data.args );
574-
}
575-
}, false );
576+
if( typeof method === 'function' ) {
577+
method.apply( Reveal, data.args );
578+
}
579+
}, false );
580+
}
576581

577582
}
578583

@@ -967,7 +972,7 @@ var Reveal = (function(){
967972

968973
// If we're in an iframe, post each reveal.js event to the
969974
// parent window. Used by the notes plugin
970-
if( window.parent !== window.self ) {
975+
if( config.postMessage && window.parent !== window.self ) {
971976
// Remove arguments that can't be stringified (circular structures)
972977
if( args && args.currentSlide ) delete args.currentSlide;
973978
if( args && args.previousSlide ) delete args.previousSlide;

0 commit comments

Comments
 (0)