Worked on sorting extra conversations.
This commit is contained in:
parent
e2e56a7afd
commit
ab173e43ef
@ -151,10 +151,38 @@ Template.chatInput.rendered = ->
|
|||||||
$('button[rel=tooltip]').tooltip()
|
$('button[rel=tooltip]').tooltip()
|
||||||
|
|
||||||
Template.extraConversations.events
|
Template.extraConversations.events
|
||||||
"click .extraConversation": (event) ->
|
"click .extraConversation": (event) ->
|
||||||
console.log "extra conversation"
|
console.log "extra conversation"
|
||||||
console.log "#{@name} #{@userId}"
|
user = @
|
||||||
# put this conversation in the 3rd position in the chat tabs collection (after public and options)
|
console.log user
|
||||||
|
console.log "#{user.name} #{user.userId}"
|
||||||
|
# put this conversation in the 3rd position in the chat tabs collection (after public and options)
|
||||||
|
# Take all the tabs and turn into an array
|
||||||
|
tabArray = chatTabs.find().fetch()
|
||||||
|
|
||||||
|
# find the index of the selected tab
|
||||||
|
index = do ->
|
||||||
|
for value, idx in tabArray
|
||||||
|
if value.userId is user.userId
|
||||||
|
selected = value
|
||||||
|
return idx
|
||||||
|
null
|
||||||
|
|
||||||
|
if index?
|
||||||
|
# take object
|
||||||
|
selected = tabArray[index]
|
||||||
|
|
||||||
|
if selected?
|
||||||
|
# remove it
|
||||||
|
tabArray.splice(index, 1)
|
||||||
|
# insert it at the 3rd index
|
||||||
|
tabArray.splice(2, 0, selected)
|
||||||
|
# clear collection
|
||||||
|
chatTabs.remove({})
|
||||||
|
|
||||||
|
# store entire array back into the collection
|
||||||
|
for value in tabArray
|
||||||
|
chatTabs.insert value
|
||||||
|
|
||||||
Template.extraConversations.helpers
|
Template.extraConversations.helpers
|
||||||
getExtraConversations: ->
|
getExtraConversations: ->
|
||||||
@ -238,27 +266,23 @@ Template.tabButtons.events
|
|||||||
|
|
||||||
Template.tabButtons.helpers
|
Template.tabButtons.helpers
|
||||||
makeTabButton: -> # create tab button for private chat or other such as options
|
makeTabButton: -> # create tab button for private chat or other such as options
|
||||||
safeClass = @class.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
safeClass = safeString(@class)
|
||||||
safeName = @name.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
safeName = safeString(@name)
|
||||||
|
|
||||||
button = ''
|
button = ''
|
||||||
button += '<li class=\"'
|
button += '<li class=\"'
|
||||||
button += 'active ' if getInSession("inChatWith") is @userId
|
button += 'active ' if getInSession("inChatWith") is @userId
|
||||||
button += 'gotUnreadMail ' if @gotMail and getInSession("displayChatNotifications")
|
|
||||||
button += "tab #{safeClass}"
|
button += "tab #{safeClass}"
|
||||||
button += '\">'
|
button += '\">'
|
||||||
button += "<a href='#' data-toggle='tab' id=\"#{safeName}\">"
|
button += "<a href='#' data-toggle='tab' id=\"#{safeName}\""
|
||||||
|
button += 'class=\'gotUnreadMail\' ' if @gotMail and getInSession("displayChatNotifications")
|
||||||
|
button += ">"
|
||||||
button += "<button class=\"close closeTab\" type=\"button\"><sup><b>X</b></sup></button> " if @class is 'privateChatTab'
|
button += "<button class=\"close closeTab\" type=\"button\"><sup><b>X</b></sup></button> " if @class is 'privateChatTab'
|
||||||
button += "#{safeName}"
|
button += "#{safeName}"
|
||||||
button += '</a>'
|
button += '</a>'
|
||||||
button += '</li>'
|
button += '</li>'
|
||||||
button
|
button
|
||||||
|
|
||||||
@activateBreakLines = (str) ->
|
|
||||||
if typeof str is 'string'
|
|
||||||
res = str.replace /\\n/gim, '<br/>'
|
|
||||||
res = res.replace /\r/gim, '<br/>'
|
|
||||||
|
|
||||||
# make links received from Flash client clickable in HTML
|
# make links received from Flash client clickable in HTML
|
||||||
@toClickable = (str) ->
|
@toClickable = (str) ->
|
||||||
if typeof str is 'string'
|
if typeof str is 'string'
|
||||||
|
Loading…
Reference in New Issue
Block a user