kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Extend tm-open-window to pass variables
rodzic
4d4181b048
commit
51d771a074
|
@ -30,7 +30,8 @@ exports.startup = function() {
|
||||||
paramObject = event.paramObject || {},
|
paramObject = event.paramObject || {},
|
||||||
template = paramObject.template || "$:/core/templates/single.tiddler.window",
|
template = paramObject.template || "$:/core/templates/single.tiddler.window",
|
||||||
width = paramObject.width || "700",
|
width = paramObject.width || "700",
|
||||||
height = paramObject.height || "600";
|
height = paramObject.height || "600",
|
||||||
|
variables = $tw.utils.extend({},paramObject,{currentTiddler: title});
|
||||||
// Open the window
|
// Open the window
|
||||||
var srcWindow = window.open("","external-" + title,"scrollbars,width=" + width + ",height=" + height),
|
var srcWindow = window.open("","external-" + title,"scrollbars,width=" + width + ",height=" + height),
|
||||||
srcDocument = srcWindow.document;
|
srcDocument = srcWindow.document;
|
||||||
|
@ -48,7 +49,7 @@ exports.startup = function() {
|
||||||
$tw.wiki.removeEventListener("change",refreshHandler);
|
$tw.wiki.removeEventListener("change",refreshHandler);
|
||||||
},false);
|
},false);
|
||||||
// Set up the styles
|
// Set up the styles
|
||||||
var styleWidgetNode = $tw.wiki.makeTranscludeWidget("$:/core/ui/PageStylesheet",{document: $tw.fakeDocument}),
|
var styleWidgetNode = $tw.wiki.makeTranscludeWidget("$:/core/ui/PageStylesheet",{document: $tw.fakeDocument, variables: variables}),
|
||||||
styleContainer = $tw.fakeDocument.createElement("style");
|
styleContainer = $tw.fakeDocument.createElement("style");
|
||||||
styleWidgetNode.render(styleContainer,null);
|
styleWidgetNode.render(styleContainer,null);
|
||||||
var styleElement = srcDocument.createElement("style");
|
var styleElement = srcDocument.createElement("style");
|
||||||
|
@ -56,7 +57,7 @@ exports.startup = function() {
|
||||||
srcDocument.head.insertBefore(styleElement,srcDocument.head.firstChild);
|
srcDocument.head.insertBefore(styleElement,srcDocument.head.firstChild);
|
||||||
// Render the text of the tiddler
|
// Render the text of the tiddler
|
||||||
var parser = $tw.wiki.parseTiddler(template),
|
var parser = $tw.wiki.parseTiddler(template),
|
||||||
widgetNode = $tw.wiki.makeWidget(parser,{document: srcDocument, parentWidget: $tw.rootWidget, variables: {currentTiddler: title}});
|
widgetNode = $tw.wiki.makeWidget(parser,{document: srcDocument, parentWidget: $tw.rootWidget, variables: variables});
|
||||||
widgetNode.render(srcDocument.body,srcDocument.body.firstChild);
|
widgetNode.render(srcDocument.body,srcDocument.body.firstChild);
|
||||||
// Function to handle refreshes
|
// Function to handle refreshes
|
||||||
refreshHandler = function(changes) {
|
refreshHandler = function(changes) {
|
||||||
|
|
Ładowanie…
Reference in New Issue