Skip to content

Commit

Permalink
show adavanced tools with JavaScript only
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Mar 28, 2018
1 parent a00078f commit 826e222
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
5 changes: 0 additions & 5 deletions inc/Ui/Search.php
Expand Up @@ -187,11 +187,6 @@ protected function isFragmentAssistanceAvailable(array $parsedQuery) {
*/
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;')
Expand Down
2 changes: 1 addition & 1 deletion inc/lang/en/lang.php
Expand Up @@ -72,7 +72,7 @@
$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';
Expand Down
16 changes: 10 additions & 6 deletions lib/scripts/search.js
Expand Up @@ -6,26 +6,30 @@ 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 () {
var $me = jQuery(this);
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();
}

Expand Down

0 comments on commit 826e222

Please sign in to comment.