jQuery(document).ready(function($) { // View suggestion details modal window.pcPreviewSuggestion = function(suggestionId) { $.ajax({ url: pcCommunitySuggestionsAdmin.ajax_url, type: 'POST', data: { action: 'pc_get_suggestion', suggestion_id: suggestionId, nonce: pcCommunitySuggestionsAdmin.nonce }, success: function(response) { if (response.success) { pcShowSuggestionModal(response.data); } else { alert(pcCommunitySuggestionsAdmin.i18n.action_failed + ': ' + response.data.message); } }, error: function() { alert(pcCommunitySuggestionsAdmin.i18n.action_failed); } }); }; function pcShowSuggestionModal(suggestion) { const modalHtml = `
`; $('body').append(modalHtml); $('.pc-modal').fadeIn(200); // Prevent background scrolling $('body').css('overflow', 'hidden'); } window.pcCloseModal = function() { $('.pc-modal').fadeOut(200, function() { $(this).remove(); }); $('body').css('overflow', ''); }; // Add comment functionality window.pcAddComment = function(suggestionId) { var $commentsRow = $('#pc-comments-' + suggestionId); $commentsRow.slideToggle(); }; window.pcSubmitComment = function(suggestionId) { var $textarea = $('#pc-comment-' + suggestionId); var comment = $textarea.val().trim(); if (!comment) { alert('Please enter a comment.'); return; } var $button = $textarea.siblings('button'); var originalText = $button.text(); $button.prop('disabled', true).text('Adding...'); $.ajax({ url: pcCommunitySuggestionsAdmin.ajax_url, type: 'POST', data: { action: 'pc_add_comment', suggestion_id: suggestionId, comment: comment, nonce: pcCommunitySuggestionsAdmin.nonce }, success: function(response) { if (response.success) { var commentHtml = '