1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +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:
Jermolene 2015-01-10 18:08:12 +00:00
parent be06cb1019
commit 3657bbe920
2 changed files with 4 additions and 4 deletions

View File

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

View File

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