1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Enhance TiddlyFox saver to display a notification on success

This commit is contained in:
Jeremy Ruston 2013-05-07 18:09:15 +01:00
parent 24db38c06b
commit e501c0ec2a
3 changed files with 11 additions and 2 deletions

3
core/messages/Saved.tid Normal file
View File

@ -0,0 +1,3 @@
title: $:/messages/Saved
Saved wiki

View File

@ -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);

View File

@ -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");
});
};
/*