Add event handlers to update text when user exits full screen by pressing 'Esc'.

This commit is contained in:
jcass 2016-02-18 11:38:20 +02:00
parent f59f6b9744
commit 7d7d8951a5
2 changed files with 18 additions and 6 deletions

View File

@ -302,10 +302,10 @@ $(document).bind("pageinit", function() {
/************** /**************
* gui stuff * * gui stuff *
**************/ **************/
function toggleFullscreen() { function toggleFullscreen() {
if (isMobileSafari) { alert ("To get this app in Full Screen, you have to add it to your home-screen using the Share button."); exit(); } if (isMobileSafari) { alert ("To get this app in Full Screen, you have to add it to your home-screen using the Share button."); exit(); }
if (!document.fullscreenElement && // alternative standard method if (!isFullscreen() ) { // current working methods
!document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods
var docElm = document.documentElement; var docElm = document.documentElement;
if (docElm.requestFullscreen) { if (docElm.requestFullscreen) {
docElm.requestFullscreen(); docElm.requestFullscreen();
@ -316,7 +316,6 @@ function toggleFullscreen() {
} else if (docElm.webkitRequestFullScreen) { } else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen(); docElm.webkitRequestFullScreen();
} }
document.getElementById("toggletxt").innerHTML = "Exit Fullscreen";
} else { } else {
if (document.exitFullscreen) { if (document.exitFullscreen) {
document.exitFullscreen(); document.exitFullscreen();
@ -327,10 +326,14 @@ function toggleFullscreen() {
} else if (document.webkitCancelFullScreen) { } else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen(); document.webkitCancelFullScreen();
} }
document.getElementById("toggletxt").innerHTML = "Fullscreen";
} }
} }
function isFullscreen() {
return (document.fullscreenElement || // alternative standard method
document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement ) // current working methods
}
function switchContent(divid, uri) { function switchContent(divid, uri) {
var hash = divid; var hash = divid;
if (uri) { if (uri) {
@ -506,7 +509,16 @@ $(document).ready(function(event) {
toggleFullscreen(); toggleFullscreen();
}); });
// remove buttons only for MusicBox // event handlers for full screen mode
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange, MSFullscreenChange', function(e) {
if (isFullscreen()) {
document.getElementById("toggletxt").innerHTML = "Exit Fullscreen";
} else {
document.getElementById("toggletxt").innerHTML = "Fullscreen";
}
});
// remove buttons only for MusicBox
if (!isMusicBox) { if (!isMusicBox) {
$('#navSettings').hide(); $('#navSettings').hide();
$('#navshutdown').hide(); $('#navshutdown').hide();

View File

@ -1,6 +1,6 @@
CACHE MANIFEST CACHE MANIFEST
# 2016-02-15:v1 # 2016-02-18:v1
NETWORK: NETWORK:
* *