HFP-1407 Improve robustness of content-id retrival

The code made an assumption that the $element.parent() would contain
the [data-content-id] which isn't always true.

Changed the code, so that it looks up the parent with [data-content-id].
pull/42/head
Tom Arild Jakobsen 2017-08-23 15:22:29 +02:00
parent 7728243c18
commit e3d7cf2562
1 changed files with 2 additions and 1 deletions

View File

@ -501,7 +501,8 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull
// We're called from an iframe.
$body = H5P.jQuery(body);
$classes = $body.add($element.get());
var iframeSelector = '#h5p-iframe-' + $element.parent().data('content-id');
var contentId = $element.closest('[data-content-id]').data('content-id');
var iframeSelector = '#h5p-iframe-' + contentId;
$iframe = H5P.jQuery(iframeSelector);
$element = $iframe.parent(); // Put iframe wrapper in fullscreen, not container.
}