commit
1c6b818841
|
@ -1,8 +1,9 @@
|
||||||
// H5P iframe Resizer
|
// H5P iframe Resizer
|
||||||
(function () {
|
(function () {
|
||||||
if (!window.postMessage || !window.addEventListener) {
|
if (!window.postMessage || !window.addEventListener || window.h5pResizerInitialized) {
|
||||||
return; // Not supported
|
return; // Not supported
|
||||||
}
|
}
|
||||||
|
window.h5pResizerInitialized = true;
|
||||||
|
|
||||||
// Map actions to handlers
|
// Map actions to handlers
|
||||||
var actionHandlers = {};
|
var actionHandlers = {};
|
||||||
|
@ -47,6 +48,11 @@
|
||||||
actionHandlers.prepareResize = function (iframe, data, respond) {
|
actionHandlers.prepareResize = function (iframe, data, respond) {
|
||||||
responseData = {};
|
responseData = {};
|
||||||
|
|
||||||
|
// Create spaceholder and insert after iframe.
|
||||||
|
var spaceholder = document.createElement('div');
|
||||||
|
spaceholder.style.height = (iframe.clientHeight - 1) + 'px';
|
||||||
|
iframe.parentNode.insertBefore(spaceholder, iframe.nextSibling);
|
||||||
|
|
||||||
// Reset iframe height, in case content has shrinked.
|
// Reset iframe height, in case content has shrinked.
|
||||||
iframe.style.height = '1px';
|
iframe.style.height = '1px';
|
||||||
|
|
||||||
|
@ -64,6 +70,7 @@
|
||||||
actionHandlers.resize = function (iframe, data, respond) {
|
actionHandlers.resize = function (iframe, data, respond) {
|
||||||
// Resize iframe so all content is visible.
|
// Resize iframe so all content is visible.
|
||||||
iframe.style.height = data.height + 'px';
|
iframe.style.height = data.height + 'px';
|
||||||
|
iframe.parentNode.removeChild(iframe.nextSibling);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,10 +3,6 @@ var H5P = H5P || {};
|
||||||
// Create object where external code may register and listen for H5P Events
|
// Create object where external code may register and listen for H5P Events
|
||||||
H5P.externalDispatcher = new H5P.EventDispatcher();
|
H5P.externalDispatcher = new H5P.EventDispatcher();
|
||||||
|
|
||||||
if (H5P.isFramed && H5P.externalEmbed === false) {
|
|
||||||
H5P.externalDispatcher.on('*', window.top.H5P.externalDispatcher.trigger);
|
|
||||||
}
|
|
||||||
|
|
||||||
// EventDispatcher extensions
|
// EventDispatcher extensions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
12
js/h5p.js
12
js/h5p.js
|
@ -67,7 +67,7 @@ H5P.init = function (target) {
|
||||||
|
|
||||||
// Determine if we can use full screen
|
// Determine if we can use full screen
|
||||||
if (H5P.canHasFullScreen === undefined) {
|
if (H5P.canHasFullScreen === undefined) {
|
||||||
H5P.canHasFullScreen = (H5P.isFramed && H5P.externalEmbed !== false) ? (document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled) : true;
|
H5P.canHasFullScreen = (H5P.isFramed && H5P.externalEmbed !== false) ? ((document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled) ? true : false) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// H5Ps added in normal DIV.
|
// H5Ps added in normal DIV.
|
||||||
|
@ -111,7 +111,7 @@ H5P.init = function (target) {
|
||||||
var instance = H5P.newRunnable(library, contentId, $container, true);
|
var instance = H5P.newRunnable(library, contentId, $container, true);
|
||||||
|
|
||||||
// Check if we should add and display a fullscreen button for this H5P.
|
// Check if we should add and display a fullscreen button for this H5P.
|
||||||
if (contentData.fullScreen == 1) {
|
if (contentData.fullScreen == 1 && H5P.canHasFullScreen) {
|
||||||
H5P.jQuery('<div class="h5p-content-controls"><div role="button" tabindex="1" class="h5p-enable-fullscreen" title="' + H5P.t('fullscreen') + '"></div></div>').prependTo($container).children().click(function () {
|
H5P.jQuery('<div class="h5p-content-controls"><div role="button" tabindex="1" class="h5p-enable-fullscreen" title="' + H5P.t('fullscreen') + '"></div></div>').prependTo($container).children().click(function () {
|
||||||
H5P.fullScreen($container, instance);
|
H5P.fullScreen($container, instance);
|
||||||
});
|
});
|
||||||
|
@ -1395,7 +1395,7 @@ H5P.cssLoaded = function (path) {
|
||||||
* @returns {array} The passed array is returned for chaining.
|
* @returns {array} The passed array is returned for chaining.
|
||||||
*/
|
*/
|
||||||
H5P.shuffleArray = function (array) {
|
H5P.shuffleArray = function (array) {
|
||||||
if (! array instanceof Array) {
|
if (!(array instanceof Array)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1747,12 +1747,16 @@ H5P.createTitle = function(rawTitle, maxLength) {
|
||||||
if (state !== undefined) {
|
if (state !== undefined) {
|
||||||
// Async is not used to prevent the request from being cancelled.
|
// Async is not used to prevent the request from being cancelled.
|
||||||
H5P.setUserData(instance.contentId, 'state', state, {deleteOnChange: true, async: false});
|
H5P.setUserData(instance.contentId, 'state', state, {deleteOnChange: true, async: false});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Relay events to top window.
|
||||||
|
if (H5P.isFramed && H5P.externalEmbed === false) {
|
||||||
|
H5P.externalDispatcher.on('*', window.top.H5P.externalDispatcher.trigger);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
})(H5P.jQuery);
|
})(H5P.jQuery);
|
||||||
|
|
Loading…
Reference in New Issue