Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         // Without setTimeout, adding children seems to override
  2.         // adding the current checkbox instead of running in addition to it
  3.         setTimeout(() => {
  4.  
  5.             let checkboxes = cb.closest( ".editor-post-taxonomies__hierarchical-terms-choice" ).querySelectorAll("input[type='checkbox']");
  6.  
  7.             if ( checkboxes.length )
  8.             {
  9.                 checkboxes = Array.from( checkboxes );
  10.                 checkboxes.splice( cb.id, 1 ); // Remove current checkbox from the array.
  11.  
  12.                 // Click the child checkboxes if they do not match the checked state of the current checkbox.
  13.                 checkboxes.map( checkbox => {
  14.                     if ( (cb.checked && !checkbox.checked) || (!cb.checked && checkbox.checked) ) {
  15.                         checkbox.click();
  16.                     }
  17.                 } );
  18.             }
  19.  
  20.             // jQuery(cb)
  21.             //     .closest('.components-base-control')
  22.             //     .siblings()
  23.             //     .find(cb.checked ? ':checkbox:not(:checked)' : ':checkbox:checked')
  24.             //     .trigger('click');
  25.  
  26.         }, 10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement