1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-04 17:16:18 +00:00

Fixes to fullscreen support

Prompted by this article:

http://generatedcontent.org/post/70347573294/is-your-fullscreen-api-code
-up-to-date-find-out-how-to
This commit is contained in:
Jermolene 2013-12-18 21:39:59 +00:00
parent cc39686693
commit 638c8b2070
2 changed files with 20 additions and 14 deletions

View File

@ -130,15 +130,6 @@ exports.convertEventName = function(eventName) {
// Setup constants for the current browser // Setup constants for the current browser
exports.getBrowserInfo = function(info) { exports.getBrowserInfo = function(info) {
info.requestFullScreen = document.body.webkitRequestFullScreen !== undefined ? "webkitRequestFullScreen" :
document.body.mozRequestFullScreen !== undefined ? "mozRequestFullScreen" :
document.body.requestFullScreen !== undefined ? "requestFullScreen" : "";
info.cancelFullScreen = document.webkitCancelFullScreen !== undefined ? "webkitCancelFullScreen" :
document.mozCancelFullScreen !== undefined ? "mozCancelFullScreen" :
document.cancelFullScreen !== undefined ? "cancelFullScreen" : "";
info.isFullScreen = document.webkitIsFullScreen !== undefined ? "webkitIsFullScreen" :
document.mozFullScreen !== undefined ? "mozFullScreen" :
document.fullScreen !== undefined ? "fullScreen" : "";
}; };
})(); })();

View File

@ -12,18 +12,33 @@ Message handler for full screen mode
/*global $tw: false, Element: false */ /*global $tw: false, Element: false */
"use strict"; "use strict";
var toggleFullScreen = function() { var d = document,
if(document[$tw.browser.isFullScreen]) { db = d.body,
document[$tw.browser.cancelFullScreen](); _requestFullscreen = db.webkitRequestFullscreen !== undefined ? "webkitRequestFullscreen" :
db.mozRequestFullScreen !== undefined ? "mozRequestFullScreen" :
db.msRequestFullscreen !== undefined ? "msRequestFullscreen" :
db.requestFullscreen !== undefined ? "requestFullscreen" : "",
_exitFullscreen = d.webkitExitFullscreen !== undefined ? "webkitExitFullscreen" :
d.mozCancelFullScreen !== undefined ? "mozCancelFullScreen" :
d.msExitFullscreen !== undefined ? "msExitFullscreen" :
d.exitFullscreen !== undefined ? "exitFullscreen" : "",
_fullscreenElement = d.webkitFullscreenElement !== undefined ? "webkitFullscreenElement" :
d.mozFullScreenElement !== undefined ? "mozFullScreenElement" :
d.msFullscreenElement !== undefined ? "msFullscreenElement" :
d.fullscreenElement !== undefined ? "fullscreenElement" : "";
var toggleFullscreen = function() {
if(document[_fullscreenElement]) {
document[_exitFullscreen]();
} else { } else {
document.documentElement[$tw.browser.requestFullScreen](Element.ALLOW_KEYBOARD_INPUT); document.documentElement[_requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
} }
}; };
exports.startup = function() { exports.startup = function() {
// Install the full screen handler // Install the full screen handler
$tw.rootWidget.addEventListener("tw-full-screen",function(event) { $tw.rootWidget.addEventListener("tw-full-screen",function(event) {
toggleFullScreen(); toggleFullscreen();
}); });
}; };