|
|
@ -29,7 +29,7 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
|
|
|
|
Chats.scrollToBottom($('.expanded-chat ul'));
|
|
|
|
Chats.scrollToBottom($('.expanded-chat ul'));
|
|
|
|
|
|
|
|
|
|
|
|
Chats.initialised = true;
|
|
|
|
Chats.initialised = true;
|
|
|
|
|
|
|
|
|
|
|
|
Chats.handleSearch();
|
|
|
|
Chats.handleSearch();
|
|
|
|
|
|
|
|
|
|
|
|
if (ajaxify.data.hasOwnProperty('roomId')) {
|
|
|
|
if (ajaxify.data.hasOwnProperty('roomId')) {
|
|
|
@ -535,71 +535,70 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
|
|
|
|
callback();
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Chats.handleSearch = function() {
|
|
|
|
Chats.handleSearch = function() {
|
|
|
|
var timeoutId = 0;
|
|
|
|
var timeoutId = 0;
|
|
|
|
|
|
|
|
|
|
|
|
components.get('chat/search').on('keyup', function() {
|
|
|
|
components.get('chat/search').on('keyup', function() {
|
|
|
|
if (timeoutId) {
|
|
|
|
if (timeoutId) {
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
timeoutId = 0;
|
|
|
|
timeoutId = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
timeoutId = setTimeout(doSearch, 250);
|
|
|
|
timeoutId = setTimeout(doSearch, 250);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function doSearch() {
|
|
|
|
function doSearch() {
|
|
|
|
var username = components.get('chat/search').val();
|
|
|
|
var username = components.get('chat/search').val();
|
|
|
|
var chatsListEl = $('[component="chat/search/list"]');
|
|
|
|
var chatsListEl = $('[component="chat/search/list"]');
|
|
|
|
|
|
|
|
|
|
|
|
if (!username) {
|
|
|
|
if (!username) {
|
|
|
|
return chatsListEl.empty();
|
|
|
|
return chatsListEl.empty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit('user.search', {
|
|
|
|
socket.emit('user.search', {
|
|
|
|
query: username,
|
|
|
|
query: username,
|
|
|
|
searchBy: 'username'
|
|
|
|
searchBy: 'username'
|
|
|
|
}, function(err, data) {
|
|
|
|
}, function(err, data) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return app.alertError(err.message);
|
|
|
|
return app.alertError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
chatsListEl.empty();
|
|
|
|
chatsListEl.empty();
|
|
|
|
|
|
|
|
|
|
|
|
if (data.users.length === 0) {
|
|
|
|
if (data.users.length === 0) {
|
|
|
|
chatsListEl.translateHtml('<li><div><span>[[users:no-users-found]]</span></div></li>');
|
|
|
|
return chatsListEl.translateHtml('<li><div><span>[[users:no-users-found]]</span></div></li>');
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
data.users.forEach(function(userObj) {
|
|
|
|
|
|
|
|
function createUserImage() {
|
|
|
|
data.users.forEach(function(userObj) {
|
|
|
|
return (userObj.picture ?
|
|
|
|
function createUserImage() {
|
|
|
|
'<img src="' + userObj.picture + '" title="' + userObj.username +'" />' :
|
|
|
|
return (userObj.picture ?
|
|
|
|
'<div class="user-icon" style="background-color: ' + userObj['icon:bgColor'] + '">' + userObj['icon:text'] + '</div>') +
|
|
|
|
'<img src="' + userObj.picture + '" title="' + userObj.username +'" />' :
|
|
|
|
'<i class="fa fa-circle status ' + userObj.status + '"></i> ' + userObj.username;
|
|
|
|
'<div class="user-icon" style="background-color: ' + userObj['icon:bgColor'] + '">' + userObj['icon:text'] + '</div>') +
|
|
|
|
}
|
|
|
|
'<i class="fa fa-circle status ' + userObj.status + '"></i> ' + userObj.username;
|
|
|
|
|
|
|
|
}
|
|
|
|
var chatEl = $('<li component="chat/search/user" />')
|
|
|
|
|
|
|
|
|
|
|
|
var chatEl = $('<li component="chat/search/user" />')
|
|
|
|
.attr('data-uid', userObj.uid)
|
|
|
|
.attr('data-uid', userObj.uid)
|
|
|
|
.appendTo(chatsListEl);
|
|
|
|
.appendTo(chatsListEl);
|
|
|
|
|
|
|
|
|
|
|
|
chatEl.append(createUserImage());
|
|
|
|
chatEl.append(createUserImage());
|
|
|
|
|
|
|
|
|
|
|
|
chatEl.click(function() {
|
|
|
|
chatEl.on('click', function() {
|
|
|
|
socket.emit('modules.chats.hasPrivateChat', userObj.uid, function(err, roomId) {
|
|
|
|
socket.emit('modules.chats.hasPrivateChat', userObj.uid, function(err, roomId) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return app.alertError(err.message);
|
|
|
|
return app.alertError(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (roomId) {
|
|
|
|
if (roomId) {
|
|
|
|
ajaxify.go('chats/' + roomId);
|
|
|
|
ajaxify.go('chats/' + roomId);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
app.newChat(userObj.uid);
|
|
|
|
app.newChat(userObj.uid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return Chats;
|
|
|
|
return Chats;
|
|
|
|
});
|
|
|
|
});
|
|
|
|