Move focus check

This commit is contained in:
Lance Stout 2013-09-17 11:25:33 -07:00
parent 6052aca7b2
commit a772ccb57c
1 changed files with 14 additions and 14 deletions

View File

@ -24,20 +24,6 @@ module.exports = {
window.location = '/login';
}
me.hasFocus = false;
$(window).blur(function () {
me.hasFocus = false;
});
$(window).focus(function () {
me.hasFocus = true;
});
window.onbeforeunload = function () {
if (client.sessionStarted) {
client.disconnect();
return "End active session?";
}
};
config = JSON.parse(config);
_.extend(this, Backbone.Events);
@ -58,6 +44,20 @@ module.exports = {
function (cb) {
window.me = new MeModel();
me.hasFocus = false;
$(window).blur(function () {
me.hasFocus = false;
});
$(window).focus(function () {
me.hasFocus = true;
});
window.onbeforeunload = function () {
if (client.sessionStarted) {
client.disconnect();
return "End active session?";
}
};
self.api = window.client = XMPP.createClient(config);
xmppEventHandlers(self.api, self);