2012-09-12 09:46:39 +00:00
|
|
|
/*\
|
|
|
|
title: $:/plugins/tiddlywiki/fullscreen/init.js
|
|
|
|
type: application/javascript
|
2014-05-03 16:49:20 +00:00
|
|
|
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";
|
|
|
|
|
2014-05-03 16:49:20 +00:00
|
|
|
// Export name and synchronous status
|
2014-05-05 09:17:50 +00:00
|
|
|
exports.name = "full-screen";
|
2014-05-03 16:49:20 +00:00
|
|
|
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" :
|
2013-12-18 21:39:59 +00:00
|
|
|
d.mozCancelFullScreen !== undefined ? "mozCancelFullScreen" :
|
|
|
|
d.msExitFullscreen !== undefined ? "msExitFullscreen" :
|
|
|
|
d.exitFullscreen !== undefined ? "exitFullscreen" : "",
|
2014-05-03 16:49:20 +00:00
|
|
|
_fullscreenElement = d.webkitFullscreenElement !== undefined ? "webkitFullscreenElement" :
|
2013-12-18 21:39:59 +00:00
|
|
|
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
|
2013-12-29 12:54:00 +00:00
|
|
|
if(_requestFullscreen) {
|
|
|
|
$tw.rootWidget.addEventListener("tw-full-screen",function(event) {
|
2014-05-03 16:49:20 +00:00
|
|
|
if(document[_fullscreenElement]) {
|
|
|
|
document[_exitFullscreen]();
|
|
|
|
} else {
|
|
|
|
document.documentElement[_requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
|
|
|
|
}
|
2013-12-29 12:54:00 +00:00
|
|
|
});
|
|
|
|
}
|
2012-09-12 09:46:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|