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:
parent
57ab9f6167
commit
c9ce606b7c
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user