mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Fix / keyboard shortcut to allow typing / within the search field
- Select all existing text in the field when pressing the shortcut. - Remove broken Algolia integration (unused since 4.0) and move the shortcut code to the main `custom.js` file.
This commit is contained in:
@@ -1,27 +0,0 @@
|
|||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var doc_version = document.querySelector('meta[name="doc_version"]').getAttribute('content');
|
|
||||||
|
|
||||||
// If the current page uses tabs, we will need this small patch
|
|
||||||
if (typeof(docsearch) == 'undefined') {
|
|
||||||
docsearch = exports['docsearch'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the Algolia search widget
|
|
||||||
docsearch({
|
|
||||||
apiKey: 'c39cb614363a2a156811478bc2d0573b',
|
|
||||||
indexName: 'godotengine',
|
|
||||||
inputSelector: '#rtd-search-form input[type=text]',
|
|
||||||
algoliaOptions: {
|
|
||||||
facetFilters: ["version:" + (doc_version || 'stable')]
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
window.addEventListener('keydown', function(event) {
|
|
||||||
if (event.key === '/') {
|
|
||||||
document.querySelector('#rtd-search-form input[type=text]').focus();
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})();
|
|
||||||
@@ -246,6 +246,17 @@ $(document).ready(() => {
|
|||||||
Documentation.hideSearchWords();
|
Documentation.hideSearchWords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener('keydown', function(event) {
|
||||||
|
if (event.key === '/') {
|
||||||
|
var searchField = document.querySelector('#rtd-search-form input[type=text]');
|
||||||
|
if (document.activeElement !== searchField) {
|
||||||
|
searchField.focus();
|
||||||
|
searchField.select();
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Initialize handlers for page scrolling and our custom sidebar.
|
// Initialize handlers for page scrolling and our custom sidebar.
|
||||||
const mediaQuery = window.matchMedia('only screen and (min-width: 769px)');
|
const mediaQuery = window.matchMedia('only screen and (min-width: 769px)');
|
||||||
|
|
||||||
|
|||||||
4
conf.py
4
conf.py
@@ -217,9 +217,7 @@ if not on_rtd:
|
|||||||
html_css_files.append("css/dev.css")
|
html_css_files.append("css/dev.css")
|
||||||
|
|
||||||
html_js_files = [
|
html_js_files = [
|
||||||
"js/custom.js?6", # Increment the number at the end when the file changes to bust the cache.
|
"js/custom.js?7", # Increment the number at the end when the file changes to bust the cache.
|
||||||
('https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js', {'defer': 'defer'}),
|
|
||||||
('js/algolia.js', {'defer': 'defer'})
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Output file base name for HTML help builder
|
# Output file base name for HTML help builder
|
||||||
|
|||||||
Reference in New Issue
Block a user