admin-script.js
39 lines
| 1 | /** |
| 2 | * Admin scripts for Easy Actions Scheduler Cleaner |
| 3 | * |
| 4 | * Handles the schedule options toggle visibility. |
| 5 | * |
| 6 | * @package EasyActionsSchedulerCleanerAyudaWP |
| 7 | * @since 1.1.0 |
| 8 | */ |
| 9 | |
| 10 | ( function () { |
| 11 | 'use strict'; |
| 12 | |
| 13 | document.addEventListener( 'DOMContentLoaded', function () { |
| 14 | var toggle = document.getElementById( 'easc-schedule-toggle' ); |
| 15 | var options = document.getElementById( 'easc-schedule-options' ); |
| 16 | |
| 17 | if ( ! toggle || ! options ) { |
| 18 | return; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Toggle schedule options visibility based on master checkbox. |
| 23 | */ |
| 24 | function updateOptionsVisibility() { |
| 25 | if ( toggle.checked ) { |
| 26 | options.classList.remove( 'easc-disabled' ); |
| 27 | } else { |
| 28 | options.classList.add( 'easc-disabled' ); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | // Set initial state. |
| 33 | updateOptionsVisibility(); |
| 34 | |
| 35 | // Listen for changes. |
| 36 | toggle.addEventListener( 'change', updateOptionsVisibility ); |
| 37 | } ); |
| 38 | } )(); |
| 39 |