|
|
|
@ -13,7 +13,7 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
|
|
|
|
|
updateFormItemVisiblity(searchIn.val());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
highlightMatches(searchQuery);
|
|
|
|
|
searchModule.highlightMatches(searchQuery, $('.search-result-text p, .search-result-text.search-result-title a'));
|
|
|
|
|
|
|
|
|
|
$('#advanced-search').off('submit').on('submit', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
@ -134,39 +134,6 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function highlightMatches(searchQuery) {
|
|
|
|
|
if (!searchQuery) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
searchQuery = utils.escapeHTML(searchQuery.replace(/^"/, '').replace(/"$/, '').trim());
|
|
|
|
|
var regexStr = searchQuery.split(' ')
|
|
|
|
|
.map(function (word) { return utils.escapeRegexChars(word); })
|
|
|
|
|
.join('|');
|
|
|
|
|
var regex = new RegExp('(' + regexStr + ')', 'gi');
|
|
|
|
|
|
|
|
|
|
$('.search-result-text p, .search-result-text h4').each(function () {
|
|
|
|
|
var result = $(this);
|
|
|
|
|
var nested = [];
|
|
|
|
|
|
|
|
|
|
result.find('*').each(function () {
|
|
|
|
|
$(this).after('<!-- ' + nested.length + ' -->');
|
|
|
|
|
nested.push($('<div></div>').append($(this)));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
result.html(result.html().replace(regex, function (match, p1) {
|
|
|
|
|
return '<strong class="search-match">' + p1 + '</strong>';
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
nested.forEach(function (nestedEl, i) {
|
|
|
|
|
result.html(result.html().replace('<!-- ' + i + ' -->', function () {
|
|
|
|
|
return nestedEl.html();
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.search-result-text').find('img:not(.not-responsive)').addClass('img-responsive');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleSavePreferences() {
|
|
|
|
|
$('#save-preferences').on('click', function () {
|
|
|
|
|
storage.setItem('search-preferences', JSON.stringify(getSearchDataFromDOM()));
|
|
|
|
|