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";
|
|
|
|
|
2013-12-18 21:39:59 +00:00
|
|
|
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 {
|
2013-12-18 21:39:59 +00:00
|
|
|
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) {
|
2013-12-18 21:39:59 +00:00
|
|
|
toggleFullscreen();
|
2013-10-25 11:53:58 +00:00
|
|
|
});
|
2012-09-12 09:46:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|