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

Add "open new window" tiddler toolbar button

This commit is contained in:
Jermolene 2015-05-02 12:12:51 +01:00
parent 52529f9b32
commit 9cf5d88cc9
5 changed files with 105 additions and 5 deletions

View File

@ -0,0 +1,9 @@
title: $:/core/images/open-window
tags: $:/tags/Image
<svg class="tc-image-open-window tc-image-button" width="22pt" height="22pt" viewBox="0 0 128 128">
<g fill-rule="evenodd">
<path d="M16,112 L104.993898,112 C108.863261,112 112,115.590712 112,120 C112,124.418278 108.858091,128 104.993898,128 L7.00610161,128 C3.13673853,128 0,124.409288 0,120 C0,119.998364 4.30952878e-07,119.996727 1.29273572e-06,119.995091 C4.89579306e-07,119.993456 0,119.99182 0,119.990183 L0,24.0098166 C0,19.586117 3.59071231,16 8,16 C12.418278,16 16,19.5838751 16,24.0098166 L16,112 Z"></path>
<path d="M96,43.1959595 L96,56 C96,60.418278 99.581722,64 104,64 C108.418278,64 112,60.418278 112,56 L112,24 C112,19.5907123 108.415101,16 103.992903,16 L72.0070969,16 C67.5881712,16 64,19.581722 64,24 C64,28.4092877 67.5848994,32 72.0070969,32 L84.5685425,32 L48.2698369,68.2987056 C45.1421332,71.4264093 45.1434327,76.4904296 48.267627,79.614624 C51.3854642,82.7324612 56.4581306,82.7378289 59.5835454,79.6124141 L96,43.1959595 Z M32,7.9992458 C32,3.58138434 35.5881049,0 39.9992458,0 L120.000754,0 C124.418616,0 128,3.5881049 128,7.9992458 L128,88.0007542 C128,92.4186157 124.411895,96 120.000754,96 L39.9992458,96 C35.5813843,96 32,92.4118951 32,88.0007542 L32,7.9992458 Z"></path>
</g>
</svg>

View File

@ -52,6 +52,8 @@ NewJournalHere/Caption: new journal here
NewJournalHere/Hint: Create a new journal tiddler tagged with this one
NewTiddler/Caption: new tiddler
NewTiddler/Hint: Create a new tiddler
OpenWindow/Caption: open in new window
OpenWindow/Hint: Open tiddler in new window
Permalink/Caption: permalink
Permalink/Hint: Set browser address bar to a direct link to this tiddler
Permaview/Caption: permaview

View File

@ -0,0 +1,63 @@
/*\
title: $:/core/modules/startup/windows.js
type: application/javascript
module-type: startup
Setup root widget handlers for the messages concerned with opening external browser windows
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
// Export name and synchronous status
exports.name = "windows";
exports.platforms = ["browser"];
exports.after = ["startup"];
exports.synchronous = true;
exports.startup = function() {
$tw.rootWidget.addEventListener("tm-open-window",function(event) {
// Get the parameters
var title = event.param || event.tiddlerTitle,
paramObject = event.paramObject || {},
template = paramObject.template || "$:/core/ui/ViewTemplate/body",
width = paramObject.width || "700",
height = paramObject.height || "600";
// Open the window
var srcWindow = window.open("","external-" + title,"width=" + width + ",height=" + height),
srcDocument = srcWindow.document;
srcWindow.onclose = function(event) {
console.log("closing popup");
};
srcWindow.addEventListener("close",function(event) {
console.log("closing2 popup");
},false);
srcDocument.write("<html><head></head><body class='tc-body'></body></html>");
srcDocument.close();
// Set up the styles
var styleWidgetNode = $tw.wiki.makeTranscludeWidget("$:/core/ui/PageStylesheet",{document: $tw.fakeDocument}),
styleContainer = $tw.fakeDocument.createElement("style");
styleWidgetNode.render(styleContainer,null);
var styleElement = srcDocument.createElement("style");
styleElement.innerHTML = styleContainer.textContent;
srcDocument.head.insertBefore(styleElement,srcDocument.head.firstChild);
$tw.wiki.addEventListener("change",function(changes) {
if(styleWidgetNode.refresh(changes,styleContainer,null)) {
styleElement.innerHTML = styleContainer.textContent;
}
});
// Render the text of the tiddler
var parser = $tw.wiki.parseTiddler(template),
widgetNode = $tw.wiki.makeWidget(parser,{document: srcDocument, variables: {currentTiddler: title}});
widgetNode.render(srcDocument.body,null);
$tw.wiki.addEventListener("change",function(changes) {
widgetNode.refresh(changes);
});
});
};
})();

View File

@ -0,0 +1,13 @@
title: $:/core/ui/Buttons/open-window
tags: $:/tags/ViewToolbar
caption: {{$:/core/images/open-window}} {{$:/language/Buttons/OpenWindow/Caption}}
description: {{$:/language/Buttons/OpenWindow/Hint}}
<$button message="tm-open-window" tooltip={{$:/language/Buttons/OpenWindow/Hint}} aria-label={{$:/language/Buttons/OpenWindow/Caption}} class=<<tv-config-toolbar-class>>>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/open-window}}
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/language/Buttons/OpenWindow/Caption}}/></span>
</$list>
</$button>

View File

@ -1,25 +1,38 @@
title: TiddlyWiki Pre-release
modified: 20150428204930183
\define colour-picker(tiddler,colour)
<$edit-text tiddler="""$tiddler$""" index="""$colour$""" type="color" tag="input"/>
\end
This is a pre-release build of TiddlyWiki.
It is provided for testing purposes. Please don't try to use it for anything important -- you should use the latest official release from http://tiddlywiki.com.
! Features for 5.1.9
!! New Tiddler Toolbar Button: "Open in new window"
An experimental new tiddler toolbar button opens a single tiddler in a separate pop-up browser window. The tiddler will be dynamically updated just as in the main window. There are several uses:
* Arranging reference tiddlers for easy access while editing in the main window
* Making good use of multi-screen layouts
* Printing the content of a single tiddler
* Running presentations in a separate window while maintaining notes in the main window
!! Improvements for visually impaired users
* Improved monochrome palettes:
* Improved monochrome palette variants:
** <$button>
<$action-setfield $tiddler="$:/theme" text="$:/themes/tiddlywiki/vanilla"/>
<$action-setfield $tiddler="$:/palette" text="$:/palettes/ContrastDark"/>
Set "Contrast (Light)" palette
</$button>
Dark palette
</$button>. Foreground: <<colour-picker "$:/palettes/ContrastDark" "foreground">>, Background: <<colour-picker "$:/palettes/ContrastDark" "background">>
** <$button>
<$action-setfield $tiddler="$:/theme" text="$:/themes/tiddlywiki/vanilla"/>
<$action-setfield $tiddler="$:/palette" text="$:/palettes/ContrastLight"/>
Set "Contrast (Dark)" palette
</$button>
Light palette
</$button>. Foreground: <<colour-picker "$:/palettes/ContrastLight" "foreground">>, Background: <<colour-picker "$:/palettes/ContrastLight" "background">>
** <$button>
<$action-setfield $tiddler="$:/theme" text="$:/themes/tiddlywiki/snowwhite"/>
<$action-setfield $tiddler="$:/palette" text="$:/palettes/Vanilla"/>