Skip to content

Commit

Permalink
Improved semi-fullscreen for iPad.
Browse files Browse the repository at this point in the history
  • Loading branch information
icc committed Oct 27, 2015
1 parent 8761354 commit f053095
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
29 changes: 28 additions & 1 deletion js/h5p.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,13 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) {

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 keyup, disableSemiFullscreen = function () {
var keyup, disableSemiFullscreen = H5P.exitFullScreen = function () {
if (lastViewport) {
metaTags[i].content = lastViewport;
}
else {
head.removeChild(metaTag);
}
$disable.remove();
$body.unbind('keyup', keyup);
done('h5p-semi-fullscreen');
Expand All @@ -551,6 +557,27 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) {
};
$disable.click(disableSemiFullscreen);
$body.keyup(keyup);

// Disable zoom
var lastViewport;
var metaTags = document.getElementsByTagName('meta');
for (var i = 0; i < metaTags.length; i++) {
if (metaTags[i].name === 'viewport') {
lastViewport = metaTags[i].content;
break;
}
}
if (!lastViewport) {
// Create tag
metaTags[i] = document.createElement('meta');
metaTags[i].name = 'viewport';
}
metaTags[i].content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0';
if (!lastViewport) {
var head = document.getElementsByTagName('head')[0];
head.appendChild(metaTag);
}

entered();
}
else {
Expand Down
8 changes: 5 additions & 3 deletions styles/h5p.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ div.h5p-fullscreen {
}

.h5p-iframe-wrapper.h5p-semi-fullscreen {
width: 100%;
height: 100%;
width: auto;
height: auto;
background: black;
position: fixed;
top: 0;
left: 0;
z-index: 1000;
right: 0;
bottom: 0;
z-index: 100001;
}
.h5p-iframe-wrapper.h5p-semi-fullscreen .buttons {
position: absolute;
Expand Down

0 comments on commit f053095

Please sign in to comment.