/** * Customizer Controls - Reset to Defaults */ ( function( $ ) { 'use strict'; $( document ).ready( function() { // Reset button click handler $( document ).on( 'click', '#nova-reset-defaults', function( e ) { e.preventDefault(); var $button = $( this ); var originalText = $button.text(); // Show confirmation dialog if ( ! confirm( novaBusinessCustomizer.confirmText ) ) { return; } // Second confirmation for extra safety if ( ! confirm( novaBusinessCustomizer.confirmYes + '?\n\n' + novaBusinessCustomizer.confirmText ) ) { return; } // Disable button and show loading state $button.prop( 'disabled', true ).text( novaBusinessCustomizer.resetting ); // Send AJAX request $.ajax( { url: novaBusinessCustomizer.ajaxurl, type: 'POST', data: { action: 'business_ai_reset_customizer', nonce: novaBusinessCustomizer.nonce }, success: function( response ) { if ( response.success ) { alert( novaBusinessCustomizer.success ); // Reload the customizer window.location.reload(); } else { alert( novaBusinessCustomizer.error ); $button.prop( 'disabled', false ).text( originalText ); } }, error: function() { alert( novaBusinessCustomizer.error ); $button.prop( 'disabled', false ).text( originalText ); } } ); } ); } ); } )( jQuery );