mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
a11y: improve search box #821
This commit is contained in:
parent
8f135335f3
commit
2c8cf85ea1
5 changed files with 29 additions and 23 deletions
|
@ -5,6 +5,7 @@
|
||||||
</header>
|
</header>
|
||||||
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
|
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
|
||||||
|
|
||||||
|
<search>
|
||||||
<form action="javascript:triggerSearch()">
|
<form action="javascript:triggerSearch()">
|
||||||
<div class="searchform">
|
<div class="searchform">
|
||||||
<label class="a11y-only" for="R-search-by-detail">{{ T "Search" }}</label>
|
<label class="a11y-only" for="R-search-by-detail">{{ T "Search" }}</label>
|
||||||
|
@ -18,6 +19,7 @@
|
||||||
)}}
|
)}}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</search>
|
||||||
<div class="searchhint">
|
<div class="searchhint">
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
{{- $link = partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}
|
{{- $link = partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- $c:="" }} {{ if $link }}<form action="{{ $link }}" method="get">{{ end }}<div class="searchbox default-animation">
|
<search>{{ if $link }}<form action="{{ $link }}" method="get">{{ end }}
|
||||||
|
<div class="searchbox default-animation">
|
||||||
{{ if $link }}<button class="search-detail" type="submit" title="{{ T "Search" }} (CTRL+ALT+f)">{{ end }}<i class="fas fa-search"{{ if not $link }} title="{{ T "Search" }} (CTRL+ALT+f)"{{ end }}></i>{{ if $link }}</button>{{ end }}
|
{{ if $link }}<button class="search-detail" type="submit" title="{{ T "Search" }} (CTRL+ALT+f)">{{ end }}<i class="fas fa-search"{{ if not $link }} title="{{ T "Search" }} (CTRL+ALT+f)"{{ end }}></i>{{ if $link }}</button>{{ end }}
|
||||||
<label class="a11y-only" for="R-search-by">{{ T "Search" }}</label>
|
<label class="a11y-only" for="R-search-by">{{ T "Search" }}</label>
|
||||||
<input data-search-input id="R-search-by" name="search-by" class="search-by" type="search" placeholder="{{ T "Search-placeholder" }}">
|
<input data-search-input id="R-search-by" name="search-by" class="search-by" type="search" placeholder="{{ T "Search-placeholder" }}">
|
||||||
<button class="search-clear" type="button" data-search-clear="" title="{{ T "Clear-search" }}"><i class="fas fa-times" title="{{ T "Clear-search" }}"></i></button>
|
<button class="search-clear" type="button" data-search-clear="" title="{{ T "Clear-search" }}"><i class="fas fa-times" title="{{ T "Clear-search" }}"></i></button>
|
||||||
</div>{{ if $link }}</form>{{ end }}
|
</div>
|
||||||
|
{{ if $link }}</form>{{ end }}</search>
|
||||||
{{- $assetBusting := not .Site.Params.disableAssetsBusting }}
|
{{- $assetBusting := not .Site.Params.disableAssetsBusting }}
|
||||||
{{- $pageBaseLang := replaceRE "([a-z]+).*" "${1}" .Page.Language.LanguageCode }}
|
{{- $pageBaseLang := replaceRE "([a-z]+).*" "${1}" .Page.Language.LanguageCode }}
|
||||||
{{- $contentlangs := (union (slice | append (.Site.Params.additionalContentLanguage | default slice)) (slice $pageBaseLang)) }}
|
{{- $contentlangs := (union (slice | append (.Site.Params.additionalContentLanguage | default slice)) (slice $pageBaseLang)) }}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
border-top: 0;
|
border-top: 0;
|
||||||
background: rgba( 255, 255, 255, 1 );
|
background: rgba( 255, 255, 255, 1 );
|
||||||
box-shadow: -1px 1px 3px rgba( 0, 0, 0, .1 );
|
box-shadow: -1px 1px 3px rgba( 0, 0, 0, .1 );
|
||||||
|
width: calc( 100% - 2rem );
|
||||||
|
|
||||||
/* core styles should not be changed */
|
/* core styles should not be changed */
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -93,9 +93,10 @@ var autoComplete = (function(){
|
||||||
pageXOffset = window.pageXOffset || document.documentElement.scrollLeft;
|
pageXOffset = window.pageXOffset || document.documentElement.scrollLeft;
|
||||||
pageYOffset = window.pageYOffset || document.documentElement.scrollTop;
|
pageYOffset = window.pageYOffset || document.documentElement.scrollTop;
|
||||||
}
|
}
|
||||||
that.sc.style.left = Math.round(rect.left + pageXOffset + o.offsetLeft - parentOffsetLeft) + 'px';
|
// Is this really the job of the tool or should it be defered to the user?
|
||||||
that.sc.style.top = Math.round(rect.bottom + pageYOffset + o.offsetTop - parentOffsetTop) + 'px';
|
// that.sc.style.left = Math.round(rect.left + pageXOffset + o.offsetLeft - parentOffsetLeft) + 'px';
|
||||||
that.sc.style.width = Math.round(rect.right - rect.left) + 'px'; // outerWidth
|
// that.sc.style.top = Math.round(rect.bottom + pageYOffset + o.offsetTop - parentOffsetTop) + 'px';
|
||||||
|
// that.sc.style.width = Math.round(rect.right - rect.left) + 'px'; // outerWidth
|
||||||
if (!resize) {
|
if (!resize) {
|
||||||
that.sc.style.display = 'block';
|
that.sc.style.display = 'block';
|
||||||
if (!that.sc.maxHeight) { that.sc.maxHeight = parseInt((window.getComputedStyle ? getComputedStyle(that.sc, null) : that.sc.currentStyle).maxHeight); }
|
if (!that.sc.maxHeight) { that.sc.maxHeight = parseInt((window.getComputedStyle ? getComputedStyle(that.sc, null) : that.sc.currentStyle).maxHeight); }
|
||||||
|
|
|
@ -271,7 +271,7 @@ function startSearch(){
|
||||||
|
|
||||||
var searchList = new autoComplete({
|
var searchList = new autoComplete({
|
||||||
/* selector for the search box element */
|
/* selector for the search box element */
|
||||||
selectorToInsert: '#R-header-wrapper',
|
selectorToInsert: 'search:has(.searchbox)',
|
||||||
selector: '#R-search-by',
|
selector: '#R-search-by',
|
||||||
/* source is the callback to perform the search */
|
/* source is the callback to perform the search */
|
||||||
source: function(term, response) {
|
source: function(term, response) {
|
||||||
|
|
Loading…
Reference in a new issue