14
const TRANSITION_END = 'transitionend'
15
const MAX_UID = 1000000
16
const MILLISECONDS_MULTIPLIER = 1000
20
if (obj === null || typeof obj === 'undefined') {
24
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase()
27
function getSpecialTransitionEndEvent() {
29
bindType: TRANSITION_END,
30
delegateType: TRANSITION_END,
32
if ($(event.target).is(this)) {
33
return event.handleObj.handler.apply(this, arguments)
41
function transitionEndEmulator(duration) {
44
$(this).one(Util.TRANSITION_END, () => {
50
Util.triggerTransitionEnd(this)
57
function setTransitionEndSupport() {
58
$.fn.emulateTransitionEnd = transitionEndEmulator
59
$.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent()
67
TRANSITION_END: 'bsTransitionEnd',
72
prefix += ~~(Math.random() * MAX_UID)
73
} while (document.getElementById(prefix))
78
getSelectorFromElement(element) {
79
let selector = element.getAttribute('data-target')
81
if (!selector || selector === '#') {
82
const hrefAttr = element.getAttribute('href')
83
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : ''
87
return document.querySelector(selector) ? selector : null
93
getTransitionDurationFromElement(element) {
99
let transitionDuration = $(element).css('transition-duration')
100
let transitionDelay = $(element).css('transition-delay')
102
const floatTransitionDuration = parseFloat(transitionDuration)
103
const floatTransitionDelay = parseFloat(transitionDelay)
106
if (!floatTransitionDuration && !floatTransitionDelay) {
111
transitionDuration = transitionDuration.split(',')[0]
112
transitionDelay = transitionDelay.split(',')[0]
114
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER
118
return element.offsetHeight
121
triggerTransitionEnd(element) {
122
$(element).trigger(TRANSITION_END)
125
supportsTransitionEnd() {
126
return Boolean(TRANSITION_END)
130
return (obj[0] || obj).nodeType
133
typeCheckConfig(componentName, config, configTypes) {
134
for (const property in configTypes) {
135
if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
136
const expectedTypes = configTypes[property]
137
const value = config[property]
138
const valueType = value && Util.isElement(value) ?
139
'element' : toType(value)
141
if (!new RegExp(expectedTypes).test(valueType)) {
143
`${componentName.toUpperCase()}: ` +
144
`Option "${property}" provided type "${valueType}" ` +
145
`but expected type "${expectedTypes}".`)
151
findShadowRoot(element) {
152
if (!document.documentElement.attachShadow) {
157
if (typeof element.getRootNode === 'function') {
158
const root = element.getRootNode()
159
return root instanceof ShadowRoot ? root : null
162
if (element instanceof ShadowRoot) {
167
if (!element.parentNode) {
171
return Util.findShadowRoot(element.parentNode)
175
if (typeof $ === 'undefined') {
176
throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.')
179
const version = $.fn.jquery.split(' ')[0].split('.')
186
if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
187
throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0')
192
Util.jQueryDetection()
193
setTransitionEndSupport()