1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

tm-open-external-window plus documentation. (#2721)

* first try - tm-open-external-window plus documentation.

* render examples and make help link a global variable
This commit is contained in:
Mario Pietsch 2018-11-27 19:43:25 +01:00 committed by Jeremy Ruston
parent 9232279a79
commit 42f7c03824
2 changed files with 51 additions and 1 deletions

View File

@ -31,6 +31,9 @@ var CONFIG_PERMALINKVIEW_COPY_TO_CLIPBOARD = "$:/config/Navigation/Permalinkview
var CONFIG_PERMALINKVIEW_UPDATE_ADDRESS_BAR = "$:/config/Navigation/Permalinkview/UpdateAddressBar"; // Can be "yes" (default) or "no"
// Links to help, if there is no param
var HELP_OPEN_EXTERNAL_WINDOW = "http://tiddlywiki.com/#WidgetMessage%3A%20tm-open-external-window";
exports.startup = function() {
// Open startup tiddlers
openStartupTiddlers();
@ -56,6 +59,14 @@ exports.startup = function() {
$tw.rootWidget.addEventListener("tm-browser-refresh",function(event) {
window.location.reload(true);
});
// Listen for tm-open-external-window message
$tw.rootWidget.addEventListener("tm-open-external-window",function(event) {
var paramObject = event.paramObject || {},
strUrl = event.param || HELP_OPEN_EXTERNAL_WINDOW,
strWindowName = paramObject.windowName,
strWindowFeatures = paramObject.windowFeatures;
window.open(strUrl, strWindowName, strWindowFeatures);
});
// Listen for the tm-print message
$tw.rootWidget.addEventListener("tm-print",function(event) {
(event.event.view || window).print();
@ -69,7 +80,7 @@ exports.startup = function() {
storyList = $tw.hooks.invokeHook("th-opening-default-tiddlers-list",storyList);
$tw.wiki.addTiddler({title: DEFAULT_STORY_TITLE, text: "", list: storyList},$tw.wiki.getModificationFields());
if(storyList[0]) {
$tw.wiki.addToHistory(storyList[0]);
$tw.wiki.addToHistory(storyList[0]);
}
});
// Listen for the tm-permalink message

View File

@ -0,0 +1,39 @@
caption: tm-open-external-window
created: 201701211823
modified: 201701211825
tags: Messages
title: WidgetMessage: tm-open-external-window
type: text/vnd.tiddlywiki
<<.from-version "5.1.14">>
The `tm-open-external-window` message opens an external link eg: "http://tiddlywiki.com" in a new //browser// window. If no parameters are specified, it opens the help tiddler. Any additional parameters passed via the <<.param "paramObject">> are being provided as variables to the new window.
|!Name |!Description |
|param |URL of the tiddler to be opened in a new browser window, defaults to the [[TiddlyWiki help|http://tiddlywiki.com/#WidgetMessage%3A%20tm-open-external-window if empty]] |
|paramObject |Optional: Hashmap of variables that will be provided to the window. see below |
''parmObject''
|!Name |!Description|!Important|
|windowName|If a parameter is provided it can be used to open different links in the same window eg: `_tiddlywiki`. Default is empty, so every link opens a new window.|The behaviour is influenced by user settings in the browser and the browsers default behavior! |
|windowFeatures|This parameter needs to be provided as a single string. eg: `"height=400, width=600"`. For detailed description about possible parameters see: [[Mozilla Help|https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features]] ||
The `tm-open-external-window` message is usually generated with the ButtonWidget or ActionSendMessageWidget and is handled by the core itself.
''Examples''
<$macrocall $name='wikitext-example-without-html'
src='<$button>
<$action-sendmessage $message="tm-open-external-window" $param="http://tiddlywiki.com" windowName="_tiddlywiki" windowFeatures="height=500, width=900"/>
Open ~TiddlyWiki - Action
</$button>
<$button>
<$action-sendmessage $message="tm-open-external-window" $param="https://developer.mozilla.org/en-US/docs/Web/API/Window/open" windowName="_tiddlywiki" windowFeatures="height=400, width=600"/>
Open Mozilla Help - Action
</$button>
<$button message="tm-open-external-window" param="http://tiddlywiki.com" >
Open ~TiddlyWiki - Button
</$button>'/>