From e5f33275bdc18c5fe4b9372b36590388b25fcb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Thu, 20 Feb 2014 23:52:45 +0000 Subject: [PATCH] Fix the confirmation dialog when closing the tab * Only nag if we're connected * Set event return value so Chrome shows the dialog --- js/glowingbear.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 2160e04..8f25def 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -849,7 +849,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // Prevent user from accidentally leaving the page window.onbeforeunload = function(event) { - event.preventDefault(); + if ($rootScope.connected) { + event.preventDefault(); + // Chrome requires us to set this or it will not show the dialog + event.returnValue = "You have an active connection to your WeeChat relay. Please disconnect using the button in the top-right corner or by pressing the Escape key."; + } $scope.favico.reset(); };