From 96f84a430ab0d9dbc576e90e1aed5a0248fa91f3 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Fri, 11 Nov 2016 11:45:59 +0100 Subject: [PATCH] Added semi fullscreen function --- js/h5p.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index e6b4555..47aae4a 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -477,6 +477,19 @@ H5P.communicator = (function () { return (window.postMessage && window.addEventListener ? new Communicator() : undefined); })(); +/** + * Enter semi fullscreen for the given H5P instance + * + * @method semiFullScreen + * @param {H5P.jQuery} $element Content container. + * @param {Object} instance + * @param {function} exitCallback Callback function called when user exits fullscreen. + * @param {H5P.jQuery} $body For internal use. Gives the body of the iframe. + */ +H5P.semiFullScreen = function ($element, instance, exitCallback, body) { + H5P.fullScreen($element, instance, exitCallback, body, true); +}; + /** * Enter fullscreen for the given H5P instance. * @@ -484,15 +497,16 @@ H5P.communicator = (function () { * @param {Object} instance * @param {function} exitCallback Callback function called when user exits fullscreen. * @param {H5P.jQuery} $body For internal use. Gives the body of the iframe. + * @param {Boolean} forceSemiFullScreen */ -H5P.fullScreen = function ($element, instance, exitCallback, body) { +H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFullScreen) { if (H5P.exitFullScreen !== undefined) { return; // Cannot enter new fullscreen until previous is over } if (H5P.isFramed && H5P.externalEmbed === false) { // Trigger resize on wrapper in parent window. - window.parent.H5P.fullScreen($element, instance, exitCallback, H5P.$body.get()); + window.parent.H5P.fullScreen($element, instance, exitCallback, H5P.$body.get(), forceSemiFullScreen); H5P.isFullscreen = true; H5P.exitFullScreen = function () { window.parent.H5P.exitFullScreen(); @@ -572,7 +586,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) { }; H5P.isFullscreen = true; - if (H5P.fullScreenBrowserPrefix === undefined) { + if (H5P.fullScreenBrowserPrefix === undefined || forceSemiFullScreen === true) { // Create semi fullscreen. if (H5P.isFramed) {