Fixed so that iframes can be loaded before resizer script.
parent
553ae243d2
commit
e961f614a4
|
@ -66,7 +66,6 @@ var H5POldEmbed = H5POldEmbed || (function () {
|
||||||
loadResizer(h5ps[i].getAttribute('data-h5p'));
|
loadResizer(h5ps[i].getAttribute('data-h5p'));
|
||||||
}
|
}
|
||||||
addIframe(h5ps[i]);
|
addIframe(h5ps[i]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,4 +108,17 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
// Let h5p iframes know we're ready!
|
||||||
|
var iframes = document.getElementsByTagName('iframe');
|
||||||
|
var ready = {
|
||||||
|
context: 'h5p',
|
||||||
|
action: 'ready'
|
||||||
|
};
|
||||||
|
for (var i = 0; i < iframes.length; i++) {
|
||||||
|
if (iframes[i].src.indexOf('h5p') !== -1) {
|
||||||
|
iframes[i].contentWindow.postMessage(ready, '*');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
10
js/h5p.js
10
js/h5p.js
|
@ -145,6 +145,11 @@ H5P.init = function () {
|
||||||
// External embed
|
// External embed
|
||||||
var parentIsFriendly = false;
|
var parentIsFriendly = false;
|
||||||
|
|
||||||
|
// Handle that the resizer is loaded after the iframe
|
||||||
|
H5P.communicator.on('ready', function () {
|
||||||
|
H5P.communicator.send('hello');
|
||||||
|
});
|
||||||
|
|
||||||
// Handle hello message from our parent window
|
// Handle hello message from our parent window
|
||||||
H5P.communicator.on('hello', function () {
|
H5P.communicator.on('hello', function () {
|
||||||
// Initial setup/handshake is done
|
// Initial setup/handshake is done
|
||||||
|
@ -153,7 +158,8 @@ H5P.init = function () {
|
||||||
// Hide scrollbars for correct size
|
// Hide scrollbars for correct size
|
||||||
document.body.style.overflow = 'hidden';
|
document.body.style.overflow = 'hidden';
|
||||||
|
|
||||||
H5P.communicator.send('prepareResize');
|
// Content need to be resized to fit the new iframe size
|
||||||
|
H5P.trigger(instance, 'resize');
|
||||||
});
|
});
|
||||||
|
|
||||||
// When resize has been prepared tell parent window to resize
|
// When resize has been prepared tell parent window to resize
|
||||||
|
@ -192,7 +198,7 @@ H5P.init = function () {
|
||||||
H5P.jQuery(window.top).resize(function () {
|
H5P.jQuery(window.top).resize(function () {
|
||||||
if (window.parent.H5P.isFullscreen) {
|
if (window.parent.H5P.isFullscreen) {
|
||||||
// Use timeout to avoid bug in certain browsers when exiting fullscreen. Some browser will trigger resize before the fullscreenchange event.
|
// Use timeout to avoid bug in certain browsers when exiting fullscreen. Some browser will trigger resize before the fullscreenchange event.
|
||||||
H5P.trigger(instance, 'resize');
|
H5P.trigger(instance, 'resize');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
H5P.trigger(instance, 'resize');
|
H5P.trigger(instance, 'resize');
|
||||||
|
|
Loading…
Reference in New Issue