From 239666d2ef6d8affbdca07a8ec355507d6d9b97d Mon Sep 17 00:00:00 2001 From: perroned Date: Thu, 10 Jul 2014 07:36:29 -0700 Subject: [PATCH] Trying to fix up, still a big mess --- .../client/stylesheets/chat.less | 2 +- .../client/views/chat/chat_bar.coffee | 26 +++++++------------ labs/meteor-client/collections/chat.coffee | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/labs/meteor-client/client/stylesheets/chat.less b/labs/meteor-client/client/stylesheets/chat.less index 3524632a8f..4f45617f63 100755 --- a/labs/meteor-client/client/stylesheets/chat.less +++ b/labs/meteor-client/client/stylesheets/chat.less @@ -2,7 +2,7 @@ position:absolute; right: 0; top: 65px; - width:20%; + width:30%; background: #fff; /*z-index: @z-index-chat;*/ overflow: hidden; diff --git a/labs/meteor-client/client/views/chat/chat_bar.coffee b/labs/meteor-client/client/views/chat/chat_bar.coffee index aa696106c3..3a6e2aad6f 100755 --- a/labs/meteor-client/client/views/chat/chat_bar.coffee +++ b/labs/meteor-client/client/views/chat/chat_bar.coffee @@ -43,19 +43,18 @@ Template.tabButtons.events Meteor.call 'invalidateAllTabs', Session.get('userId'), false console.log @name toUpdate = Meteor.ChatTabs.findOne({name:@name}) - Meteor.ChatTabs.update({_id: toUpdate._id}, {$set: 'isActive':true}) + if toUpdate? then Meteor.ChatTabs.update({_id: toUpdate._id}, {$set: 'isActive':true}) 'click .close': (event) -> # user closes private chat toRemove = Meteor.ChatTabs.findOne({name:@name}) - if toRemove then Meteor.ChatTabs.remove({_id: toRemove._id}) # should probably delete chat history here too? - Session.set 'inChatWith', "PUBLIC_CHAT" # switch over to public chat - Meteor.call 'invalidateAllTabs', Session.get('userId'), true - # only set public active if they click to remove whats being viewed - # if $(event.target.parentElement.parentElement).hasClass('active') - # $(".publicChatTab").addClass("active") - - # # # safety checking, make public active by default if nothing is active - # if not $('.tab').hasClass('active') then $(".publicChatTab").addClass("active") + if toRemove? then Meteor.ChatTabs.remove({_id: toRemove._id}) # should probably delete chat history here too? + + Session.set 'display_chatPane', true + Session.set 'inChatWith', 'PUBLIC_CHAT' + Meteor.call 'invalidateAllTabs', Session.get('userId'), false + toUpdate = Meteor.ChatTabs.findOne({name:"Public"}) + Meteor.ChatTabs.update({_id: toUpdate._id}, {$set: 'isActive':true}) + event.stopPropogation() Template.chatInput.events @@ -107,6 +106,7 @@ Template.optionsBar.events Meteor.ChatTabs.insert({belongsTo: currUserId, name: @user.name, isActive: true, class: "privateChatTab", 'userId': @userId}) # Give tab to recipient to notify them Meteor.ChatTabs.insert({belongsTo: @userId, name: getUsersName(), isActive: false, class: "privateChatTab", 'userId': currUserId}) + Session.set 'display_chatPane', true Session.set "inChatWith", @userId # $('.tab').removeClass('active') # Todo: @@ -131,12 +131,6 @@ Template.tabButtons.helpers button += 'class="' button += 'active ' if @isActive button += "#{@class} tab\">#{@name}" - - if @isActive - button += "(active)" - else - button += "(not active)" - button += ' ' if @name isnt 'Public' and @name isnt 'Options' button += '' console.log "and here it is the button" diff --git a/labs/meteor-client/collections/chat.coffee b/labs/meteor-client/collections/chat.coffee index 5c58c0abfd..725e3d13c1 100755 --- a/labs/meteor-client/collections/chat.coffee +++ b/labs/meteor-client/collections/chat.coffee @@ -27,5 +27,5 @@ Meteor.methods if setFirst # able to specify the first to be active console.log "setting first tab as active" - firstRecord = Meteor.ChatTabs.findOne({'belongsTo':userId}) + firstRecord = Meteor.ChatTabs.findOne({'belongsTo':userId, name:"Public"}) Meteor.ChatTabs.update({_id: firstRecord._id}, {$set: isActive:true})