1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-08-13 17:03:51 -04:00

Move focus check

This commit is contained in:
Lance Stout 2013-09-17 11:25:33 -07:00
parent 6052aca7b2
commit a772ccb57c

View File

@ -24,20 +24,6 @@ module.exports = {
window.location = '/login'; 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); config = JSON.parse(config);
_.extend(this, Backbone.Events); _.extend(this, Backbone.Events);
@ -58,6 +44,20 @@ module.exports = {
function (cb) { function (cb) {
window.me = new MeModel(); 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); self.api = window.client = XMPP.createClient(config);
xmppEventHandlers(self.api, self); xmppEventHandlers(self.api, self);