From a4c3da02baac885f2b31d0cd220c20be38547f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 19 Jun 2014 20:51:48 +0200 Subject: [PATCH] Properly support message type CLEAR --- file/js/be.bastelstu.Chat.litcoffee | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/file/js/be.bastelstu.Chat.litcoffee b/file/js/be.bastelstu.Chat.litcoffee index a8c1fcd..b7a5c16 100644 --- a/file/js/be.bastelstu.Chat.litcoffee +++ b/file/js/be.bastelstu.Chat.litcoffee @@ -297,8 +297,7 @@ Clear the chat by removing every single message once the clear button is `clicke $('#timsChatClear').click (event) -> do event.preventDefault - do $('.timsChatMessageContainer.active .timsChatMessage').remove - $('.timsChatMessageContainer.active').scrollTop $('.timsChatMessageContainer.active').prop 'scrollHeight' + clearChannel openChannel Handle toggling of the toggleable buttons. @@ -619,6 +618,10 @@ Insert the given messages into the chat stream. if lastMessage.type is message.type and lastMessage.sender is message.sender and lastMessage.receiver is message.receiver and lastMessage.isInPrivateChannel is message.isInPrivateChannel createNewMessage = no + if message.type is v.config.messageTypes.CLEAR + createNewMessage = yes + clearChannel 0 + if createNewMessage message.isFollowUp = no output = v.messageTemplate.fetch @@ -1013,6 +1016,12 @@ Close private channel openPrivateChannel 0 +Clears a channel + + clearChannel = (userID) -> + do $("#timsChatMessageContainer#{userID} .timsChatMessage").remove + $("#timsChatMessageContainer#{userID}").scrollTop $("#timsChatMessageContainer#{userID}").prop 'scrollHeight' + Bind the given callback to the given event. addListener = (event, callback) ->