File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ $ ( document ) . ready ( fixSearch ) ;
2
+
3
+ function fixSearch ( ) {
4
+ var target = document . getElementById ( 'rtd-search-form' ) ;
5
+ var config = { attributes : true , childList : true } ;
6
+
7
+ var observer = new MutationObserver ( function ( mutations ) {
8
+ // if it isn't disconnected it'll loop infinitely because the observed element is modified
9
+ observer . disconnect ( ) ;
10
+ var form = $ ( '#rtd-search-form' ) ;
11
+ form . empty ( ) ;
12
+ form . attr ( 'action' , 'https://' + window . location . hostname + '/en/' + determineSelectedBranch ( ) + '/search.html' ) ;
13
+ $ ( '<input>' ) . attr ( {
14
+ type : "text" ,
15
+ name : "q" ,
16
+ placeholder : "Search docs"
17
+ } ) . appendTo ( form ) ;
18
+ } ) ;
19
+ // don't run this outside RTD hosting
20
+ if ( window . location . origin . indexOf ( 'readthedocs' ) > - 1 ) {
21
+ observer . observe ( target , config ) ;
22
+ }
23
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ google_analytics: ['UA-29492860-5', 'auto']
6
6
theme : ' readthedocs'
7
7
site_dir : ' deploy'
8
8
extra_css : [assets/fathom.css]
9
+ extra_js : [assets/fix_search.js]
9
10
10
11
pages :
11
12
- ' Overview ' : index.md
You can’t perform that action at this time.
0 commit comments