Skip to content
Snippets Groups Projects
Commit f462b777 authored by Aspectis's avatar Aspectis Committed by Dorian Merz
Browse files

refs #18784 [fid_bbi] keep search filters

* add option to keep search filters

* improve keep-filters accessibility
** Extend clickable area
** Fix focus styles
** Show tooltip on keyboard focus

* improve search input with keep-filters
** Long search strings were overlapped by the keep-filters checkbox, fixed by adding padding.
parent 5149b37e
No related merge requests found
...@@ -10,6 +10,8 @@ Book Bag = Merkliste ...@@ -10,6 +10,8 @@ Book Bag = Merkliste
Close = Schließen Close = Schließen
Close functions & filters = Funktionen & Filter schließen Close functions & filters = Funktionen & Filter schließen
FAQs = Häufige Fragen FAQs = Häufige Fragen
Filters are kept = Filter werden beibehalten
Filters are not kept = Filter werden nicht beibehalten
Find = Suchen Find = Suchen
For Subject Specialists = Für Fachreferate For Subject Specialists = Für Fachreferate
From the year = Vom Jahr From the year = Vom Jahr
......
...@@ -54,6 +54,10 @@ ...@@ -54,6 +54,10 @@
box-shadow: 0 0 0 g(.25) $shade-strong; box-shadow: 0 0 0 g(.25) $shade-strong;
} }
&.-pad-right {
padding-right: g(1.75); // space for keep-filters checkbox
}
.layout.-default & { .layout.-default & {
@media #{$bp3} { @media #{$bp3} {
border-color: #fff; border-color: #fff;
...@@ -71,6 +75,60 @@ ...@@ -71,6 +75,60 @@
} }
} }
.search_keep-filters {
margin: 0 g(.5) 0 g(-2);
position: relative;
top: g(-.25);
right: g(.25);
label {
cursor: pointer;
}
.icon {
height: g(1.5);
width: g(1.5);
padding: g(.25);
}
input {
@include hover {
~ .icon {
background: $shade;
}
~ .tooltip {
margin-right: g(.25);
opacity: 1;
}
}
}
:checked ~ .icon path {
fill: currentColor;
}
.tooltip {
span {
display: none;
+ span {
display: inline;
}
}
}
:checked ~ .tooltip {
span {
display: inline;
+ span {
display: none;
}
}
}
}
.search_links { .search_links {
margin: g(.5) 0 0; margin: g(.5) 0 0;
......
...@@ -29,12 +29,13 @@ ...@@ -29,12 +29,13 @@
} }
} }
a:focus, a,
a:hover, button {
button:focus, &:focus,
button:hover { &:hover {
.tooltip { .tooltip {
margin-right: g(.25); margin-right: g(.25);
opacity: 1; opacity: 1;
}
} }
} }
...@@ -65,23 +65,23 @@ $tabConfig = $this->searchTabs()->getTabConfig( ...@@ -65,23 +65,23 @@ $tabConfig = $this->searchTabs()->getTabConfig(
<div class="tab-content clearfix no-gutter-all"> <div class="tab-content clearfix no-gutter-all">
<?php endif; ?> <?php endif; ?>
<p class="adv_search_terms"> <p class="adv_search_terms">
<?=$this->transEsc("Your search terms")?>: <?=$this->translate('Your search terms')?>:
"<strong><?=$this->escapeHtml($this->lookfor)?></strong>" "<strong><?=$this->escapeHtml($this->lookfor)?></strong>"
</p> </p>
<ul class="adv_search_links"> <ul class="adv_search_links">
<li> <li>
<a href="<?=$this->url($advSearch)?>?edit=<?=$this->escapeHtmlAttr($this->searchId)?>"> <a href="<?=$this->url($advSearch)?>?edit=<?=$this->escapeHtmlAttr($this->searchId)?>">
<?=$this->transEsc("Edit this Advanced Search")?> <?=$this->translate('Edit this Advanced Search')?>
</a> </a>
</li> </li>
<li> <li>
<a href="<?=$this->url($advSearch) . $hiddenFilterParams?>"> <a href="<?=$this->url($advSearch) . $hiddenFilterParams?>">
<?=$this->transEsc("Start a new Advanced Search")?> <?=$this->translate('Start a new Advanced Search')?>
</a> </a>
</li> </li>
<li> <li>
<a href="<?=$this->url($searchHome) . $hiddenFilterParams?>"> <a href="<?=$this->url($searchHome) . $hiddenFilterParams?>">
<?=$this->transEsc("Start a new Basic Search")?> <?=$this->translate('Start a new Basic Search')?>
</a> </a>
</li> </li>
</ul> </ul>
...@@ -91,7 +91,7 @@ $tabConfig = $this->searchTabs()->getTabConfig( ...@@ -91,7 +91,7 @@ $tabConfig = $this->searchTabs()->getTabConfig(
</div> </div>
<?php else: ?> <?php else: ?>
<!-- TODO: Use longer placeholder on large screen, like in the mockup?--> <!-- TODO: Use longer placeholder on large screen, like in the mockup?-->
<?php $placeholder = $this->transEsc("search_terms"); ?> <?php $placeholder = $this->translate('search_terms'); ?>
<form <form
action="<?=$this->url($basicSearch)?>" action="<?=$this->url($basicSearch)?>"
autocomplete="off" autocomplete="off"
...@@ -99,9 +99,19 @@ $tabConfig = $this->searchTabs()->getTabConfig( ...@@ -99,9 +99,19 @@ $tabConfig = $this->searchTabs()->getTabConfig(
id="searchForm" id="searchForm"
name="searchForm" name="searchForm"
> >
<?php
// Modfied copy from fid_adlr
$filterDetails = $this->searchbox()->getFilterDetails(
isset($this->filterList) && is_array($this->filterList) ? $this->filterList : [],
isset($this->checkboxFilters) && is_array($this->checkboxFilters) ? $this->checkboxFilters : []
);
$filterActive = !empty($filterDetails)
|| (($tabConfig['tabs'][0]['label'] ?? '') !== ($tabConfig['selected']['label'] ?? ''));
?>
<input <input
aria-label="<?=$this->transEsc('search_terms')?>" aria-label="<?=$this->translate('search_terms')?>"
class="search_input" class="search_input <?=$filterActive ? '-pad-right' : ''?>"
data-focus-off-canvas data-focus-off-canvas
name="lookfor" name="lookfor"
onblur="this.placeholder = '<?=$placeholder?>'" onblur="this.placeholder = '<?=$placeholder?>'"
...@@ -110,11 +120,81 @@ $tabConfig = $this->searchTabs()->getTabConfig( ...@@ -110,11 +120,81 @@ $tabConfig = $this->searchTabs()->getTabConfig(
type="text" type="text"
value="<?=$this->escapeHtmlAttr($this->lookfor)?>" value="<?=$this->escapeHtmlAttr($this->lookfor)?>"
> >
<?php if ($filterActive): ?>
<?php $defaultFilterState = $options->getRetainFilterSetting() ? 'checked' : ''; ?>
<div id="searchFormKeepFilters" class="search_keep-filters">
<?php // NOTE: ID keepfilters and class searchFormKeepFilters required by JS ?>
<label>
<input id="keepfilters" type="checkbox" <?=$defaultFilterState?> class="searchFormKeepFilters">
<?=$this->icon('small/filter')?>
<div class="tooltip">
<span>
<?=$this->translate('Filters are kept')?>
</span>
<span>
<?=$this->translate('Filters are not kept')?>
</span>
</div>
</label>
</div>
<div class="hidden">
<?php foreach ($filterDetails as $current): ?>
<input
class="applied-filter"
id="<?=$this->escapeHtmlAttr($current['id'])?>"
type="checkbox"
<?=$defaultFilterState?>
name="filter[]"
value="<?=$this->escapeHtmlAttr($current['value'])?>"
>
<label for="<?=$this->escapeHtmlAttr($current['id'])?>">
<?=$this->escapeHtml($current['value'])?>
</label>
<?php endforeach; ?>
<?php if (isset($hasDefaultsApplied) && $hasDefaultsApplied): ?>
<?php
// This is a hidden element that flags whether or not default filters have been applied;
// it is intentionally unlabeled, as users are not meant to manipulate it directly.
?>
<input
class="applied-filter"
id="dfApplied"
type="checkbox"
name="dfApplied"
value="1"
<?=$defaultFilterState?>
>
<?php endif; ?>
</div>
<?php endif; ?>
<button class="search_submit" type="submit"> <button class="search_submit" type="submit">
<?=$this->icon('small/magnifier')?> <?=$this->icon('small/magnifier')?>
<?=$this->transEsc('Find')?> <?=$this->transEsc('Find')?>
</button> </button>
</form> </form>
<?php // Modfied copy from fid_adlr ?>
<script type="text/javascript">
$(document).ready(function() {
$('#keepfilters').on('click', function () {
// reset type / category filter to default: All
if ($('input[id ="keepfilters"]').prop('checked') == false) {
var typeOptions = $('input[name ="format-pre-filter"]');
for (var opt, j = 0; opt = typeOptions[j]; j++) {
if (opt.id.includes("All")) {
opt.checked = true;
} else {
opt.checked = false;
}
}
}
});
});
</script>
<?php endif; ?> <?php endif; ?>
<!-- fid_bbi: search - searchbox - END --> <!-- fid_bbi: search - searchbox - END -->
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment