1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-12 04:25:05 -05:00

Make notifications smarter with page focus test

This commit is contained in:
Lance Stout 2013-09-14 02:12:57 -07:00
parent 6e93404215
commit 4a0cb10197
4 changed files with 14 additions and 2 deletions

View File

@ -24,6 +24,14 @@ module.exports = {
window.location = '/login';
}
app.hasFocus = false;
$(window).blur(function () {
me.hasFocus = false;
});
$(window).focus(function () {
me.hasFocus = true;
});
config = JSON.parse(config);
_.extend(this, Backbone.Events);

View File

@ -159,7 +159,7 @@ module.exports = HumanModel.define({
addMessage: function (message, notify) {
message.owner = me.jid.bare;
if (notify && !this.activeContact && message.from.bare === this.jid) {
if (notify && (!this.activeContact || (this.activeContact && !app.hasFocus)) && message.from.bare === this.jid) {
this.unreadCount++;
app.notifier.show({
title: this.displayName,

View File

@ -10,6 +10,9 @@ var uuid = require('node-uuid');
module.exports = HumanModel.define({
initialize: function () {
this.bind('change:jid', this.loadContacts, this);
this.bind('change:hasFocus', function () {
this.setActiveContact(this._activeContact);
}, this);
},
session: {
jid: ['object', true],
@ -17,6 +20,7 @@ module.exports = HumanModel.define({
avatar: ['string', true, ''],
connected: ['bool', true, false],
shouldAskForAlertsPermission: ['bool', true, false],
hasFocus: ['bool', true, false],
_activeContact: ['string', true, '']
},
collections: {

View File

@ -303,7 +303,7 @@ nav.main a {
#chatInput {
position: fixed;
bottom: 0px;
left: 176px;
left: 156px;
right: 0px;
z-index: 100;
background: #ecf0f2;