Initial favouriting and horrible toggle code fix it Zere
This commit is contained in:
parent
1ab52cb174
commit
c4f28a6ac5
|
@ -60,8 +60,18 @@ export default new class EmoteModule extends BuiltinModule {
|
|||
{
|
||||
text: 'Favourite',
|
||||
type: 'toggle',
|
||||
checked: (target) => { console.log(target); if (target.alt && target.alt === ';cirThree;') { console.log('yes'); return true; } else return false; },
|
||||
onChange: (checked, target) => { if (target.alt && target.alt === ';cirThree;') { console.log('yes'); return true; } else return false; }
|
||||
checked: (target) => {
|
||||
const { alt } = target;
|
||||
if (!alt) return false;
|
||||
return this.favourites.find(e => e.alt === alt);
|
||||
},
|
||||
onChange: (checked, target) => {
|
||||
const { alt } = target;
|
||||
if (!alt) return false;
|
||||
const fav = this.favourites.find(e => e.alt === alt);
|
||||
if (fav) return this._favourites = this._favourites.filter(e => e.alt !== target.alt);
|
||||
this.favourites.push({ alt: target.alt });
|
||||
}
|
||||
}
|
||||
], filter => filter.closest('.bd-emote'));
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
<div class="bd-cmGroup" ref="test">
|
||||
<template v-for="(item, index) in items">
|
||||
<CMButton v-if="!item.type || item.type === 'button'" :item="item" :onClick="() => { item.onClick(); closeMenu(); }" />
|
||||
<CMToggle v-else-if="item.type === 'toggle'" :item="item" :checked="typeof item.checked === 'function' ? item.checked(target) : item.checked" :onClick="() => { }" />
|
||||
<CMToggle v-else-if="item.type === 'toggle'" :item="item" :checked="typeof item.checked === 'function' ? item.checked(target) : item.checked" :onClick="() => { typeof item.checked === 'function' ? (item.onChange(!item.checked(target), target), $forceUpdate()) : item.onChange(!item.checked) }" />
|
||||
<div v-else-if="item.type === 'sub'" class="bd-cmItem bd-cmSub" @mouseenter="e => subMenuMouseEnter(e, index, item)" @mouseleave="e => subMenuMouseLeave(e, index, item)">
|
||||
{{item.text}}
|
||||
<MiChevronDown />
|
||||
<div ref="test2" class="bd-cm" v-if="index === visibleSub" :style="subStyle">
|
||||
<template v-for="(item, index) in item.items">
|
||||
<CMButton v-if="!item.type || item.type === 'button'" :item="item" :onClick="() => { item.onClick(); closeMenu(); }" />
|
||||
<CMToggle v-else-if="item.type === 'toggle'" :item="item" :checked="typeof item.checked === 'function' ? item.checked(target) : item.checked" :onClick="() => { }" />
|
||||
<CMToggle v-else-if="item.type === 'toggle'" :item="item" :checked="typeof item.checked === 'function' ? item.checked(target) : item.checked" :onClick="() => { typeof item.checked === 'function' ? item.onChange(!item.checked(target), target) && $forceUpdate() : item.onChange(!item.checked) }" />
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue