1/** 2 * -------------------------------------------------------------------------- 3 * Bootstrap (v4.0.0-alpha.6): util.js 4 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 * -------------------------------------------------------------------------- 6 */ 7 8var UtilEm = function ($) { 9 10 /** 11 * ------------------------------------------------------------------------ 12 * Private TransitionEnd Helpers 13 * ------------------------------------------------------------------------ 14 */ 15 16 var transition = false; 17 18 var MAX_UID = 1000000; 19 20 var TransitionEndEvent = { 21 WebkitTransition: 'webkitTransitionEnd', 22 MozTransition: 'transitionend', 23 OTransition: 'oTransitionEnd otransitionend', 24 transition: 'transitionend' 25 }; 26 27 // shoutout AngusCroll (https://goo.gl/pxwQGp) 28 function toType(obj) { 29 return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); 30 } 31 32 function isElement(obj) { 33 return (obj[0] || obj).nodeType; 34 } 35 36 function getSpecialTransitionEndEvent() { 37 return { 38 bindType: transition.end, 39 delegateType: transition.end, 40 handle: function handle(event) { 41 if ($(event.target).is(this)) { 42 return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params 43 } 44 return undefined; 45 } 46 }; 47 } 48 49 function transitionEndTest() { 50 if (window.QUnit) { 51 return false; 52 } 53 54 var el = document.createElement('bootstrap'); 55 56 for (var name in TransitionEndEvent) { 57 if (el.style[name] !== undefined) { 58 return { 59 end: TransitionEndEvent[name] 60 }; 61 } 62 } 63 64 return false; 65 } 66 67 function transitionEndEmulator(duration) { 68 var _this = this; 69 70 var called = false; 71 72 $(this).one(Util.TRANSITION_END, function () { 73 called = true; 74 }); 75 76 setTimeout(function () { 77 if (!called) { 78 Util.triggerTransitionEnd(_this); 79 } 80 }, duration); 81 82 return this; 83 } 84 85 function setTransitionEndSupport() { 86 transition = transitionEndTest(); 87 88 $.fn.emulateTransitionEnd = transitionEndEmulator; 89 90 if (Util.supportsTransitionEnd()) { 91 $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); 92 } 93 } 94 95 /** 96 * -------------------------------------------------------------------------- 97 * Public Util Api 98 * -------------------------------------------------------------------------- 99 */ 100 101 var Util = { 102 103 TRANSITION_END: 'bsTransitionEnd', 104 105 getUID: function getUID(prefix) { 106 do { 107 // eslint-disable-next-line no-bitwise 108 prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here 109 } while (document.getElementById(prefix)); 110 return prefix; 111 }, 112 getSelectorFromElement: function getSelectorFromElement(element) { 113 var selector = element.getAttribute('data-target'); 114 115 if (!selector) { 116 selector = element.getAttribute('href') || ''; 117 selector = /^#[a-z]/i.test(selector) ? selector : null; 118 } 119 120 return selector; 121 }, 122 reflow: function reflow(element) { 123 return element.offsetHeight; 124 }, 125 triggerTransitionEnd: function triggerTransitionEnd(element) { 126 $(element).trigger(transition.end); 127 }, 128 supportsTransitionEnd: function supportsTransitionEnd() { 129 return Boolean(transition); 130 }, 131 typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { 132 for (var property in configTypes) { 133 if (configTypes.hasOwnProperty(property)) { 134 var expectedTypes = configTypes[property]; 135 var value = config[property]; 136 var valueType = value && 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 }; 145 146 setTransitionEndSupport(); 147 148 return Util; 149}(jQuery); 150//# sourceMappingURL=util.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.