mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-02 05:40:43 +01:00
feat: polish for user blocks UX
This commit is contained in:
@@ -1,16 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/account/blocks', ['forum/account/header', 'autocomplete'], function (header, autocomplete) {
|
||||
define('forum/account/blocks', ['forum/account/header'], function (header) {
|
||||
var Blocks = {};
|
||||
|
||||
Blocks.init = function () {
|
||||
header.init();
|
||||
|
||||
autocomplete.user($('#user-search'), function (ev, ui) {
|
||||
app.parseAndTranslate('account/blocks', 'edit', {
|
||||
edit: [ui.item.user],
|
||||
}, function (html) {
|
||||
$('.block-edit').html(html);
|
||||
$('#user-search').on('keyup', function () {
|
||||
var username = this.value;
|
||||
|
||||
socket.emit('user.search', {
|
||||
query: username,
|
||||
searchBy: 'username',
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
// Only show first 10 matches
|
||||
if (data.matchCount > 10) {
|
||||
data.users.length = 10;
|
||||
}
|
||||
|
||||
app.parseAndTranslate('account/blocks', 'edit', {
|
||||
edit: data.users,
|
||||
}, function (html) {
|
||||
$('.block-edit').html(html);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user