Intermediate commit
This commit is contained in:
parent
0589488d24
commit
b0218e0de2
2 changed files with 11 additions and 13 deletions
|
@ -32,6 +32,9 @@ export class VotingValue {
|
|||
callbacks: {
|
||||
onTipInserted: (el): void => {
|
||||
console.debug('onTipInserted', this, arguments)
|
||||
},
|
||||
onTipRemoved: (el): void => {
|
||||
console.debug('onTipRemoved', el.forumPopoverTip)
|
||||
}
|
||||
},
|
||||
popoverOpts: {
|
||||
|
@ -43,11 +46,11 @@ export class VotingValue {
|
|||
this.cachedContent = 'asd'
|
||||
if (el.forumPopoverTip) {
|
||||
el.forumPopoverTip
|
||||
.getElementsByClassName('popover-body')[0]
|
||||
.replaceChildren(this.cachedContent)
|
||||
.getElementsByClassName('popover-body').item(0)
|
||||
?.replaceChildren(this.cachedContent)
|
||||
el.forumPopoverConfig.popoverObj.update()
|
||||
} else console.debug('NO TIP')
|
||||
}, 1000)
|
||||
}, 3000)
|
||||
}
|
||||
return this.cachedContent
|
||||
},
|
||||
|
|
|
@ -24,6 +24,7 @@ type PassedPopoverOpts<ElCls extends HTMLElement> =
|
|||
|
||||
interface CallbacksType<ElCls extends HTMLElement> {
|
||||
onTipInserted?: (el: ForumPopoverEl<ElCls>) => void
|
||||
onTipRemoved?: (el: ForumPopoverEl<ElCls>) => void
|
||||
}
|
||||
|
||||
interface InitConfigType<ElCls extends HTMLElement> {
|
||||
|
@ -82,6 +83,9 @@ function onTipRemoved<ElCls extends HTMLElement>(
|
|||
elTip.removeEventListener('focusin', onFocusinTip)
|
||||
elTip.removeEventListener('focusout', onFocusoutTip)
|
||||
const config = elTip.forumPopoverEl.forumPopoverConfig
|
||||
if (config.callbacks?.onTipRemoved) {
|
||||
config.callbacks.onTipRemoved(elTip.forumPopoverEl)
|
||||
}
|
||||
config.isElementHovered = false
|
||||
config.isTipFocused = false
|
||||
delete elTip.forumPopoverEl.forumPopoverTip
|
||||
|
@ -141,7 +145,7 @@ function onMouseleaveElement<ElCls extends HTMLElement>(
|
|||
// use this function as an umbrella to only call it once
|
||||
function onGetContent<ElCls extends HTMLElement>(
|
||||
el: ForumPopoverEl<ElCls>
|
||||
): string | HTMLElement {
|
||||
): string | Element {
|
||||
if (el.forumPopoverConfig.cachedContent == null) {
|
||||
el.forumPopoverConfig.cachedContent = el.forumPopoverConfig.origGetContent
|
||||
? el.forumPopoverConfig.origGetContent(el)
|
||||
|
@ -280,12 +284,3 @@ export function teardown<ElCls extends HTMLElement>(el: ElCls): void {
|
|||
// @ts-expect-error Popover is being destroyed so it's okay
|
||||
delete el.forumPopoverConfig
|
||||
}
|
||||
|
||||
// const x = <HTMLAnchorElement>document.getElementById('x')
|
||||
|
||||
// add(x, {
|
||||
// callbacks: {
|
||||
// onTipInserted: (el) => {
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
|
|
Loading…
Reference in a new issue