From c4e13bc94afb022e40aaa70b06464084188acfea Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 8 Oct 2016 10:10:54 +0100 Subject: [PATCH] Add icon and message handler for print button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’m inclined to think it’s not worth adding a corresponding page control button because it’ll require a lot of tiddlers for the translation etc. --- core/images/print-button.tid | 12 ++++++++++++ core/modules/startup/story.js | 4 ++++ .../tiddlers/messages/WidgetMessage_ tm-print.tid | 10 ++++++++++ 3 files changed, 26 insertions(+) create mode 100644 core/images/print-button.tid create mode 100644 editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-print.tid diff --git a/core/images/print-button.tid b/core/images/print-button.tid new file mode 100644 index 000000000..5e7c1d8e0 --- /dev/null +++ b/core/images/print-button.tid @@ -0,0 +1,12 @@ +title: $:/core/images/print-button +tags: $:/tags/Image + + + + + + + + + + \ No newline at end of file diff --git a/core/modules/startup/story.js b/core/modules/startup/story.js index 987bee216..20eb5e71a 100644 --- a/core/modules/startup/story.js +++ b/core/modules/startup/story.js @@ -53,6 +53,10 @@ exports.startup = function() { $tw.rootWidget.addEventListener("tm-browser-refresh",function(event) { window.location.reload(true); }); + // Listen for the tm-print message + $tw.rootWidget.addEventListener("tm-print",function(event) { + window.print(); + }); // Listen for the tm-home message $tw.rootWidget.addEventListener("tm-home",function(event) { window.location.hash = ""; diff --git a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-print.tid b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-print.tid new file mode 100644 index 000000000..c114811ef --- /dev/null +++ b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-print.tid @@ -0,0 +1,10 @@ +created: 20161008085627406 +modified: 20161008085627406 +tags: Messages +title: WidgetMessage: tm-print +type: text/vnd.tiddlywiki +caption: tm-print + +<<.from-version "5.1.14">> The `tm-print` message causes the browser to display the print dialog for the current page. It does not require any properties on the `event` object. + +The print message is usually generated with the ButtonWidget and is handled by the core.