1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 10:37:20 +00:00
TiddlyWiki5/plugins/tiddlywiki/fullscreen/init.js

46 lines
1.5 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: browser-startup
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";
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]();
2012-09-12 09:46:39 +00:00
} else {
document.documentElement[_requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
2012-09-12 09:46:39 +00:00
}
};
exports.startup = function() {
// Install the full screen handler
2013-10-25 11:53:58 +00:00
$tw.rootWidget.addEventListener("tw-full-screen",function(event) {
toggleFullscreen();
2013-10-25 11:53:58 +00:00
});
2012-09-12 09:46:39 +00:00
};
})();