Layout von Websiten mit Bootstrap und Foundation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

util.js 6.5KB

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