diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 6614931..7e90398 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -16,6 +16,7 @@ TimWolla.WCF ?= {} title: document.title messageTemplate: null newMessageCount: null + events: { newMessage: $.Callbacks() } init: () -> @bindEvents() @refreshRoomList() @@ -175,6 +176,8 @@ TimWolla.WCF ?= {} ### handleMessages: (messages) -> for message in messages + @events.newMessage.fire message + output = @messageTemplate.fetch message li = $ '
' li.addClass 'chatMessage chatMessage'+message.type diff --git a/template/chat.tpl b/template/chat.tpl index 2859cee..6436d19 100644 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -182,7 +182,9 @@ animations: {CHAT_ANIMATIONS}, maxTextLength: {CHAT_LENGTH} } + {event name='shouldInit'} TimWolla.WCF.Chat.init(); + {event name='didInit'} TimWolla.WCF.Chat.handleMessages([ {implode from=$newestMessages item='message'} {@$message->jsonify()}