From 51d771a07493f91c32145b69e4f5534724416d2e Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 31 Aug 2015 14:13:32 +0100 Subject: [PATCH] Extend tm-open-window to pass variables --- core/modules/startup/windows.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/modules/startup/windows.js b/core/modules/startup/windows.js index 40fca87b7..9ce34f842 100644 --- a/core/modules/startup/windows.js +++ b/core/modules/startup/windows.js @@ -30,7 +30,8 @@ exports.startup = function() { paramObject = event.paramObject || {}, template = paramObject.template || "$:/core/templates/single.tiddler.window", width = paramObject.width || "700", - height = paramObject.height || "600"; + height = paramObject.height || "600", + variables = $tw.utils.extend({},paramObject,{currentTiddler: title}); // Open the window var srcWindow = window.open("","external-" + title,"scrollbars,width=" + width + ",height=" + height), srcDocument = srcWindow.document; @@ -48,7 +49,7 @@ exports.startup = function() { $tw.wiki.removeEventListener("change",refreshHandler); },false); // 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"); styleWidgetNode.render(styleContainer,null); var styleElement = srcDocument.createElement("style"); @@ -56,7 +57,7 @@ exports.startup = function() { srcDocument.head.insertBefore(styleElement,srcDocument.head.firstChild); // Render the text of the tiddler 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); // Function to handle refreshes refreshHandler = function(changes) {