-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* This file is licensed under the Affero General Public License. */ | ||
|
||
/*global deviceType */ | ||
(function() { | ||
// Don't show on mobile | ||
if(deviceType === 'mobile') { | ||
return; | ||
} | ||
|
||
// Create clock widget | ||
var fsbutton = document.createElement('span'); | ||
fsbutton.id = 'barFullscreen'; | ||
fsbutton.textContent = "Fullscreen"; | ||
|
||
// Handle clicks | ||
fsbutton.addEventListener("click",fs); | ||
|
||
// Add to bar | ||
window.bar.addItem(fsbutton); | ||
|
||
// Fullscreen functions | ||
var html = document.getElementsByTagName('html')[0]; | ||
function fs(enter) { | ||
if (enter === true || | ||
enter != false && | ||
!html.classList.contains('fullscreen')) { // current working methods | ||
// Make app fullscreen | ||
if (html.requestFullscreen) { | ||
html.requestFullscreen(); | ||
} else if (html.mozRequestFullScreen) { | ||
html.mozRequestFullScreen(); | ||
} else if (html.webkitRequestFullscreen) { | ||
html.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); | ||
} | ||
} else { | ||
// Exit fullscreen | ||
if (document.cancelFullScreen) { | ||
document.cancelFullScreen(); | ||
} else if (document.mozCancelFullScreen) { | ||
document.mozCancelFullScreen(); | ||
} else if (document.webkitCancelFullScreen) { | ||
document.webkitCancelFullScreen(); | ||
} | ||
} | ||
} | ||
|
||
function onFullScreenChange() { | ||
if ( | ||
document.fullscreenElement || | ||
document.mozFullScreenElement || | ||
document.webkitFullscreenElement | ||
) { | ||
html.classList.add('fullscreen'); | ||
fsbutton.textContent = "Close fullscreen"; | ||
} else { | ||
html.classList.remove('fullscreen'); | ||
fsbutton.textContent = "Fullscreen"; | ||
} | ||
} | ||
|
||
function onFullScreenError() { | ||
alert('Could not enter into fullscreen.'); | ||
} | ||
|
||
document.addEventListener('fullscreenchange', onFullScreenChange); | ||
document.addEventListener('mozfullscreenchange', onFullScreenChange); | ||
document.addEventListener('webkitfullscreenchange', onFullScreenChange); | ||
|
||
document.addEventListener('fullscreenerror', onFullScreenError); | ||
document.addEventListener('mozfullscreenerror', onFullScreenError); | ||
document.addEventListener('webkitfullscreenerror', onFullScreenError); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters