mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-06-25 14:43:01 +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});
|
$tw.syncer = new $tw.Syncer({wiki: $tw.wiki});
|
||||||
// Host-specific startup
|
// Host-specific startup
|
||||||
if($tw.browser) {
|
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
|
// Install the popup manager
|
||||||
$tw.popup = new $tw.utils.Popup({
|
$tw.popup = new $tw.utils.Popup({
|
||||||
rootElement: document.body
|
rootElement: document.body
|
||||||
|
@ -45,6 +45,17 @@ function Syncer(options) {
|
|||||||
this.wiki.addEventListener("change",function(changes) {
|
this.wiki.addEventListener("change",function(changes) {
|
||||||
self.syncToServer(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
|
// Listen out for lazyLoad events
|
||||||
if(this.syncadaptor) {
|
if(this.syncadaptor) {
|
||||||
this.wiki.addEventListener("lazyLoad",function(title) {
|
this.wiki.addEventListener("lazyLoad",function(title) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user