mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-15 17:16:16 -08:00
Refactor Setting class to update and append items
This commit is contained in:
1 parent
1d191fe658
commit
c84157e30b
8 files changed
+217
-115
No files matched your search
@@ -0,0 +1,125 @@
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
setting: true,
|
||||
flip: true,
|
||||
playbackRate: true,
|
||||
aspectRatio: true,
|
||||
subtitleOffset: true,
|
||||
settings: [
|
||||
{
|
||||
width: 200,
|
||||
html: 'Subtitle',
|
||||
tooltip: 'Bilingual',
|
||||
icon: '<img width="22" heigth="22" src="/assets/img/subtitle.svg">',
|
||||
selector: [
|
||||
{
|
||||
html: 'Display',
|
||||
tooltip: 'Show',
|
||||
switch: true,
|
||||
onSwitch: function (item) {
|
||||
item.tooltip = item.switch ? 'Hide' : 'Show';
|
||||
art.subtitle.show = !item.switch;
|
||||
return !item.switch;
|
||||
},
|
||||
},
|
||||
{
|
||||
default: true,
|
||||
html: 'Bilingual',
|
||||
url: '/assets/sample/subtitle.srt',
|
||||
},
|
||||
{
|
||||
html: 'Chinese',
|
||||
url: '/assets/sample/subtitle.cn.srt',
|
||||
},
|
||||
{
|
||||
html: 'Japanese',
|
||||
url: '/assets/sample/subtitle.jp.srt',
|
||||
},
|
||||
],
|
||||
onSelect: function (item) {
|
||||
art.subtitle.switch(item.url, {
|
||||
name: item.html,
|
||||
});
|
||||
return item.html;
|
||||
},
|
||||
mounted: function (...args) {
|
||||
console.info(args);
|
||||
},
|
||||
},
|
||||
{
|
||||
html: 'Switcher',
|
||||
icon: '<img width="22" heigth="22" src="/assets/img/state.svg">',
|
||||
tooltip: 'OFF',
|
||||
switch: false,
|
||||
onSwitch: function (item) {
|
||||
item.tooltip = item.switch ? 'OFF' : 'ON';
|
||||
console.info('You clicked on the custom switch', item.switch);
|
||||
return !item.switch;
|
||||
},
|
||||
mounted: function (...args) {
|
||||
console.info(args);
|
||||
},
|
||||
},
|
||||
{
|
||||
html: 'Slider',
|
||||
icon: '<img width="22" heigth="22" src="/assets/img/state.svg">',
|
||||
tooltip: '5x',
|
||||
range: [5, 1, 10, 0.1],
|
||||
onRange: function (item) {
|
||||
return item.range + 'x';
|
||||
},
|
||||
mounted: function (...args) {
|
||||
console.info(args);
|
||||
},
|
||||
},
|
||||
],
|
||||
}, async () => {
|
||||
const { sleep } = Artplayer.utils;
|
||||
art.setting.show = true;
|
||||
await sleep(100);
|
||||
art.setting.resize();
|
||||
console.log(art.setting.builtin);
|
||||
console.log(art.setting.find('aspect-ratio'));
|
||||
console.log(art.setting.find('aspect-ratio2'));
|
||||
await sleep(1000);
|
||||
art.setting.remove('aspect-ratio');
|
||||
try {
|
||||
art.setting.remove('aspect-ratio2');
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
}
|
||||
await sleep(1000);
|
||||
art.setting.update({
|
||||
name: 'subtitle-offset',
|
||||
html: 'new offset',
|
||||
range: [5, -11, 11, 1],
|
||||
});
|
||||
await sleep(1000);
|
||||
art.setting.find('subtitle-offset').$range.value = -11;
|
||||
await sleep(1000);
|
||||
art.setting.update({
|
||||
name: 'flip',
|
||||
html: 'new flip',
|
||||
tooltip: 'OFF',
|
||||
switch: false,
|
||||
});
|
||||
await sleep(1000);
|
||||
art.setting.update({
|
||||
name: 'flip2',
|
||||
html: 'new flip2',
|
||||
tooltip: 'OFF',
|
||||
switch: true,
|
||||
});
|
||||
await sleep(1000);
|
||||
try {
|
||||
art.setting.add({
|
||||
name: 'flip2',
|
||||
html: 'new flip2',
|
||||
tooltip: 'OFF',
|
||||
switch: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
}
|
||||
});
|
||||
@@ -4577,7 +4577,6 @@ class Setting extends (0, _componentDefault.default) {
|
||||
this.id = 0;
|
||||
this.active = null;
|
||||
this.cache = new Map();
|
||||
this.symbol = Symbol("setting");
|
||||
this.option = [
|
||||
...this.builtin,
|
||||
...option.settings
|
||||
@@ -4614,11 +4613,11 @@ class Setting extends (0, _componentDefault.default) {
|
||||
format(option = this.option, parent, parents, names = []) {
|
||||
for(let index = 0; index < option.length; index++){
|
||||
const item = option[index];
|
||||
if (item?.name) {
|
||||
(0, _utils.errorHandle)(!names.includes(item.name), `The [${item.name}] is already exist in [setting]`);
|
||||
names.push(item.name);
|
||||
} else item.name = `setting-${this.id++}`;
|
||||
if (!item.$formatted) {
|
||||
if (item?.name) {
|
||||
(0, _utils.errorHandle)(!names.includes(item.name), `The [${item.name}] is already exist in [setting]`);
|
||||
names.push(item.name);
|
||||
} else item.name = `setting-${this.id++}`;
|
||||
(0, _utils.def)(item, "$parent", {
|
||||
get: ()=>parent
|
||||
});
|
||||
@@ -4676,6 +4675,7 @@ class Setting extends (0, _componentDefault.default) {
|
||||
item.$option.splice(index, 1);
|
||||
for(let index = 0; index < item.$events.length; index++)item.$events[index]();
|
||||
if (item.$item) (0, _utils.remove)(item.$item);
|
||||
item.$events.length = 0;
|
||||
this.render();
|
||||
}
|
||||
update(target) {
|
||||
@@ -4685,7 +4685,7 @@ class Setting extends (0, _componentDefault.default) {
|
||||
this.format();
|
||||
this.creatItem(item, true);
|
||||
this.render();
|
||||
} else this.add(item);
|
||||
} else this.add(target);
|
||||
}
|
||||
add(item, option = this.option) {
|
||||
option.push(item);
|
||||
@@ -4722,8 +4722,8 @@ class Setting extends (0, _componentDefault.default) {
|
||||
const $item = (0, _utils.createElement)("div");
|
||||
(0, _utils.addClass)($item, "art-setting-item");
|
||||
(0, _utils.setStyle)($item, "height", `${constructor.SETTING_ITEM_HEIGHT}px`);
|
||||
if ((0, _utils.isStringOrNumber)(item.name)) $item.dataset.name = item.name;
|
||||
if ((0, _utils.isStringOrNumber)(item.value)) $item.dataset.value = item.value;
|
||||
$item.dataset.name = item.name || "";
|
||||
$item.dataset.value = item.value || "";
|
||||
const $left = (0, _utils.append)($item, '<div class="art-setting-item-left"></div>');
|
||||
const $right = (0, _utils.append)($item, '<div class="art-setting-item-right"></div>');
|
||||
const $icon = (0, _utils.createElement)("div");
|
||||
@@ -4731,10 +4731,10 @@ class Setting extends (0, _componentDefault.default) {
|
||||
switch(type){
|
||||
case "switch":
|
||||
case "range":
|
||||
(0, _utils.append)($icon, (0, _utils.isStringOrNumber)(item.icon) || item.icon instanceof Element ? item.icon : icons.config);
|
||||
(0, _utils.append)($icon, item.icon ?? icons.config);
|
||||
break;
|
||||
case "selector":
|
||||
if (item.selector && item.selector.length) (0, _utils.append)($icon, (0, _utils.isStringOrNumber)(item.icon) || item.icon instanceof Element ? item.icon : icons.config);
|
||||
if (item.selector && item.selector.length) (0, _utils.append)($icon, item.icon ?? icons.config);
|
||||
else (0, _utils.append)($icon, icons.check);
|
||||
break;
|
||||
default:
|
||||
@@ -4742,6 +4742,7 @@ class Setting extends (0, _componentDefault.default) {
|
||||
}
|
||||
(0, _utils.append)($left, $icon);
|
||||
(0, _utils.def)(item, "$icon", {
|
||||
configurable: true,
|
||||
get: ()=>$icon
|
||||
});
|
||||
(0, _utils.def)(item, "icon", {
|
||||
@@ -4750,7 +4751,8 @@ class Setting extends (0, _componentDefault.default) {
|
||||
return $icon.innerHTML;
|
||||
},
|
||||
set (value) {
|
||||
if ((0, _utils.isStringOrNumber)(value)) $icon.innerHTML = value;
|
||||
$icon.innerHTML = "";
|
||||
(0, _utils.append)($icon, value);
|
||||
}
|
||||
});
|
||||
const $html = (0, _utils.createElement)("div");
|
||||
@@ -4758,6 +4760,7 @@ class Setting extends (0, _componentDefault.default) {
|
||||
(0, _utils.append)($html, item.html || "");
|
||||
(0, _utils.append)($left, $html);
|
||||
(0, _utils.def)(item, "$html", {
|
||||
configurable: true,
|
||||
get: ()=>$html
|
||||
});
|
||||
(0, _utils.def)(item, "html", {
|
||||
@@ -4766,7 +4769,8 @@ class Setting extends (0, _componentDefault.default) {
|
||||
return $html.innerHTML;
|
||||
},
|
||||
set (value) {
|
||||
if ((0, _utils.isStringOrNumber)(value)) $html.innerHTML = value;
|
||||
$html.innerHTML = "";
|
||||
(0, _utils.append)($html, value);
|
||||
}
|
||||
});
|
||||
const $tooltip = (0, _utils.createElement)("div");
|
||||
@@ -4774,6 +4778,7 @@ class Setting extends (0, _componentDefault.default) {
|
||||
(0, _utils.append)($tooltip, item.tooltip || "");
|
||||
(0, _utils.append)($right, $tooltip);
|
||||
(0, _utils.def)(item, "$tooltip", {
|
||||
configurable: true,
|
||||
get: ()=>$tooltip
|
||||
});
|
||||
(0, _utils.def)(item, "tooltip", {
|
||||
@@ -4782,7 +4787,8 @@ class Setting extends (0, _componentDefault.default) {
|
||||
return $tooltip.innerHTML;
|
||||
},
|
||||
set (value) {
|
||||
if ((0, _utils.isStringOrNumber)(value)) $tooltip.innerHTML = value;
|
||||
$tooltip.innerHTML = "";
|
||||
(0, _utils.append)($tooltip, value);
|
||||
}
|
||||
});
|
||||
switch(type){
|
||||
@@ -4818,23 +4824,15 @@ class Setting extends (0, _componentDefault.default) {
|
||||
const $state = (0, _utils.createElement)("div");
|
||||
(0, _utils.addClass)($state, "art-setting-item-right-icon");
|
||||
const $range = (0, _utils.append)($state, '<input type="range">');
|
||||
$range.value = item.range[0] || 0;
|
||||
$range.min = item.range[1] || 0;
|
||||
$range.max = item.range[2] || 10;
|
||||
$range.step = item.range[3] || 1;
|
||||
$range.min = item.range[1];
|
||||
$range.max = item.range[2];
|
||||
$range.step = item.range[3];
|
||||
$range.value = item.range[0];
|
||||
(0, _utils.addClass)($range, "art-setting-range");
|
||||
(0, _utils.append)($right, $state);
|
||||
(0, _utils.def)(item, "$range", {
|
||||
get: ()=>$range
|
||||
});
|
||||
(0, _utils.def)(item, "range", {
|
||||
configurable: true,
|
||||
get () {
|
||||
return $range.valueAsNumber;
|
||||
},
|
||||
set (value) {
|
||||
$range.value = Number(value);
|
||||
}
|
||||
get: ()=>$range
|
||||
});
|
||||
}
|
||||
break;
|
||||
@@ -4898,10 +4896,8 @@ class Setting extends (0, _componentDefault.default) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
(0, _utils.def)($item, this.symbol, {
|
||||
get: ()=>item
|
||||
});
|
||||
(0, _utils.def)(item, "$item", {
|
||||
configurable: true,
|
||||
get: ()=>$item
|
||||
});
|
||||
if (isUpdate) (0, _utils.replaceElement)($item, oldItem);
|
||||
@@ -4922,7 +4918,7 @@ class Setting extends (0, _componentDefault.default) {
|
||||
(0, _utils.inverseClass)($panel, "art-current");
|
||||
for(let index = 0; index < option.length; index++){
|
||||
const item = option[index];
|
||||
if (item.mounted) item.mounted.call(this.art, $panel, item);
|
||||
if (item.mounted) item.mounted.call(this.art, item.$item, item);
|
||||
}
|
||||
}
|
||||
this.resize();
|
||||
@@ -4937,9 +4933,9 @@ parcelHelpers.export(exports, "default", ()=>flip);
|
||||
var _utils = require("../utils");
|
||||
function flip(art) {
|
||||
const { i18n, icons, constructor: { SETTING_ITEM_WIDTH, FLIP } } = art;
|
||||
function update($panel, $tooltip, value) {
|
||||
function update($item, $tooltip, value) {
|
||||
if ($tooltip) $tooltip.innerText = i18n.get((0, _utils.capitalize)(value));
|
||||
const $current = (0, _utils.queryAll)(".art-setting-item", $panel).find((item)=>item.dataset.value === value);
|
||||
const $current = (0, _utils.queryAll)(".art-setting-item", $item).find((item)=>item.dataset.value === value);
|
||||
if ($current) (0, _utils.inverseClass)($current, "art-current");
|
||||
}
|
||||
return {
|
||||
@@ -4960,10 +4956,10 @@ function flip(art) {
|
||||
art.flip = item.value;
|
||||
return item.html;
|
||||
},
|
||||
mounted: ($panel, item)=>{
|
||||
update($panel, item.$tooltip, art.flip);
|
||||
mounted: ($item, item)=>{
|
||||
update($item, item.$tooltip, art.flip);
|
||||
art.on("flip", ()=>{
|
||||
update($panel, item.$tooltip, art.flip);
|
||||
update($item, item.$tooltip, art.flip);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -4979,9 +4975,9 @@ function aspectRatio(art) {
|
||||
function getI18n(value) {
|
||||
return value === "default" ? i18n.get("Default") : value;
|
||||
}
|
||||
function update($panel, $tooltip, value) {
|
||||
function update($item, $tooltip, value) {
|
||||
if ($tooltip) $tooltip.innerText = getI18n(value);
|
||||
const $current = (0, _utils.queryAll)(".art-setting-item", $panel).find((item)=>item.dataset.value === value);
|
||||
const $current = (0, _utils.queryAll)(".art-setting-item", $item).find((item)=>item.dataset.value === value);
|
||||
if ($current) (0, _utils.inverseClass)($current, "art-current");
|
||||
}
|
||||
return {
|
||||
@@ -5002,10 +4998,10 @@ function aspectRatio(art) {
|
||||
art.aspectRatio = item.value;
|
||||
return item.html;
|
||||
},
|
||||
mounted: ($panel, item)=>{
|
||||
update($panel, item.$tooltip, art.aspectRatio);
|
||||
mounted: ($item, item)=>{
|
||||
update($item, item.$tooltip, art.aspectRatio);
|
||||
art.on("aspectRatio", ()=>{
|
||||
update($panel, item.$tooltip, art.aspectRatio);
|
||||
update($item, item.$tooltip, art.aspectRatio);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -5021,9 +5017,9 @@ function playbackRate(art) {
|
||||
function getI18n(value) {
|
||||
return value === 1.0 ? i18n.get("Normal") : value.toFixed(1);
|
||||
}
|
||||
function update($panel, $tooltip, value) {
|
||||
function update($item, $tooltip, value) {
|
||||
if ($tooltip) $tooltip.innerText = getI18n(value);
|
||||
const $current = (0, _utils.queryAll)(".art-setting-item", $panel).find((item)=>Number(item.dataset.value) === value);
|
||||
const $current = (0, _utils.queryAll)(".art-setting-item", $item).find((item)=>Number(item.dataset.value) === value);
|
||||
if ($current) (0, _utils.inverseClass)($current, "art-current");
|
||||
}
|
||||
return {
|
||||
@@ -5044,10 +5040,10 @@ function playbackRate(art) {
|
||||
art.playbackRate = item.value;
|
||||
return item.html;
|
||||
},
|
||||
mounted: ($panel, item)=>{
|
||||
update($panel, item.$tooltip, art.playbackRate);
|
||||
mounted: ($item, item)=>{
|
||||
update($item, item.$tooltip, art.playbackRate);
|
||||
art.on("video:ratechange", ()=>{
|
||||
update($panel, item.$tooltip, art.playbackRate);
|
||||
update($item, item.$tooltip, art.playbackRate);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -5072,8 +5068,8 @@ function subtitleOffset(art) {
|
||||
0.1
|
||||
],
|
||||
onChange (item) {
|
||||
art.subtitleOffset = item.range;
|
||||
return item.range + "s";
|
||||
art.subtitleOffset = item.$range.valueAsNumber;
|
||||
return item.$range.valueAsNumber + "s";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAI,KAAK;AACT,MAAM,YAAY,EAAE;AACL,MAAM,kBAAkB,CAAA,GAAA,uBAAO,AAAD;IACzC,YAAY,MAAM,EAAE,aAAa,CAAE;QAC/B,KAAK;QAEL,IAAI,CAAC,EAAE,GAAG,EAAE;QAEZ,MAAM,cAAc,OAAM,SAAS,CAAC,UAAU,MAAM,EAAE;QACtD,YAAY,SAAS,GAAG,OAAO,SAAS;QAExC,IAAI,CAAC,MAAM,GAAG,CAAA,GAAA,+BAAS,AAAD,EAAE,aAAa,CAAA,GAAA,sBAAM,AAAD;QAE1C,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,SAAS,GAAG;QAEjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA,GAAA,wBAAQ,AAAD,EAAE,IAAI;QACjC,IAAI,CAAC,MAAM,GAAG,IAAI,C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AC9B,UAAU,qBAAqB,GAAG;AAClC,UAAU,kBAAkB,GAAG;AAC/B,UAAU,oBAAoB,GAAG;AACjC,UAAU,iBAAiB,GAAG;AAC9B,UAAU,YAAY,GAAG;AACzB,UAAU,kBAAkB,GAAG;AAC/B,UAAU,mBAAmB,GAAG;AAChC,UAAU,iBAAiB,GAAG;AAC9B,UAAU,qBAAqB,GAAG;AAClC,UAAU,cAAc,GAAG;AAC3B,UAAU,kBAAkB,GAAG;AAC/B,UAAU,iBAAiB,GAAG;AAC9B,UAAU,gBAAgB,GAAG;AAC7B,UAAU,WAAW,GAAG;AACxB,UAAU,SAAS,GAAG;AACtB,UAAU,aAAa,GAAG;IAAC;IAAK;IAAM;IAAG;IAAM;IAAK;CAAE;AACtD,UAAU,YAAY,GAAG;IAAC;IAAW;IAAO;CAAO;AACnD,UAAU,IAAI,GAAG;IAAC;IAAU;IAAc;CAAW;AACrD,UAAU,sBAAsB,GAAG;AACnC,UAAU,WAAW,GAAG;AACxB,UAAU,OAAO,GAAG;AAEpB,IAAI,OAAM,SAAS,EAAE;IACjB,MAAM,CAAC,YAAY,GAAG;IAEtB,OAAM,YAAY,CAAC,mBAAmB,CAAA,GAAA,yBAAK,AAAD;IAE1C,WAAW;QACP,IAAI,UAAU,WAAW,EACrB,QAAQ,GAAG,CACP,CAAC,gBAAgB,EAAE,UAAU,OAAO,CAAC,yBAAyB,CAAC,EAC/D,oCACA,oCACA;IAGZ,GAAG;AALine truncated
|
||||
@@ -11,9 +11,9 @@ export default function aspectRatio(art) {
|
||||
return value === 'default' ? i18n.get('Default') : value;
|
||||
}
|
||||
|
||||
function update($panel, $tooltip, value) {
|
||||
function update($item, $tooltip, value) {
|
||||
if ($tooltip) $tooltip.innerText = getI18n(value);
|
||||
const $current = queryAll('.art-setting-item', $panel).find((item) => item.dataset.value === value);
|
||||
const $current = queryAll('.art-setting-item', $item).find((item) => item.dataset.value === value);
|
||||
if ($current) inverseClass($current, 'art-current');
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ export default function aspectRatio(art) {
|
||||
art.aspectRatio = item.value;
|
||||
return item.html;
|
||||
},
|
||||
mounted: ($panel, item) => {
|
||||
update($panel, item.$tooltip, art.aspectRatio);
|
||||
mounted: ($item, item) => {
|
||||
update($item, item.$tooltip, art.aspectRatio);
|
||||
art.on('aspectRatio', () => {
|
||||
update($panel, item.$tooltip, art.aspectRatio);
|
||||
update($item, item.$tooltip, art.aspectRatio);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -7,9 +7,9 @@ export default function flip(art) {
|
||||
constructor: { SETTING_ITEM_WIDTH, FLIP },
|
||||
} = art;
|
||||
|
||||
function update($panel, $tooltip, value) {
|
||||
function update($item, $tooltip, value) {
|
||||
if ($tooltip) $tooltip.innerText = i18n.get(capitalize(value));
|
||||
const $current = queryAll('.art-setting-item', $panel).find((item) => item.dataset.value === value);
|
||||
const $current = queryAll('.art-setting-item', $item).find((item) => item.dataset.value === value);
|
||||
if ($current) inverseClass($current, 'art-current');
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ export default function flip(art) {
|
||||
art.flip = item.value;
|
||||
return item.html;
|
||||
},
|
||||
mounted: ($panel, item) => {
|
||||
update($panel, item.$tooltip, art.flip);
|
||||
mounted: ($item, item) => {
|
||||
update($item, item.$tooltip, art.flip);
|
||||
art.on('flip', () => {
|
||||
update($panel, item.$tooltip, art.flip);
|
||||
update($item, item.$tooltip, art.flip);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -36,7 +36,6 @@ export default class Setting extends Component {
|
||||
this.id = 0;
|
||||
this.active = null;
|
||||
this.cache = new Map();
|
||||
this.symbol = Symbol('setting');
|
||||
this.option = [...this.builtin, ...option.settings];
|
||||
|
||||
if (option.setting) {
|
||||
@@ -89,14 +88,15 @@ export default class Setting extends Component {
|
||||
format(option = this.option, parent, parents, names = []) {
|
||||
for (let index = 0; index < option.length; index++) {
|
||||
const item = option[index];
|
||||
if (!item.$formatted) {
|
||||
if (item?.name) {
|
||||
errorHandle(!names.includes(item.name), `The [${item.name}] is already exist in [setting]`);
|
||||
names.push(item.name);
|
||||
} else {
|
||||
item.name = `setting-${this.id++}`;
|
||||
}
|
||||
|
||||
if (item?.name) {
|
||||
errorHandle(!names.includes(item.name), `The [${item.name}] is already exist in [setting]`);
|
||||
names.push(item.name);
|
||||
} else {
|
||||
item.name = `setting-${this.id++}`;
|
||||
}
|
||||
|
||||
if (!item.$formatted) {
|
||||
def(item, '$parent', {
|
||||
get: () => parent,
|
||||
});
|
||||
@@ -176,6 +176,7 @@ export default class Setting extends Component {
|
||||
if (item.$item) {
|
||||
remove(item.$item);
|
||||
}
|
||||
item.$events.length = 0;
|
||||
this.render();
|
||||
}
|
||||
|
||||
@@ -187,7 +188,7 @@ export default class Setting extends Component {
|
||||
this.creatItem(item, true);
|
||||
this.render();
|
||||
} else {
|
||||
this.add(item);
|
||||
this.add(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,13 +245,8 @@ export default class Setting extends Component {
|
||||
addClass($item, 'art-setting-item');
|
||||
setStyle($item, 'height', `${constructor.SETTING_ITEM_HEIGHT}px`);
|
||||
|
||||
if (isStringOrNumber(item.name)) {
|
||||
$item.dataset.name = item.name;
|
||||
}
|
||||
|
||||
if (isStringOrNumber(item.value)) {
|
||||
$item.dataset.value = item.value;
|
||||
}
|
||||
$item.dataset.name = item.name || '';
|
||||
$item.dataset.value = item.value || '';
|
||||
|
||||
const $left = append($item, '<div class="art-setting-item-left"></div>');
|
||||
const $right = append($item, '<div class="art-setting-item-right"></div>');
|
||||
@@ -261,14 +257,11 @@ export default class Setting extends Component {
|
||||
switch (type) {
|
||||
case 'switch':
|
||||
case 'range':
|
||||
append($icon, isStringOrNumber(item.icon) || item.icon instanceof Element ? item.icon : icons.config);
|
||||
append($icon, item.icon ?? icons.config);
|
||||
break;
|
||||
case 'selector':
|
||||
if (item.selector && item.selector.length) {
|
||||
append(
|
||||
$icon,
|
||||
isStringOrNumber(item.icon) || item.icon instanceof Element ? item.icon : icons.config,
|
||||
);
|
||||
append($icon, item.icon ?? icons.config);
|
||||
} else {
|
||||
append($icon, icons.check);
|
||||
}
|
||||
@@ -280,6 +273,7 @@ export default class Setting extends Component {
|
||||
append($left, $icon);
|
||||
|
||||
def(item, '$icon', {
|
||||
configurable: true,
|
||||
get: () => $icon,
|
||||
});
|
||||
|
||||
@@ -289,9 +283,8 @@ export default class Setting extends Component {
|
||||
return $icon.innerHTML;
|
||||
},
|
||||
set(value) {
|
||||
if (isStringOrNumber(value)) {
|
||||
$icon.innerHTML = value;
|
||||
}
|
||||
$icon.innerHTML = '';
|
||||
append($icon, value);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -301,6 +294,7 @@ export default class Setting extends Component {
|
||||
append($left, $html);
|
||||
|
||||
def(item, '$html', {
|
||||
configurable: true,
|
||||
get: () => $html,
|
||||
});
|
||||
|
||||
@@ -310,9 +304,8 @@ export default class Setting extends Component {
|
||||
return $html.innerHTML;
|
||||
},
|
||||
set(value) {
|
||||
if (isStringOrNumber(value)) {
|
||||
$html.innerHTML = value;
|
||||
}
|
||||
$html.innerHTML = '';
|
||||
append($html, value);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -322,6 +315,7 @@ export default class Setting extends Component {
|
||||
append($right, $tooltip);
|
||||
|
||||
def(item, '$tooltip', {
|
||||
configurable: true,
|
||||
get: () => $tooltip,
|
||||
});
|
||||
|
||||
@@ -331,9 +325,8 @@ export default class Setting extends Component {
|
||||
return $tooltip.innerHTML;
|
||||
},
|
||||
set(value) {
|
||||
if (isStringOrNumber(value)) {
|
||||
$tooltip.innerHTML = value;
|
||||
}
|
||||
$tooltip.innerHTML = '';
|
||||
append($tooltip, value);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -345,8 +338,8 @@ export default class Setting extends Component {
|
||||
const $switchOff = append($state, icons.switchOff);
|
||||
setStyle(item.switch ? $switchOff : $switchOn, 'display', 'none');
|
||||
append($right, $state);
|
||||
item.$switch = item.switch;
|
||||
|
||||
item.$switch = item.switch;
|
||||
def(item, 'switch', {
|
||||
configurable: true,
|
||||
get() {
|
||||
@@ -370,25 +363,16 @@ export default class Setting extends Component {
|
||||
const $state = createElement('div');
|
||||
addClass($state, 'art-setting-item-right-icon');
|
||||
const $range = append($state, '<input type="range">');
|
||||
$range.value = item.range[0] || 0;
|
||||
$range.min = item.range[1] || 0;
|
||||
$range.max = item.range[2] || 10;
|
||||
$range.step = item.range[3] || 1;
|
||||
$range.min = item.range[1];
|
||||
$range.max = item.range[2];
|
||||
$range.step = item.range[3];
|
||||
$range.value = item.range[0];
|
||||
addClass($range, 'art-setting-range');
|
||||
append($right, $state);
|
||||
|
||||
def(item, '$range', {
|
||||
get: () => $range,
|
||||
});
|
||||
|
||||
def(item, 'range', {
|
||||
configurable: true,
|
||||
get() {
|
||||
return $range.valueAsNumber;
|
||||
},
|
||||
set(value) {
|
||||
$range.value = Number(value);
|
||||
},
|
||||
get: () => $range,
|
||||
});
|
||||
}
|
||||
break;
|
||||
@@ -469,11 +453,8 @@ export default class Setting extends Component {
|
||||
break;
|
||||
}
|
||||
|
||||
def($item, this.symbol, {
|
||||
get: () => item,
|
||||
});
|
||||
|
||||
def(item, '$item', {
|
||||
configurable: true,
|
||||
get: () => $item,
|
||||
});
|
||||
|
||||
@@ -508,7 +489,7 @@ export default class Setting extends Component {
|
||||
for (let index = 0; index < option.length; index++) {
|
||||
const item = option[index];
|
||||
if (item.mounted) {
|
||||
item.mounted.call(this.art, $panel, item);
|
||||
item.mounted.call(this.art, item.$item, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ export default function playbackRate(art) {
|
||||
return value === 1.0 ? i18n.get('Normal') : value.toFixed(1);
|
||||
}
|
||||
|
||||
function update($panel, $tooltip, value) {
|
||||
function update($item, $tooltip, value) {
|
||||
if ($tooltip) $tooltip.innerText = getI18n(value);
|
||||
const $current = queryAll('.art-setting-item', $panel).find((item) => Number(item.dataset.value) === value);
|
||||
const $current = queryAll('.art-setting-item', $item).find((item) => Number(item.dataset.value) === value);
|
||||
if ($current) inverseClass($current, 'art-current');
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ export default function playbackRate(art) {
|
||||
art.playbackRate = item.value;
|
||||
return item.html;
|
||||
},
|
||||
mounted: ($panel, item) => {
|
||||
update($panel, item.$tooltip, art.playbackRate);
|
||||
mounted: ($item, item) => {
|
||||
update($item, item.$tooltip, art.playbackRate);
|
||||
art.on('video:ratechange', () => {
|
||||
update($panel, item.$tooltip, art.playbackRate);
|
||||
update($item, item.$tooltip, art.playbackRate);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -9,8 +9,8 @@ export default function subtitleOffset(art) {
|
||||
tooltip: '0s',
|
||||
range: [0, -5, 5, 0.1],
|
||||
onChange(item) {
|
||||
art.subtitleOffset = item.range;
|
||||
return item.range + 's';
|
||||
art.subtitleOffset = item.$range.valueAsNumber;
|
||||
return item.$range.valueAsNumber + 's';
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user