Sha256: c02e7797851c7ec979b1236d7c1de2d3fe332fbf8ae903e92fe58eac01c62faf

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

/**
 * --------------------------------------------------------------------------
 * Bootstrap (v5.1.3): util/component-functions.js
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
 * --------------------------------------------------------------------------
 */

import EventHandler from '../dom/event-handler'
import { getElementFromSelector, isDisabled } from './index'

const enableDismissTrigger = (component, method = 'hide') => {
  const clickEvent = `click.dismiss${component.EVENT_KEY}`
  const name = component.NAME

  EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
    if (['A', 'AREA'].includes(this.tagName)) {
      event.preventDefault()
    }

    if (isDisabled(this)) {
      return
    }

    const target = getElementFromSelector(this) || this.closest(`.${name}`)
    const instance = component.getOrCreateInstance(target)

    // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
    instance[method]()
  })
}

export {
  enableDismissTrigger
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
card-mod-bootstrap-0.18.1 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.18.0 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.17.0 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.16.0 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.15.6 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.15.5 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.15.4 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.15.3 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.15.1.2 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.15.2.pre1 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.15.1.1 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.15.1 vendor/bootstrap/js/src/util/component-functions.js
card-mod-bootstrap-0.15.0 vendor/bootstrap/js/src/util/component-functions.js