From 96f84a430ab0d9dbc576e90e1aed5a0248fa91f3 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Fri, 11 Nov 2016 11:45:59 +0100 Subject: [PATCH 1/4] 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) { From 088287955265330ef2eb2479b507d88574754655 Mon Sep 17 00:00:00 2001 From: Tom Arild Jakobsen Date: Mon, 28 Nov 2016 14:54:33 +0100 Subject: [PATCH 2/4] Allow subContentId in group validation. Relates to: #HFP-285 --- h5p.classes.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/h5p.classes.php b/h5p.classes.php index 4d7223b..03d5136 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3063,6 +3063,11 @@ class H5PContentValidator { } else { foreach ($group as $key => &$value) { + // If subContentId is set, keep value + if($key == 'subContentId' && $value == TRUE){ + continue; + } + // Find semantics for name=$key $found = FALSE; foreach ($semantics->fields as $field) { From 5494443533aa25b3a3a117f299b3f87200a35897 Mon Sep 17 00:00:00 2001 From: Tom Arild Jakobsen Date: Tue, 29 Nov 2016 15:44:32 +0100 Subject: [PATCH 3/4] validateGroup must handle isSubContent * Update validateGroup in h4p.classes.php to allow subContentId into the data * Fix h5p-content-upgrade-process.js to take into account isSubContent Relates to: #HFP-285 --- h5p.classes.php | 6 ++++-- js/h5p-content-upgrade-process.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 03d5136..a403856 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3056,7 +3056,9 @@ class H5PContentValidator { $function = null; $field = null; - if (count($semantics->fields) == 1 && $flatten) { + $isSubContent = isset($semantics->isSubContent) && $semantics->isSubContent === TRUE; + + if (count($semantics->fields) == 1 && $flatten && !$isSubContent) { $field = $semantics->fields[0]; $function = $this->typeMap[$field->type]; $this->$function($group, $field); @@ -3064,7 +3066,7 @@ class H5PContentValidator { else { foreach ($group as $key => &$value) { // If subContentId is set, keep value - if($key == 'subContentId' && $value == TRUE){ + if($isSubContent && ($key == 'subContentId')){ continue; } diff --git a/js/h5p-content-upgrade-process.js b/js/h5p-content-upgrade-process.js index 1d886cc..e54dbb7 100644 --- a/js/h5p-content-upgrade-process.js +++ b/js/h5p-content-upgrade-process.js @@ -182,7 +182,7 @@ H5P.ContentUpgradeProcess = (function (Version) { break; case 'group': - if (field.fields.length === 1) { + if (field.fields.length === 1 && field.isSubContent !== true) { // Single field to process, wrapper will be skipped self.processField(field.fields[0], params, function (err, upgradedParams) { if (upgradedParams) { From 32d06356b19a584c20dced4fc7eedbc583ed9974 Mon Sep 17 00:00:00 2001 From: Tom Arild Jakobsen Date: Tue, 29 Nov 2016 16:44:20 +0100 Subject: [PATCH 4/4] Bump to version 1.11 Relates to: #HFP-285 --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index a403856..f564114 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1676,7 +1676,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 10 + 'minorVersion' => 11 ); public static $styles = array( 'styles/h5p.css',