diff --git a/inc/Ui/Search.php b/inc/Ui/Search.php index 9535c3640e541e89d6e0bee6e6f746dd0b9a500b..47171902fe09035ab0648286be39538055534c2b 100644 --- a/inc/Ui/Search.php +++ b/inc/Ui/Search.php @@ -187,11 +187,6 @@ class Search extends Ui */ protected function addSearchAssistanceElements(Form $searchForm) { - global $lang; - $searchForm->addButton('toggleAssistant', $lang['search_toggle_tools']) - ->attr('type', 'button') - ->addClass('toggleAssistant'); - $searchForm->addTagOpen('div') ->addClass('advancedOptions') ->attr('style', 'display: none;') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index b60cdd0a995b4f7d4592cc483c998fff0205da5f..4d11bac08d924ffb08c19d0d17d90606da555b98 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -72,7 +72,7 @@ $lang['nosecedit'] = 'The page was changed in the meantime, section $lang['searchcreatepage'] = 'If you didn\'t find what you were looking for, you can create or edit the page %s, named after your query.'; $lang['search_fullresults'] = 'Fulltext results'; -$lang['search_toggle_tools'] = 'Toggle search tools'; +$lang['js']['search_toggle_tools'] = 'Toggle Search Tools'; $lang['search_exact_match'] = 'Exact match'; $lang['search_starts_with'] = 'Starts with'; $lang['search_ends_with'] = 'Ends with'; diff --git a/lib/scripts/search.js b/lib/scripts/search.js index c6171256fd242569d8d3633f2fe2109da9eca97b..363170825a2d3090cfdb560e28fb6f164c0e3073 100644 --- a/lib/scripts/search.js +++ b/lib/scripts/search.js @@ -6,10 +6,13 @@ jQuery(function () { return; } - const $toggleAssistanceButton = $searchForm.find('button.toggleAssistant'); - if (!$toggleAssistanceButton.length) { - return; - } + const $toggleAssistanceButton = jQuery('<button>') + .addClass('toggleAssistant') + .attr('type', 'button') + .attr('aria-expanded', 'false') + .text(LANG.search_toggle_tools) + .prependTo($searchForm.find('fieldset')) + ; $toggleAssistanceButton.on('click', function () { jQuery('.advancedOptions').toggle(0, function () { @@ -17,15 +20,16 @@ jQuery(function () { if ($me.attr('aria-hidden')) { $me.removeAttr('aria-hidden'); $toggleAssistanceButton.attr('aria-expanded', 'true'); + DokuCookie.setValue('sa', 'on'); } else { $me.attr('aria-hidden', 'true'); $toggleAssistanceButton.attr('aria-expanded', 'false'); + DokuCookie.setValue('sa', 'off'); } }); - DokuCookie.setValue('sa', !DokuCookie.getValue('sa')); }); - if (DokuCookie.getValue('sa')) { + if (DokuCookie.getValue('sa') === 'on') { $toggleAssistanceButton.click(); }