wordpress-event-bridge-for-.../assets/js/event-bridge-for-activitypub-admin.js

35 lines
1.3 KiB
JavaScript
Raw Normal View History

jQuery( function( $ ) {
// Accordion handling in various areas.
$( '.event-bridge-for-activitypub-settings-accordion' ).on( 'click', '.event-bridge-for-activitypub-settings-accordion-trigger', function() {
var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) );
if ( isExpanded ) {
$( this ).attr( 'aria-expanded', 'false' );
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', true );
} else {
$( this ).attr( 'aria-expanded', 'true' );
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', false );
}
} );
2024-11-19 21:05:21 +01:00
// Function to toggle visibility of custom details based on selected radio button.
function toggleCustomDetailsForSummary() {
2024-12-06 17:14:20 +01:00
if ($("#event_bridge_for_activitypub_summary_type_custom").is(':checked')) {
$("#event_bridge_for_activitypub_summary_type_custom-details").show();
2024-11-19 21:05:21 +01:00
} else {
2024-12-06 17:14:20 +01:00
$("#event_bridge_for_activitypub_summary_type_custom-details").hide();
2024-11-19 21:05:21 +01:00
}
}
// Run the toggle function on page load.
$(document).ready(function() {
2024-12-06 16:51:54 +01:00
window.console.log("test");
2024-11-19 21:05:21 +01:00
toggleCustomDetailsForSummary(); // Set the correct state on load.
// Listen for changes on the radio buttons
2024-12-06 17:14:20 +01:00
$("input[name=event_bridge_for_activitypub_summary_type]").change(function() {
2024-11-19 21:05:21 +01:00
toggleCustomDetailsForSummary(); // Update visibility on change.
});
});
} );