From a4d6f3aaabd87c40b3d18ba1d82ff3f745353fb0 Mon Sep 17 00:00:00 2001 From: Timothy Lim Date: Mon, 12 Dec 2016 11:28:23 +0100 Subject: [PATCH] Restore deprecated variable H5P.canHasFullScreen for backwards compatability HFP-339 --- h5p.classes.php | 2 +- js/h5p.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 3276151..0d92330 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1676,7 +1676,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 11 + 'minorVersion' => 12 ); public static $styles = array( 'styles/h5p.css', diff --git a/js/h5p.js b/js/h5p.js index b266b5e..618aae7 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -97,6 +97,15 @@ H5P.init = function (target) { // element sizing corrected. Ref. https://connect.microsoft.com/IE/feedback/details/838286/ie-11-incorrectly-reports-dom-element-sizes-in-fullscreen-mode-when-fullscreened-element-is-within-an-iframe } + // Deprecated variable, kept to maintain backwards compatability + if (H5P.canHasFullScreen === undefined) { + /** + * @deprecated since version 1.11 + * @type {boolean} + */ + H5P.canHasFullScreen = (H5P.isFramed && H5P.externalEmbed !== false) ? ((document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled) ? true : false) : true; + } + // H5Ps added in normal DIV. var $containers = H5P.jQuery('.h5p-content:not(.h5p-initialized)', target).each(function () { var $element = H5P.jQuery(this).addClass('h5p-initialized'); @@ -147,6 +156,13 @@ H5P.init = function (target) { }); } + // Check if we should add and display a fullscreen button for this H5P using + // the deprecated variable for backwards compatability. + if (contentData.fullScreen == 1 && H5P.canHasFullScreen) { + H5P.jQuery('
').prependTo($container).children().click(function () { + H5P.fullScreen($container, instance); + }); + } // Create action bar var $actions = H5P.jQuery('');