mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-22 19:19:57 +00:00
- Bump `eslint`, `typescript-eslint` and `eslint-plugin-unicorn` (to v68), and configure the rules added in unicorn v66/v67/v68. - Remove `eslint-plugin-github` and its workarounds (rules, type stub, pnpm peer override, in-code `eslint-disable` comments); the rules worth keeping are covered by `unicorn` equivalents. - Apply the resulting fixes and autofixes across the JS codebase. _Prepared with Claude (Opus 4.8)._ --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
19 lines
960 B
TypeScript
19 lines
960 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="${CSS.escape(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');
|
|
});
|
|
}
|
|
}
|