Sha256: 944a29ec603b5a27ee5dc2db824a7d2edb9b8ae3f1a1c81336b2e0e1c19369b5
Contents?: true
Size: 918 Bytes
Versions: 51
Compression:
Stored size: 918 Bytes
Contents
import { Controller } from '@hotwired/stimulus' import * as bootstrap from 'bootstrap' export default class extends Controller { tooltip = null connect () { if (this.element.dataset.bsTrigger === 'contextmenu') { this.element.addEventListener('contextmenu', (ev) => { ev.preventDefault() if (!this.tooltip) { this.tooltip = new bootstrap.Tooltip(this.element, { trigger: 'focus' }) this.tooltip.show() } }) } else { this.tooltip = new bootstrap.Tooltip(this.element) } } setContent (content) { this.tooltip.setContent({ '.tooltip-inner': content }) } hide () { this.tooltip.hide() } disconnect () { if (this.tooltip) { // setTimeout because of: // https://github.com/twbs/bootstrap/issues/37474 setTimeout(() => { this.tooltip.dispose() }, 300) } } }
Version data entries
51 entries across 51 versions & 1 rubygems