mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-06 04:01:05 +09:00
Clean up the fomantic helpers that nothing inside fomantic depends on. Manually tested all functionality. --------- Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
19 lines
948 B
TypeScript
19 lines
948 B
TypeScript
import {queryElemSiblings} from '../../utils/dom.ts';
|
|
|
|
export function initTabSwitcher(tabItemContainer: Element) {
|
|
// Clicking a `.item[data-tab]` menu item activates the matching `.ui.tab[data-tab=...]` panel
|
|
// This design is from Fomantic UI, and it has problems like :
|
|
// * The panel selector is global, callers should make sure the "data-tab" values don't conflict on the same page
|
|
const tabItems = tabItemContainer.querySelectorAll('.item[data-tab]');
|
|
for (const elItem of tabItems) {
|
|
const tabName = elItem.getAttribute('data-tab')!;
|
|
elItem.addEventListener('click', () => {
|
|
const elPanel = document.querySelector(`.ui.tab[data-tab="${tabName}"]`)!;
|
|
queryElemSiblings(elPanel, '.ui.tab', (el) => el.classList.remove('active'));
|
|
queryElemSiblings(elItem, '.item[data-tab]', (el) => el.classList.remove('active'));
|
|
elItem.classList.add('active');
|
|
elPanel.classList.add('active');
|
|
});
|
|
}
|
|
}
|