Moved registering of external dispatcher listener.

- This will dispatch events that are dispatched inside the constructor of
  content types
HFP-86
improved-message-for-library-in-smantics-no-valid
thomasmars 2016-11-17 12:56:15 +01:00
parent ec2ff180c1
commit d55134151c
1 changed files with 15 additions and 12 deletions

View File

@ -1984,6 +1984,21 @@ H5P.createTitle = function (rawTitle, maxLength) {
// Init H5P when page is fully loadded // Init H5P when page is fully loadded
$(document).ready(function () { $(document).ready(function () {
/**
* Indicates if H5P is embedded on an external page using iframe.
* @member {boolean} H5P.externalEmbed
*/
// Relay events to top window. This must be done before H5P.init
// since events may be fired on initialization.
if (H5P.isFramed && H5P.externalEmbed === false) {
H5P.externalDispatcher.on('*', function (event) {
console.log("external dispatcher got event, relaying it", event);
window.parent.H5P.externalDispatcher.trigger.call(this, event);
});
}
/** /**
* Prevent H5P Core from initializing. Must be overriden before document ready. * Prevent H5P Core from initializing. Must be overriden before document ready.
* @member {boolean} H5P.preventInit * @member {boolean} H5P.preventInit
@ -2025,18 +2040,6 @@ H5P.createTitle = function (rawTitle, maxLength) {
// pagehide is used on iPad when tabs are switched // pagehide is used on iPad when tabs are switched
H5P.$window.on('pagehide', storeCurrentState); H5P.$window.on('pagehide', storeCurrentState);
} }
/**
* Indicates if H5P is embedded on an external page using iframe.
* @member {boolean} H5P.externalEmbed
*/
// Relay events to top window.
if (H5P.isFramed && H5P.externalEmbed === false) {
H5P.externalDispatcher.on('*', function (event) {
window.parent.H5P.externalDispatcher.trigger.call(this, event);
});
}
}); });
})(H5P.jQuery); })(H5P.jQuery);