File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -64,3 +64,34 @@ $(function() {
64
64
drawer . toggleClass ( "js-hidden" ) ;
65
65
} ) ;
66
66
} ) ;
67
+
68
+ // Search functionality
69
+ var toggleDrawers = function ( show ) {
70
+ $ ( ".toc header" ) . each ( function ( ) {
71
+ var header = $ ( this ) ;
72
+ var drawer = header . find ( ".toc-drawer" ) ;
73
+ if ( show ) {
74
+ drawer . removeClass ( "js-hidden" ) ;
75
+ } else {
76
+ drawer . addClass ( "js-hidden" ) ;
77
+ }
78
+ } ) ;
79
+ } ;
80
+
81
+ $ ( function ( ) {
82
+ $ ( "#searchbar" ) . on ( 'input' , function ( ) {
83
+ var query = $ ( this ) . val ( ) ;
84
+ if ( query . length > 1 ) {
85
+ toggleDrawers ( true ) ;
86
+ $ ( ".leaf-article" ) . each ( function ( ) {
87
+ $ ( this ) . show ( ) ;
88
+ if ( $ ( this ) . text ( ) . indexOf ( query ) == - 1 ) {
89
+ $ ( this ) . hide ( ) ;
90
+ }
91
+ } ) ;
92
+ } else {
93
+ $ ( ".leaf-article" ) . each ( function ( ) { $ ( this ) . show ( ) ; } ) ;
94
+ toggleDrawers ( false ) ;
95
+ }
96
+ } )
97
+ } ) ;
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ <h1>{{ custom_title | xml_escape }}</h1>
35
35
{% if page.btcversion != "index" %}
36
36
{% assign groups = site.doc | where:"btcversion", page.btcversion | group_by:"btcgroup" | sort: "name" %}
37
37
< section class ="toc ">
38
+ < input id ="searchbar " type ="text " value ="" placeholder ="Search... "/>
38
39
{% for group in groups %}
39
40
{% if group.name != "index" %}
40
41
< header >
@@ -45,7 +46,7 @@ <h3 class="toc-header">
45
46
< div class ="toc-drawer js-hide-on-start ">
46
47
< ul >
47
48
{% for article in group.items %}
48
- < li > < a href ="{{article.url}} "> {{article.name}}</ a > </ li >
49
+ < li class =" leaf-article " > < a href ="{{article.url}} "> {{article.name}}</ a > </ li >
49
50
{% endfor %}
50
51
</ ul >
51
52
</ div >
You can’t perform that action at this time.
0 commit comments