Fix: use switch-case

This commit is contained in:
eight 2017-11-09 09:00:46 +08:00
parent 7842ac752a
commit c17433c350

View File

@ -42,7 +42,8 @@ function configDialog(style) {
for (const key of Object.keys(vars)) { for (const key of Object.keys(vars)) {
const va = vars[key]; const va = vars[key];
let appendChild; let appendChild;
if (va.type === 'color') { switch (va.type) {
case 'color':
va.inputColor = $element({tag: 'input', type: 'color'}); va.inputColor = $element({tag: 'input', type: 'color'});
va.inputAlpha = $element({ va.inputAlpha = $element({
tag: 'input', tag: 'input',
@ -62,7 +63,9 @@ function configDialog(style) {
appendChild = [ appendChild = [
$element({appendChild: [va.inputColor, va.inputAlpha]}) $element({appendChild: [va.inputColor, va.inputAlpha]})
]; ];
} else if (va.type === 'checkbox') { break;
case 'checkbox':
va.input = $element({tag: 'input', type: 'checkbox'}); va.input = $element({tag: 'input', type: 'checkbox'});
va.input.onchange = () => { va.input.onchange = () => {
va.dirty = true; va.dirty = true;
@ -74,7 +77,11 @@ function configDialog(style) {
$element({tag: 'span'}) $element({tag: 'span'})
]}) ]})
]; ];
} else if (va.type === 'select' || va.type === 'dropdown' || va.type === 'image') { break;
case 'select':
case 'dropdown':
case 'image':
// TODO: a image picker input? // TODO: a image picker input?
va.input = $element({ va.input = $element({
tag: 'select', tag: 'select',
@ -87,13 +94,16 @@ function configDialog(style) {
va.value = va.input.value; va.value = va.input.value;
}; };
appendChild = [va.input]; appendChild = [va.input];
} else { break;
default:
va.input = $element({tag: 'input', type: 'text'}); va.input = $element({tag: 'input', type: 'text'});
va.input.oninput = () => { va.input.oninput = () => {
va.dirty = true; va.dirty = true;
va.value = va.input.value; va.value = va.input.value;
}; };
appendChild = [va.input]; appendChild = [va.input];
break;
} }
appendChild.unshift($element({tag: 'span', appendChild: va.label})); appendChild.unshift($element({tag: 'span', appendChild: va.label}));
labels.push($element({ labels.push($element({