|
|
|
@ -3,7 +3,8 @@
|
|
|
|
|
define('chat', [
|
|
|
|
|
'components',
|
|
|
|
|
'taskbar',
|
|
|
|
|
], function (components, taskbar) {
|
|
|
|
|
'translator',
|
|
|
|
|
], function (components, taskbar, translator) {
|
|
|
|
|
var module = {};
|
|
|
|
|
var newMessage = false;
|
|
|
|
|
|
|
|
|
@ -20,28 +21,34 @@ define('chat', [
|
|
|
|
|
return room.teaser;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.parseAndTranslate('partials/chats/dropdown', { rooms: rooms }, function (html) {
|
|
|
|
|
chatsListEl.find('*').not('.navigation-link').remove();
|
|
|
|
|
chatsListEl.prepend(html);
|
|
|
|
|
app.createUserTooltips(chatsListEl, 'right');
|
|
|
|
|
chatsListEl.off('click').on('click', '[data-roomid]', function (ev) {
|
|
|
|
|
if ($(ev.target).parents('.user-link').length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var roomId = $(this).attr('data-roomid');
|
|
|
|
|
if (!ajaxify.currentPage.match(/^chats\//)) {
|
|
|
|
|
app.openChat(roomId);
|
|
|
|
|
} else {
|
|
|
|
|
ajaxify.go('user/' + app.user.userslug + '/chats/' + roomId);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('[component="chats/mark-all-read"]').off('click').on('click', function () {
|
|
|
|
|
socket.emit('modules.chats.markAllRead', function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err);
|
|
|
|
|
translator.toggleTimeagoShorthand(function () {
|
|
|
|
|
for (var i = 0; i < rooms.length; i += 1) {
|
|
|
|
|
rooms[i].teaser.timeago = $.timeago(new Date(parseInt(rooms[i].teaser.timestamp, 10)));
|
|
|
|
|
}
|
|
|
|
|
translator.toggleTimeagoShorthand();
|
|
|
|
|
app.parseAndTranslate('partials/chats/dropdown', { rooms: rooms }, function (html) {
|
|
|
|
|
chatsListEl.find('*').not('.navigation-link').remove();
|
|
|
|
|
chatsListEl.prepend(html);
|
|
|
|
|
app.createUserTooltips(chatsListEl, 'right');
|
|
|
|
|
chatsListEl.off('click').on('click', '[data-roomid]', function (ev) {
|
|
|
|
|
if ($(ev.target).parents('.user-link').length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var roomId = $(this).attr('data-roomid');
|
|
|
|
|
if (!ajaxify.currentPage.match(/^chats\//)) {
|
|
|
|
|
app.openChat(roomId);
|
|
|
|
|
} else {
|
|
|
|
|
ajaxify.go('user/' + app.user.userslug + '/chats/' + roomId);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('[component="chats/mark-all-read"]').off('click').on('click', function () {
|
|
|
|
|
socket.emit('modules.chats.markAllRead', function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|