2787 |
rexy |
1 |
/*!
|
|
|
2 |
* Bootstrap util.js v4.3.1 (https://getbootstrap.com/)
|
|
|
3 |
* Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
|
|
4 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
|
|
5 |
*/
|
|
|
6 |
(function (global, factory) {
|
|
|
7 |
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
|
|
|
8 |
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
|
|
|
9 |
(global = global || self, global.Util = factory(global.jQuery));
|
|
|
10 |
}(this, function ($) { 'use strict';
|
|
|
11 |
|
|
|
12 |
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* --------------------------------------------------------------------------
|
|
|
16 |
* Bootstrap (v4.3.1): util.js
|
|
|
17 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
|
|
18 |
* --------------------------------------------------------------------------
|
|
|
19 |
*/
|
|
|
20 |
/**
|
|
|
21 |
* ------------------------------------------------------------------------
|
|
|
22 |
* Private TransitionEnd Helpers
|
|
|
23 |
* ------------------------------------------------------------------------
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
var TRANSITION_END = 'transitionend';
|
|
|
27 |
var MAX_UID = 1000000;
|
|
|
28 |
var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
|
|
29 |
|
|
|
30 |
function toType(obj) {
|
|
|
31 |
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
function getSpecialTransitionEndEvent() {
|
|
|
35 |
return {
|
|
|
36 |
bindType: TRANSITION_END,
|
|
|
37 |
delegateType: TRANSITION_END,
|
|
|
38 |
handle: function handle(event) {
|
|
|
39 |
if ($(event.target).is(this)) {
|
|
|
40 |
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
return undefined; // eslint-disable-line no-undefined
|
|
|
44 |
}
|
|
|
45 |
};
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
function transitionEndEmulator(duration) {
|
|
|
49 |
var _this = this;
|
|
|
50 |
|
|
|
51 |
var called = false;
|
|
|
52 |
$(this).one(Util.TRANSITION_END, function () {
|
|
|
53 |
called = true;
|
|
|
54 |
});
|
|
|
55 |
setTimeout(function () {
|
|
|
56 |
if (!called) {
|
|
|
57 |
Util.triggerTransitionEnd(_this);
|
|
|
58 |
}
|
|
|
59 |
}, duration);
|
|
|
60 |
return this;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
function setTransitionEndSupport() {
|
|
|
64 |
$.fn.emulateTransitionEnd = transitionEndEmulator;
|
|
|
65 |
$.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
|
|
|
66 |
}
|
|
|
67 |
/**
|
|
|
68 |
* --------------------------------------------------------------------------
|
|
|
69 |
* Public Util Api
|
|
|
70 |
* --------------------------------------------------------------------------
|
|
|
71 |
*/
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
var Util = {
|
|
|
75 |
TRANSITION_END: 'bsTransitionEnd',
|
|
|
76 |
getUID: function getUID(prefix) {
|
|
|
77 |
do {
|
|
|
78 |
// eslint-disable-next-line no-bitwise
|
|
|
79 |
prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
|
|
|
80 |
} while (document.getElementById(prefix));
|
|
|
81 |
|
|
|
82 |
return prefix;
|
|
|
83 |
},
|
|
|
84 |
getSelectorFromElement: function getSelectorFromElement(element) {
|
|
|
85 |
var selector = element.getAttribute('data-target');
|
|
|
86 |
|
|
|
87 |
if (!selector || selector === '#') {
|
|
|
88 |
var hrefAttr = element.getAttribute('href');
|
|
|
89 |
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
try {
|
|
|
93 |
return document.querySelector(selector) ? selector : null;
|
|
|
94 |
} catch (err) {
|
|
|
95 |
return null;
|
|
|
96 |
}
|
|
|
97 |
},
|
|
|
98 |
getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
|
|
|
99 |
if (!element) {
|
|
|
100 |
return 0;
|
|
|
101 |
} // Get transition-duration of the element
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
var transitionDuration = $(element).css('transition-duration');
|
|
|
105 |
var transitionDelay = $(element).css('transition-delay');
|
|
|
106 |
var floatTransitionDuration = parseFloat(transitionDuration);
|
|
|
107 |
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
|
|
|
108 |
|
|
|
109 |
if (!floatTransitionDuration && !floatTransitionDelay) {
|
|
|
110 |
return 0;
|
|
|
111 |
} // If multiple durations are defined, take the first
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
transitionDuration = transitionDuration.split(',')[0];
|
|
|
115 |
transitionDelay = transitionDelay.split(',')[0];
|
|
|
116 |
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
|
|
117 |
},
|
|
|
118 |
reflow: function reflow(element) {
|
|
|
119 |
return element.offsetHeight;
|
|
|
120 |
},
|
|
|
121 |
triggerTransitionEnd: function triggerTransitionEnd(element) {
|
|
|
122 |
$(element).trigger(TRANSITION_END);
|
|
|
123 |
},
|
|
|
124 |
// TODO: Remove in v5
|
|
|
125 |
supportsTransitionEnd: function supportsTransitionEnd() {
|
|
|
126 |
return Boolean(TRANSITION_END);
|
|
|
127 |
},
|
|
|
128 |
isElement: function isElement(obj) {
|
|
|
129 |
return (obj[0] || obj).nodeType;
|
|
|
130 |
},
|
|
|
131 |
typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
|
|
|
132 |
for (var property in configTypes) {
|
|
|
133 |
if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
|
|
|
134 |
var expectedTypes = configTypes[property];
|
|
|
135 |
var value = config[property];
|
|
|
136 |
var valueType = value && Util.isElement(value) ? 'element' : toType(value);
|
|
|
137 |
|
|
|
138 |
if (!new RegExp(expectedTypes).test(valueType)) {
|
|
|
139 |
throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
|
|
|
140 |
}
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
},
|
|
|
144 |
findShadowRoot: function findShadowRoot(element) {
|
|
|
145 |
if (!document.documentElement.attachShadow) {
|
|
|
146 |
return null;
|
|
|
147 |
} // Can find the shadow root otherwise it'll return the document
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
if (typeof element.getRootNode === 'function') {
|
|
|
151 |
var root = element.getRootNode();
|
|
|
152 |
return root instanceof ShadowRoot ? root : null;
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
if (element instanceof ShadowRoot) {
|
|
|
156 |
return element;
|
|
|
157 |
} // when we don't find a shadow root
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
if (!element.parentNode) {
|
|
|
161 |
return null;
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
return Util.findShadowRoot(element.parentNode);
|
|
|
165 |
}
|
|
|
166 |
};
|
|
|
167 |
setTransitionEndSupport();
|
|
|
168 |
|
|
|
169 |
return Util;
|
|
|
170 |
|
|
|
171 |
}));
|