@@ -38,12 +38,16 @@ <h2>Filter results</h2>
38
38
< label for ="categoryAll "> All</ label >
39
39
</ div >
40
40
< div class ="search-page--sidebar--category-filter--checkbox-child ">
41
- < input type ="checkbox " id ="categoryDocumentation " name ="categoryGroup " value ="Documentation " class ="category-checkbox ">
41
+ < input type ="checkbox " id ="categoryDocumentation " name ="categoryGroup " value ="docs " class ="category-checkbox " checked >
42
42
< label for ="categoryDocumentation "> Documentation</ label >
43
43
</ div >
44
44
< div class ="search-page--sidebar--category-filter--checkbox-child ">
45
- < input type ="checkbox " id ="categoryNews " name ="categoryGroup " value ="News " class ="category-checkbox ">
46
- < label for ="categoryNews "> News</ label >
45
+ < input type ="checkbox " id ="categoryBlog " name ="categoryGroup " value ="blogs " class ="category-checkbox " checked >
46
+ < label for ="categoryBlog "> Blog</ label >
47
+ </ div >
48
+ < div class ="search-page--sidebar--category-filter--checkbox-child ">
49
+ < input type ="checkbox " id ="categoryEvent " name ="categoryGroup " value ="events " class ="category-checkbox " checked >
50
+ < label for ="categoryEvent "> Event</ label >
47
51
</ div >
48
52
</ div >
49
53
</ form >
@@ -97,24 +101,21 @@ <h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></
97
101
98
102
function getSelectedCategory ( ) {
99
103
const allCheckbox = document . getElementById ( 'categoryAll' ) ;
100
- if ( allCheckbox . checked ) {
101
- return "All" ;
102
- }
103
- return document . querySelector ( 'input[name="categoryGroup"]:checked' ) ;
104
+ return document . querySelectorAll ( 'input[name="categoryGroup"]:checked' ) ;
104
105
}
105
106
106
107
function triggerSearch ( query ) {
107
108
const searchResultsHeader = document . getElementById ( 'searchPageResultsHeader' ) ;
108
109
109
110
if ( query ) {
110
111
trucatedQuery = truncateSentence ( query , 20 ) ;
111
- if ( getSelectedCategory ( ) == null ) {
112
+ if ( getSelectedCategory ( ) . length === 0 ) {
112
113
searchResultsHeader . textContent = 'Select the result type for your search.' ;
113
114
document . getElementById ( 'searchPageResultsContainer' ) . innerHTML = '' ;
114
115
return ;
115
116
}
116
- const selectedCategory = getSelectedCategory ( ) . value ;
117
- const searchType = selectedCategory == ( "Documentation" ) ? "docs" : selectedCategory == ( "News" ) ? "proj" : "all" ;
117
+ const selectedCategory = getSelectedCategory ( ) ;
118
+ const searchType = Array . from ( selectedCategory ) . map ( element => element . value ) . join ( ',' ) ;
118
119
const urlPath = window . location . pathname ;
119
120
const versionMatch = urlPath . match ( / ( \d + \. \d + ) / ) ;
120
121
const docsVersion = versionMatch ? versionMatch [ 1 ] : "latest" ;
@@ -139,11 +140,12 @@ <h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></
139
140
document . addEventListener ( 'DOMContentLoaded' , function ( ) {
140
141
const categoryAll = document . getElementById ( 'categoryAll' ) ;
141
142
const categoryDocumentation = document . getElementById ( 'categoryDocumentation' ) ;
142
- const categoryNews = document . getElementById ( 'categoryNews' ) ;
143
+ const categoryBlog = document . getElementById ( 'categoryBlog' ) ;
144
+ const categoryEvent = document . getElementById ( 'categoryEvent' ) ;
143
145
const searchInput = document . getElementById ( 'searchPageInput' ) ;
144
146
145
147
function updateAllCheckbox ( ) {
146
- if ( categoryDocumentation . checked && categoryNews . checked ) {
148
+ if ( categoryDocumentation . checked && categoryBlog . checked && categoryEvent . checked ) {
147
149
categoryAll . checked = true ;
148
150
} else {
149
151
categoryAll . checked = false ;
@@ -153,10 +155,12 @@ <h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></
153
155
function updateChildCheckboxes ( ) {
154
156
if ( categoryAll . checked ) {
155
157
categoryDocumentation . checked = true ;
156
- categoryNews . checked = true ;
158
+ categoryBlog . checked = true ;
159
+ categoryEvent . checked = true ;
157
160
} else {
158
161
categoryDocumentation . checked = false ;
159
- categoryNews . checked = false ;
162
+ categoryBlog . checked = false ;
163
+ categoryEvent . checked = false ;
160
164
}
161
165
}
162
166
@@ -168,7 +172,11 @@ <h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></
168
172
updateAllCheckbox ( ) ;
169
173
triggerSearch ( searchInput . value . trim ( ) ) ;
170
174
} ) ;
171
- categoryNews . addEventListener ( 'change' , ( ) => {
175
+ categoryBlog . addEventListener ( 'change' , ( ) => {
176
+ updateAllCheckbox ( ) ;
177
+ triggerSearch ( searchInput . value . trim ( ) ) ;
178
+ } ) ;
179
+ categoryEvent . addEventListener ( 'change' , ( ) => {
172
180
updateAllCheckbox ( ) ;
173
181
triggerSearch ( searchInput . value . trim ( ) ) ;
174
182
} ) ;
0 commit comments