From fc561804f935538b5a64d5a7706f1ca268a7a9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 27 Dec 2011 17:07:12 +0100 Subject: [PATCH 1/2] Adding basic message-event --- file/js/TimWolla.WCF.Chat.coffee | 3 +++ 1 file changed, 3 insertions(+) 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 From d7183001f39947ca77716d24056c3a43844cf425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 27 Dec 2011 17:10:39 +0100 Subject: [PATCH 2/2] Adding shouldInit and didInit event --- template/chat.tpl | 2 ++ 1 file changed, 2 insertions(+) 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()}