mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 21:39:57 +00:00
638c8b2070
Prompted by this article: http://generatedcontent.org/post/70347573294/is-your-fullscreen-api-code -up-to-date-find-out-how-to
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
/*\
|
|
title: $:/plugins/tiddlywiki/fullscreen/init.js
|
|
type: application/javascript
|
|
module-type: browser-startup
|
|
|
|
Message handler for full screen mode
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false, Element: false */
|
|
"use strict";
|
|
|
|
var d = document,
|
|
db = d.body,
|
|
_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 {
|
|
document.documentElement[_requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
|
|
}
|
|
};
|
|
|
|
exports.startup = function() {
|
|
// Install the full screen handler
|
|
$tw.rootWidget.addEventListener("tw-full-screen",function(event) {
|
|
toggleFullscreen();
|
|
});
|
|
};
|
|
|
|
})();
|