// Team page navigation script $(document).ready(function() { // Handle team dropdown items click within the page $('.team-dropdown-item').on('click', function(e) { // Only prevent default if it's a hash link on the same page var href = $(this).attr('href'); // If it's an anchor link on the current page if (href.indexOf('#') === 0) { e.preventDefault(); // Get the target section ID from the href attribute var targetId = href; var targetSection = $(targetId); // Scroll to the section if it exists if (targetSection.length) { $('html, body').animate({ scrollTop: targetSection.offset().top - 100 // Offset for fixed header }, 800); } } }); // Track scrolling to highlight active section in navigation $(window).scroll(function() { var scrollPosition = $(this).scrollTop() + 120; // Add offset for better detection var currentSection = ''; // Check each section and find which one is in view $('#director-section, #phd-section, #undergrad-section, #alumni-section, #general-alumni-section, #researchers-section, #collaborators-section').each(function() { var topDistance = $(this).offset().top; if (scrollPosition >= topDistance) { currentSection = '#' + $(this).attr('id'); } }); // Update active class for navigation if (currentSection !== '') { $('.team-dropdown-item').removeClass('section-active'); $('.team-dropdown-item[href="' + currentSection + '"]').addClass('section-active'); } }); // Initialize PhD section toggle behavior $('#current-phds-btn').click(function() { showPhDSection('current-phds'); }); $('#alumni-phds-btn').click(function() { showPhDSection('alumni-phds'); }); // Ensure the onclick attributes also work properly $(document).on('click', '#current-phds-btn', function() { showPhDSection('current-phds'); }); $(document).on('click', '#alumni-phds-btn', function() { showPhDSection('alumni-phds'); }); // Show current-phds section by default showPhDSection('current-phds'); // Trigger scroll event once to highlight the initial section $(window).scroll(); }); // Function to toggle between current PhDs and alumni PhDs function showPhDSection(sectionId) { console.log("Showing section:", sectionId); // Debug log // Hide all PhD sections $('.phd-section').hide(); // Show the selected section $('#' + sectionId).show(); // Update button states if (sectionId === 'current-phds') { $('#current-phds-btn').addClass('active').removeClass('btn-outline-primary').addClass('btn-primary'); $('#alumni-phds-btn').removeClass('active').removeClass('btn-primary').addClass('btn-outline-primary'); } else { $('#alumni-phds-btn').addClass('active').removeClass('btn-outline-primary').addClass('btn-primary'); $('#current-phds-btn').removeClass('active').removeClass('btn-primary').addClass('btn-outline-primary'); } }