chat windows added to taskbar

v1.18.x
Baris Usakli 12 years ago
parent ffbd777642
commit 38e1b39c2d

@ -246,6 +246,20 @@
}); });
socket.on('chatMessage', function(data){
var username = data.username;
var fromuid = data.fromuid;
var message = data.message;
require(['chat'], function(chat) {
var chatModal = chat.createModalIfDoesntExist(username, fromuid);
chatModal.show();
chat.bringModalToTop(chatModal);
chat.appendChatMessage(chatModal, message);
});
});
ajaxify.register_events([ ajaxify.register_events([
'event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room', 'event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room',

@ -20,16 +20,19 @@ define(['taskbar'], function(taskbar) {
if(!chatModal.length) { if(!chatModal.length) {
var chatModal = $('#chat-modal').clone(); var chatModal = $('#chat-modal').clone();
chatModal.attr('id','chat-modal-'+touid); chatModal.attr('id','chat-modal-'+touid);
var uuid = utils.generateUUID();
chatModal.attr('UUID', uuid);
chatModal.appendTo($('body')); chatModal.appendTo($('body'));
chatModal.draggable({ chatModal.draggable({
start:function(){ start:function(){
bringModalToTop(chatModal); module.bringModalToTop(chatModal);
} }
}); });
chatModal.find('#chat-with-name').html(username); chatModal.find('#chat-with-name').html(username);
chatModal.find('.close').on('click',function(e){ chatModal.find('.close').on('click',function(e){
chatModal.hide(); chatModal.hide();
taskbar.discard('chat', uuid);
}); });
chatModal.on('click', function(e){ chatModal.on('click', function(e){
@ -37,11 +40,25 @@ define(['taskbar'], function(taskbar) {
}); });
addSendHandler(chatModal, touid); addSendHandler(chatModal, touid);
taskbar.push('chat', uuid, {title:'chat with '+username});
} }
return chatModal; return chatModal;
} }
module.load = function(uuid) {
var chatModal = $('div[UUID="'+uuid+'"]');
chatModal.show();
module.bringModalToTop(chatModal);
}
module.minimize = function(uuid) {
var chatModal = $('div[UUID="'+uuid+'"]');
chatModal.hide();
taskbar.minimize('chat', uuid);
}
function addSendHandler(chatModal, touid) { function addSendHandler(chatModal, touid) {
chatModal.find('#chat-message-input').off('keypress'); chatModal.find('#chat-message-input').off('keypress');
chatModal.find('#chat-message-input').on('keypress', function(e) { chatModal.find('#chat-message-input').on('keypress', function(e) {
@ -63,23 +80,12 @@ define(['taskbar'], function(taskbar) {
msg = msg +'\n'; msg = msg +'\n';
socket.emit('sendChatMessage', { touid:touid, message:msg}); socket.emit('sendChatMessage', { touid:touid, message:msg});
chatModal.find('#chat-message-input').val(''); chatModal.find('#chat-message-input').val('');
appendChatMessage(chatModal, 'You : ' + msg); module.appendChatMessage(chatModal, 'You : ' + msg);
} }
} }
socket.on('chatMessage', function(data){
var username = data.username;
var fromuid = data.fromuid;
var message = data.message;
var chatModal = module.createModalIfDoesntExist(username, fromuid);
chatModal.show();
module.bringModalToTop(chatModal);
appendChatMessage(chatModal, message)
});
function appendChatMessage(chatModal, message){ module.appendChatMessage = function(chatModal, message){
var chatContent = chatModal.find('#chat-content'); var chatContent = chatModal.find('#chat-content');
chatContent.append(message); chatContent.append(message);
chatContent.scrollTop( chatContent.scrollTop(

Loading…
Cancel
Save