/** * Hi-School Slide Manager - Admin Sortable functionality * * Handles drag-and-drop ordering of slides in the admin list table */ jQuery(document).ready(function($) { 'use strict'; // Only initialize on the slides list page if (typeof hssmAjax === 'undefined' || !$('.wp-list-table tbody').length) { return; } // Initialize sortable functionality initializeSortable(); /** * Initialize jQuery UI sortable on the slides table */ function initializeSortable() { const $tbody = $('.wp-list-table tbody'); // Make the table body sortable $tbody.sortable({ handle: '.hssm-drag-handle', placeholder: 'ui-sortable-placeholder', helper: function(e, tr) { var $helper = tr.clone(); $helper.children().each(function(index) { $(this).width(tr.children().eq(index).width()); }); return $helper; }, start: function(e, ui) { ui.placeholder.height(ui.item.height()); ui.item.addClass('ui-sortable-helper'); }, stop: function(e, ui) { ui.item.removeClass('ui-sortable-helper'); updateSlideOrder(); }, tolerance: 'pointer', cursor: 'move', opacity: 0.8, distance: 5 }); // Add visual feedback $tbody.on('mouseenter', '.hssm-drag-handle', function() { $(this).closest('tr').addClass('hssm-sortable-hover'); }); $tbody.on('mouseleave', '.hssm-drag-handle', function() { $(this).closest('tr').removeClass('hssm-sortable-hover'); }); // Add CSS for hover effect if (!$('#hssm-sortable-styles').length) { $('