mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-28 09:31:17 +01:00
feat: polish for user blocks UX
This commit is contained in:
@@ -1,16 +1,32 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/account/blocks', ['forum/account/header', 'autocomplete'], function (header, autocomplete) {
|
define('forum/account/blocks', ['forum/account/header'], function (header) {
|
||||||
var Blocks = {};
|
var Blocks = {};
|
||||||
|
|
||||||
Blocks.init = function () {
|
Blocks.init = function () {
|
||||||
header.init();
|
header.init();
|
||||||
|
|
||||||
autocomplete.user($('#user-search'), function (ev, ui) {
|
$('#user-search').on('keyup', function () {
|
||||||
app.parseAndTranslate('account/blocks', 'edit', {
|
var username = this.value;
|
||||||
edit: [ui.item.user],
|
|
||||||
}, function (html) {
|
socket.emit('user.search', {
|
||||||
$('.block-edit').html(html);
|
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