-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2023. Hion Digital | ||
*/ | ||
|
||
// Use jQuery as $ within this file scope. | ||
const $ = jQuery; // eslint-disable-line no-unused-vars | ||
|
||
/** | ||
* Export the class reference. | ||
*/ | ||
export default class SearchFilters { | ||
|
||
/** | ||
* Check or uncheck checkboxes depending on selections | ||
* | ||
* @param {Object} event Change event | ||
*/ | ||
SearchFilters( event ) { | ||
const $checkBoxContainer = $( '.search-filters' ); | ||
const $checkBoxes = $checkBoxContainer.find( 'input[type=checkbox]' ); | ||
const $clickedCheckbox = event.target; | ||
|
||
if ( $( $clickedCheckbox ).is( ':checked' ) ) { | ||
// Uncheck "All"-checkbox when others are checked | ||
if ( $( $clickedCheckbox ).prop( 'id' ) !== 'cpt-all' ) { | ||
$( '#cpt-all' ).prop( 'checked', false ); | ||
} | ||
// Uncheck other checkboxes when "All" is selected | ||
else { | ||
$checkBoxes.each( function() { | ||
if ( $( this ).prop( 'id' ) !== 'cpt-all' ) { | ||
$( this ).prop( 'checked', false ); | ||
} | ||
} ); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Run when the document is ready. | ||
* | ||
* @return {void} | ||
*/ | ||
docReady() { | ||
$( '.search-filters input[type=checkbox]' ).on( 'change', this.SearchFilters.bind( this ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters