update setting

This commit is contained in:
zhw2590582 committed 2022-02-11 20:23:27 +08:00
1 parent 81ba45adf9
commit 1de2d2aaed
12 files changed
+177 -153

No files matched your search

@@ -7,8 +7,8 @@ export default function aspectRatio(art) {
return value === 'default' ? i18n.get('Default') : value;
}
function update($panel, $desc, value) {
if ($desc) $desc.innerText = getI18n(value);
function update($panel, $description, value) {
if ($description) $description.innerText = getI18n(value);
const $current = queryAll('.art-setting-item', $panel).find((item) => item.dataset.value === value);
if ($current) inverseClass($current, 'art-current');
}
@@ -17,7 +17,7 @@ export default function aspectRatio(art) {
width: 200,
html: i18n.get('Aspect Ratio'),
icon: icons.aspectRatio,
desc: getI18n(art.aspectRatio),
description: getI18n(art.aspectRatio),
selector: ['default', '4:3', '16:9'].map((item) => {
return {
value: item,
@@ -27,11 +27,12 @@ export default function aspectRatio(art) {
}),
onSelect(item) {
art.aspectRatio = item.value;
return getI18n(item.value);
},
mounted: ($panel, item) => {
update($panel, item.$desc, art.aspectRatio);
update($panel, item._$description, art.aspectRatio);
art.on('aspectRatio', () => {
update($panel, item.$desc, art.aspectRatio);
update($panel, item._$description, art.aspectRatio);
});
},
};
+6 -5
View File
@@ -9,8 +9,8 @@ export default function flip(art) {
vertical: 'Vertical',
};
function update($panel, $desc, value) {
if ($desc) $desc.innerText = i18n.get(keys[value]);
function update($panel, $description, value) {
if ($description) $description.innerText = i18n.get(keys[value]);
const $current = queryAll('.art-setting-item', $panel).find((item) => item.dataset.value === value);
if ($current) inverseClass($current, 'art-current');
}
@@ -18,7 +18,7 @@ export default function flip(art) {
return {
width: 200,
html: i18n.get('Video Flip'),
desc: i18n.get(keys[art.flip]),
description: i18n.get(keys[art.flip]),
icon: icons.config,
selector: Object.keys(keys).map((item) => {
return {
@@ -29,11 +29,12 @@ export default function flip(art) {
}),
onSelect(item) {
art.flip = item.value;
return i18n.get(keys[item.value]);
},
mounted: ($panel, item) => {
update($panel, item.$desc, art.flip);
update($panel, item._$description, art.flip);
art.on('flip', () => {
update($panel, item.$desc, art.flip);
update($panel, item._$description, art.flip);
});
},
};
+12 -7
View File
@@ -133,13 +133,13 @@ export default class Setting extends Component {
append($left, item.html);
if (hasChildren) {
const $desc = document.createElement('div');
addClass($desc, 'art-setting-item-right-desc');
append($right, $desc);
item.$desc = $desc;
const $description = document.createElement('div');
addClass($description, 'art-setting-item-right-description');
append($right, $description);
item._$description = $description;
if (item.desc) {
$desc.innerText = item.desc;
if (item.description) {
$description.innerHTML = item.description;
}
const $iconRight = document.createElement('div');
@@ -159,7 +159,12 @@ export default class Setting extends Component {
}
if (item._parentItem && item._parentItem.onSelect) {
item._parentItem.onSelect.call(this.art, item, $item, event);
const result = item._parentItem.onSelect.call(this.art, item, $item, event);
if (item._parentItem._$description) {
if (typeof result === 'string' || typeof result === 'number') {
item._parentItem._$description.innerHTML = result;
}
}
}
}
});
@@ -7,8 +7,8 @@ export default function playbackRate(art) {
return value === 1.0 ? i18n.get('Normal') : value;
}
function update($panel, $desc, value) {
if ($desc) $desc.innerText = getI18n(value);
function update($panel, $description, value) {
if ($description) $description.innerText = getI18n(value);
const $current = queryAll('.art-setting-item', $panel).find((item) => Number(item.dataset.value) === value);
if ($current) inverseClass($current, 'art-current');
}
@@ -16,7 +16,7 @@ export default function playbackRate(art) {
return {
width: 200,
html: i18n.get('Play Speed'),
desc: getI18n(art.playbackRate),
description: getI18n(art.playbackRate),
icon: icons.playbackRate,
selector: [0.5, 0.75, 1.0, 1.25, 1.5, 2.0].map((item) => {
return {
@@ -27,11 +27,12 @@ export default function playbackRate(art) {
}),
onSelect(item) {
art.playbackRate = item.value;
return getI18n(item.value);
},
mounted: ($panel, item) => {
update($panel, item.$desc, art.playbackRate);
update($panel, item._$description, art.playbackRate);
art.on('playbackRate', () => {
update($panel, item.$desc, art.playbackRate);
update($panel, item._$description, art.playbackRate);
});
},
};
@@ -7,8 +7,8 @@ export default function subtitleOffset(art) {
return value === 0 ? i18n.get('Normal') : value;
}
function update($panel, $desc, value) {
if ($desc) $desc.innerText = getI18n(value);
function update($panel, $description, value) {
if ($description) $description.innerText = getI18n(value);
const $current = queryAll('.art-setting-item', $panel).find((item) => Number(item.dataset.value) === value);
if ($current) inverseClass($current, 'art-current');
}
@@ -16,7 +16,7 @@ export default function subtitleOffset(art) {
return {
width: 200,
html: i18n.get('Subtitle Offset'),
desc: getI18n(art.subtitleOffset),
description: getI18n(art.subtitleOffset),
icon: icons.subtitle,
selector: [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5].map((item) => {
return {
@@ -27,11 +27,12 @@ export default function subtitleOffset(art) {
}),
onSelect(item) {
art.subtitleOffset = item.value;
return getI18n(item.value);
},
mounted: ($panel, item) => {
update($panel, item.$desc, art.subtitleOffset);
update($panel, item._$description, art.subtitleOffset);
art.on('subtitleOffset', () => {
update($panel, item.$desc, art.subtitleOffset);
update($panel, item._$description, art.subtitleOffset);
});
},
};