Fix the confirmation dialog when closing the tab

* Only nag if we're connected
* Set event return value so Chrome shows the dialog
This commit is contained in:
Lorenz Hübschle-Schneider 2014-02-20 23:52:45 +00:00
parent 0deb14fc84
commit e5f33275bd
1 changed files with 5 additions and 1 deletions

View File

@ -849,7 +849,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Prevent user from accidentally leaving the page
window.onbeforeunload = function(event) {
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();
};