Commit e779fb695a2193a4012bf077e6a337d84f269b06
1 parent
ea821930
Exists in
master
and in
27 other branches
chat: conversation loading and word-wrap
Showing
3 changed files
with
47 additions
and
41 deletions
Show diff stats
public/javascripts/application.js
| ... | ... | @@ -587,20 +587,6 @@ function display_notice(message) { |
| 587 | 587 | setTimeout(function() { $noticeBox.fadeOut('fast'); }, 5000); |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | -function open_chat_window(jid) { | |
| 591 | - jQuery('#chat').addClass('opened'); | |
| 592 | - jQuery('#chat-label').addClass('opened'); | |
| 593 | - jQuery("#chat" ).trigger('opengroup', jid); | |
| 594 | - return false; | |
| 595 | -} | |
| 596 | - | |
| 597 | -function toggle_chat_window() { | |
| 598 | - if(jQuery('#conversations .conversation').length == 0) jQuery('.buddies a').first().click(); | |
| 599 | - jQuery('#chat').toggleClass('opened'); | |
| 600 | - jQuery('#chat-label').toggleClass('opened'); | |
| 601 | - return false; | |
| 602 | -} | |
| 603 | - | |
| 604 | 590 | jQuery(function($) { |
| 605 | 591 | /* Adds a class to "opera" to the body element if Opera browser detected. |
| 606 | 592 | */ | ... | ... |
public/javascripts/chat.js
| ... | ... | @@ -534,31 +534,6 @@ jQuery(function($) { |
| 534 | 534 | Jabber.connect(); |
| 535 | 535 | }); |
| 536 | 536 | |
| 537 | - // detect when click in chat with a community or person in main window of Noosfero environment | |
| 538 | - $('#chat').bind('opengroup', function(ev, jid) { | |
| 539 | - var jid_id = Jabber.jid_to_id(jid); | |
| 540 | - var name = Jabber.name_of(jid_id); | |
| 541 | - if (jid) { | |
| 542 | - if (Strophe.getDomainFromJid(jid) == Jabber.muc_domain) { | |
| 543 | - if (Jabber.muc_supported) { | |
| 544 | - log('opening groupchat with ' + jid); | |
| 545 | - Jabber.jids[jid_id] = {jid: jid, name: name, type: 'groupchat'}; | |
| 546 | - var conversation = create_conversation_tab(name, jid_id); | |
| 547 | - Jabber.enter_room(jid); | |
| 548 | - conversation.find('.conversation').show(); | |
| 549 | - recent_messages(jid); | |
| 550 | - } | |
| 551 | - } | |
| 552 | - else { | |
| 553 | - log('opening chat with ' + jid); | |
| 554 | - var conversation = create_conversation_tab(name, jid_id); | |
| 555 | - conversation.find('.conversation').show(); | |
| 556 | - recent_messages(jid); | |
| 557 | - } | |
| 558 | - conversation.find('.input').focus(); | |
| 559 | - } | |
| 560 | - }); | |
| 561 | - | |
| 562 | 537 | $('.conversation textarea').live('keydown', function(e) { |
| 563 | 538 | if (e.keyCode == 13) { |
| 564 | 539 | var jid = $(this).attr('data-to'); |
| ... | ... | @@ -605,6 +580,51 @@ jQuery(function($) { |
| 605 | 580 | $('.conversation textarea:visible').focus(); |
| 606 | 581 | }); |
| 607 | 582 | |
| 583 | + function toggle_chat_window() { | |
| 584 | + if(jQuery('#conversations .conversation').length == 0) jQuery('.buddies a').first().click(); | |
| 585 | + jQuery('#chat').toggleClass('opened'); | |
| 586 | + jQuery('#chat-label').toggleClass('opened'); | |
| 587 | + } | |
| 588 | + | |
| 589 | + function load_conversation(jid) { | |
| 590 | + var jid_id = Jabber.jid_to_id(jid); | |
| 591 | + var name = Jabber.name_of(jid_id); | |
| 592 | + if (jid) { | |
| 593 | + if (Strophe.getDomainFromJid(jid) == Jabber.muc_domain) { | |
| 594 | + if (Jabber.muc_supported) { | |
| 595 | + log('opening groupchat with ' + jid); | |
| 596 | + Jabber.jids[jid_id] = {jid: jid, name: name, type: 'groupchat'}; | |
| 597 | + var conversation = create_conversation_tab(name, jid_id); | |
| 598 | + Jabber.enter_room(jid); | |
| 599 | + recent_messages(jid); | |
| 600 | + return conversation; | |
| 601 | + } | |
| 602 | + } | |
| 603 | + else { | |
| 604 | + log('opening chat with ' + jid); | |
| 605 | + Jabber.jids[jid_id] = {jid: jid, name: name, type: 'friendchat'}; | |
| 606 | + var conversation = create_conversation_tab(name, jid_id); | |
| 607 | + recent_messages(jid); | |
| 608 | + return conversation; | |
| 609 | + } | |
| 610 | + } | |
| 611 | + } | |
| 612 | + | |
| 613 | + function open_conversation(jid) { | |
| 614 | + var conversation = load_conversation(jid); | |
| 615 | + var jid_id = $(this).attr('id'); | |
| 616 | + | |
| 617 | + $('.conversation').hide(); | |
| 618 | + conversation.show(); | |
| 619 | + count_unread_messages(jid_id, true); | |
| 620 | + if(conversation.find('.chat-offset-container-0').length == 0) | |
| 621 | + recent_messages(Jabber.jid_of(jid_id)); | |
| 622 | + conversation.find('.input').focus(); | |
| 623 | + $('#chat').addClass('opened'); | |
| 624 | + $('#chat-label').addClass('opened'); | |
| 625 | + $.post('/chat/tab', {tab_id: jid_id}); | |
| 626 | + } | |
| 627 | + | |
| 608 | 628 | function create_conversation_tab(title, jid_id) { |
| 609 | 629 | var conversation_id = Jabber.conversation_prefix + jid_id; |
| 610 | 630 | var conversation = $('#' + conversation_id); |
| ... | ... | @@ -789,7 +809,7 @@ jQuery(function($) { |
| 789 | 809 | var options = {body: message.body, icon: avatar, tag: jid_id}; |
| 790 | 810 | console.log('Notify '+name); |
| 791 | 811 | $(notifyMe(name, options)).on('click', function(){ |
| 792 | - open_chat_window(jid); | |
| 812 | + open_conversation(jid); | |
| 793 | 813 | }); |
| 794 | 814 | $.sound.play('/sounds/receive.wav'); |
| 795 | 815 | } | ... | ... |
public/stylesheets/chat.css