diff --git a/admin/js/wp-allstars-admin.js b/admin/js/wp-allstars-admin.js index 4cd28ef..5b8e67a 100644 --- a/admin/js/wp-allstars-admin.js +++ b/admin/js/wp-allstars-admin.js @@ -1,3 +1,6 @@ +// Define loadTheme in the global scope so it can be called from inline scripts +var loadTheme; + jQuery(document).ready(function($) { // Function to show notification function showNotification(message, $element, isError = false) { @@ -20,6 +23,7 @@ jQuery(document).ready(function($) { $notification.fadeOut(300, function() { $(this).remove(); }); + }, 2000); } @@ -40,6 +44,7 @@ jQuery(document).ready(function($) { } return response; }); + } // Handle toggle switch clicks @@ -50,11 +55,13 @@ jQuery(document).ready(function($) { $checkbox.prop('checked', !isChecked).trigger('change'); }); + // Prevent label clicks from toggling the checkbox directly $('.wp-setting-label, .wp-allstars-toggle-left label').on('click', function(e) { e.stopPropagation(); }); + // Handle checkbox changes $('.wp-toggle-switch input[type="checkbox"]').on('change', function(e) { e.stopPropagation(); @@ -70,8 +77,10 @@ jQuery(document).ready(function($) { .catch(function() { showNotification('Error saving settings', $label, true); }); + }); + // Handle text input changes $('.wp-allstars-setting-row input[type="text"], .wp-allstars-setting-row input[type="number"], .wp-allstars-setting-row textarea').on('change', function() { var $input = $(this); @@ -87,8 +96,10 @@ jQuery(document).ready(function($) { console.error('Error:', error); showNotification('Error saving setting', $label, true); }); + }); + // Toggle expandable panels $('.wp-allstars-toggle-header').on('click', function(e) { if (!$(e.target).closest('.wp-toggle-switch').length && @@ -101,6 +112,7 @@ jQuery(document).ready(function($) { } }); + // Set initial panel states $('.wp-allstars-toggle-header').each(function() { var $settings = $(this).closest('.wp-allstars-toggle').find('.wp-allstars-toggle-settings'); @@ -111,6 +123,7 @@ jQuery(document).ready(function($) { } }); + // Remove JavaScript-based tab switching - let the native WordPress tab links work // Plugin category filters @@ -126,6 +139,7 @@ jQuery(document).ready(function($) { // Load plugins for the selected category loadPlugins(category); }); + // Load initial plugins if we're on the recommended tab if ($('#recommended').is(':visible') && $('#wpa-plugin-list').is(':empty')) { @@ -141,7 +155,7 @@ jQuery(document).ready(function($) { // Function to load plugins function loadPlugins(category) { var $container = $('#wpa-plugin-list'); - var $loadingOverlay = $('
'); + var $loadingOverlay = $(' '); // Show loading overlay $container.css('position', 'relative').append($loadingOverlay); @@ -168,6 +182,14 @@ jQuery(document).ready(function($) { // Initialize plugin action buttons initPluginActions(); + + // Show standard WordPress spinner in each plugin card + $('.plugin-card .plugin-spinner').addClass('is-active').show(); + + // Hide spinners after all plugin details have loaded + setTimeout(function() { + $('.plugin-card .plugin-spinner').removeClass('is-active').hide(); + }, 1000); } else { // Show error message $container.html('' + response.data + '
Failed to load themes. Please try again. Error: ' + error + '
" + response.data + "