feat: make handleSearch public

v1.18.x
Barış Soner Uşaklı 5 years ago
parent 2a5fe2b8f4
commit ebe5ed22bb

@ -5,6 +5,7 @@ define('forum/users', ['translator', 'benchpress'], function (translator, Benchp
var Users = {};
var searchTimeoutID = 0;
var searchResultCount = 0;
$(window).on('action:ajaxify.start', function () {
if (searchTimeoutID) {
@ -20,7 +21,7 @@ define('forum/users', ['translator', 'benchpress'], function (translator, Benchp
$('.nav-pills li').removeClass('active').find('a[href="' + window.location.pathname + section + '"]').parent()
.addClass('active');
handleSearch();
Users.handleSearch();
handleInvite();
@ -28,7 +29,8 @@ define('forum/users', ['translator', 'benchpress'], function (translator, Benchp
socket.on('event:user_status_change', onUserStatusChange);
};
function handleSearch() {
Users.handleSearch = function (params) {
searchResultCount = params && params.resultCount;
searchTimeoutID = 0;
$('#search-user').on('keyup', function () {
@ -43,7 +45,7 @@ define('forum/users', ['translator', 'benchpress'], function (translator, Benchp
$('.search select, .search input[type="checkbox"]').on('change', function () {
doSearch();
});
}
};
function doSearch() {
$('[component="user/search/icon"]').removeClass('fa-search').addClass('fa-spinner fa-spin');
@ -103,6 +105,10 @@ define('forum/users', ['translator', 'benchpress'], function (translator, Benchp
$('.pagination-container').replaceWith(html);
});
if (searchResultCount) {
data.users = data.users.slice(0, searchResultCount);
}
Benchpress.parse('users', 'users', data, function (html) {
translator.translate(html, function (translated) {
translated = $(translated);

Loading…
Cancel
Save