PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
jetpack / jetpack_vendor / automattic / jetpack-search / src / widgets / js / search-widget.js

search-widget.js in Jetpack – WP Security, Backup, Speed, & Growth 16.3, at jetpack_vendor/automattic/jetpack-search/src/widgets/js/search-widget.js

48 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var jetpackSearchModule = function () {
2 var i,
3 j,
4 checkboxes,
5 filter_list = document.querySelectorAll( '.jetpack-search-filters-widget__filter-list' );
6
7 for ( i = 0; i < filter_list.length; i++ ) {
8 filter_list[ i ].addEventListener( 'click', function ( event ) {
9 var target = event.target;
10 var precedingCheckbox;
11 var nextAnchor;
12
13 // If the target is an anchor, we want to toggle the checkbox.
14 if ( target.nodeName && 'a' === target.nodeName.toLowerCase() ) {
15 precedingCheckbox = target.previousElementSibling;
16 if (
17 precedingCheckbox &&
18 precedingCheckbox.type &&
19 'checkbox' === precedingCheckbox.type
20 ) {
21 precedingCheckbox.checked = ! precedingCheckbox.checked;
22 }
23 }
24
25 // If the target is a checkbox, we want to navigate.
26 if ( target.type && 'checkbox' === target.type ) {
27 nextAnchor = target.nextElementSibling;
28 if ( nextAnchor && 'a' === nextAnchor.nodeName.toLowerCase() ) {
29 window.location.href = nextAnchor.getAttribute( 'href' );
30 }
31 }
32 } );
33
34 // Enable checkboxes now that we're setup.
35 checkboxes = filter_list[ i ].querySelectorAll( 'input[type="checkbox"]' );
36 for ( j = 0; j < checkboxes.length; j++ ) {
37 checkboxes[ j ].disabled = false;
38 checkboxes[ j ].style.cursor = 'inherit';
39 }
40 }
41 };
42
43 if ( document.readyState === 'interactive' || document.readyState === 'complete' ) {
44 jetpackSearchModule();
45 } else {
46 document.addEventListener( 'DOMContentLoaded', jetpackSearchModule );
47 }
48