|
|
|
@ -98,7 +98,11 @@ define('forum/chats', [
|
|
|
|
|
}
|
|
|
|
|
loading = true;
|
|
|
|
|
var start = parseInt($('.chat-content').children('[data-index]').first().attr('data-index'), 10) + 1;
|
|
|
|
|
socket.emit('modules.chats.getMessages', { roomId: roomId, uid: uid, start: start }, function (err, data) {
|
|
|
|
|
socket.emit('modules.chats.getMessages', {
|
|
|
|
|
roomId: roomId,
|
|
|
|
|
uid: uid,
|
|
|
|
|
start: start,
|
|
|
|
|
}, function (err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
@ -122,7 +126,7 @@ define('forum/chats', [
|
|
|
|
|
Chats.addEditDeleteHandler = function (element, roomId) {
|
|
|
|
|
element.on('click', '[data-action="edit"]', function () {
|
|
|
|
|
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
|
|
|
|
var inputEl = components.get('chat/input');
|
|
|
|
|
var inputEl = $('[data-roomid="' + roomId + '"] [component="chat/input"]');
|
|
|
|
|
messages.prepEdit(inputEl, messageId, roomId);
|
|
|
|
|
}).on('click', '[data-action="delete"]', function () {
|
|
|
|
|
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
|
|
|
@ -170,7 +174,10 @@ define('forum/chats', [
|
|
|
|
|
if (oldName === newName) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
socket.emit('modules.chats.renameRoom', { roomId: roomId, newName: newName }, function (err) {
|
|
|
|
|
socket.emit('modules.chats.renameRoom', {
|
|
|
|
|
roomId: roomId,
|
|
|
|
|
newName: newName,
|
|
|
|
|
}, function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
@ -235,10 +242,15 @@ define('forum/chats', [
|
|
|
|
|
if (event.item === app.user.username) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
socket.emit('modules.chats.addUserToRoom', { roomId: data.roomId, username: event.item }, function (err) {
|
|
|
|
|
socket.emit('modules.chats.addUserToRoom', {
|
|
|
|
|
roomId: data.roomId,
|
|
|
|
|
username: event.item,
|
|
|
|
|
}, function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
app.alertError(err.message);
|
|
|
|
|
tagEl.tagsinput('remove', event.item, { nouser: true });
|
|
|
|
|
tagEl.tagsinput('remove', event.item, {
|
|
|
|
|
nouser: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -262,7 +274,10 @@ define('forum/chats', [
|
|
|
|
|
if (event.options && event.options.nouser) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
socket.emit('modules.chats.removeUserFromRoom', { roomId: data.roomId, username: event.item }, function (err) {
|
|
|
|
|
socket.emit('modules.chats.removeUserFromRoom', {
|
|
|
|
|
roomId: data.roomId,
|
|
|
|
|
username: event.item,
|
|
|
|
|
}, function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
@ -319,7 +334,12 @@ define('forum/chats', [
|
|
|
|
|
} else {
|
|
|
|
|
var recentEl = components.get('chat/recent');
|
|
|
|
|
templates.parse('partials/chats/recent_room', {
|
|
|
|
|
rooms: { roomId: data.roomId, lastUser: data.message.fromUser, usernames: data.message.fromUser.username, unread: true },
|
|
|
|
|
rooms: {
|
|
|
|
|
roomId: data.roomId,
|
|
|
|
|
lastUser: data.message.fromUser,
|
|
|
|
|
usernames: data.message.fromUser.username,
|
|
|
|
|
unread: true,
|
|
|
|
|
},
|
|
|
|
|
}, function (html) {
|
|
|
|
|
translator.translate(html, function (translated) {
|
|
|
|
|
recentEl.prepend(translated);
|
|
|
|
@ -341,7 +361,7 @@ define('forum/chats', [
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Chats.resizeMainWindow = function () {
|
|
|
|
|
var messagesList = $('.expanded-chat .chat-content');
|
|
|
|
|
var messagesList = $('.expanded-chat .chat-content');
|
|
|
|
|
|
|
|
|
|
if (messagesList.length) {
|
|
|
|
|
var margin = $('.expanded-chat ul').outerHeight(true) - $('.expanded-chat ul').height();
|
|
|
|
|