Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
316a5fc5
Commit
316a5fc5
authored
Jan 21, 2018
by
Marcel Stör
Browse files
With RTD the JS search seems no longer necessary
parent
6ef6db90
Changes
1
Hide whitespace changes
Inline
Side-by-side
docs/js/extra.js
View file @
316a5fc5
...
...
@@ -8,7 +8,6 @@ var nodemcu = nodemcu || {};
$
(
document
).
ready
(
function
()
{
addToc
();
fixSearch
();
hideNavigationForAllButSelectedLanguage
();
addLanguageSelectorToRtdFlyOutMenu
();
replaceRelativeLinksWithStaticGitHubUrl
();
...
...
@@ -45,34 +44,6 @@ var nodemcu = nodemcu || {};
}
}
/*
* RTD messes up MkDocs' search feature by tinkering with the search box defined in the theme, see
* https://github.com/rtfd/readthedocs.org/issues/1088. This function sets up a DOM4 MutationObserver
* to react to changes to the search form (triggered by RTD on doc ready). It then reverts everything
* the RTD JS code modified.
*/
function
fixSearch
()
{
var
target
=
document
.
getElementById
(
'
rtd-search-form
'
);
var
config
=
{
attributes
:
true
,
childList
:
true
};
var
observer
=
new
MutationObserver
(
function
(
mutations
)
{
// if it isn't disconnected it'll loop infinitely because the observed element is modified
observer
.
disconnect
();
var
form
=
$
(
'
#rtd-search-form
'
);
form
.
empty
();
form
.
attr
(
'
action
'
,
'
https://
'
+
window
.
location
.
hostname
+
'
/en/
'
+
determineSelectedBranch
()
+
'
/search.html
'
);
$
(
'
<input>
'
).
attr
({
type
:
"
text
"
,
name
:
"
q
"
,
placeholder
:
"
Search docs
"
}).
appendTo
(
form
);
});
if
(
window
.
location
.
origin
.
indexOf
(
'
readthedocs
'
)
>
-
1
)
{
observer
.
observe
(
target
,
config
);
}
}
function
hideNavigationForAllButSelectedLanguage
()
{
var
selectedLanguageCode
=
determineSelectedLanguageCode
();
var
selectedLanguageName
=
languageCodeToNameMap
[
selectedLanguageCode
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment