/* Maple GDPR Cookies - Admin JavaScript */ (function ($) { "use strict"; $(document).ready(function () { // Initialize color picker if ($.fn.wpColorPicker) { $(".mgc-color-picker").wpColorPicker(); } // Custom color input preview function updateColorPreview(input) { var color = $(input).val(); var hexPattern = /^#[0-9A-F]{6}$/i; if (hexPattern.test(color)) { $(input).css({ "border-left": "5px solid " + color, "border-color": color, }); } else { $(input).css({ "border-left": "", "border-color": "", }); } } // Add event listeners for custom color inputs $("#mgc_custom_button_color, #mgc_custom_button_hover_color").on( "input change", function () { updateColorPreview(this); }, ); // Initialize preview on page load $("#mgc_custom_button_color, #mgc_custom_button_hover_color").each( function () { updateColorPreview(this); }, ); // Preview functionality $("#mgc-preview-button").on("click", function (e) { e.preventDefault(); // Trigger preview update updatePreview(); }); function updatePreview() { // Simple preview update logic console.log("Preview updated"); } // Handle preference display type radio buttons var $preferenceRadios = $('input[name="mgc_preference_display_type"]'); var $gdprWarning = $("#mgc-gdpr-warning"); // Function to toggle GDPR warning visibility function toggleGdprWarning() { var selectedType = $( 'input[name="mgc_preference_display_type"]:checked', ).val(); if (selectedType === "neither") { // Create warning if it doesn't exist if ($gdprWarning.length === 0) { var warningHtml = '
To remain GDPR compliant, you must add this shortcode to your footer or make it easily accessible on all pages:
' + '[mgc_cookie_preferences]' +
'GDPR requires users to have easy access to withdraw their consent at any time.
' + "