From e501c0ec2a3a0ce54fc483433b914fdaead727f6 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Tue, 7 May 2013 18:09:15 +0100 Subject: [PATCH] Enhance TiddlyFox saver to display a notification on success --- core/messages/Saved.tid | 3 +++ core/modules/savers/tiddlyfox.js | 6 +++++- core/modules/wiki.js | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 core/messages/Saved.tid diff --git a/core/messages/Saved.tid b/core/messages/Saved.tid new file mode 100644 index 000000000..14704640b --- /dev/null +++ b/core/messages/Saved.tid @@ -0,0 +1,3 @@ +title: $:/messages/Saved + +Saved wiki diff --git a/core/modules/savers/tiddlyfox.js b/core/modules/savers/tiddlyfox.js index 2da109a67..6213ad744 100644 --- a/core/modules/savers/tiddlyfox.js +++ b/core/modules/savers/tiddlyfox.js @@ -15,7 +15,7 @@ Handles saving changes via the TiddlyFox file extension var TiddlyFoxSaver = function(wiki) { }; -TiddlyFoxSaver.prototype.save = function(text) { +TiddlyFoxSaver.prototype.save = function(text,callback) { var messageBox = document.getElementById("tiddlyfox-message-box"); if(messageBox) { // Create the message element and put it in the message box @@ -23,6 +23,10 @@ TiddlyFoxSaver.prototype.save = function(text) { message.setAttribute("data-tiddlyfox-path",decodeURIComponent(document.location.pathname)); message.setAttribute("data-tiddlyfox-content",text); messageBox.appendChild(message); + // Add an event handler for when the file has been saved + message.addEventListener("tiddlyfox-have-saved-file",function(event) { + callback(null); + }, false); // Create and dispatch the custom event to the extension var event = document.createEvent("Events"); event.initEvent("tiddlyfox-save-file",true,false); diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 5fe55e438..c739778a6 100644 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -622,7 +622,9 @@ exports.saveWiki = function(options) { var template = options.template || "$:/core/templates/tiddlywiki5.template.html", downloadType = options.downloadType || "text/plain"; var text = this.renderTiddler(downloadType,template); - this.callSaver("save",text); + this.callSaver("save",text,function(err) { + $tw.notifier.display("$:/messages/Saved"); + }); }; /*