diff --git a/core/images/open-window.tid b/core/images/open-window.tid new file mode 100644 index 000000000..337c582a1 --- /dev/null +++ b/core/images/open-window.tid @@ -0,0 +1,9 @@ +title: $:/core/images/open-window +tags: $:/tags/Image + + \ No newline at end of file diff --git a/core/language/en-GB/Buttons.multids b/core/language/en-GB/Buttons.multids index f90c138ef..9cd9c6fd5 100644 --- a/core/language/en-GB/Buttons.multids +++ b/core/language/en-GB/Buttons.multids @@ -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 diff --git a/core/modules/startup/windows.js b/core/modules/startup/windows.js new file mode 100644 index 000000000..cb4c755f5 --- /dev/null +++ b/core/modules/startup/windows.js @@ -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("
"); + 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); + }); + + }); +}; + +})(); diff --git a/core/ui/ViewToolbar/open-window.tid b/core/ui/ViewToolbar/open-window.tid new file mode 100644 index 000000000..6c885fc94 --- /dev/null +++ b/core/ui/ViewToolbar/open-window.tid @@ -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=<