Skip to content

Commit e112b64

Browse files
committed
refactor: 更新样式选择弹窗脚本
1 parent 67610f1 commit e112b64

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
import { insertAfter } from "../../_content/BootstrapBlazor/modules/utility.js"
2-
import Data from "../../_content/BootstrapBlazor/modules/data.js"
3-
import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js"
1+
import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js"
42

53
export function init(id) {
6-
const el = document.getElementById(id)
4+
const el = document.getElementById(id);
75
if (el === null) {
8-
return
6+
return;
97
}
10-
const themeList = el.querySelector('.theme-list')
11-
12-
Data.set(id, { el });
138

9+
const themeList = document.querySelector('.theme-list');
10+
const close = document.querySelector('.theme-list .btn-close');
1411
EventHandler.on(el, 'click', () => {
15-
themeList.classList.toggle('is-open')
16-
})
12+
themeList.classList.toggle('is-open');
13+
});
14+
EventHandler.on(close, 'click', () => {
15+
themeList.classList.remove('is-open');
16+
});
1717
}
1818

1919
export function dispose(id) {
20-
const theme = Data.get(id)
21-
Data.remove(id)
20+
const el = document.getElementById(id);
21+
if (el) {
22+
EventHandler.off(el, 'click');
23+
}
2224

23-
if (theme) {
24-
EventHandler.off(theme.el, 'click')
25+
const close = document.querySelector('.theme-list .btn-close');
26+
if (close) {
27+
EventHandler.off(close, 'click');
2528
}
2629
}

0 commit comments

Comments
 (0)