Prevent assigning to the htmlcollection.

pull/6/head
Frode Petterson 2015-11-13 11:18:53 +01:00
parent 16aa6813ae
commit 3c34ab223a
1 changed files with 17 additions and 12 deletions

View File

@ -540,11 +540,13 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) {
before('h5p-semi-fullscreen'); before('h5p-semi-fullscreen');
var $disable = H5P.jQuery('<div role="button" tabindex="1" class="h5p-disable-fullscreen" title="' + H5P.t('disableFullscreen') + '"></div>').appendTo($container.find('.h5p-content-controls')); var $disable = H5P.jQuery('<div role="button" tabindex="1" class="h5p-disable-fullscreen" title="' + H5P.t('disableFullscreen') + '"></div>').appendTo($container.find('.h5p-content-controls'));
var keyup, disableSemiFullscreen = H5P.exitFullScreen = function () { var keyup, disableSemiFullscreen = H5P.exitFullScreen = function () {
if (lastViewport) { if (prevViewportContent) {
metaTags[i].content = lastViewport; // Use content from the previous viewport tag
h5pViewport.content = prevViewportContent;
} }
else { else {
head.removeChild(metaTags[i]); // Remove viewport tag
head.removeChild(h5pViewport);
} }
$disable.remove(); $disable.remove();
$body.unbind('keyup', keyup); $body.unbind('keyup', keyup);
@ -559,23 +561,26 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) {
$body.keyup(keyup); $body.keyup(keyup);
// Disable zoom // Disable zoom
var lastViewport; var prevViewportContent, h5pViewport;
var metaTags = document.getElementsByTagName('meta'); var metaTags = document.getElementsByTagName('meta');
for (var i = 0; i < metaTags.length; i++) { for (var i = 0; i < metaTags.length; i++) {
if (metaTags[i].name === 'viewport') { if (metaTags[i].name === 'viewport') {
lastViewport = metaTags[i].content; // Use the existing viewport tag
h5pViewport = metaTags[i];
prevViewportContent = h5pViewport.content;
break; break;
} }
} }
if (!lastViewport) { if (!prevViewportContent) {
// Create tag // Create a new viewport tag
metaTags[i] = document.createElement('meta'); h5pViewport = document.createElement('meta');
metaTags[i].name = 'viewport'; h5pViewport.name = 'viewport';
} }
metaTags[i].content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'; h5pViewport.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0';
if (!lastViewport) { if (!prevViewportContent) {
// Insert the new viewport tag
var head = document.getElementsByTagName('head')[0]; var head = document.getElementsByTagName('head')[0];
head.appendChild(metaTags[i]); head.appendChild(h5pViewport);
} }
entered(); entered();