1 (function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
3 typeof define === 'function' && define.amd ? define(['jquery'], factory) :
4 (global.Util = factory(global.jQuery));
5 }(this, (function ($) { 'use strict';
7 $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
10 * --------------------------------------------------------------------------
11 * Bootstrap (v4.1.3): util.js
12 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
13 * --------------------------------------------------------------------------
16 var Util = function ($$$1) {
18 * ------------------------------------------------------------------------
19 * Private TransitionEnd Helpers
20 * ------------------------------------------------------------------------
22 var TRANSITION_END = 'transitionend';
23 var MAX_UID = 1000000;
24 var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
26 function toType(obj) {
27 return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
30 function getSpecialTransitionEndEvent() {
32 bindType: TRANSITION_END,
33 delegateType: TRANSITION_END,
34 handle: function handle(event) {
35 if ($$$1(event.target).is(this)) {
36 return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
39 return undefined; // eslint-disable-line no-undefined
44 function transitionEndEmulator(duration) {
48 $$$1(this).one(Util.TRANSITION_END, function () {
51 setTimeout(function () {
53 Util.triggerTransitionEnd(_this);
59 function setTransitionEndSupport() {
60 $$$1.fn.emulateTransitionEnd = transitionEndEmulator;
61 $$$1.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
64 * --------------------------------------------------------------------------
66 * --------------------------------------------------------------------------
71 TRANSITION_END: 'bsTransitionEnd',
72 getUID: function getUID(prefix) {
74 // eslint-disable-next-line no-bitwise
75 prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
76 } while (document.getElementById(prefix));
80 getSelectorFromElement: function getSelectorFromElement(element) {
81 var selector = element.getAttribute('data-target');
83 if (!selector || selector === '#') {
84 selector = element.getAttribute('href') || '';
88 return document.querySelector(selector) ? selector : null;
93 getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
96 } // Get transition-duration of the element
99 var transitionDuration = $$$1(element).css('transition-duration');
100 var floatTransitionDuration = parseFloat(transitionDuration); // Return 0 if element or transition duration is not found
102 if (!floatTransitionDuration) {
104 } // If multiple durations are defined, take the first
107 transitionDuration = transitionDuration.split(',')[0];
108 return parseFloat(transitionDuration) * MILLISECONDS_MULTIPLIER;
110 reflow: function reflow(element) {
111 return element.offsetHeight;
113 triggerTransitionEnd: function triggerTransitionEnd(element) {
114 $$$1(element).trigger(TRANSITION_END);
116 // TODO: Remove in v5
117 supportsTransitionEnd: function supportsTransitionEnd() {
118 return Boolean(TRANSITION_END);
120 isElement: function isElement(obj) {
121 return (obj[0] || obj).nodeType;
123 typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
124 for (var property in configTypes) {
125 if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
126 var expectedTypes = configTypes[property];
127 var value = config[property];
128 var valueType = value && Util.isElement(value) ? 'element' : toType(value);
130 if (!new RegExp(expectedTypes).test(valueType)) {
131 throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
137 setTransitionEndSupport();
144 //# sourceMappingURL=util.js.map