Skip to content

Commit 14f03fe

Browse files
authored
Merge branch '6-dev' into add-extensions
2 parents a63040b + 3edfad9 commit 14f03fe

File tree

6 files changed

+137
-14
lines changed

6 files changed

+137
-14
lines changed

docs/_static/custom.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,25 @@ div.admonition.admonition-todo>.admonition-title::before {
184184
display: block;
185185
}
186186

187+
#search-form:focus-within #shortcut-page,
188+
.bd-search:focus-within #shortcut {
189+
display: none;
190+
}
191+
192+
#shortcut-page.input-group-text {
193+
padding-top: 0;
194+
padding-bottom: 0;
195+
}
196+
197+
input#q {
198+
border-radius: .25rem 0 0 .25rem;
199+
}
200+
201+
.form-control:focus {
202+
box-shadow: none;
203+
border-width: 2px;
204+
}
205+
187206
ul.search {
188207
margin-left: 0;
189208
}
@@ -234,6 +253,45 @@ ul.search li p.context {
234253
margin-left: 0;
235254
}
236255

256+
/* Search form sidebar */
257+
258+
.bd-search {
259+
font-size: .8rem;
260+
}
261+
262+
.bd-search:focus-within #search-input {
263+
border-radius: .25rem;
264+
}
265+
266+
#shortcut.input-group-text {
267+
padding-top: 0;
268+
padding-bottom: 0;
269+
}
270+
271+
.bd-search input,
272+
.bd-search .input-group-text {
273+
font-size: .8rem;
274+
padding-left: .5em;
275+
}
276+
277+
input#search-input {
278+
padding-left: 2.1875rem;
279+
border-radius: .25rem 0 0 .25rem;
280+
}
281+
282+
.search-icon {
283+
position: absolute;
284+
color: #a4a6a7;
285+
left: .625rem;
286+
z-index: 100;
287+
align-self: center;
288+
}
289+
290+
.input-group-text kbd {
291+
padding: 0rem 0.4rem;
292+
font-size: 135%;
293+
}
294+
237295
.pathseparator {
238296
padding: 0 0.7rem;
239297
}

docs/_static/search_shortcut.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Add shortcut `ctrl+k` to focus on search field
3+
*/
4+
5+
$(document).ready(() => {
6+
if (window.location.pathname === '/search.html') {
7+
$('form.bd-search .input-group').hide(); // Hide Sidebar Search field
8+
9+
$(document).keydown(function(event) {
10+
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
11+
event.preventDefault();
12+
$('#q').focus();
13+
}
14+
});
15+
} else {
16+
$(document).keydown(function(event) {
17+
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
18+
event.preventDefault();
19+
$('#search-input').focus();
20+
}
21+
});
22+
}
23+
24+
// if OS isn't Mac change visual indication of search field
25+
if (navigator.platform.indexOf('Mac') === -1) {
26+
$('#search-shortcut').html("^");
27+
$('#search-page-shortcut').html("^");
28+
}
29+
30+
});
31+
32+
function onReset() {
33+
$('#search-form').trigger('reset');
34+
$('#search-form').trigger('submit');
35+
}

docs/_static/searchtools.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,10 @@ var Search = {
342342
else {
343343
Search.stopPulse();
344344
Search.title.text(_('Search Results'));
345-
if (!resultCount)
345+
if (query === '') {
346+
Search.status.text(_('No query, no results.'));
347+
}
348+
else if (!resultCount)
346349
Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly. Searching for multiple words only shows matches that contain all words.'));
347350
else
348351
Search.status.text(_('Found %s page(s) matching the search query.').replace('%s', resultCount));

docs/_templates/search-field.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<form class="bd-search d-flex align-items-center" action="{{ pathto('search') }}" method="get">
2+
<div class="input-group">
3+
<label for="q" class="sr-only">Search string
4+
</label>
5+
<i class="fa fa-search fa-lg search-icon" aria-hidden="true"></i>
6+
<input
7+
type="search" name="q" id="search-input"
8+
class="form-control"
9+
placeholder="{{ _(theme_search_bar_text) }}"
10+
aria-labelledby="{{ _(theme_search_bar_text) }}"
11+
value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
12+
/>
13+
<div class="input-group-append">
14+
<span class="input-group-text" id="shortcut">
15+
<kbd id="search-shortcut"></kbd>&nbsp;<kbd>K</kbd>
16+
</span>
17+
</div>
18+
</div>
19+
</form>

docs/_templates/search.html

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,29 @@ <h1 id="search-documentation">{{ _('Search') }}</h1>
4848
>
4949
<div class="row">
5050
<div class="input-group col-xl-8 mb-2">
51+
<label for="q" class="sr-only">Search string
52+
</label>
5153
<input
52-
type="text" name="q" id="q"
53-
class="form-control"
54-
placeholder="Search the docs…"
55-
aria-labelledby="search-documentation" value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
56-
<label for="q" class="sr-only">Search string</label>
54+
type="search" name="q" id="q"
55+
class="form-control"
56+
placeholder="{{ _(theme_search_bar_text) }}"
57+
aria-labelledby="{{ _(theme_search_bar_text) }}"
58+
value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
59+
/>
5760
<div class="input-group-append">
58-
<button type="submit" class="btn btn-primary">{{ _('search') }}</button>
61+
<span class="input-group-text" id="shortcut-page">
62+
<kbd id="search-page-shortcut"></kbd>&nbsp;<kbd>K</kbd>
63+
</span>
5964
</div>
6065
<div class="input-group-append">
6166
<button
62-
type="button"
63-
class="clear_search btn btn-secondary"
64-
>{{ _('reset') }}</button>
67+
type="button"
68+
onclick="onReset()"
69+
class="btn btn-danger"
70+
><i class="fas fa-times"></i></button>
71+
</div>
72+
<div class="input-group-append">
73+
<button type="submit" class="btn btn-primary"><i class="fas fa-search fa-lg" aria-hidden="true"></i></button>
6574
</div>
6675
</div>
6776
</div>
@@ -70,7 +79,7 @@ <h1 id="search-documentation">{{ _('Search') }}</h1>
7079
<label for="doc_section" class="col sr-only">Filter by section</label>
7180
<div class="col">
7281
<div class="form-check">
73-
<input class="form-check-input" type="radio" name="doc_section" id="doc_section_all" value="all">
82+
<input class="form-check-input" type="radio" name="doc_section" id="doc_section_all" value="all" checked>
7483
<label class="form-check-label" for="doc_section_all">
7584
All Documentation
7685
</label>

docs/conf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@
132132
"volto/developer-guidelines/branch-policy.md",
133133
]
134134

135-
html_js_files = [
136-
"patch_scrollToActive.js",
137-
]
135+
html_js_files = ["patch_scrollToActive.js", "search_shortcut.js"]
138136

139137
html_extra_path = [
140138
"robots.txt",
@@ -253,6 +251,7 @@
253251
"use_repository_button": True,
254252
"use_issues_button": True,
255253
"use_edit_page_button": True,
254+
"search_bar_text": "Search",
256255
"switcher": {
257256
"json_url": "/_static/switcher.json",
258257
"version_match": version,

0 commit comments

Comments
 (0)