mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: category quick search on world page, theme version updates, #13255
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/world', ['topicList', 'sort', 'hooks', 'alerts', 'api', 'bootbox'], function (topicList, sort, hooks, alerts, api, bootbox) {
|
define('forum/world', ['topicList', 'search', 'sort', 'hooks', 'alerts', 'api', 'bootbox'], function (topicList, search, sort, hooks, alerts, api, bootbox) {
|
||||||
const World = {};
|
const World = {};
|
||||||
|
|
||||||
World.init = function () {
|
World.init = function () {
|
||||||
@@ -12,6 +12,21 @@ define('forum/world', ['topicList', 'sort', 'hooks', 'alerts', 'api', 'bootbox']
|
|||||||
handleIgnoreWatch(-1);
|
handleIgnoreWatch(-1);
|
||||||
handleHelp();
|
handleHelp();
|
||||||
|
|
||||||
|
search.enableQuickSearch({
|
||||||
|
searchElements: {
|
||||||
|
inputEl: $('[component="category-search"]'),
|
||||||
|
resultEl: $('.world .quick-search-container'),
|
||||||
|
},
|
||||||
|
searchOptions: {
|
||||||
|
in: 'categories',
|
||||||
|
},
|
||||||
|
dropdown: {
|
||||||
|
maxWidth: '400px',
|
||||||
|
maxHeight: '350px',
|
||||||
|
},
|
||||||
|
hideOnNoMatches: false,
|
||||||
|
});
|
||||||
|
|
||||||
hooks.fire('action:topics.loaded', { topics: ajaxify.data.topics });
|
hooks.fire('action:topics.loaded', { topics: ajaxify.data.topics });
|
||||||
hooks.fire('action:category.loaded', { cid: ajaxify.data.cid });
|
hooks.fire('action:category.loaded', { cid: ajaxify.data.cid });
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -132,6 +132,27 @@ define('search', [
|
|||||||
options.searchOptions.searchOnly = 1;
|
options.searchOptions.searchOnly = 1;
|
||||||
Search.api(options.searchOptions, function (data) {
|
Search.api(options.searchOptions, function (data) {
|
||||||
quickSearchResults.find('.loading-indicator').addClass('hidden');
|
quickSearchResults.find('.loading-indicator').addClass('hidden');
|
||||||
|
|
||||||
|
if (options.searchOptions.in === 'categories') {
|
||||||
|
if (!data.categories || (options.hideOnNoMatches && !data.categories.length)) {
|
||||||
|
return quickSearchResults.addClass('hidden').find('.quick-search-results-container').html('');
|
||||||
|
}
|
||||||
|
|
||||||
|
data.dropdown = { maxWidth: '400px', maxHeight: '500px', ...options.dropdown };
|
||||||
|
app.parseAndTranslate('partials/quick-category-search-results', data, (html) => {
|
||||||
|
if (html.length) {
|
||||||
|
html.find('.timeago').timeago();
|
||||||
|
}
|
||||||
|
quickSearchResults.toggleClass('hidden', !html.length || !inputEl.is(':focus'))
|
||||||
|
.find('.quick-search-results-container')
|
||||||
|
.html(html.length ? html : '');
|
||||||
|
|
||||||
|
hooks.fire('action:search.quick.complete', {
|
||||||
|
data: data,
|
||||||
|
options: options,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
if (!data.posts || (options.hideOnNoMatches && !data.posts.length)) {
|
if (!data.posts || (options.hideOnNoMatches && !data.posts.length)) {
|
||||||
return quickSearchResults.addClass('hidden').find('.quick-search-results-container').html('');
|
return quickSearchResults.addClass('hidden').find('.quick-search-results-container').html('');
|
||||||
}
|
}
|
||||||
@@ -160,6 +181,7 @@ define('search', [
|
|||||||
options: options,
|
options: options,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user