Defer socket setup until initialization and on document ready.
Code at the top level of a module should be related to definition only. Things that execute code should be inside of initialization methods. All evidence suggests that the binding to `window.onload` was arbitrary, and that this can be done as soon as the document is ready with no ill-effects.pull/404/head
parent
3fb62956b9
commit
b1d871d0fd
|
@ -20,11 +20,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$(window).bind("load", function()
|
||||
{
|
||||
getCollabClient.windowLoaded = true;
|
||||
});
|
||||
|
||||
var chat = require('/chat').chat;
|
||||
|
||||
// Dependency fill on init. This exists for `pad.socket` only.
|
||||
|
@ -268,19 +263,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
}*/
|
||||
}
|
||||
|
||||
function setUpSocketWhenWindowLoaded()
|
||||
{
|
||||
if (getCollabClient.windowLoaded)
|
||||
{
|
||||
setUpSocket();
|
||||
}
|
||||
else
|
||||
{
|
||||
setTimeout(setUpSocketWhenWindowLoaded, 200);
|
||||
}
|
||||
}
|
||||
setTimeout(setUpSocketWhenWindowLoaded, 0);
|
||||
|
||||
var hiccupCount = 0;
|
||||
|
||||
function handleCometHiccup(params)
|
||||
|
@ -654,8 +636,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
}, 0);
|
||||
}
|
||||
|
||||
var self;
|
||||
return (self = {
|
||||
var self = {
|
||||
setOnUserJoin: function(cb)
|
||||
{
|
||||
callbacks.onUserJoin = cb;
|
||||
|
@ -698,7 +679,10 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
callWhenNotCommitting: callWhenNotCommitting,
|
||||
addHistoricalAuthors: tellAceAboutHistoricalAuthors,
|
||||
setChannelState: setChannelState
|
||||
});
|
||||
};
|
||||
|
||||
$(document).ready(setUpSocket);
|
||||
return self;
|
||||
}
|
||||
|
||||
function selectElementContents(elem)
|
||||
|
|
Loading…
Reference in New Issue