Sha256: 5a10f11905622adabde75b74167d9752c734388b9c28df37f1a110a3475e8f04

Contents?: true

Size: 969 Bytes

Versions: 44

Compression:

Stored size: 969 Bytes

Contents

import { Controller } from '@hotwired/stimulus'
import * as bootstrap from 'bootstrap'

export default class extends Controller {
  popover = null

  connect () {
    const container = this.element.closest('.modal-body') ? '.modal-body' : 'body'
    this.popover = new bootstrap.Popover(this.element, {
      // WARNING: don't use for user input html
      sanitize: false,
      container,
      template: `
<div class="popover" role="tooltip" data-controller="popover">
  <div class="popover-arrow"></div>
  <div class="popover-header"></div>
  <button type="button" class="btn-close position-absolute" data-action="popover#close" style="top: 1em; right: 1em;" aria-label="Close"></button>
  <div class="popover-body">
  </div>
</div>
      `
    })
  }

  disconnect () {
    if (this.popover) {
      // setTimeout because of:
      // https://github.com/twbs/bootstrap/issues/37474
      setTimeout(() => {
        this.popover.dispose()
      }, 300)
    }
  }
}

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
pg_rails-7.6.23 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.22 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.22.pre.3 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.22.pre.2 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.22.pre.1 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.11 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.10 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.9 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.8 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.7 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.6 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.5 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.4 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.3 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.2 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.21.pre.1 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.20 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.19 pg_layout/app/javascript/controllers/popover_toggler_controller.js
pg_rails-7.6.18 pg_layout/app/javascript/controllers/popover_toggler_controller.js