found when a given chat tab should be flashing

This commit is contained in:
Anton Georgiev 2014-09-24 00:18:27 +00:00
parent 18c876b69c
commit 5876d5ef9a
3 changed files with 22 additions and 4 deletions

View File

@ -169,11 +169,12 @@ Handlebars.registerHelper "visibility", (section) ->
newObj = {
userId: u.userId
name: u.user.name
gotMail: false
class: "privateChatTab"
}
tabs = [
{userId: "PUBLIC_CHAT", name: "Public", class: "publicChatTab"},
{userId: "OPTIONS", name: "Options", class: "optionsChatTab"}
{userId: "PUBLIC_CHAT", name: "Public", gotMail: false, class: "publicChatTab"},
{userId: "OPTIONS", name: "Options", gotMail: false, class: "optionsChatTab"}
].concat privTabs
@setInSession = (k, v) -> SessionAmplify.set k, v

View File

@ -75,7 +75,6 @@ Meteor.startup ->
setInSession "display_chatbar", true
setInSession "display_whiteboard", true
setInSession "display_chatPane", true
setInSession 'inChatWith', "PUBLIC_CHAT"
setInSession "joinedAt", getTime()
setInSession "isSharingAudio", false
setInSession "inChatWith", 'PUBLIC_CHAT'

View File

@ -107,9 +107,27 @@ Template.chatbar.helpers
msgs
markNewAsUnread: ->
#if the current tab is not the same as the tab we just published in
Meteor.Chat.find({}).observe({
added: (chatMessage) =>
destinationTab = ->
if chatMessage.message?.chat_type is "PUBLIC_CHAT"
"PUBLIC_CHAT"
else
chatMessage.message?.from_userid
console.log "destination=" + destinationTab()
if destinationTab() isnt getInSession "inChatWith"
console.log "there should be flashing on:" + destinationTab()
#currentTab = document.getElementsByClassName("active")[0].getElementsByTagName("a")[0].id #TODO how can I simplify this?!?
})
# When chatbar gets rendered, scroll to the bottom
Template.chatbar.rendered = ->
Template.chatbar.markNewAsUnread()
$('#chatbody').scrollTop($('#chatbody')[0]?.scrollHeight)
false
# Scrolls the message container to the bottom. The number of pixels to scroll down is the height of the container
@ -178,7 +196,7 @@ Template.tabButtons.helpers
button = '<li '
button += 'class="'
button += 'active ' if getInSession("inChatWith") is @userId
button += "tab #{safeClass}\"><a href=\"#\" data-toggle=\"tab\">#{safeName}"
button += "tab #{safeClass}\"><a href=\"#\" data-toggle=\"tab\" id=\"#{safeName}\" \>#{safeName}"
button += '&nbsp;<button class="close closeTab" type="button" >×</button>' if @class is 'privateChatTab'
button += '</a></li>'
button