From 7cb15e5e9c6d0685e8c24568a83a96375c6622b5 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Tue, 9 Jul 2013 19:41:14 +0200 Subject: [PATCH] First working draft of private channels --- file/js/be.bastelstu.Chat.litcoffee | 50 +++++++++++++++++++++++------ template/chat.tpl | 2 +- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/file/js/be.bastelstu.Chat.litcoffee b/file/js/be.bastelstu.Chat.litcoffee index faa1071..dd9a09d 100644 --- a/file/js/be.bastelstu.Chat.litcoffee +++ b/file/js/be.bastelstu.Chat.litcoffee @@ -216,8 +216,8 @@ Clear the chat by removing every single message once the clear button is `clicke $('#timsChatClear').click (event) -> event.preventDefault() - $('.timsChatMessage').remove() - $('#timsChatMessageContainer').scrollTop $('#timsChatMessageContainer').prop('scrollHeight') + $('.timsChatMessageContainer.active .timsChatMessage').remove() + $('.timsChatMessageContainer.active').scrollTop $('.timsChatMessageContainer.active').prop('scrollHeight') Handle toggling of the toggleable buttons. @@ -278,9 +278,9 @@ Scroll down when autoscroll is being activated. $('#timsChatAutoscroll').click (event) -> if $('#timsChatAutoscroll').data 'status' - $('#timsChatMessageContainer').scrollTop $('#timsChatMessageContainer').prop('scrollHeight') + $('.timsChatMessageContainer.active').scrollTop $('.timsChatMessageContainer.active').prop('scrollHeight') - $('#timsChatMessageContainer').on 'scroll', (event) -> + $('.timsChatMessageContainer.active').on 'scroll', (event) -> element = $ @ scrollTop = element.scrollTop() scrollHeight = element.prop 'scrollHeight' @@ -413,7 +413,7 @@ Prevent loading messages in parallel. Insert the given messages into the chat stream. handleMessages = (messages) -> - $('#timsChatMessageContainer').trigger 'scroll' + $('.timsChatMessageContainer.active').trigger 'scroll' for message in messages events.newMessage.fire message @@ -435,8 +435,16 @@ Insert the given messages into the chat stream. li.addClass "user#{message.sender}" li.addClass 'ownMessage' if message.sender is WCF.User.userID li.append output - - li.appendTo $ '#timsChatMessageContainer > ul' + + if message.type is parseInt v.config.messageTypes.WHISPER + if message.sender is WCF.User.userID && $.wcfIsset "timsChatMessageContainer#{message.receiver}" + li.appendTo $ "#timsChatMessageContainer#{message.receiver} > ul" + else if $.wcfIsset "timsChatMessageContainer#{message.sender}" + li.appendTo $ "#timsChatMessageContainer#{message.sender} > ul" + else + li.appendTo $ '#timsChatMessageContainer0 > ul' + else + li.appendTo $ '#timsChatMessageContainer0 > ul' else message.isFollowUp = yes output = v.messageTemplate.fetch @@ -446,7 +454,7 @@ Insert the given messages into the chat stream. $('.timsChatMessage:last-child .text').append $(output).find('.text li:last-child') lastMessage = message - $('#timsChatMessageContainer').scrollTop $('#timsChatMessageContainer').prop('scrollHeight') if $('#timsChatAutoscroll').data('status') is 1 + $('.timsChatMessageContainer.active').scrollTop $('.timsChatMessageContainer.active').prop('scrollHeight') if $('#timsChatAutoscroll').data('status') is 1 Rebuild the userlist based on the given `users`. @@ -541,7 +549,7 @@ Send out notifications for the given `message`. The number of unread messages wi notify = (message) -> if scrollUpNotifications - $('#timsChatMessageContainer').addClass 'notification' + $('.timsChatMessageContainer.active').addClass 'notification' return if isActive or $('#timsChatNotify').data('status') is 0 @@ -654,6 +662,28 @@ Joins a room. failure: -> showError WCF.Language.get 'chat.error.join' +Open private channel + + openPrivateChannel = (userID) -> + $('.timsChatMessageContainer').removeClass 'active' + + if !$.wcfIsset "timsChatMessageContainer#{userID}" + div = $('
') + div.attr 'id', "timsChatMessageContainer#{userID}" + div.addClass 'timsChatMessageContainer' + div.addClass 'marginTop' + div.addClass 'container' + div.wrapInner '
-
+