Correct targeting
This commit is contained in:
parent
f315c8b134
commit
1ab52cb174
|
@ -60,8 +60,8 @@ export default new class EmoteModule extends BuiltinModule {
|
||||||
{
|
{
|
||||||
text: 'Favourite',
|
text: 'Favourite',
|
||||||
type: 'toggle',
|
type: 'toggle',
|
||||||
checked: false,
|
checked: (target) => { console.log(target); if (target.alt && target.alt === ';cirThree;') { console.log('yes'); return true; } else return false; },
|
||||||
onChange: (checked, target) => { console.log(target); return checked; }
|
onChange: (checked, target) => { if (target.alt && target.alt === ';cirThree;') { console.log('yes'); return true; } else return false; }
|
||||||
}
|
}
|
||||||
], filter => filter.closest('.bd-emote'));
|
], filter => filter.closest('.bd-emote'));
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
<div class="bd-cmGroup" ref="test">
|
<div class="bd-cmGroup" ref="test">
|
||||||
<template v-for="(item, index) in items">
|
<template v-for="(item, index) in items">
|
||||||
<CMButton v-if="!item.type || item.type === 'button'" :item="item" :onClick="() => { item.onClick(); closeMenu(); }" />
|
<CMButton v-if="!item.type || item.type === 'button'" :item="item" :onClick="() => { item.onClick(); closeMenu(); }" />
|
||||||
<CMToggle v-else-if="item.type === 'toggle'" :item="item" :onClick="() => { item.checked = item.onChange(!item.checked, target) }"/>
|
<CMToggle v-else-if="item.type === 'toggle'" :item="item" :checked="typeof item.checked === 'function' ? item.checked(target) : item.checked" :onClick="() => { }" />
|
||||||
<div v-else-if="item.type === 'sub'" class="bd-cmItem bd-cmSub" @mouseenter="e => subMenuMouseEnter(e, index, item)" @mouseleave="e => subMenuMouseLeave(e, index, item)">
|
<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}}
|
{{item.text}}
|
||||||
<MiChevronDown />
|
<MiChevronDown />
|
||||||
<div ref="test2" class="bd-cm" v-if="index === visibleSub" :style="subStyle">
|
<div ref="test2" class="bd-cm" v-if="index === visibleSub" :style="subStyle">
|
||||||
<template v-for="(item, index) in item.items">
|
<template v-for="(item, index) in item.items">
|
||||||
<CMButton v-if="!item.type || item.type === 'button'" :item="item" :onClick="() => { item.onClick(); closeMenu(); }" />
|
<CMButton v-if="!item.type || item.type === 'button'" :item="item" :onClick="() => { item.onClick(); closeMenu(); }" />
|
||||||
<CMToggle v-else-if="item.type === 'toggle'" :item="item" :onClick="() => { item.checked = item.onChange(!item.checked) }" />
|
<CMToggle v-else-if="item.type === 'toggle'" :item="item" :checked="typeof item.checked === 'function' ? item.checked(target) : item.checked" :onClick="() => { }" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -57,3 +57,5 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
// return typeof this.item.checked === 'function' ? this.item.checked(target) : this.item.checked;
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="bd-cmItem bd-cmToggle" @click="onClick">
|
<div class="bd-cmItem bd-cmToggle" @click="onClick">
|
||||||
<div class="bd-cmLabel">{{item.text}}</div>
|
<div class="bd-cmLabel">{{item.text}}</div>
|
||||||
<div class="bd-cmCheckbox">
|
<div class="bd-cmCheckbox" :checked="checked">
|
||||||
<div class="bd-cmCheckboxInner">
|
<div class="bd-cmCheckboxInner">
|
||||||
<input type="checkbox" :checked="item.checked || item.enabled"/>
|
<input type="checkbox" :checked="checked"/>
|
||||||
<span></span>
|
<span></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,6 +22,6 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: ['item', 'onClick']
|
props: ['item', 'onClick', 'checked']
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -66,11 +66,12 @@ export class DiscordContextMenu {
|
||||||
|
|
||||||
static renderCm(component, args, retVal, res) {
|
static renderCm(component, args, retVal, res) {
|
||||||
if (!retVal.props || !res.props) return;
|
if (!retVal.props || !res.props) return;
|
||||||
const { target } = res.props;
|
const { target } = component.props;
|
||||||
const { top, left } = retVal.props.style;
|
const { top, left } = retVal.props.style;
|
||||||
if (!target || !top || !left) return;
|
if (!target || !top || !left) return;
|
||||||
if (!retVal.props.children) return;
|
if (!retVal.props.children) return;
|
||||||
if (!(retVal.props.children instanceof Array)) retVal.props.children = [retVal.props.children];
|
if (!(retVal.props.children instanceof Array)) retVal.props.children = [retVal.props.children];
|
||||||
|
|
||||||
for (const menu of this.menus.filter(menu => { if (!menu.filter) return true; return menu.filter(target)})) {
|
for (const menu of this.menus.filter(menu => { if (!menu.filter) return true; return menu.filter(target)})) {
|
||||||
retVal.props.children.push(VueInjector.createReactElement(CMGroup, {
|
retVal.props.children.push(VueInjector.createReactElement(CMGroup, {
|
||||||
target,
|
target,
|
||||||
|
|
Loading…
Reference in New Issue