1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-26 10:00:34 +00:00
TiddlyWiki5/plugins/tiddlywiki/fullscreen/init.js

49 lines
1.6 KiB
JavaScript
Raw Normal View History

2012-09-12 09:46:39 +00:00
/*\
title: $:/plugins/tiddlywiki/fullscreen/init.js
type: application/javascript
module-type: startup
2012-09-12 09:46:39 +00:00
Message handler for full screen mode
\*/
(function(){
/*jslint node: true, browser: true */
2012-11-06 17:21:56 +00:00
/*global $tw: false, Element: false */
2012-09-12 09:46:39 +00:00
"use strict";
// Export name and synchronous status
exports.name = "full-screen";
exports.platforms = ["browser"];
exports.after = ["startup"];
exports.synchronous = true;
exports.startup = function() {
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" : "";
2012-09-12 09:46:39 +00:00
// Install the full screen handler
if(_requestFullscreen) {
$tw.rootWidget.addEventListener("tw-full-screen",function(event) {
if(document[_fullscreenElement]) {
document[_exitFullscreen]();
} else {
document.documentElement[_requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
}
});
}
2012-09-12 09:46:39 +00:00
};
})();