Removed all window.unload event handlers. This kind of fixes #200

This commit is contained in:
Peter 'Pita' Martischka 2012-02-27 17:33:27 +01:00
parent 0c77052698
commit d00be5b817
3 changed files with 14 additions and 22 deletions

View file

@ -4654,7 +4654,6 @@ function Ace2Inner(){
function bindTheEventHandlers() function bindTheEventHandlers()
{ {
bindEventHandler(window, "unload", teardown);
bindEventHandler(document, "keydown", handleKeyEvent); bindEventHandler(document, "keydown", handleKeyEvent);
bindEventHandler(document, "keypress", handleKeyEvent); bindEventHandler(document, "keypress", handleKeyEvent);
bindEventHandler(document, "keyup", handleKeyEvent); bindEventHandler(document, "keyup", handleKeyEvent);

View file

@ -84,13 +84,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
{} {}
}; };
$(window).bind("unload", function()
{
if (getSocket())
{
setChannelState("DISCONNECTED", "unload");
}
});
if ($.browser.mozilla) if ($.browser.mozilla)
{ {
// Prevent "escape" from taking effect and canceling a comet connection; // Prevent "escape" from taking effect and canceling a comet connection;

View file

@ -164,7 +164,8 @@ function handshake()
//connect //connect
socket = pad.socket = io.connect(url, { socket = pad.socket = io.connect(url, {
resource: resource, resource: resource,
'max reconnection attempts': 3 'max reconnection attempts': 3,
'sync disconnect on unload' : false
}); });
function sendClientReady(isReconnect) function sendClientReady(isReconnect)
@ -222,7 +223,10 @@ function handshake()
sendClientReady(true); sendClientReady(true);
}); });
socket.on('disconnect', function () { socket.on('disconnect', function (reason) {
if(reason == "booted"){
pad.collabClient.setChannelState("DISCONNECTED");
} else {
function disconnectEvent() function disconnectEvent()
{ {
pad.collabClient.setChannelState("DISCONNECTED", "reconnect_timeout"); pad.collabClient.setChannelState("DISCONNECTED", "reconnect_timeout");
@ -231,6 +235,7 @@ function handshake()
pad.collabClient.setChannelState("RECONNECTING"); pad.collabClient.setChannelState("RECONNECTING");
disconnectTimeout = setTimeout(disconnectEvent, 10000); disconnectTimeout = setTimeout(disconnectEvent, 10000);
}
}); });
var receivedClientVars = false; var receivedClientVars = false;
@ -396,11 +401,6 @@ var pad = {
getParams(); getParams();
handshake(); handshake();
}); });
$(window).unload(function()
{
pad.dispose();
});
}, },
_afterHandshake: function() _afterHandshake: function()
{ {