/**
 * @fileoverview Manages room member functionality and permissions.
 * This file handles:
 * - User selection interface using Select2
 * - Room member permissions management
 * - Auto-saving permission changes
 */

/**
 * Initializes room member functionality when the document is ready.
 * Sets up:
 * - Select2 dropdown for user selection with Bootstrap 5 theme
 * - Auto-save functionality for permission changes
 * @function
 */
$(document).ready(function() {
    // Initialize Select2 for user selection
    $('.select2').select2({
        theme: 'bootstrap-5',
        width: '100%',
        placeholder: 'Search for a user...',
        allowClear: true
    });
    
    // Auto-submit permission form on checkbox change
    document.querySelectorAll('.auto-save-perms-form input[type="checkbox"]').forEach(function(checkbox) {
        checkbox.addEventListener('change', function() {
            this.closest('form').submit();
        });
    });
}); 