1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 09:30:28 +00:00

Move the unsaved changes warning into the syncer

This commit is contained in:
Jermolene 2014-08-13 19:29:00 +01:00
parent 57ab9f6167
commit c9ce606b7c
2 changed files with 11 additions and 9 deletions

View File

@ -54,15 +54,6 @@ exports.startup = function() {
$tw.syncer = new $tw.Syncer({wiki: $tw.wiki});
// Host-specific startup
if($tw.browser) {
// Set up our beforeunload handler
window.addEventListener("beforeunload",function(event) {
var confirmationMessage = undefined;
if($tw.syncer.isDirty()) {
confirmationMessage = $tw.language.getString("UnsavedChangesWarning");
event.returnValue = confirmationMessage; // Gecko
}
return confirmationMessage;
});
// Install the popup manager
$tw.popup = new $tw.utils.Popup({
rootElement: document.body

View File

@ -45,6 +45,17 @@ function Syncer(options) {
this.wiki.addEventListener("change",function(changes) {
self.syncToServer(changes);
});
// Set up our beforeunload handler
if($tw.browser) {
window.addEventListener("beforeunload",function(event) {
var confirmationMessage = undefined;
if(self.isDirty()) {
confirmationMessage = $tw.language.getString("UnsavedChangesWarning");
event.returnValue = confirmationMessage; // Gecko
}
return confirmationMessage;
});
}
// Listen out for lazyLoad events
if(this.syncadaptor) {
this.wiki.addEventListener("lazyLoad",function(title) {