added two new client-side hooks for search to allow plugins to add fields

v1.18.x
Julian Lam 8 years ago
parent e0de922ede
commit 3ddf332e0c

@ -17,7 +17,7 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
$('#advanced-search').off('submit').on('submit', function (e) {
e.preventDefault();
searchModule.query(getSearchData(), function () {
searchModule.query(getSearchDataFromDOM(), function () {
$('#search-input').val('');
});
return false;
@ -30,7 +30,7 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
fillOutForm();
};
function getSearchData() {
function getSearchDataFromDOM() {
var form = $('#advanced-search');
var searchData = {
in: $('#search-in').val(),
@ -50,6 +50,11 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
searchData.showAs = form.find('#show-as-topics').is(':checked') ? 'topics' : 'posts';
}
$(window).trigger('action:search.getSearchDataFromDOM', {
form: form,
data: searchData,
});
return searchData;
}
@ -146,7 +151,7 @@ define('forum/search', ['search', 'autocomplete', 'storage'], function (searchMo
function handleSavePreferences() {
$('#save-preferences').on('click', function () {
storage.setItem('search-preferences', JSON.stringify(getSearchData()));
storage.setItem('search-preferences', JSON.stringify(getSearchDataFromDOMFromDOM()));
app.alertSuccess('[[search:search-preferences-saved]]');
return false;
});

@ -74,6 +74,12 @@ define('search', ['navigator', 'translator', 'storage'], function (nav, translat
if (data.showAs) {
query.showAs = data.showAs;
}
$(window).trigger('action:search.createQueryString', {
query: query,
dom: data,
});
return decodeURIComponent($.param(query));
}

Loading…
Cancel
Save