Sha256: 9798165eee89979da3ac39f29fc29af65afe63cf443265759d6139aff4edb7c9
Contents?: true
Size: 1.18 KB
Versions: 7
Compression:
Stored size: 1.18 KB
Contents
import PbEnhancedElement from '../pb_enhanced_element' import Popper from 'popper.js' const POPOVER_OFFSET_Y = '0,8' export default class PbPopover extends PbEnhancedElement { static get selector() { return '[data-pb-popover-kit]' } connect() { this.popper = new Popper(this.triggerElement, this.tooltip, { placement: this.position, modifiers: { offset: { offset: this.offset, }, }, }) this.triggerElement.addEventListener('click', () => { this.tooltip.classList.toggle('show') this.popper.scheduleUpdate() }) } get triggerElement() { return this._triggerElement = (this._triggerElement || document.querySelector(`#${this.triggerElementId}`)) } get tooltip() { return this._tooltip = (this._tooltip || this.element.querySelector(`#${this.tooltipId}`)) } get position() { return this.element.dataset.pbPopoverPosition } get triggerElementId() { return this.element.dataset.pbPopoverTriggerElementId } get tooltipId() { return this.element.dataset.pbPopoverTooltipId } get offset() { return this.element.dataset.pbPopoverOffset === 'true' ? POPOVER_OFFSET_Y : '0,0' } }
Version data entries
7 entries across 7 versions & 1 rubygems