PluginProbe
BeyondWords – AI audio for publishers / trunk
BeyondWords – AI audio for publishers vtrunk
7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.7.0 All 43 releases
speechkit / src / settings / preselect.js

preselect.js in BeyondWords – AI audio for publishers trunk, at src/settings/preselect.js

74 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*
2 * Preferences → "Preselect 'Generate audio'" field: progressive disclosure.
3 *
4 * Checkboxes render server-side with their correct initial visibility, so this
5 * is enhancement only; hiding the term trees never clears their selections.
6 */
7 ( function () {
8 'use strict';
9
10 const sync = ( fieldset ) => {
11 const enabled = fieldset.querySelector(
12 '.beyondwords-setting__preselect--enabled'
13 );
14 const options = fieldset.querySelector(
15 '.beyondwords-setting__preselect--options'
16 );
17
18 if ( ! enabled || ! options ) {
19 return;
20 }
21
22 const all = options.querySelector(
23 '.beyondwords-setting__preselect--all'
24 );
25 const taxonomies = options.querySelector(
26 '.beyondwords-setting__preselect--taxonomies'
27 );
28
29 options.style.display = enabled.checked ? '' : 'none';
30
31 if ( taxonomies && all ) {
32 taxonomies.style.display =
33 enabled.checked && ! all.checked ? '' : 'none';
34 }
35 };
36
37 const init = () => {
38 const fieldsets = document.querySelectorAll(
39 '.beyondwords-setting__preselect--post-type'
40 );
41
42 fieldsets.forEach( ( fieldset ) => {
43 const enabled = fieldset.querySelector(
44 '.beyondwords-setting__preselect--enabled'
45 );
46 const all = fieldset.querySelector(
47 '.beyondwords-setting__preselect--all'
48 );
49
50 if ( enabled ) {
51 enabled.addEventListener( 'change', () => {
52 // Enabling defaults to "All" (preselect the whole type).
53 if ( enabled.checked && all ) {
54 all.checked = true;
55 }
56 sync( fieldset );
57 } );
58 }
59
60 if ( all ) {
61 all.addEventListener( 'change', () => sync( fieldset ) );
62 }
63
64 sync( fieldset );
65 } );
66 };
67
68 if ( document.readyState !== 'loading' ) {
69 init();
70 } else {
71 document.addEventListener( 'DOMContentLoaded', init );
72 }
73 } )();
74