mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-10-29 06:37:39 +00:00
Refactor browser unload task handling
Make it possible to register multiple task functions that will be called when the window is unloaded
This commit is contained in:
@@ -39,14 +39,14 @@ function Syncer(options) {
|
||||
// Browser event handlers
|
||||
if($tw.browser) {
|
||||
// Set up our beforeunload handler
|
||||
window.onbeforeunload = function(event) {
|
||||
$tw.addUnloadTask(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();
|
||||
|
||||
Reference in New Issue
Block a user