v1.18.x
barisusakli 10 years ago
parent e769ebe668
commit 38874345b7

@ -315,19 +315,19 @@ var socket,
require(['chat'], function (chat) { require(['chat'], function (chat) {
chat.canMessage(touid, function(err) { chat.canMessage(touid, function(err) {
if (!err) { function loadAndCenter(chatModal) {
if (!chat.modalExists(touid)) { chat.load(chatModal.attr('UUID'));
chat.createModal(username, touid, loadAndCenter); chat.center(chatModal);
} else { }
loadAndCenter(chat.getModal(touid));
}
function loadAndCenter(chatModal) { if (err) {
chat.load(chatModal.attr('UUID')); return app.alertError(err.message);
chat.center(chatModal); }
}
if (!chat.modalExists(touid)) {
chat.createModal(username, touid, loadAndCenter);
} else { } else {
app.alertError(err.message); loadAndCenter(chat.getModal(touid));
} }
}); });
}); });

@ -115,7 +115,8 @@ define('chat', ['taskbar', 'string', 'sounds', 'forum/chats'], function(taskbar,
}); });
socket.on('event:user_status_change', function(data) { socket.on('event:user_status_change', function(data) {
updateStatus(data.status); var modal = module.getModal(data.uid);
updateStatus(modal, data.status);
}); });
}; };
@ -148,13 +149,13 @@ define('chat', ['taskbar', 'string', 'sounds', 'forum/chats'], function(taskbar,
if (err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
updateStatus(status); updateStatus(chatModal, status);
}); });
} }
function updateStatus(status) { function updateStatus(chatModal, status) {
translator.translate('[[global:' + status + ']]', function(translated) { translator.translate('[[global:' + status + ']]', function(translated) {
$('#chat-user-status').attr('class', 'fa fa-circle status ' + status) chatModal.find('#chat-user-status').attr('class', 'fa fa-circle status ' + status)
.attr('title', translated) .attr('title', translated)
.attr('data-original-title', translated); .attr('data-original-title', translated);
}); });
@ -175,6 +176,7 @@ define('chat', ['taskbar', 'string', 'sounds', 'forum/chats'], function(taskbar,
chatModal.css('position', 'fixed'); chatModal.css('position', 'fixed');
chatModal.css('zIndex', 100); chatModal.css('zIndex', 100);
chatModal.appendTo($('body')); chatModal.appendTo($('body'));
module.center(chatModal);
chatModal.draggable({ chatModal.draggable({
start:function() { start:function() {
module.bringModalToTop(chatModal); module.bringModalToTop(chatModal);
@ -268,9 +270,17 @@ define('chat', ['taskbar', 'string', 'sounds', 'forum/chats'], function(taskbar,
}; };
module.center = function(chatModal) { module.center = function(chatModal) {
chatModal.css("left", Math.max(0, (($(window).width() - $(chatModal).outerWidth()) / 2) + $(window).scrollLeft()) + "px"); var hideAfter = false;
chatModal.css("top", Math.max(0, $(window).height() / 2 - $(chatModal).outerHeight() / 2) + "px"); if (chatModal.hasClass('hide')) {
chatModal.removeClass('hide');
hideAfter = true;
}
chatModal.css('left', Math.max(0, (($(window).width() - $(chatModal).outerWidth()) / 2) + $(window).scrollLeft()) + 'px');
chatModal.css('top', Math.max(0, $(window).height() / 2 - $(chatModal).outerHeight() / 2) + 'px');
chatModal.find('#chat-message-input').focus(); chatModal.find('#chat-message-input').focus();
if (hideAfter) {
chatModal.addClass('hide');
}
return chatModal; return chatModal;
}; };
@ -280,7 +290,6 @@ define('chat', ['taskbar', 'string', 'sounds', 'forum/chats'], function(taskbar,
checkStatus(chatModal); checkStatus(chatModal);
taskbar.updateActive(uuid); taskbar.updateActive(uuid);
Chats.scrollToBottom(chatModal.find('#chat-content')); Chats.scrollToBottom(chatModal.find('#chat-content'));
module.center(chatModal);
module.bringModalToTop(chatModal); module.bringModalToTop(chatModal);
socket.emit('modules.chats.markRead', chatModal.attr('touid')); socket.emit('modules.chats.markRead', chatModal.attr('touid'));
}; };

@ -30,10 +30,7 @@ define('taskbar', function() {
module.minimize(uuid); module.minimize(uuid);
} }
}); });
}); return false;
this.taskbar.on('click', 'li a', function(e) {
e.preventDefault();
}); });
taskbar.initialized = true; taskbar.initialized = true;
@ -50,7 +47,6 @@ define('taskbar', function() {
}, },
discard: function(module, uuid) { discard: function(module, uuid) {
// Commit
var btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]'); var btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
btnEl.remove(); btnEl.remove();
taskbar.update(); taskbar.update();

Loading…
Cancel
Save