diff --git a/patches/github.com/h5p/moodle-mod_hvp/425-match-handling-of-allowframeembedding-for-mobile-app-like-moodle-core.patch b/patches/github.com/h5p/moodle-mod_hvp/425-match-handling-of-allowframeembedding-for-mobile-app-like-moodle-core.patch new file mode 100644 index 0000000000000000000000000000000000000000..309a6b1aa603d5d12909e8ed7bc71fbb81f07738 --- /dev/null +++ b/patches/github.com/h5p/moodle-mod_hvp/425-match-handling-of-allowframeembedding-for-mobile-app-like-moodle-core.patch @@ -0,0 +1,23 @@ +From 0d4b125d2266948f3d9200d6c2df6feff8599b31 Mon Sep 17 00:00:00 2001 +From: Kevin Pham <keevan.pham@gmail.com> +Date: Wed, 18 Aug 2021 17:02:54 +1000 +Subject: [PATCH] Fix checks to match with core handling for allowframeemedding + +lib/weblib.php:2285 states that it only passes the 'X-Frame-Options: sameorigin' setting if embedding is disabled AND if the user is not loading the page from the app. +--- + classes/output/mobile.php | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/classes/output/mobile.php b/classes/output/mobile.php +index 3a8f91f1..241bf0c8 100644 +--- a/classes/output/mobile.php ++++ b/classes/output/mobile.php +@@ -27,7 +27,7 @@ public static function mobile_course_view($args) { + global $DB, $CFG, $OUTPUT, $USER; + + $cmid = $args['cmid']; +- if (!$CFG->allowframembedding) { ++ if (empty($CFG->allowframembedding) && !\core_useragent::is_moodle_app()) { + $context = \context_system::instance(); + if (has_capability('moodle/site:config', $context)) { + $template = 'mod_hvp/iframe_embedding_disabled'; diff --git a/patches/github.com/h5p/moodle-mod_hvp/458-fix-for-embedded-video-resizing-problem.patch b/patches/github.com/h5p/moodle-mod_hvp/458-fix-for-embedded-video-resizing-problem.patch new file mode 100644 index 0000000000000000000000000000000000000000..93edc6ac71313dadba2e91e7b9b25879c75fd40a --- /dev/null +++ b/patches/github.com/h5p/moodle-mod_hvp/458-fix-for-embedded-video-resizing-problem.patch @@ -0,0 +1,206 @@ +From df8f21d296e6367adb1d61810271c92fbaa56ad7 Mon Sep 17 00:00:00 2001 +From: Sean Brain <sbrain@us.ibm.com> +Date: Mon, 4 Oct 2021 09:16:34 -0400 +Subject: [PATCH 1/2] Fix for embedded video resizing problem + +--- + amd/build/embed.min.js | 3 +- + amd/build/embed.min.js.map | 1 + + amd/src/embed.js | 119 ++++++++++++++++++++----------------- + 3 files changed, 66 insertions(+), 57 deletions(-) + create mode 100644 amd/build/embed.min.js.map + +diff --git a/amd/build/embed.min.js b/amd/build/embed.min.js +index fdd34ede..78ae5ca7 100644 +--- a/amd/build/embed.min.js ++++ b/amd/build/embed.min.js +@@ -1 +1,2 @@ +-define(["jquery","mod_hvp/communicator"],function(a,b){a(document).ready(function(){a(".h5p-iframe").ready(function(){var a=document.querySelector(".h5p-iframe"),c=a.contentWindow.H5P;if(c&&c.instances&&c.instances[0]){var d,e=c.instances[0],f=!1;b.on("ready",function(){b.send("hello")}),b.on("hello",function(){f=!0,a.contentDocument.body.style.overflow="hidden",document.body.classList.add("h5p-resizing"),c.trigger(e,"resize")}),b.on("resizePrepared",function(){b.send("resize",{scrollHeight:a.contentDocument.body.scrollHeight})}),b.on("resize",function(){c.trigger(e,"resize")}),c.on(e,"resize",function(){c.isFullscreen||(clearTimeout(d),d=setTimeout(function(){f?b.send("prepareResize",{scrollHeight:a.contentDocument.body.scrollHeight,clientHeight:a.contentDocument.body.clientHeight}):b.send("hello")},0))}),c.trigger(e,"resize")}})})}); +\ No newline at end of file ++define ("mod_hvp/embed",["jquery","mod_hvp/communicator"],function($,H5PEmbedCommunicator){$(document).ready(function(){$(".h5p-iframe").ready(function(){initEmbedCommunicator=function initEmbedCommunicator(){var resizeDelay,instance=H5P.instances[0],parentIsFriendly=!1;H5PEmbedCommunicator.on("ready",function(){H5PEmbedCommunicator.send("hello")});H5PEmbedCommunicator.on("hello",function(){parentIsFriendly=!0;iFrame.contentDocument.body.style.overflow="hidden";document.body.classList.add("h5p-resizing");H5P.trigger(instance,"resize")});H5PEmbedCommunicator.on("resizePrepared",function(){H5PEmbedCommunicator.send("resize",{scrollHeight:iFrame.contentDocument.body.scrollHeight})});H5PEmbedCommunicator.on("resize",function(){H5P.trigger(instance,"resize")});H5P.on(instance,"resize",function(){if(H5P.isFullscreen){return}clearTimeout(resizeDelay);resizeDelay=setTimeout(function(){if(parentIsFriendly){H5PEmbedCommunicator.send("prepareResize",{scrollHeight:iFrame.contentDocument.body.scrollHeight,clientHeight:iFrame.contentDocument.body.clientHeight})}else{H5PEmbedCommunicator.send("hello")}},0)});H5P.trigger(instance,"resize")};var iFrame=document.querySelector(".h5p-iframe"),H5P=iFrame.contentWindow.H5P;if(!H5P||!H5P.instances||!H5P.instances[0]){console.warn("H5P embed.js: ACK! Embedded H5P.instances[0] in lowest iframe is not set up yet. Waiting for 'initialized' event");window.H5P.externalDispatcher.on("initialized",function(){console.log("H5P embed.js: 'initialized' event received");H5P=iFrame.contentWindow.H5P;initEmbedCommunicator()})}else{initEmbedCommunicator()}})})}); ++//# sourceMappingURL=embed.min.js.map +diff --git a/amd/build/embed.min.js.map b/amd/build/embed.min.js.map +new file mode 100644 +index 00000000..9412c4e7 +--- /dev/null ++++ b/amd/build/embed.min.js.map +@@ -0,0 +1 @@ ++{"version":3,"sources":["../src/embed.js"],"names":["define","$","H5PEmbedCommunicator","document","ready","initEmbedCommunicator","resizeDelay","instance","H5P","instances","parentIsFriendly","on","send","iFrame","contentDocument","body","style","overflow","classList","add","trigger","scrollHeight","isFullscreen","clearTimeout","setTimeout","clientHeight","querySelector","contentWindow","console","warn","window","externalDispatcher","log"],"mappings":"AAeAA,OAAM,iBAAC,CAAC,QAAD,CAAW,sBAAX,CAAD,CAAqC,SAASC,CAAT,CAAYC,oBAAZ,CAAkC,CAGzED,CAAC,CAACE,QAAD,CAAD,CAAYC,KAAZ,CAAkB,UAAW,CACzBH,CAAC,CAAC,aAAD,CAAD,CAAiBG,KAAjB,CAAuB,UAAW,CAC9BC,qBAAqB,CAAG,gCAAW,IAC3BC,CAAAA,WAD2B,CAE3BC,QAAQ,CA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CAACU,IAArB,CAA0B,OAA1B,CACH,CACJ,CAZuB,CAYrB,CAZqB,CAa3B,CApBD,EAuBAJ,GAAG,CAACY,OAAJ,CAAYb,QAAZ,CAAsB,QAAtB,CACH,CA3DD,CAD8B,GA6D1BM,CAAAA,MAAM,CAAGV,QAAQ,CAACuB,aAAT,CAAuB,aAAvB,CA7DiB,CA8D1BlB,GAAG,CAAGK,MAAM,CAACc,aAAP,CAAqBnB,GA9DD,CAgE9B,GAAI,CAACA,GAAD,EAAQ,CAACA,GAAG,CAACC,SAAb,EAA0B,CAACD,GAAG,CAACC,SAAJ,CAAc,CAAd,CAA/B,CAAiD,CAC7CmB,OAAO,CAACC,IAAR,CAAa,kHAAb,EACAC,MAAM,CAACtB,GAAP,CAAWuB,kBAAX,CAA8BpB,EAA9B,CAAiC,aAAjC,CAAgD,UAAgB,CAC5DiB,OAAO,CAACI,GAAR,CAAY,4CAAZ,EACAxB,GAAG,CAAGK,MAAM,CAACc,aAAP,CAAqBnB,GAA3B,CACAH,qBAAqB,EACxB,CAJD,CAKH,CAPD,IAOO,CACHA,qBAAqB,EACxB,CACJ,CA1ED,CA2EH,CA5ED,CA8EH,CAjFK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n/* eslint-disable no-undef, no-console, no-unused-vars, max-len */\ndefine(['jquery', 'mod_hvp/communicator'], function($, H5PEmbedCommunicator) {\n\n // Wait for instances to be initialize.\n $(document).ready(function() {\n $('.h5p-iframe').ready(function() {\n initEmbedCommunicator = function() {\n var resizeDelay;\n var instance = H5P.instances[0];\n var parentIsFriendly = false;\n\n // Handle that the resizer is loaded after the iframe.\n H5PEmbedCommunicator.on('ready', function() {\n H5PEmbedCommunicator.send('hello');\n });\n\n // Handle hello message from our parent window.\n H5PEmbedCommunicator.on('hello', function() {\n // Initial setup/handshake is done.\n parentIsFriendly = true;\n\n // Hide scrollbars for correct size.\n iFrame.contentDocument.body.style.overflow = 'hidden';\n\n document.body.classList.add('h5p-resizing');\n\n // Content need to be resized to fit the new iframe size.\n H5P.trigger(instance, 'resize');\n });\n\n // When resize has been prepared tell parent window to resize.\n H5PEmbedCommunicator.on('resizePrepared', function() {\n H5PEmbedCommunicator.send('resize', {\n scrollHeight: iFrame.contentDocument.body.scrollHeight\n });\n });\n\n H5PEmbedCommunicator.on('resize', function() {\n H5P.trigger(instance, 'resize');\n });\n\n H5P.on(instance, 'resize', function() {\n if (H5P.isFullscreen) {\n return; // Skip iframe resize.\n }\n\n // Use a delay to make sure iframe is resized to the correct size.\n clearTimeout(resizeDelay);\n resizeDelay = setTimeout(function() {\n // Only resize if the iframe can be resized.\n if (parentIsFriendly) {\n H5PEmbedCommunicator.send('prepareResize',\n {\n scrollHeight: iFrame.contentDocument.body.scrollHeight,\n clientHeight: iFrame.contentDocument.body.clientHeight\n }\n );\n } else {\n H5PEmbedCommunicator.send('hello');\n }\n }, 0);\n });\n\n // Trigger initial resize for instance.\n H5P.trigger(instance, 'resize');\n };\n var iFrame = document.querySelector('.h5p-iframe');\n var H5P = iFrame.contentWindow.H5P;\n // Check for H5P instances.\n if (!H5P || !H5P.instances || !H5P.instances[0]) {\n console.warn(\"H5P embed.js: ACK! Embedded H5P.instances[0] in lowest iframe is not set up yet. Waiting for 'initialized' event\");\n window.H5P.externalDispatcher.on('initialized', function(event) {\n console.log(\"H5P embed.js: 'initialized' event received\");\n H5P = iFrame.contentWindow.H5P;\n initEmbedCommunicator();\n });\n } else {\n initEmbedCommunicator();\n }\n });\n });\n\n});\n"],"file":"embed.min.js"} +\ No newline at end of file +diff --git a/amd/src/embed.js b/amd/src/embed.js +index 77ddbfea..6109a0b8 100644 +--- a/amd/src/embed.js ++++ b/amd/src/embed.js +@@ -12,78 +12,85 @@ + // + // You should have received a copy of the GNU General Public License + // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +- ++/* eslint-disable no-undef, no-console, no-unused-vars, max-len */ + define(['jquery', 'mod_hvp/communicator'], function($, H5PEmbedCommunicator) { + + // Wait for instances to be initialize. + $(document).ready(function() { + $('.h5p-iframe').ready(function() { +- var iFrame = document.querySelector('.h5p-iframe'); +- var H5P = iFrame.contentWindow.H5P; +- +- // Check for H5P instances. +- if (!H5P || !H5P.instances || !H5P.instances[0]) { +- return; +- } +- +- var resizeDelay; +- var instance = H5P.instances[0]; +- var parentIsFriendly = false; +- +- // Handle that the resizer is loaded after the iframe. +- H5PEmbedCommunicator.on('ready', function() { +- H5PEmbedCommunicator.send('hello'); +- }); ++ initEmbedCommunicator = function() { ++ var resizeDelay; ++ var instance = H5P.instances[0]; ++ var parentIsFriendly = false; + +- // Handle hello message from our parent window. +- H5PEmbedCommunicator.on('hello', function() { +- // Initial setup/handshake is done. +- parentIsFriendly = true; ++ // Handle that the resizer is loaded after the iframe. ++ H5PEmbedCommunicator.on('ready', function() { ++ H5PEmbedCommunicator.send('hello'); ++ }); + +- // Hide scrollbars for correct size. +- iFrame.contentDocument.body.style.overflow = 'hidden'; ++ // Handle hello message from our parent window. ++ H5PEmbedCommunicator.on('hello', function() { ++ // Initial setup/handshake is done. ++ parentIsFriendly = true; + +- document.body.classList.add('h5p-resizing'); ++ // Hide scrollbars for correct size. ++ iFrame.contentDocument.body.style.overflow = 'hidden'; + +- // Content need to be resized to fit the new iframe size. +- H5P.trigger(instance, 'resize'); +- }); ++ document.body.classList.add('h5p-resizing'); + +- // When resize has been prepared tell parent window to resize. +- H5PEmbedCommunicator.on('resizePrepared', function() { +- H5PEmbedCommunicator.send('resize', { +- scrollHeight: iFrame.contentDocument.body.scrollHeight ++ // Content need to be resized to fit the new iframe size. ++ H5P.trigger(instance, 'resize'); + }); +- }); + +- H5PEmbedCommunicator.on('resize', function() { +- H5P.trigger(instance, 'resize'); +- }); ++ // When resize has been prepared tell parent window to resize. ++ H5PEmbedCommunicator.on('resizePrepared', function() { ++ H5PEmbedCommunicator.send('resize', { ++ scrollHeight: iFrame.contentDocument.body.scrollHeight ++ }); ++ }); + +- H5P.on(instance, 'resize', function() { +- if (H5P.isFullscreen) { +- return; // Skip iframe resize. +- } ++ H5PEmbedCommunicator.on('resize', function() { ++ H5P.trigger(instance, 'resize'); ++ }); + +- // Use a delay to make sure iframe is resized to the correct size. +- clearTimeout(resizeDelay); +- resizeDelay = setTimeout(function() { +- // Only resize if the iframe can be resized. +- if (parentIsFriendly) { +- H5PEmbedCommunicator.send('prepareResize', +- { +- scrollHeight: iFrame.contentDocument.body.scrollHeight, +- clientHeight: iFrame.contentDocument.body.clientHeight +- } +- ); +- } else { +- H5PEmbedCommunicator.send('hello'); ++ H5P.on(instance, 'resize', function() { ++ if (H5P.isFullscreen) { ++ return; // Skip iframe resize. + } +- }, 0); +- }); + +- // Trigger initial resize for instance. +- H5P.trigger(instance, 'resize'); ++ // Use a delay to make sure iframe is resized to the correct size. ++ clearTimeout(resizeDelay); ++ resizeDelay = setTimeout(function() { ++ // Only resize if the iframe can be resized. ++ if (parentIsFriendly) { ++ H5PEmbedCommunicator.send('prepareResize', ++ { ++ scrollHeight: iFrame.contentDocument.body.scrollHeight, ++ clientHeight: iFrame.contentDocument.body.clientHeight ++ } ++ ); ++ } else { ++ H5PEmbedCommunicator.send('hello'); ++ } ++ }, 0); ++ }); ++ ++ // Trigger initial resize for instance. ++ H5P.trigger(instance, 'resize'); ++ }; ++ var iFrame = document.querySelector('.h5p-iframe'); ++ var H5P = iFrame.contentWindow.H5P; ++ // Check for H5P instances. ++ if (!H5P || !H5P.instances || !H5P.instances[0]) { ++ console.warn("H5P embed.js: ACK! Embedded H5P.instances[0] in lowest iframe is not set up yet. Waiting for 'initialized' event"); ++ window.H5P.externalDispatcher.on('initialized', function(event) { ++ console.log("H5P embed.js: 'initialized' event received"); ++ H5P = iFrame.contentWindow.H5P; ++ initEmbedCommunicator(); ++ }); ++ } else { ++ initEmbedCommunicator(); ++ } + }); + }); + + +From 6bdaa548676f498909a71902078ee08223bcd6d2 Mon Sep 17 00:00:00 2001 +From: Mikhail Golenkov <mikhailgolenkov@catalyst-au.net> +Date: Thu, 2 Jun 2022 14:51:20 +1000 +Subject: [PATCH 2/2] Grunt embed.js + +--- + amd/build/embed.min.js | 5 +++-- + amd/build/embed.min.js.map | 2 +- + 2 files changed, 4 insertions(+), 3 deletions(-) + +diff --git a/amd/build/embed.min.js b/amd/build/embed.min.js +index 78ae5ca7..145924e6 100644 +--- a/amd/build/embed.min.js ++++ b/amd/build/embed.min.js +@@ -1,2 +1,3 @@ +-define ("mod_hvp/embed",["jquery","mod_hvp/communicator"],function($,H5PEmbedCommunicator){$(document).ready(function(){$(".h5p-iframe").ready(function(){initEmbedCommunicator=function initEmbedCommunicator(){var resizeDelay,instance=H5P.instances[0],parentIsFriendly=!1;H5PEmbedCommunicator.on("ready",function(){H5PEmbedCommunicator.send("hello")});H5PEmbedCommunicator.on("hello",function(){parentIsFriendly=!0;iFrame.contentDocument.body.style.overflow="hidden";document.body.classList.add("h5p-resizing");H5P.trigger(instance,"resize")});H5PEmbedCommunicator.on("resizePrepared",function(){H5PEmbedCommunicator.send("resize",{scrollHeight:iFrame.contentDocument.body.scrollHeight})});H5PEmbedCommunicator.on("resize",function(){H5P.trigger(instance,"resize")});H5P.on(instance,"resize",function(){if(H5P.isFullscreen){return}clearTimeout(resizeDelay);resizeDelay=setTimeout(function(){if(parentIsFriendly){H5PEmbedCommunicator.send("prepareResize",{scrollHeight:iFrame.contentDocument.body.scrollHeight,clientHeight:iFrame.contentDocument.body.clientHeight})}else{H5PEmbedCommunicator.send("hello")}},0)});H5P.trigger(instance,"resize")};var iFrame=document.querySelector(".h5p-iframe"),H5P=iFrame.contentWindow.H5P;if(!H5P||!H5P.instances||!H5P.instances[0]){console.warn("H5P embed.js: ACK! Embedded H5P.instances[0] in lowest iframe is not set up yet. Waiting for 'initialized' event");window.H5P.externalDispatcher.on("initialized",function(){console.log("H5P embed.js: 'initialized' event received");H5P=iFrame.contentWindow.H5P;initEmbedCommunicator()})}else{initEmbedCommunicator()}})})}); +-//# sourceMappingURL=embed.min.js.map ++define("mod_hvp/embed",["jquery","mod_hvp/communicator"],(function($,H5PEmbedCommunicator){$(document).ready((function(){$(".h5p-iframe").ready((function(){initEmbedCommunicator=function(){var resizeDelay,instance=H5P.instances[0],parentIsFriendly=!1;H5PEmbedCommunicator.on("ready",(function(){H5PEmbedCommunicator.send("hello")})),H5PEmbedCommunicator.on("hello",(function(){parentIsFriendly=!0,iFrame.contentDocument.body.style.overflow="hidden",document.body.classList.add("h5p-resizing"),H5P.trigger(instance,"resize")})),H5PEmbedCommunicator.on("resizePrepared",(function(){H5PEmbedCommunicator.send("resize",{scrollHeight:iFrame.contentDocument.body.scrollHeight})})),H5PEmbedCommunicator.on("resize",(function(){H5P.trigger(instance,"resize")})),H5P.on(instance,"resize",(function(){H5P.isFullscreen||(clearTimeout(resizeDelay),resizeDelay=setTimeout((function(){parentIsFriendly?H5PEmbedCommunicator.send("prepareResize",{scrollHeight:iFrame.contentDocument.body.scrollHeight,clientHeight:iFrame.contentDocument.body.clientHeight}):H5PEmbedCommunicator.send("hello")}),0))})),H5P.trigger(instance,"resize")};var iFrame=document.querySelector(".h5p-iframe"),H5P=iFrame.contentWindow.H5P;H5P&&H5P.instances&&H5P.instances[0]?initEmbedCommunicator():(console.warn("H5P embed.js: ACK! Embedded H5P.instances[0] in lowest iframe is not set up yet. Waiting for 'initialized' event"),window.H5P.externalDispatcher.on("initialized",(function(event){console.log("H5P embed.js: 'initialized' event received"),H5P=iFrame.contentWindow.H5P,initEmbedCommunicator()})))}))}))})); ++ ++//# sourceMappingURL=embed.min.js.map +\ No newline at end of file +diff --git a/amd/build/embed.min.js.map b/amd/build/embed.min.js.map +index 9412c4e7..ffe463a3 100644 +--- a/amd/build/embed.min.js.map ++++ b/amd/build/embed.min.js.map +@@ -1 +1 @@ +-{"version":3,"sources":["../src/embed.js"],"names":["define","$","H5PEmbedCommunicator","document","ready","initEmbedCommunicator","resizeDelay","instance","H5P","instances","parentIsFriendly","on","send","iFrame","contentDocument","body","style","overflow","classList","add","trigger","scrollHeight","isFullscreen","clearTimeout","setTimeout","clientHeight","querySelector","contentWindow","console","warn","window","externalDispatcher","log"],"mappings":"AAeAA,OAAM,iBAAC,CAAC,QAAD,CAAW,sBAAX,CAAD,CAAqC,SAASC,CAAT,CAAYC,oBAAZ,CAAkC,CAGzED,CAAC,CAACE,QAAD,CAAD,CAAYC,KAAZ,CAAkB,UAAW,CACzBH,CAAC,CAAC,aAAD,CAAD,CAAiBG,KAAjB,CAAuB,UAAW,CAC9BC,qBAAqB,CAAG,gCAAW,IAC3BC,CAAAA,WAD2B,CAE3BC,QAAQ,CAAGC,GAAG,CAACC,SAAJ,CAAc,CAAd,CAFgB,CAG3BC,gBAAgB,GAHW,CAM/BR,oBAAoB,CAACS,EAArB,CAAwB,OAAxB,CAAiC,UAAW,CACxCT,oBAAoB,CAACU,IAArB,CAA0B,OAA1B,CACH,CAFD,EAKAV,oBAAoB,CAACS,EAArB,CAAwB,OAAxB,CAAiC,UAAW,CAExCD,gBAAgB,GAAhB,CAGAG,MAAM,CAACC,eAAP,CAAuBC,IAAvB,CAA4BC,KAA5B,CAAkCC,QAAlC,CAA6C,QAA7C,CAEAd,QAAQ,CAACY,IAAT,CAAcG,SAAd,CAAwBC,GAAxB,CAA4B,cAA5B,EAGAX,GAAG,CAACY,OAAJ,CAAYb,QAAZ,CAAsB,QAAtB,CACH,CAXD,EAcAL,oBAAoB,CAACS,EAArB,CAAwB,gBAAxB,CAA0C,UAAW,CACjDT,oBAAoB,CAACU,IAArB,CAA0B,QAA1B,CAAoC,CAChCS,YAAY,CAAER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aAAP,CAAqBnB,GAA3B,CACAH,qBAAqB,EACxB,CAJD,CAKH,CAPD,IAOO,CACHA,qBAAqB,EACxB,CACJ,CA1ED,CA2EH,CA5ED,CA8EH,CAjFK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n/* eslint-disable no-undef, no-console, no-unused-vars, max-len */\ndefine(['jquery', 'mod_hvp/communicator'], function($, H5PEmbedCommunicator) {\n\n // Wait for instances to be initialize.\n $(document).ready(function() {\n $('.h5p-iframe').ready(function() {\n initEmbedCommunicator = function() {\n var resizeDelay;\n var instance = H5P.instances[0];\n var parentIsFriendly = false;\n\n // Handle that the resizer is loaded after the iframe.\n H5PEmbedCommunicator.on('ready', function() {\n H5PEmbedCommunicator.send('hello');\n });\n\n // Handle hello message from our parent window.\n H5PEmbedCommunicator.on('hello', function() {\n // Initial setup/handshake is done.\n parentIsFriendly = true;\n\n // Hide scrollbars for correct size.\n iFrame.contentDocument.body.style.overflow = 'hidden';\n\n document.body.classList.add('h5p-resizing');\n\n // Content need to be resized to fit the new iframe size.\n H5P.trigger(instance, 'resize');\n });\n\n // When resize has been prepared tell parent window to resize.\n H5PEmbedCommunicator.on('resizePrepared', function() {\n H5PEmbedCommunicator.send('resize', {\n scrollHeight: iFrame.contentDocument.body.scrollHeight\n });\n });\n\n H5PEmbedCommunicator.on('resize', function() {\n H5P.trigger(instance, 'resize');\n });\n\n H5P.on(instance, 'resize', function() {\n if (H5P.isFullscreen) {\n return; // Skip iframe resize.\n }\n\n // Use a delay to make sure iframe is resized to the correct size.\n clearTimeout(resizeDelay);\n resizeDelay = setTimeout(function() {\n // Only resize if the iframe can be resized.\n if (parentIsFriendly) {\n H5PEmbedCommunicator.send('prepareResize',\n {\n scrollHeight: iFrame.contentDocument.body.scrollHeight,\n clientHeight: iFrame.contentDocument.body.clientHeight\n }\n );\n } else {\n H5PEmbedCommunicator.send('hello');\n }\n }, 0);\n });\n\n // Trigger initial resize for instance.\n H5P.trigger(instance, 'resize');\n };\n var iFrame = document.querySelector('.h5p-iframe');\n var H5P = iFrame.contentWindow.H5P;\n // Check for H5P instances.\n if (!H5P || !H5P.instances || !H5P.instances[0]) {\n console.warn(\"H5P embed.js: ACK! Embedded H5P.instances[0] in lowest iframe is not set up yet. Waiting for 'initialized' event\");\n window.H5P.externalDispatcher.on('initialized', function(event) {\n console.log(\"H5P embed.js: 'initialized' event received\");\n H5P = iFrame.contentWindow.H5P;\n initEmbedCommunicator();\n });\n } else {\n initEmbedCommunicator();\n }\n });\n });\n\n});\n"],"file":"embed.min.js"} +\ No newline at end of file ++{"version":3,"file":"embed.min.js","sources":["../src/embed.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n/* eslint-disable no-undef, no-console, no-unused-vars, max-len */\ndefine(['jquery', 'mod_hvp/communicator'], function($, H5PEmbedCommunicator) {\n\n // Wait for instances to be initialize.\n $(document).ready(function() {\n $('.h5p-iframe').ready(function() {\n initEmbedCommunicator = function() {\n var resizeDelay;\n var instance = H5P.instances[0];\n var parentIsFriendly = false;\n\n // Handle that the resizer is loaded after the iframe.\n H5PEmbedCommunicator.on('ready', function() {\n H5PEmbedCommunicator.send('hello');\n });\n\n // Handle hello message from our parent window.\n H5PEmbedCommunicator.on('hello', function() {\n // Initial setup/handshake is done.\n parentIsFriendly = true;\n\n // Hide scrollbars for correct size.\n iFrame.contentDocument.body.style.overflow = 'hidden';\n\n document.body.classList.add('h5p-resizing');\n\n // Content need to be resized to fit the new iframe size.\n H5P.trigger(instance, 'resize');\n });\n\n // When resize has been prepared tell parent window to resize.\n H5PEmbedCommunicator.on('resizePrepared', function() {\n H5PEmbedCommunicator.send('resize', {\n scrollHeight: iFrame.contentDocument.body.scrollHeight\n });\n });\n\n H5PEmbedCommunicator.on('resize', function() {\n H5P.trigger(instance, 'resize');\n });\n\n H5P.on(instance, 'resize', function() {\n if (H5P.isFullscreen) {\n return; // Skip iframe resize.\n }\n\n // Use a delay to make sure iframe is resized to the correct size.\n clearTimeout(resizeDelay);\n resizeDelay = setTimeout(function() {\n // Only resize if the iframe can be resized.\n if (parentIsFriendly) {\n H5PEmbedCommunicator.send('prepareResize',\n {\n scrollHeight: iFrame.contentDocument.body.scrollHeight,\n clientHeight: iFrame.contentDocument.body.clientHeight\n }\n );\n } else {\n H5PEmbedCommunicator.send('hello');\n }\n }, 0);\n });\n\n // Trigger initial resize for instance.\n H5P.trigger(instance, 'resize');\n };\n var iFrame = document.querySelector('.h5p-iframe');\n var H5P = iFrame.contentWindow.H5P;\n // Check for H5P instances.\n if (!H5P || !H5P.instances || !H5P.instances[0]) {\n console.warn(\"H5P embed.js: ACK! Embedded H5P.instances[0] in lowest iframe is not set up yet. Waiting for 'initialized' event\");\n window.H5P.externalDispatcher.on('initialized', function(event) {\n console.log(\"H5P embed.js: 'initialized' event received\");\n H5P = iFrame.contentWindow.H5P;\n initEmbedCommunicator();\n });\n } else {\n initEmbedCommunicator();\n }\n });\n });\n\n});\n"],"names":["define","$","H5PEmbedCommunicator","document","ready","initEmbedCommunicator","resizeDelay","instance","H5P","instances","parentIsFriendly","on","send","iFrame","contentDocument","body","style","overflow","classList","add","trigger","scrollHeight","isFullscreen","clearTimeout","setTimeout","clientHeight","querySelector","contentWindow","console","warn","window","externalDispatcher","event","log"],"mappings":"AAeAA,uBAAO,CAAC,SAAU,yBAAyB,SAASC,EAAGC,sBAGnDD,EAAEE,UAAUC,OAAM,WACdH,EAAE,eAAeG,OAAM,WACnBC,sBAAwB,eAChBC,YACAC,SAAWC,IAAIC,UAAU,GACzBC,kBAAmB,EAGvBR,qBAAqBS,GAAG,SAAS,WAC7BT,qBAAqBU,KAAK,YAI9BV,qBAAqBS,GAAG,SAAS,WAE7BD,kBAAmB,EAGnBG,OAAOC,gBAAgBC,KAAKC,MAAMC,SAAW,SAE7Cd,SAASY,KAAKG,UAAUC,IAAI,gBAG5BX,IAAIY,QAAQb,SAAU,aAI1BL,qBAAqBS,GAAG,kBAAkB,WACtCT,qBAAqBU,KAAK,SAAU,CAChCS,aAAcR,OAAOC,gBAAgBC,KAAKM,kBAIlDnB,qBAAqBS,GAAG,UAAU,WAC9BH,IAAIY,QAAQb,SAAU,aAG1BC,IAAIG,GAAGJ,SAAU,UAAU,WACnBC,IAAIc,eAKRC,aAAajB,aACbA,YAAckB,YAAW,WAEjBd,iBACAR,qBAAqBU,KAAK,gBACtB,CACIS,aAAcR,OAAOC,gBAAgBC,KAAKM,aAC1CI,aAAcZ,OAAOC,gBAAgBC,KAAKU,eAIlDvB,qBAAqBU,KAAK,WAE/B,OAIPJ,IAAIY,QAAQb,SAAU,eAEtBM,OAASV,SAASuB,cAAc,eAChClB,IAAMK,OAAOc,cAAcnB,IAE1BA,KAAQA,IAAIC,WAAcD,IAAIC,UAAU,GAQzCJ,yBAPAuB,QAAQC,KAAK,oHACbC,OAAOtB,IAAIuB,mBAAmBpB,GAAG,eAAe,SAASqB,OACrDJ,QAAQK,IAAI,8CACZzB,IAAMK,OAAOc,cAAcnB,IAC3BH"} +\ No newline at end of file