HFP-3008 Add content language to iframe document

pull/92/head
Thomas Marstrander 2020-08-28 16:54:16 +02:00
parent 16c71b444b
commit 1a644dda11
No known key found for this signature in database
GPG Key ID: 59D7F1EC8B90E9A6
1 changed files with 4 additions and 1 deletions

View File

@ -378,8 +378,11 @@ H5P.init = function (target) {
// Insert H5Ps that should be in iframes.
H5P.jQuery('iframe.h5p-iframe:not(.h5p-initialized)', target).each(function () {
var contentId = H5P.jQuery(this).addClass('h5p-initialized').data('content-id');
const contentData = H5PIntegration.contents['cid-' + contentId];
const language = contentData && contentData.metadata && contentData.metadata.defaultLanguage
? contentData.metadata.defaultLanguage : 'en';
this.contentDocument.open();
this.contentDocument.write('<!doctype html><html class="h5p-iframe"><head>' + H5P.getHeadTags(contentId) + '</head><body><div class="h5p-content" data-content-id="' + contentId + '"/></body></html>');
this.contentDocument.write('<!doctype html><html class="h5p-iframe" lang="' + language + '"><head>' + H5P.getHeadTags(contentId) + '</head><body><div class="h5p-content" data-content-id="' + contentId + '"/></body></html>');
this.contentDocument.close();
});
};