mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Switch from addEventListener to onbeforeunload
This makes it possible for TiddlyDesktop to reuse these functions to handle detecting unsaved changes
This commit is contained in:
parent
be06cb1019
commit
3657bbe920
@ -75,14 +75,14 @@ function SaverHandler(options) {
|
||||
}
|
||||
});
|
||||
// Set up our beforeunload handler
|
||||
window.addEventListener("beforeunload",function(event) {
|
||||
window.onbeforeunload = function(event) {
|
||||
var confirmationMessage;
|
||||
if(self.isDirty()) {
|
||||
confirmationMessage = $tw.language.getString("UnsavedChangesWarning");
|
||||
event.returnValue = confirmationMessage; // Gecko
|
||||
}
|
||||
return confirmationMessage;
|
||||
});
|
||||
};
|
||||
}
|
||||
// Install the save action handlers
|
||||
if($tw.browser) {
|
||||
|
@ -39,14 +39,14 @@ function Syncer(options) {
|
||||
// Browser event handlers
|
||||
if($tw.browser) {
|
||||
// Set up our beforeunload handler
|
||||
window.addEventListener("beforeunload",function(event) {
|
||||
window.onbeforeunload = function(event) {
|
||||
var confirmationMessage;
|
||||
if(self.isDirty()) {
|
||||
confirmationMessage = $tw.language.getString("UnsavedChangesWarning");
|
||||
event.returnValue = confirmationMessage; // Gecko
|
||||
}
|
||||
return confirmationMessage;
|
||||
});
|
||||
};
|
||||
// Listen out for login/logout/refresh events in the browser
|
||||
$tw.rootWidget.addEventListener("tm-login",function() {
|
||||
self.handleLoginEvent();
|
||||
|
Loading…
Reference in New Issue
Block a user