the postMessage API now works for getter methods
This commit is contained in:
25
js/reveal.js
25
js/reveal.js
@ -1276,7 +1276,11 @@
|
||||
|
||||
// Check if the requested method can be found
|
||||
if( data.method && typeof Reveal[data.method] === 'function' ) {
|
||||
Reveal[data.method].apply( Reveal, data.args );
|
||||
var result = Reveal[data.method].apply( Reveal, data.args );
|
||||
|
||||
// Dispatch a postMessage event with the returned value from
|
||||
// our method invocation for getter functions
|
||||
dispatchPostMessage( 'callback', { method: data.method, result: result } );
|
||||
}
|
||||
}
|
||||
}, false );
|
||||
@ -1981,8 +1985,25 @@
|
||||
|
||||
// If we're in an iframe, post each reveal.js event to the
|
||||
// parent window. Used by the notes plugin
|
||||
dispatchPostMessage( type );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatched a postMessage of the given type from our window.
|
||||
*/
|
||||
function dispatchPostMessage( type, data ) {
|
||||
|
||||
if( config.postMessageEvents && window.parent !== window.self ) {
|
||||
window.parent.postMessage( JSON.stringify({ namespace: 'reveal', eventName: type, state: getState() }), '*' );
|
||||
var message = {
|
||||
namespace: 'reveal',
|
||||
eventName: type,
|
||||
state: getState()
|
||||
};
|
||||
|
||||
extend( message, data );
|
||||
|
||||
window.parent.postMessage( JSON.stringify( message ), '*' );
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user