diff options
author | XhmikosR <xhmikosr@gmail.com> | 2020-11-23 16:17:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 16:17:16 +0300 |
commit | 3e823e0b752b51b277a3a2d563c6b987f7496cf9 (patch) | |
tree | 24b73ff30fa930455a0c6430aaa2e78459d0d7b5 /dist/js/bootstrap.js | |
parent | 21737ed530b7ac37fe1ce67026df373c04282ac8 (diff) |
Dist (#32216)
Diffstat (limited to 'dist/js/bootstrap.js')
-rw-r--r-- | dist/js/bootstrap.js | 168 |
1 files changed, 86 insertions, 82 deletions
diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index 1c6474d44d..28f0d84651 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -86,7 +86,7 @@ }; var getSelector = function getSelector(element) { - var selector = element.getAttribute('data-target'); + var selector = element.getAttribute('data-bs-target'); if (!selector || selector === '#') { var hrefAttr = element.getAttribute('href'); @@ -121,8 +121,8 @@ transitionDuration = _window$getComputedSt.transitionDuration, transitionDelay = _window$getComputedSt.transitionDelay; - var floatTransitionDuration = parseFloat(transitionDuration); - var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found + var floatTransitionDuration = Number.parseFloat(transitionDuration); + var floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found if (!floatTransitionDuration && !floatTransitionDelay) { return 0; @@ -131,7 +131,7 @@ transitionDuration = transitionDuration.split(',')[0]; transitionDelay = transitionDelay.split(',')[0]; - return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; + return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; }; var triggerTransitionEnd = function triggerTransitionEnd(element) { @@ -221,7 +221,7 @@ var _window = window, jQuery = _window.jQuery; - if (jQuery && !document.body.hasAttribute('data-no-jquery')) { + if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { return jQuery; } @@ -325,7 +325,7 @@ mouseenter: 'mouseover', mouseleave: 'mouseout' }; - var nativeEvents = ['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']; + var nativeEvents = new Set(['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']); /** * ------------------------------------------------------------------------ * Private methods @@ -407,7 +407,7 @@ typeEvent = custom; } - var isNative = nativeEvents.indexOf(typeEvent) > -1; + var isNative = nativeEvents.has(typeEvent); if (!isNative) { typeEvent = originalTypeEvent; @@ -464,7 +464,7 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) { var storeElementEvent = events[typeEvent] || {}; Object.keys(storeElementEvent).forEach(function (handlerKey) { - if (handlerKey.indexOf(namespace) > -1) { + if (handlerKey.includes(namespace)) { var event = storeElementEvent[handlerKey]; removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); } @@ -490,7 +490,7 @@ var inNamespace = typeEvent !== originalTypeEvent; var events = getEvent(element); - var isNamespace = originalTypeEvent.charAt(0) === '.'; + var isNamespace = originalTypeEvent.startsWith('.'); if (typeof originalHandler !== 'undefined') { // Simplest case: handler is passed, remove that listener ONLY. @@ -512,7 +512,7 @@ Object.keys(storeElementEvent).forEach(function (keyHandlers) { var handlerKey = keyHandlers.replace(stripUidRegex, ''); - if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) { + if (!inNamespace || originalTypeEvent.includes(handlerKey)) { var event = storeElementEvent[keyHandlers]; removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); } @@ -526,7 +526,7 @@ var $ = getjQuery(); var typeEvent = event.replace(stripNameRegex, ''); var inNamespace = event !== typeEvent; - var isNative = nativeEvents.indexOf(typeEvent) > -1; + var isNative = nativeEvents.has(typeEvent); var jQueryEvent; var bubbles = true; var nativeDispatch = true; @@ -589,7 +589,7 @@ var DATA_KEY = 'bs.alert'; var EVENT_KEY = "." + DATA_KEY; var DATA_API_KEY = '.data-api'; - var SELECTOR_DISMISS = '[data-dismiss="alert"]'; + var SELECTOR_DISMISS = '[data-bs-dismiss="alert"]'; var EVENT_CLOSE = "close" + EVENT_KEY; var EVENT_CLOSED = "closed" + EVENT_KEY; var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY; @@ -748,7 +748,7 @@ var EVENT_KEY$1 = "." + DATA_KEY$1; var DATA_API_KEY$1 = '.data-api'; var CLASS_NAME_ACTIVE = 'active'; - var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]'; + var SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]'; var EVENT_CLICK_DATA_API$1 = "click" + EVENT_KEY$1 + DATA_API_KEY$1; /** * ------------------------------------------------------------------------ @@ -879,25 +879,28 @@ var Manipulator = { setDataAttribute: function setDataAttribute(element, key, value) { - element.setAttribute("data-" + normalizeDataKey(key), value); + element.setAttribute("data-bs-" + normalizeDataKey(key), value); }, removeDataAttribute: function removeDataAttribute(element, key) { - element.removeAttribute("data-" + normalizeDataKey(key)); + element.removeAttribute("data-bs-" + normalizeDataKey(key)); }, getDataAttributes: function getDataAttributes(element) { if (!element) { return {}; } - var attributes = _extends({}, element.dataset); - - Object.keys(attributes).forEach(function (key) { - attributes[key] = normalizeData(attributes[key]); + var attributes = {}; + Object.keys(element.dataset).filter(function (key) { + return key.startsWith('bs'); + }).forEach(function (key) { + var pureKey = key.replace(/^bs/, ''); + pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length); + attributes[pureKey] = normalizeData(element.dataset[key]); }); return attributes; }, getDataAttribute: function getDataAttribute(element, key) { - return normalizeData(element.getAttribute("data-" + normalizeDataKey(key))); + return normalizeData(element.getAttribute("data-bs-" + normalizeDataKey(key))); }, offset: function offset(element) { var rect = element.getBoundingClientRect(); @@ -1061,8 +1064,8 @@ var SELECTOR_ITEM_IMG = '.carousel-item img'; var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev'; var SELECTOR_INDICATORS = '.carousel-indicators'; - var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]'; - var SELECTOR_DATA_RIDE = '[data-ride="carousel"]'; + var SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'; + var SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]'; var PointerType = { TOUCH: 'touch', PEN: 'pen' @@ -1393,7 +1396,7 @@ return; } - var elementInterval = parseInt(element.getAttribute('data-interval'), 10); + var elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10); if (elementInterval) { this._config.defaultInterval = this._config.defaultInterval || this._config.interval; @@ -1538,7 +1541,7 @@ var config = _extends({}, Manipulator.getDataAttributes(target), Manipulator.getDataAttributes(this)); - var slideIndex = this.getAttribute('data-slide-to'); + var slideIndex = this.getAttribute('data-bs-slide-to'); if (slideIndex) { config.interval = false; @@ -1640,7 +1643,7 @@ var WIDTH = 'width'; var HEIGHT = 'height'; var SELECTOR_ACTIVES = '.show, .collapsing'; - var SELECTOR_DATA_TOGGLE$1 = '[data-toggle="collapse"]'; + var SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="collapse"]'; /** * ------------------------------------------------------------------------ * Class Definition @@ -1652,7 +1655,7 @@ this._isTransitioning = false; this._element = element; this._config = this._getConfig(config); - this._triggerArray = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1 + "[href=\"#" + element.id + "\"]," + (SELECTOR_DATA_TOGGLE$1 + "[data-target=\"#" + element.id + "\"]")); + this._triggerArray = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1 + "[href=\"#" + element.id + "\"]," + (SELECTOR_DATA_TOGGLE$1 + "[data-bs-target=\"#" + element.id + "\"]")); var toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1); for (var i = 0, len = toggleList.length; i < len; i++) { @@ -1707,7 +1710,7 @@ if (this._parent) { actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(function (elem) { if (typeof _this._config.parent === 'string') { - return elem.getAttribute('data-parent') === _this._config.parent; + return elem.getAttribute('data-bs-parent') === _this._config.parent; } return elem.classList.contains(CLASS_NAME_COLLAPSE); @@ -1721,10 +1724,10 @@ var container = SelectorEngine.findOne(this._selector); if (actives) { - var tempActiveData = actives.filter(function (elem) { + var tempActiveData = actives.find(function (elem) { return container !== elem; }); - activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY$3) : null; + activesData = tempActiveData ? Data.getData(tempActiveData, DATA_KEY$3) : null; if (activesData && activesData._isTransitioning) { return; @@ -1880,7 +1883,7 @@ parent = SelectorEngine.findOne(parent); } - var selector = SELECTOR_DATA_TOGGLE$1 + "[data-parent=\"" + parent + "\"]"; + var selector = SELECTOR_DATA_TOGGLE$1 + "[data-bs-parent=\"" + parent + "\"]"; SelectorEngine.find(selector, parent).forEach(function (element) { var selected = getElementFromSelector(element); @@ -2046,7 +2049,7 @@ var CLASS_NAME_MENURIGHT = 'dropdown-menu-right'; var CLASS_NAME_NAVBAR = 'navbar'; var CLASS_NAME_POSITION_STATIC = 'position-static'; - var SELECTOR_DATA_TOGGLE$2 = '[data-toggle="dropdown"]'; + var SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="dropdown"]'; var SELECTOR_FORM_CHILD = '.dropdown form'; var SELECTOR_MENU = '.dropdown-menu'; var SELECTOR_NAVBAR_NAV = '.navbar-nav'; @@ -2125,12 +2128,12 @@ if (showEvent.defaultPrevented) { return; - } // Disable totally Popper.js for Dropdown in Navbar + } // Totally disable Popper for Dropdowns in Navbar if (!this._inNavbar) { if (typeof Popper__default['default'] === 'undefined') { - throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org)'); + throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)'); } var referenceElement = this._element; @@ -2297,7 +2300,7 @@ boundariesElement: this._config.boundary } } - }; // Disable Popper.js if we have a static display + }; // Disable Popper if we have a static display if (this._config.display === 'static') { popperConfig.modifiers.applyStyle = { @@ -2563,8 +2566,8 @@ var CLASS_NAME_STATIC = 'modal-static'; var SELECTOR_DIALOG = '.modal-dialog'; var SELECTOR_MODAL_BODY = '.modal-body'; - var SELECTOR_DATA_TOGGLE$3 = '[data-toggle="modal"]'; - var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]'; + var SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="modal"]'; + var SELECTOR_DATA_DISMISS = '[data-bs-dismiss="modal"]'; var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; var SELECTOR_STICKY_CONTENT = '.sticky-top'; /** @@ -2875,7 +2878,11 @@ return; } - _this8._triggerBackdropTransition(); + if (_this8._config.backdrop === 'static') { + _this8._triggerBackdropTransition(); + } else { + _this8.hide(); + } }); if (animate) { @@ -2917,39 +2924,35 @@ _proto._triggerBackdropTransition = function _triggerBackdropTransition() { var _this9 = this; - if (this._config.backdrop === 'static') { - var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED); + var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED); - if (hideEvent.defaultPrevented) { - return; - } + if (hideEvent.defaultPrevented) { + return; + } - var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; + var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; - if (!isModalOverflowing) { - this._element.style.overflowY = 'hidden'; - } + if (!isModalOverflowing) { + this._element.style.overflowY = 'hidden'; + } - this._element.classList.add(CLASS_NAME_STATIC); + this._element.classList.add(CLASS_NAME_STATIC); - var modalTransitionDuration = getTransitionDurationFromElement(this._dialog); - EventHandler.off(this._element, TRANSITION_END); - EventHandler.one(this._element, TRANSITION_END, function () { - _this9._element.classList.remove(CLASS_NAME_STATIC); + var modalTransitionDuration = getTransitionDurationFromElement(this._dialog); + EventHandler.off(this._element, TRANSITION_END); + EventHandler.one(this._element, TRANSITION_END, function () { + _this9._element.classList.remove(CLASS_NAME_STATIC); - if (!isModalOverflowing) { - EventHandler.one(_this9._element, TRANSITION_END, function () { - _this9._element.style.overflowY = ''; - }); - emulateTransitionEnd(_this9._element, modalTransitionDuration); - } - }); - emulateTransitionEnd(this._element, modalTransitionDuration); + if (!isModalOverflowing) { + EventHandler.one(_this9._element, TRANSITION_END, function () { + _this9._element.style.overflowY = ''; + }); + emulateTransitionEnd(_this9._element, modalTransitionDuration); + } + }); + emulateTransitionEnd(this._element, modalTransitionDuration); - this._element.focus(); - } else { - this.hide(); - } + this._element.focus(); } // ---------------------------------------------------------------------- // the following methods are used to handle overflowing modals // ---------------------------------------------------------------------- @@ -2989,20 +2992,20 @@ var actualPadding = element.style.paddingRight; var calculatedPadding = window.getComputedStyle(element)['padding-right']; Manipulator.setDataAttribute(element, 'padding-right', actualPadding); - element.style.paddingRight = parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px"; + element.style.paddingRight = Number.parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px"; }); // Adjust sticky content margin SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach(function (element) { var actualMargin = element.style.marginRight; var calculatedMargin = window.getComputedStyle(element)['margin-right']; Manipulator.setDataAttribute(element, 'margin-right', actualMargin); - element.style.marginRight = parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px"; + element.style.marginRight = Number.parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px"; }); // Adjust body padding var actualPadding = document.body.style.paddingRight; var calculatedPadding = window.getComputedStyle(document.body)['padding-right']; Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding); - document.body.style.paddingRight = parseFloat(calculatedPadding) + this._scrollbarWidth + "px"; + document.body.style.paddingRight = Number.parseFloat(calculatedPadding) + this._scrollbarWidth + "px"; } document.body.classList.add(CLASS_NAME_OPEN); @@ -3156,7 +3159,7 @@ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']; + var uriAttrs = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']); var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; /** * A pattern that recognizes a commonly useful subset of URLs that are safe. @@ -3176,8 +3179,8 @@ var allowedAttribute = function allowedAttribute(attr, allowedAttributeList) { var attrName = attr.nodeName.toLowerCase(); - if (allowedAttributeList.indexOf(attrName) !== -1) { - if (uriAttrs.indexOf(attrName) !== -1) { + if (allowedAttributeList.includes(attrName)) { + if (uriAttrs.has(attrName)) { return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)); } @@ -3253,7 +3256,7 @@ var el = elements[i]; var elName = el.nodeName.toLowerCase(); - if (allowlistKeys.indexOf(elName) === -1) { + if (!allowlistKeys.includes(elName)) { el.parentNode.removeChild(el); return "continue"; } @@ -3289,7 +3292,7 @@ var EVENT_KEY$6 = "." + DATA_KEY$6; var CLASS_PREFIX = 'bs-tooltip'; var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g'); - var DISALLOWED_ATTRIBUTES = ['sanitize', 'allowList', 'sanitizeFn']; + var DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']); var DefaultType$4 = { animation: 'boolean', template: 'string', @@ -3364,7 +3367,7 @@ var Tooltip = /*#__PURE__*/function () { function Tooltip(element, config) { if (typeof Popper__default['default'] === 'undefined') { - throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org)'); + throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)'); } // private @@ -3653,7 +3656,7 @@ }; _proto.getTitle = function getTitle() { - var title = this.element.getAttribute('data-original-title'); + var title = this.element.getAttribute('data-bs-original-title'); if (!title) { title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title; @@ -3769,10 +3772,11 @@ }; _proto._fixTitle = function _fixTitle() { - var titleType = typeof this.element.getAttribute('data-original-title'); + var title = this.element.getAttribute('title'); + var originalTitleType = typeof this.element.getAttribute('data-bs-original-title'); - if (this.element.getAttribute('title') || titleType !== 'string') { - this.element.setAttribute('data-original-title', this.element.getAttribute('title') || ''); + if (title || originalTitleType !== 'string') { + this.element.setAttribute('data-bs-original-title', title || ''); this.element.setAttribute('title', ''); } }; @@ -3855,7 +3859,7 @@ _proto._getConfig = function _getConfig(config) { var dataAttributes = Manipulator.getDataAttributes(this.element); Object.keys(dataAttributes).forEach(function (dataAttr) { - if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) { + if (DISALLOWED_ATTRIBUTES.has(dataAttr)) { delete dataAttributes[dataAttr]; } }); @@ -4113,7 +4117,7 @@ }; _proto._getContent = function _getContent() { - return this.element.getAttribute('data-content') || this.config.content; + return this.element.getAttribute('data-bs-content') || this.config.content; }; _proto._cleanTipClass = function _cleanTipClass() { @@ -4249,7 +4253,7 @@ var EVENT_LOAD_DATA_API$1 = "load" + EVENT_KEY$8 + DATA_API_KEY$6; var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'; var CLASS_NAME_ACTIVE$2 = 'active'; - var SELECTOR_DATA_SPY = '[data-spy="scroll"]'; + var SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]'; var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; var SELECTOR_NAV_LINKS = '.nav-link'; var SELECTOR_NAV_ITEMS = '.nav-item'; @@ -4412,7 +4416,7 @@ this._clear(); var queries = this._selector.split(',').map(function (selector) { - return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]"; + return selector + "[data-bs-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]"; }); var link = SelectorEngine.findOne(queries.join(',')); @@ -4550,7 +4554,7 @@ var SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group'; var SELECTOR_ACTIVE$1 = '.active'; var SELECTOR_ACTIVE_UL = ':scope > li > .active'; - var SELECTOR_DATA_TOGGLE$4 = '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]'; + var SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; var SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle'; var SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active'; /** @@ -4783,7 +4787,7 @@ autohide: true, delay: 5000 }; - var SELECTOR_DATA_DISMISS$1 = '[data-dismiss="toast"]'; + var SELECTOR_DATA_DISMISS$1 = '[data-bs-dismiss="toast"]'; /** * ------------------------------------------------------------------------ * Class Definition |