2018-07-24 02:51:14 +02:00
( function ( global , factory ) {
typeof exports === 'object' && typeof module !== 'undefined' ? module . exports = factory ( require ( 'jquery' ) ) :
typeof define === 'function' && define . amd ? define ( [ 'jquery' ] , factory ) :
( global . Util = factory ( global . jQuery ) ) ;
} ( this , ( function ( $ ) { 'use strict' ;
$ = $ && $ . hasOwnProperty ( 'default' ) ? $ [ 'default' ] : $ ;
2017-09-30 23:28:03 +02:00
2015-05-08 01:34:28 +02:00
/ * *
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
2018-07-24 04:25:52 +02:00
* Bootstrap ( v4 . 1.3 ) : util . js
2018-07-24 02:51:14 +02:00
* Licensed under MIT ( https : //github.com/twbs/bootstrap/blob/master/LICENSE)
2015-05-08 01:34:28 +02:00
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
* /
2015-05-07 21:48:22 +02:00
2018-07-24 02:51:14 +02:00
var Util = function ( $$$1 ) {
/ * *
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
* Private TransitionEnd Helpers
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
* /
var TRANSITION _END = 'transitionend' ;
var MAX _UID = 1000000 ;
var MILLISECONDS _MULTIPLIER = 1000 ; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
function toType ( obj ) {
return { } . toString . call ( obj ) . match ( /\s([a-z]+)/i ) [ 1 ] . toLowerCase ( ) ;
}
2015-05-07 21:48:22 +02:00
2018-07-24 02:51:14 +02:00
function getSpecialTransitionEndEvent ( ) {
return {
bindType : TRANSITION _END ,
delegateType : TRANSITION _END ,
handle : function handle ( event ) {
if ( $$$1 ( event . target ) . is ( this ) ) {
return event . handleObj . handler . apply ( this , arguments ) ; // eslint-disable-line prefer-rest-params
}
2017-09-30 23:28:03 +02:00
2018-07-24 02:51:14 +02:00
return undefined ; // eslint-disable-line no-undefined
}
} ;
}
2017-09-30 23:28:03 +02:00
2018-07-24 02:51:14 +02:00
function transitionEndEmulator ( duration ) {
var _this = this ;
2015-05-07 21:48:22 +02:00
2018-07-24 02:51:14 +02:00
var called = false ;
$$$1 ( this ) . one ( Util . TRANSITION _END , function ( ) {
called = true ;
} ) ;
setTimeout ( function ( ) {
if ( ! called ) {
Util . triggerTransitionEnd ( _this ) ;
}
} , duration ) ;
return this ;
}
function setTransitionEndSupport ( ) {
$$$1 . fn . emulateTransitionEnd = transitionEndEmulator ;
$$$1 . event . special [ Util . TRANSITION _END ] = getSpecialTransitionEndEvent ( ) ;
}
/ * *
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
* Public Util Api
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
* /
var Util = {
TRANSITION _END : 'bsTransitionEnd' ,
getUID : function getUID ( prefix ) {
do {
// eslint-disable-next-line no-bitwise
prefix += ~ ~ ( Math . random ( ) * MAX _UID ) ; // "~~" acts like a faster Math.floor() here
} while ( document . getElementById ( prefix ) ) ;
return prefix ;
} ,
getSelectorFromElement : function getSelectorFromElement ( element ) {
var selector = element . getAttribute ( 'data-target' ) ;
2018-08-19 05:22:08 +02:00
var method = 'querySelector' ;
2018-07-24 02:51:14 +02:00
if ( ! selector || selector === '#' ) {
2018-08-19 05:22:08 +02:00
selector = ( element . getAttribute ( 'href' ) || '' ) . trim ( ) ;
}
var validSelector = selector ;
if ( selector . charAt ( 0 ) === '#' && selector . indexOf ( ',' ) === - 1 ) {
selector = selector . substr ( 1 ) ;
method = 'getElementById' ;
2018-07-24 02:51:14 +02:00
}
try {
2018-08-19 05:22:08 +02:00
return document [ method ] ( selector ) ? validSelector : null ;
2018-07-24 02:51:14 +02:00
} catch ( err ) {
return null ;
}
} ,
getTransitionDurationFromElement : function getTransitionDurationFromElement ( element ) {
if ( ! element ) {
return 0 ;
} // Get transition-duration of the element
var transitionDuration = $$$1 ( element ) . css ( 'transition-duration' ) ;
var floatTransitionDuration = parseFloat ( transitionDuration ) ; // Return 0 if element or transition duration is not found
if ( ! floatTransitionDuration ) {
return 0 ;
} // If multiple durations are defined, take the first
transitionDuration = transitionDuration . split ( ',' ) [ 0 ] ;
return parseFloat ( transitionDuration ) * MILLISECONDS _MULTIPLIER ;
} ,
reflow : function reflow ( element ) {
return element . offsetHeight ;
} ,
triggerTransitionEnd : function triggerTransitionEnd ( element ) {
$$$1 ( element ) . trigger ( TRANSITION _END ) ;
} ,
// TODO: Remove in v5
supportsTransitionEnd : function supportsTransitionEnd ( ) {
return Boolean ( TRANSITION _END ) ;
} ,
isElement : function isElement ( obj ) {
return ( obj [ 0 ] || obj ) . nodeType ;
} ,
typeCheckConfig : function typeCheckConfig ( componentName , config , configTypes ) {
for ( var property in configTypes ) {
if ( Object . prototype . hasOwnProperty . call ( configTypes , property ) ) {
var expectedTypes = configTypes [ property ] ;
var value = config [ property ] ;
var valueType = value && Util . isElement ( value ) ? 'element' : toType ( value ) ;
if ( ! new RegExp ( expectedTypes ) . test ( valueType ) ) {
throw new Error ( componentName . toUpperCase ( ) + ": " + ( "Option \"" + property + "\" provided type \"" + valueType + "\" " ) + ( "but expected type \"" + expectedTypes + "\"." ) ) ;
}
2015-08-19 05:28:28 +02:00
}
2015-05-13 23:46:50 +02:00
}
}
2018-07-24 02:51:14 +02:00
} ;
setTransitionEndSupport ( ) ;
return Util ;
} ( $ ) ;
2015-05-08 01:34:28 +02:00
return Util ;
2018-07-24 02:51:14 +02:00
} ) ) ) ;
//# sourceMappingURL=util.js.map