1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 02:19:55 +00:00

Extent tm-full-screen message to support forcing the status

Now one can force "enter" or "exit", instead of just toggling the current status
This commit is contained in:
Jermolene 2018-08-14 22:53:53 +01:00
parent b89e8d1635
commit 3140ff9e49
2 changed files with 30 additions and 6 deletions

View File

@ -42,10 +42,16 @@ exports.startup = function() {
var fullscreen = $tw.utils.getFullScreenApis();
if(fullscreen) {
$tw.rootWidget.addEventListener("tm-full-screen",function(event) {
if(event.event.target.ownerDocument[fullscreen._fullscreenElement]) {
if(event.param === "enter") {
event.event.target.ownerDocument.documentElement[fullscreen._requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
} else if(event.param === "exit") {
event.event.target.ownerDocument[fullscreen._exitFullscreen]();
} else {
event.event.target.ownerDocument.documentElement[fullscreen._requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
if(event.event.target.ownerDocument[fullscreen._fullscreenElement]) {
event.event.target.ownerDocument[fullscreen._exitFullscreen]();
} else {
event.event.target.ownerDocument.documentElement[fullscreen._requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
}
}
});
}

View File

@ -1,10 +1,28 @@
caption: tm-full-screen
created: 20140811112400855
modified: 20140811113627373
modified: 20180814215126941
tags: Messages
title: WidgetMessage: tm-full-screen
type: text/vnd.tiddlywiki
caption: tm-full-screen
The fullscreen message toggles the "fullscreen" mode of the browser, if it supports it.
The fullscreen message is used to enter, exit or toggle the "fullscreen" mode of the browser, if it supports it. It uses the following properties on the `event` object:
|!Name |!Description |
|param |`enter` to enter full screen mode, `exit` to exit it, otherwise toggle the full screen status |
The fullscreen message is handled by the TiddlyWiki core.
<$macrocall $name='wikitext-example-without-html'
src='<$button message="tm-full-screen">
Full screen toggle
</$button>
<$button message="tm-full-screen" param="enter">
Full screen enter
</$button>
<$button message="tm-full-screen" param="exit">
Full screen exit
</$button>'/>
The fullscreen message is handled by the TiddlyWiki core.