@@ -38,12 +38,16 @@ <h2>Filter results</h2>
3838 < label for ="categoryAll "> All</ label >
3939 </ div >
4040 < 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 >
4242 < label for ="categoryDocumentation "> Documentation</ label >
4343 </ div >
4444 < 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 >
4751 </ div >
4852 </ div >
4953 </ form >
@@ -97,24 +101,21 @@ <h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></
97101
98102 function getSelectedCategory ( ) {
99103 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' ) ;
104105 }
105106
106107 function triggerSearch ( query ) {
107108 const searchResultsHeader = document . getElementById ( 'searchPageResultsHeader' ) ;
108109
109110 if ( query ) {
110111 trucatedQuery = truncateSentence ( query , 20 ) ;
111- if ( getSelectedCategory ( ) == null ) {
112+ if ( getSelectedCategory ( ) . length === 0 ) {
112113 searchResultsHeader . textContent = 'Select the result type for your search.' ;
113114 document . getElementById ( 'searchPageResultsContainer' ) . innerHTML = '' ;
114115 return ;
115116 }
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 ( ',' ) ;
118119 const urlPath = window . location . pathname ;
119120 const versionMatch = urlPath . match ( / ( \d + \. \d + ) / ) ;
120121 const docsVersion = versionMatch ? versionMatch [ 1 ] : "latest" ;
@@ -139,11 +140,12 @@ <h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></
139140 document . addEventListener ( 'DOMContentLoaded' , function ( ) {
140141 const categoryAll = document . getElementById ( 'categoryAll' ) ;
141142 const categoryDocumentation = document . getElementById ( 'categoryDocumentation' ) ;
142- const categoryNews = document . getElementById ( 'categoryNews' ) ;
143+ const categoryBlog = document . getElementById ( 'categoryBlog' ) ;
144+ const categoryEvent = document . getElementById ( 'categoryEvent' ) ;
143145 const searchInput = document . getElementById ( 'searchPageInput' ) ;
144146
145147 function updateAllCheckbox ( ) {
146- if ( categoryDocumentation . checked && categoryNews . checked ) {
148+ if ( categoryDocumentation . checked && categoryBlog . checked && categoryEvent . checked ) {
147149 categoryAll . checked = true ;
148150 } else {
149151 categoryAll . checked = false ;
@@ -153,10 +155,12 @@ <h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></
153155 function updateChildCheckboxes ( ) {
154156 if ( categoryAll . checked ) {
155157 categoryDocumentation . checked = true ;
156- categoryNews . checked = true ;
158+ categoryBlog . checked = true ;
159+ categoryEvent . checked = true ;
157160 } else {
158161 categoryDocumentation . checked = false ;
159- categoryNews . checked = false ;
162+ categoryBlog . checked = false ;
163+ categoryEvent . checked = false ;
160164 }
161165 }
162166
@@ -168,7 +172,11 @@ <h1 class="search-page--results--diplay--header" id="searchPageResultsHeader"></
168172 updateAllCheckbox ( ) ;
169173 triggerSearch ( searchInput . value . trim ( ) ) ;
170174 } ) ;
171- categoryNews . addEventListener ( 'change' , ( ) => {
175+ categoryBlog . addEventListener ( 'change' , ( ) => {
176+ updateAllCheckbox ( ) ;
177+ triggerSearch ( searchInput . value . trim ( ) ) ;
178+ } ) ;
179+ categoryEvent . addEventListener ( 'change' , ( ) => {
172180 updateAllCheckbox ( ) ;
173181 triggerSearch ( searchInput . value . trim ( ) ) ;
174182 } ) ;
0 commit comments