From 3ddf332e0ceff1ffa98ef59b82383ac81086ecef Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 7 Jul 2017 15:48:01 -0400 Subject: [PATCH] added two new client-side hooks for search to allow plugins to add fields --- public/src/client/search.js | 11 ++++++++--- public/src/modules/search.js | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/public/src/client/search.js b/public/src/client/search.js index 515f7030b5..19f66daebe 100644 --- a/public/src/client/search.js +++ b/public/src/client/search.js @@ -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; }); diff --git a/public/src/modules/search.js b/public/src/modules/search.js index 5b77ab7572..d9188e10c8 100644 --- a/public/src/modules/search.js +++ b/public/src/modules/search.js @@ -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)); }