Skip to content

Commit 00e138d

Browse files
committed
compiled all js to a single file
1 parent f1c6780 commit 00e138d

File tree

4 files changed

+40
-24
lines changed

4 files changed

+40
-24
lines changed

docs/_static/search_shortcut.js

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

docs/_templates/page.html

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,6 @@
1313
$(".sticky-top .bd-toc").css("visibility", "hidden");
1414
}
1515
});
16-
$(document).keydown(function(event) {
17-
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
18-
event.preventDefault();
19-
$('#search-input').focus();
20-
}
21-
});
22-
if (navigator.platform.indexOf('Mac') === -1) $('#search-shortcut-sidebar').html("^K"); // if OS isn't Mac change Visual indication of search field
23-
24-
// Show & hide seach input when focusin & focusout
25-
$('#search-input').focus(() => {
26-
$('#search-shortcut-sidebar').hide();
27-
});
28-
$('#search-input').focusout(() => {
29-
$('#search-shortcut-sidebar').show();
30-
})
3116
</script>
3217

3318
{% endblock %}

docs/_templates/search.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ <h1 id="search-documentation">{{ _('Search') }}</h1>
123123
$(".topbar-contents .bd-toc").css("visibility", "hidden");
124124
}
125125
});
126-
127-
$('form.bd-search').css('visibility','hidden'); // Hide Sidebar Search field
128-
if (navigator.platform.indexOf('Mac') === -1) $('#search-shortcut-page').html("^K"); // if OS isn't Mac change Visual indication of search field
129-
$(document).keydown(function(event) {
130-
if ((event.ctrlKey || event.metaKey) && event.key == "k") {
131-
event.preventDefault();
132-
$('#q').focus();
133-
}
134-
});
135126
</script>
136127

137128
{% endblock %}

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130

131131
html_js_files = [
132132
"patch_scrollToActive.js",
133+
"search_shortcut.js"
133134
]
134135

135136
html_extra_path = [
@@ -248,6 +249,7 @@
248249
"use_repository_button": True,
249250
"use_issues_button": True,
250251
"use_edit_page_button": True,
252+
"search_bar_text": "Search the docs…",
251253
"switcher": {
252254
"json_url": "/_static/switcher.json",
253255
"version_match": version,

0 commit comments

Comments
 (0)