v1.18.x
Barış Soner Uşaklı 7 years ago
parent 7df57ba7a7
commit f0a538bd4a

@ -66,7 +66,7 @@
"mubsub-nbb": "^1.5.0", "mubsub-nbb": "^1.5.0",
"nconf": "^0.10.0", "nconf": "^0.10.0",
"nodebb-plugin-composer-default": "6.0.26", "nodebb-plugin-composer-default": "6.0.26",
"nodebb-plugin-dbsearch": "2.0.17", "nodebb-plugin-dbsearch": "2.0.18",
"nodebb-plugin-emoji": "^2.2.2", "nodebb-plugin-emoji": "^2.2.2",
"nodebb-plugin-emoji-android": "2.0.0", "nodebb-plugin-emoji-android": "2.0.0",
"nodebb-plugin-markdown": "8.4.3", "nodebb-plugin-markdown": "8.4.3",

@ -38,7 +38,7 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
searchData.term = $('#search-input').val(); searchData.term = $('#search-input').val();
if (searchData.in === 'posts' || searchData.in === 'titlesposts' || searchData.in === 'titles') { if (searchData.in === 'posts' || searchData.in === 'titlesposts' || searchData.in === 'titles') {
searchData.matchWords = form.find('#match-words-filter').val(); searchData.matchWords = form.find('#match-words-filter').val();
searchData.by = form.find('#posted-by-user').val(); searchData.by = form.find('#posted-by-user').tagsinput('items');
searchData.categories = form.find('#posted-in-categories').val(); searchData.categories = form.find('#posted-in-categories').val();
searchData.searchChildren = form.find('#search-children').is(':checked'); searchData.searchChildren = form.find('#search-children').is(':checked');
searchData.hasTags = form.find('#has-tags').tagsinput('items'); searchData.hasTags = form.find('#has-tags').tagsinput('items');
@ -85,7 +85,10 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
} }
if (formData.by) { if (formData.by) {
$('#posted-by-user').val(formData.by); formData.by = Array.isArray(formData.by) ? formData.by : [formData.by];
formData.by.forEach(function (by) {
$('#posted-by-user').tagsinput('add', by);
});
} }
if (formData.categories) { if (formData.categories) {
@ -176,7 +179,12 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
} }
function enableAutoComplete() { function enableAutoComplete() {
autocomplete.user($('#posted-by-user')); var userEl = $('#posted-by-user');
userEl.tagsinput({
confirmKeys: [13, 44],
trimValue: true,
});
autocomplete.user(userEl.siblings('.bootstrap-tagsinput').find('input'));
var tagEl = $('#has-tags'); var tagEl = $('#has-tags');
tagEl.tagsinput({ tagEl.tagsinput({
@ -184,7 +192,7 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
trimValue: true, trimValue: true,
}); });
autocomplete.tag($('#has-tags').siblings('.bootstrap-tagsinput').find('input')); autocomplete.tag(tagEl.siblings('.bootstrap-tagsinput').find('input'));
} }
return Search; return Search;

@ -12,7 +12,9 @@ define('autocomplete', function () {
open: function () { open: function () {
$(this).autocomplete('widget').css('z-index', 100005); $(this).autocomplete('widget').css('z-index', 100005);
}, },
select: onselect, select: function (event, ui) {
handleOnSelect(input, onselect, event, ui);
},
source: function (request, response) { source: function (request, response) {
socket.emit('user.search', { socket.emit('user.search', {
query: request.term, query: request.term,
@ -90,14 +92,7 @@ define('autocomplete', function () {
$(this).autocomplete('widget').css('z-index', 20000); $(this).autocomplete('widget').css('z-index', 20000);
}, },
select: function (event, ui) { select: function (event, ui) {
onselect = onselect || function () {}; handleOnSelect(input, onselect, event, ui);
var e = jQuery.Event('keypress');
e.which = 13;
e.keyCode = 13;
setTimeout(function () {
input.trigger(e);
}, 100);
onselect(event, ui);
}, },
source: function (request, response) { source: function (request, response) {
socket.emit('topics.autocompleteTags', { socket.emit('topics.autocompleteTags', {
@ -117,5 +112,16 @@ define('autocomplete', function () {
}); });
}; };
function handleOnSelect(input, onselect, event, ui) {
onselect = onselect || function () {};
var e = jQuery.Event('keypress');
e.which = 13;
e.keyCode = 13;
setTimeout(function () {
input.trigger(e);
}, 100);
onselect(event, ui);
}
return module; return module;
}); });

@ -45,7 +45,7 @@ define('search', ['navigator', 'translator', 'storage'], function (nav, translat
query.matchWords = data.matchWords; query.matchWords = data.matchWords;
} }
if (postedBy && (searchIn === 'posts' || searchIn === 'titles' || searchIn === 'titlesposts')) { if (postedBy && postedBy.length && (searchIn === 'posts' || searchIn === 'titles' || searchIn === 'titlesposts')) {
query.by = postedBy; query.by = postedBy;
} }

Loading…
Cancel
Save