This commit is contained in:
Harvey Zack committed 2018-11-08 08:57:47 +08:00
1 parent ddcf432717
commit 8148973d39
5 files changed
+9 -19

No files matched your search

+5 -16
View File
@@ -1,15 +1,14 @@
import { setStyle, append } from '../utils';
import { setStyle, append, insertByIndex } from '../utils';
import Common from './common';
let id = 0;
export default class Setting {
constructor(art) {
id = 0;
this.art = art;
this.state = false;
this.$settings = [];
if (art.option.setting) {
this.init();
this.mount();
}
}
@@ -29,6 +28,7 @@ export default class Setting {
}
add(setting) {
const { refs } = this.art;
const { option } = setting;
if (option && !option.disable) {
id++;
@@ -39,23 +39,12 @@ export default class Setting {
$setting.dataset.settingIndex = option.index || id;
append($setting, `<div class="art-setting-header">${this.art.i18n.get(title)}</div>`);
append($setting, '<div class="art-setting-body"></div>');
this.$settings.push($setting);
setting.apply && setting.apply(this.art, $setting);
this[name] = setting;
this[name] = $setting;
insertByIndex(refs.$settingBody, $setting, option.index || id);
}
}
mount() {
this.$settings
.sort(
(a, b) =>
Number(a.dataset.settingIndex) - Number(b.dataset.settingIndex)
)
.forEach($setting => {
append(this.art.refs.$settingBody, $setting);
});
}
show() {
const { refs: { $setting }, i18n, notice } = this.art;
setStyle($setting, 'display', 'flex');