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:
Jermolene
2015-05-03 16:23:35 +01:00
parent d23f174d01
commit 48dcf959ff
3 changed files with 29 additions and 5 deletions
+2 -2
View File
@@ -75,14 +75,14 @@ function SaverHandler(options) {
}
});
// 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;
};
});
}
// Install the save action handlers
if($tw.browser) {