add jsdoc comments
This commit is contained in:
1 parent
6de354ad47
commit
8c1205bc13
24 files changed
+1228
-425
No files matched your search
+10
-5
@@ -3,14 +3,14 @@ import "./css/tab.scss";
|
||||
/**
|
||||
* Tab 页创建参数类
|
||||
* @typedef TabOption
|
||||
* @property {HTMLElement} container - 父容器
|
||||
* @property {HTMLElement} container 父容器
|
||||
*/
|
||||
|
||||
import { createElement } from "../functions";
|
||||
|
||||
/**
|
||||
* 创建 Tab 页
|
||||
* @param {TabOption | HTMLElement} options - 创建选项
|
||||
* @param {TabOption | HTMLElement} options 创建选项
|
||||
*/
|
||||
export function createTab(options) {
|
||||
if (options instanceof HTMLElement) {
|
||||
@@ -29,13 +29,18 @@ export function createTab(options) {
|
||||
createElement('div', header => {
|
||||
header.className = 'ui-tab-header';
|
||||
header.addEventListener('click', e => {
|
||||
const title = e.target;
|
||||
if (title.classList.contains('ui-tab-title')) {
|
||||
const title = /** @type {HTMLElement} */ (e.target);
|
||||
if (title != null && title.classList.contains('ui-tab-title')) {
|
||||
// title
|
||||
header.querySelectorAll('.ui-tab-title').forEach(t => t === title ? t.classList.add('selected') : t.classList.remove('selected'));
|
||||
// pages
|
||||
const page = title.dataset.for;
|
||||
container.querySelectorAll('[data-page]').forEach(p => p.style.display = p.dataset.page === page ? 'block' : '');
|
||||
container.querySelectorAll('[data-page]').forEach(p => {
|
||||
if (!(p instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
p.style.display = p.dataset.page === page ? 'block' : '';
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user