Enhance TiddlyFox saver to display a notification on success

print-window-tiddler
Jeremy Ruston 2013-05-07 18:09:15 +01:00
rodzic 24db38c06b
commit e501c0ec2a
3 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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