From 3657bbe9206d1ede62d0e9ed688e04e8f232afdd Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 10 Jan 2015 18:08:12 +0000 Subject: [PATCH] Switch from addEventListener to onbeforeunload This makes it possible for TiddlyDesktop to reuse these functions to handle detecting unsaved changes --- core/modules/saver-handler.js | 4 ++-- core/modules/syncer.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/modules/saver-handler.js b/core/modules/saver-handler.js index 0669ec917..3344495c7 100644 --- a/core/modules/saver-handler.js +++ b/core/modules/saver-handler.js @@ -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) { diff --git a/core/modules/syncer.js b/core/modules/syncer.js index 08d5deb19..617c54155 100644 --- a/core/modules/syncer.js +++ b/core/modules/syncer.js @@ -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();