@@ -45,7 +45,7 @@ class Filter {
4545
4646 setEventListener ( ) {
4747 // hide filter button
48- this . filterElement . querySelector ( this . identifier . hideFilterButton ) . addEventListener ( 'click' , function ( event ) {
48+ this . filterElement . querySelector ( this . identifier . hideFilterButton ) . addEventListener ( 'click' , function ( event ) {
4949 if ( this . filter . length === 0 ) {
5050 this . toggleFilterVisibility ( ) ;
5151 } else {
@@ -55,19 +55,19 @@ class Filter {
5555 } . bind ( this ) ) ;
5656
5757 // show filter button
58- this . filterElement . querySelector ( this . identifier . showFilterButton ) . addEventListener ( 'click' , function ( event ) {
58+ this . filterElement . querySelector ( this . identifier . showFilterButton ) . addEventListener ( 'click' , function ( event ) {
5959 this . toggleFilterVisibility ( event ) ;
6060 } . bind ( this ) ) ;
6161
6262
63- this . filterElement . querySelectorAll ( this . identifier . filterSection ) . forEach ( function ( fieldSet ) {
63+ this . filterElement . querySelectorAll ( this . identifier . filterSection ) . forEach ( function ( fieldSet ) {
6464 // visibility toggle of filter sections
65- fieldSet . querySelector ( this . identifier . filterLegend ) . addEventListener ( 'click' , function ( event ) {
65+ fieldSet . querySelector ( this . identifier . filterLegend ) . addEventListener ( 'click' , function ( event ) {
6666 event . target . nextElementSibling . classList . toggle ( this . identifier . hideElement . substring ( 1 ) ) ;
6767 } . bind ( this ) ) ;
6868
6969 // tab navigation for filter
70- fieldSet . addEventListener ( 'keypress' , function ( event ) {
70+ fieldSet . addEventListener ( 'keypress' , function ( event ) {
7171 if ( event . which === 13 ) {
7272 event . target . querySelector ( this . identifier . filterLegend ) . click ( ) ;
7373 }
@@ -85,7 +85,7 @@ class Filter {
8585 if ( this . filter . length > 0 && this . openFilterOnLoad ) {
8686 this . toggleFilterVisibility ( ) ;
8787
88- this . filter . forEach ( function ( filterName ) {
88+ this . filter . forEach ( function ( filterName ) {
8989 let filterFieldset = this . filterElement . querySelector ( '[data-filtergroup="' + filterName + '"]' ) ;
9090 let filter = filterFieldset . querySelector ( this . identifier . filterOptionContainer ) ;
9191
@@ -95,7 +95,7 @@ class Filter {
9595 }
9696
9797 prepareCheckboxes ( ) {
98- this . filterElement . querySelectorAll ( this . identifier . filterOptionContainer ) . forEach ( function ( filterOptionContainer ) {
98+ this . filterElement . querySelectorAll ( this . identifier . filterOptionContainer ) . forEach ( function ( filterOptionContainer ) {
9999 let filterStatus = this . isFilterSet ( filterOptionContainer ) ;
100100
101101 if ( filterStatus ) {
@@ -158,7 +158,7 @@ class Filter {
158158 let selectionString = '' ;
159159 let filterFieldSets = this . filterElement . querySelectorAll ( this . identifier . filterSection ) ;
160160
161- filterFieldSets . forEach ( function ( filterFieldSet ) {
161+ filterFieldSets . forEach ( function ( filterFieldSet ) {
162162 let selectedOptions = filterFieldSet . querySelectorAll ( this . identifier . filterCheckbox + ':checked, ' + this . identifier . filterRadio + ':checked' ) ;
163163
164164 if ( selectedOptions . length > 0 ) {
@@ -186,13 +186,14 @@ class Filter {
186186 selectionString = '#' + selectionString ;
187187 }
188188
189- window . location = location . protocol + '//' + location . host + location . pathname + ( location . search ? location . search : '' ) + selectionString ;
189+ const url = location . protocol + '//' + location . host + location . pathname + ( location . search ? location . search : '' ) + selectionString ;
190+ history . pushState ( { } , '' , url ) ;
190191 } ;
191192
192193 updateFilterByHashArguments ( hashArguments ) {
193194 let page = 1 ;
194195
195- hashArguments . forEach ( function ( hashArgument ) {
196+ hashArguments . forEach ( function ( hashArgument ) {
196197 // if argument page is set
197198 if ( hashArgument . name === 'page' ) {
198199 page = hashArgument . values [ 0 ] ;
@@ -221,19 +222,21 @@ class Filter {
221222 } ;
222223
223224 setFilterCheckboxEventListener ( ) {
224- this . filterElement . querySelector ( this . identifier . filterSectionContainer ) . addEventListener ( 'click' , function ( evt ) {
225+ this . filterElement . querySelector ( this . identifier . filterSectionContainer ) . addEventListener ( 'click' , function ( evt ) {
225226 let target = evt . target ;
226227
227228 if ( target . tagName === 'INPUT' ) {
228229 // if a show all checkbox is clicked
229230 if ( target . classList . contains ( this . identifier . filterShowAllCheckbox . substring ( 1 ) ) ) {
231+ this . onClick ( evt ) ;
230232 let filterContainer = target . closest ( this . identifier . filterOptionContainer ) ;
231233 this . resetFilter ( filterContainer ) ;
232234 }
233235
234236 // if a specific filter checkbox is clicked
235237 if ( target . classList . contains ( this . identifier . filterCheckbox . substring ( 1 ) ) || target . classList . contains ( this . identifier . filterRadio . substring ( 1 ) ) ) {
236238 let showAllCheckbox = target . closest ( this . identifier . filterOptionContainer ) . querySelector ( this . identifier . filterShowAllCheckbox ) ;
239+ this . onClick ( evt ) ;
237240 showAllCheckbox . checked = false ;
238241 showAllCheckbox . disabled = false ;
239242 }
@@ -302,6 +305,9 @@ class Filter {
302305
303306 return status ;
304307 }
308+
309+ onClick ( ) {
310+ }
305311}
306312
307313export { Filter }
0 commit comments