From 3c0c2d14a5f59aaf8d98827da5db819b90a7b391 Mon Sep 17 00:00:00 2001 From: Tomm Warham Date: Fri, 27 Nov 2015 11:37:48 +0000 Subject: [PATCH 1/3] Fullscreen iFrame on course presentation --- iframe-embed.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/iframe-embed.js b/iframe-embed.js index 27ab8a2..7208629 100644 --- a/iframe-embed.js +++ b/iframe-embed.js @@ -54,13 +54,20 @@ H5P.IFrameEmbed = function (options, contentId) { }; this.resize = function () { - // Set size of 'iframe' on startup, and when the browser - // is resized, or enters fullscreen. - if(options.resizeSupported) { - $iframe.css( - (H5P.isFullscreen) ? {width: '100%', height: '100%'} : getElementSize($iframe) - ); + // console.log("resize?"); + // console.log(this.parent); + // console.log(this.parent.slides) + // console.log(this.parent.slides.length) + if(this.parent && this.parent.slides && this.parent.slides.length >= 10) { // checks if the parent has slides and is therefore a course presentation + $iframe.css({width: '100%', height: '100%'}); // always set 100% if course pres + } else { // default standalone config + if(options.resizeSupported) { + $iframe.css( + (H5P.isFullscreen) ? {width: '100%', height: '100%'} : getElementSize($iframe) + ); + } } + // console.log("at end"); }; var getElementSize = function ($element) { From d3179544b8fd72dc06341f96fc8ed53c9030e8d6 Mon Sep 17 00:00:00 2001 From: Tomm Warham Date: Fri, 27 Nov 2015 14:38:49 +0000 Subject: [PATCH 2/3] Added html entity decoding for urls --- iframe-embed.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/iframe-embed.js b/iframe-embed.js index 7208629..00ac5e6 100644 --- a/iframe-embed.js +++ b/iframe-embed.js @@ -25,7 +25,7 @@ H5P.IFrameEmbed = function (options, contentId) { if (options.source !== undefined) { if (options.source.trim().toLowerCase().substring(0, 4) === 'http') { - iFrameSource = options.source; + iFrameSource = decode_entities(options.source); } else { iFrameSource = H5P.getContentPath(contentId) + '/' + options.source; @@ -54,10 +54,6 @@ H5P.IFrameEmbed = function (options, contentId) { }; this.resize = function () { - // console.log("resize?"); - // console.log(this.parent); - // console.log(this.parent.slides) - // console.log(this.parent.slides.length) if(this.parent && this.parent.slides && this.parent.slides.length >= 10) { // checks if the parent has slides and is therefore a course presentation $iframe.css({width: '100%', height: '100%'}); // always set 100% if course pres } else { // default standalone config @@ -67,7 +63,6 @@ H5P.IFrameEmbed = function (options, contentId) { ); } } - // console.log("at end"); }; var getElementSize = function ($element) { @@ -86,6 +81,29 @@ H5P.IFrameEmbed = function (options, contentId) { }; }; + var decode_entities = (function() { + // Remove HTML Entities + var element = document.createElement('div'); + + function decode_HTML_entities (str) { + if (str && typeof str === 'string') { + // Escape HTML before decoding for HTML Entities + str = escape(str).replace(/%26/g,'&').replace(/%23/g,'#').replace(/%3B/g,';'); + element.innerHTML = str; + if (element.innerText) { + str = element.innerText; + element.innerText = ''; + } else { + // Firefox support + str = element.textContent; + element.textContent = ''; + } + } + return unescape(str); + } + return decode_HTML_entities; + })(); + // This is a fix/hack to make touch work in iframe on mobile safari, // like if the iframe is listening to touch events on the iframe's // window object. (like in PHET simulations) From 3fc35ae010fbe87bc830df98631e23846fb22136 Mon Sep 17 00:00:00 2001 From: Tomm Warham Date: Fri, 27 Nov 2015 14:41:24 +0000 Subject: [PATCH 3/3] Removed modification work, just patched in html entity decoding. --- iframe-embed.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/iframe-embed.js b/iframe-embed.js index 00ac5e6..69002e4 100644 --- a/iframe-embed.js +++ b/iframe-embed.js @@ -54,14 +54,10 @@ H5P.IFrameEmbed = function (options, contentId) { }; this.resize = function () { - if(this.parent && this.parent.slides && this.parent.slides.length >= 10) { // checks if the parent has slides and is therefore a course presentation - $iframe.css({width: '100%', height: '100%'}); // always set 100% if course pres - } else { // default standalone config - if(options.resizeSupported) { - $iframe.css( - (H5P.isFullscreen) ? {width: '100%', height: '100%'} : getElementSize($iframe) - ); - } + if(options.resizeSupported) { + $iframe.css( + (H5P.isFullscreen) ? {width: '100%', height: '100%'} : getElementSize($iframe) + ); } };