Отображение вкладок в структуре вуза

This commit is contained in:
2026-06-04 23:46:26 +03:00
parent 6a03931190
commit 9e6e0038c6
4 changed files with 39 additions and 46 deletions

View File

@@ -53,41 +53,26 @@ export async function initUniversityStructure() {
let allProfiles = [];
// --- Логика переключения табов ---
function deactivateTabs() {
[tabDepartments, tabSpecialties, tabProfiles].forEach(tab => {
if (tab) {
tab.classList.remove('active');
tab.style.borderBottomColor = 'transparent';
tab.style.color = 'var(--text-secondary)';
const structureTabs = [
{ button: tabDepartments, panel: contentDepartments },
{ button: tabSpecialties, panel: contentSpecialties },
{ button: tabProfiles, panel: contentProfiles },
];
function activateStructureTab(activeButton) {
structureTabs.forEach(({ button, panel }) => {
const active = button === activeButton;
button?.classList.toggle('active', active);
button?.setAttribute('aria-selected', active ? 'true' : 'false');
if (panel) {
panel.classList.toggle('active', active);
panel.hidden = !active;
}
});
[contentDepartments, contentSpecialties, contentProfiles].forEach(content => {
if (content) content.style.display = 'none';
});
}
tabDepartments.addEventListener('click', () => {
deactivateTabs();
tabDepartments.classList.add('active');
tabDepartments.style.borderBottomColor = 'var(--primary)';
tabDepartments.style.color = 'var(--text-main)';
contentDepartments.style.display = 'block';
});
tabSpecialties.addEventListener('click', () => {
deactivateTabs();
tabSpecialties.classList.add('active');
tabSpecialties.style.borderBottomColor = 'var(--primary)';
tabSpecialties.style.color = 'var(--text-main)';
contentSpecialties.style.display = 'block';
});
tabProfiles.addEventListener('click', () => {
deactivateTabs();
tabProfiles.classList.add('active');
tabProfiles.style.borderBottomColor = 'var(--primary)';
tabProfiles.style.color = 'var(--text-main)';
contentProfiles.style.display = 'block';
structureTabs.forEach(({ button }) => {
button?.addEventListener('click', () => activateStructureTab(button));
});
// --- Загрузка данных ---