diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /templates/sidebar | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'templates/sidebar')
| -rw-r--r-- | templates/sidebar/search-widget.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/templates/sidebar/search-widget.php b/templates/sidebar/search-widget.php index 6d870ba..c314673 100644 --- a/templates/sidebar/search-widget.php +++ b/templates/sidebar/search-widget.php @@ -1,6 +1,7 @@ <form action="<?= URLHelper::getLink($url) ?>" method="<?= $method ?>" - <? if (isset($id)) printf('id="%s"', htmlReady($id)); ?> + <? $id = $id ?? 'form-'.md5(uniqid()) ?> + <? printf('id="%s"', htmlReady($id)) ?> <?= $onsubmit ? 'onsubmit="'.htmlReady($onsubmit).'"' : '' ?> class="sidebar-search"> <? foreach ($url_params as $key => $value): ?> @@ -8,9 +9,10 @@ <? endforeach; ?> <ul class="needles"> <? foreach ($needles as $needle): ?> + <? $hash = md5($url . '|' . $needle['name']) ?> <li <? if ($needle['quick_search'] && $needle['quick_search']->hasExtendedLayout()) echo 'class="extendedLayout" id="' . $needle['quick_search']->getId() . '_frame"'; ?>> <div class="input-group files-search"> - <label for="needle-<?= $hash = md5($url . '|' . $needle['name']) ?>" <? if ($needle['placeholder']) echo 'style="display:none;"'; ?>> + <label for="needle-<?= $hash ?>" <? if ($needle['placeholder']) echo 'class="sr-only"'; ?>> <?= htmlReady($needle['label']) ?> </label> <? if ($needle['quick_search']): ?> @@ -22,16 +24,24 @@ <? if ($needle['placeholder']) printf('placeholder="%s"', htmlReady($needle['label'])); ?> <?= arrayToHtmlAttributes($needle['attributes']) ?>> <? endif; ?> - <? if ($reset_link): ?> - <a class="reset-search" href="<?= $reset_link ?>" tabindex="0" role="button" - title="<?= _('Suche zurücksetzen') ?>"> - <?= Icon::create('decline')->asImg(20) ?> - </a> - <? endif; ?> <button type="submit" class="submit-search<?= $reset_link ? ' is-executed' : '' ?>" title="<?= _('Suche ausführen') ?>"> <?= Icon::create('search')->asImg(20) ?> </button> + <? if ($reset_link): ?> + <? if ($onsubmit) : ?> + <?= Icon::create('decline')->asInput([ + 'title' => _('Suche zurücksetzen'), + 'class' => 'reset-search', + 'onclick' => "document.getElementById('needle-".$hash."').value = ''; this.remove();" + ]) ?> + <? else : ?> + <a class="reset-search" href="<?= $reset_link ?>" tabindex="0" role="button" + title="<?= _('Suche zurücksetzen') ?>"> + <?= Icon::create('decline')->asImg(20) ?> + </a> + <? endif ?> + <? endif; ?> </li> <? endforeach; ?> </ul> |
