1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Added title notifications

This commit is contained in:
max-m 2011-12-26 22:16:37 +01:00
parent b7b7d064ee
commit cded6e79a3

View File

@ -13,7 +13,9 @@ TimWolla.WCF ?= {}
(($) ->
TimWolla.WCF.Chat =
titleTemplate: null
title: document.title
messageTemplate: null
newMessageCount: null
init: () ->
@bindEvents()
@refreshRoomList()
@ -25,6 +27,19 @@ TimWolla.WCF ?= {}
# Binds all the events needed for Tims Chat.
###
bindEvents: () ->
@isActive = true
$(window).focus $.proxy () ->
document.title = @title
@newMessageCount = 0
clearTimeout @timeout
@isActive = true
, this
$(window).blur $.proxy () ->
@title = document.title
@isActive = false
, this
$('.smiley').click $.proxy (event) ->
@insertText ' ' + $(event.target).attr('alt') + ' '
, this
@ -137,6 +152,15 @@ TimWolla.WCF ?= {}
dataType: 'json'
type: 'POST'
success: $.proxy((data, textStatus, jqXHR) ->
if (!@isActive)
@newMessageCount += data.length
if (@newMessageCount > 0)
@timeout = setTimeout $.proxy(() ->
document.title = @newMessageCount + WCF.Language.get('wcf.chat.newMessages')
setTimeout $.proxy(() ->
document.title = @title
, this), 3000
, this), 1000
@handleMessages(data)
, this)
###