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

TimWolla.WCF.Chat.notify is added as event

And we notify only when the window is not focused and notifications are active
This commit is contained in:
Tim Düsterhus 2012-01-21 22:49:15 +01:00
parent c2745de23b
commit 48531785a9

View File

@ -21,9 +21,11 @@ TimWolla.WCF ?= {}
init: () -> init: () ->
console.log('[TimWolla.WCF.Chat] Initializing'); console.log('[TimWolla.WCF.Chat] Initializing');
@bindEvents() @bindEvents()
@refreshRoomList() @events.newMessage.add $.proxy @notify, @
new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, @), 60e3 new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, @), 60e3
new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1000 new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1000
@refreshRoomList()
@getMessages() @getMessages()
console.log '[TimWolla.WCF.Chat] Finished initializing' console.log '[TimWolla.WCF.Chat] Finished initializing'
@ -171,7 +173,6 @@ TimWolla.WCF ?= {}
handleMessages: (messages) -> handleMessages: (messages) ->
for message in messages for message in messages
@events.newMessage.fire message @events.newMessage.fire message
@notify message
output = @messageTemplate.fetch message output = @messageTemplate.fetch message
li = $ '<li></li>' li = $ '<li></li>'
@ -246,7 +247,7 @@ TimWolla.WCF ?= {}
# @param object message # @param object message
### ###
notify: (message) -> notify: (message) ->
#return if (@isActive or $('#chatNotify').data('status') is 0) return if (@isActive or $('#chatNotify').data('status') is 0)
@newMessageCount++ @newMessageCount++
document.title = @newMessageCount + ' ' + WCF.Language.get('wcf.chat.newMessages') + ' - ' + @titleTemplate.fetch({ title: $('#chatRoomList .activeMenuItem a').text() }) document.title = @newMessageCount + ' ' + WCF.Language.get('wcf.chat.newMessages') + ' - ' + @titleTemplate.fetch({ title: $('#chatRoomList .activeMenuItem a').text() })