Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions iframe-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,9 +54,7 @@ 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) {
if(options.resizeSupported) {
$iframe.css(
(H5P.isFullscreen) ? {width: '100%', height: '100%'} : getElementSize($iframe)
);
Expand All @@ -79,6 +77,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)
Expand Down