diff options
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/modal.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/dist/modal.js | 182 |
1 files changed, 92 insertions, 90 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/modal.js b/vendor/twbs/bootstrap/js/dist/modal.js index c808df191..92a9c77b6 100644 --- a/vendor/twbs/bootstrap/js/dist/modal.js +++ b/vendor/twbs/bootstrap/js/dist/modal.js @@ -1,5 +1,5 @@ /*! - * Bootstrap modal.js v4.5.2 (https://getbootstrap.com/) + * Bootstrap modal.js v4.5.3 (https://getbootstrap.com/) * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ @@ -9,8 +9,10 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Modal = factory(global.jQuery, global.Util)); }(this, (function ($, Util) { 'use strict'; - $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $; - Util = Util && Object.prototype.hasOwnProperty.call(Util, 'default') ? Util['default'] : Util; + function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + + var $__default = /*#__PURE__*/_interopDefaultLegacy($); + var Util__default = /*#__PURE__*/_interopDefaultLegacy(Util); function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } @@ -24,11 +26,11 @@ */ var NAME = 'modal'; - var VERSION = '4.5.2'; + var VERSION = '4.5.3'; var DATA_KEY = 'bs.modal'; var EVENT_KEY = "." + DATA_KEY; var DATA_API_KEY = '.data-api'; - var JQUERY_NO_CONFLICT = $.fn[NAME]; + var JQUERY_NO_CONFLICT = $__default['default'].fn[NAME]; var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key var Default = { @@ -102,14 +104,14 @@ return; } - if ($(this._element).hasClass(CLASS_NAME_FADE)) { + if ($__default['default'](this._element).hasClass(CLASS_NAME_FADE)) { this._isTransitioning = true; } - var showEvent = $.Event(EVENT_SHOW, { + var showEvent = $__default['default'].Event(EVENT_SHOW, { relatedTarget: relatedTarget }); - $(this._element).trigger(showEvent); + $__default['default'](this._element).trigger(showEvent); if (this._isShown || showEvent.isDefaultPrevented()) { return; @@ -127,12 +129,12 @@ this._setResizeEvent(); - $(this._element).on(EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) { + $__default['default'](this._element).on(EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) { return _this.hide(event); }); - $(this._dialog).on(EVENT_MOUSEDOWN_DISMISS, function () { - $(_this._element).one(EVENT_MOUSEUP_DISMISS, function (event) { - if ($(event.target).is(_this._element)) { + $__default['default'](this._dialog).on(EVENT_MOUSEDOWN_DISMISS, function () { + $__default['default'](_this._element).one(EVENT_MOUSEUP_DISMISS, function (event) { + if ($__default['default'](event.target).is(_this._element)) { _this._ignoreBackdropClick = true; } }); @@ -154,15 +156,15 @@ return; } - var hideEvent = $.Event(EVENT_HIDE); - $(this._element).trigger(hideEvent); + var hideEvent = $__default['default'].Event(EVENT_HIDE); + $__default['default'](this._element).trigger(hideEvent); if (!this._isShown || hideEvent.isDefaultPrevented()) { return; } this._isShown = false; - var transition = $(this._element).hasClass(CLASS_NAME_FADE); + var transition = $__default['default'](this._element).hasClass(CLASS_NAME_FADE); if (transition) { this._isTransitioning = true; @@ -172,14 +174,14 @@ this._setResizeEvent(); - $(document).off(EVENT_FOCUSIN); - $(this._element).removeClass(CLASS_NAME_SHOW); - $(this._element).off(EVENT_CLICK_DISMISS); - $(this._dialog).off(EVENT_MOUSEDOWN_DISMISS); + $__default['default'](document).off(EVENT_FOCUSIN); + $__default['default'](this._element).removeClass(CLASS_NAME_SHOW); + $__default['default'](this._element).off(EVENT_CLICK_DISMISS); + $__default['default'](this._dialog).off(EVENT_MOUSEDOWN_DISMISS); if (transition) { - var transitionDuration = Util.getTransitionDurationFromElement(this._element); - $(this._element).one(Util.TRANSITION_END, function (event) { + var transitionDuration = Util__default['default'].getTransitionDurationFromElement(this._element); + $__default['default'](this._element).one(Util__default['default'].TRANSITION_END, function (event) { return _this2._hideModal(event); }).emulateTransitionEnd(transitionDuration); } else { @@ -189,7 +191,7 @@ _proto.dispose = function dispose() { [window, this._element, this._dialog].forEach(function (htmlElement) { - return $(htmlElement).off(EVENT_KEY); + return $__default['default'](htmlElement).off(EVENT_KEY); }); /** * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API` @@ -197,8 +199,8 @@ * It will remove `EVENT_CLICK_DATA_API` event that should remain */ - $(document).off(EVENT_FOCUSIN); - $.removeData(this._element, DATA_KEY); + $__default['default'](document).off(EVENT_FOCUSIN); + $__default['default'].removeData(this._element, DATA_KEY); this._config = null; this._element = null; this._dialog = null; @@ -217,7 +219,7 @@ _proto._getConfig = function _getConfig(config) { config = _extends({}, Default, config); - Util.typeCheckConfig(NAME, config, DefaultType); + Util__default['default'].typeCheckConfig(NAME, config, DefaultType); return config; }; @@ -225,10 +227,10 @@ var _this3 = this; if (this._config.backdrop === 'static') { - var hideEventPrevented = $.Event(EVENT_HIDE_PREVENTED); - $(this._element).trigger(hideEventPrevented); + var hideEventPrevented = $__default['default'].Event(EVENT_HIDE_PREVENTED); + $__default['default'](this._element).trigger(hideEventPrevented); - if (hideEventPrevented.defaultPrevented) { + if (hideEventPrevented.isDefaultPrevented()) { return; } @@ -240,13 +242,13 @@ this._element.classList.add(CLASS_NAME_STATIC); - var modalTransitionDuration = Util.getTransitionDurationFromElement(this._dialog); - $(this._element).off(Util.TRANSITION_END); - $(this._element).one(Util.TRANSITION_END, function () { + var modalTransitionDuration = Util__default['default'].getTransitionDurationFromElement(this._dialog); + $__default['default'](this._element).off(Util__default['default'].TRANSITION_END); + $__default['default'](this._element).one(Util__default['default'].TRANSITION_END, function () { _this3._element.classList.remove(CLASS_NAME_STATIC); if (!isModalOverflowing) { - $(_this3._element).one(Util.TRANSITION_END, function () { + $__default['default'](_this3._element).one(Util__default['default'].TRANSITION_END, function () { _this3._element.style.overflowY = ''; }).emulateTransitionEnd(_this3._element, modalTransitionDuration); } @@ -261,7 +263,7 @@ _proto._showElement = function _showElement(relatedTarget) { var _this4 = this; - var transition = $(this._element).hasClass(CLASS_NAME_FADE); + var transition = $__default['default'](this._element).hasClass(CLASS_NAME_FADE); var modalBody = this._dialog ? this._dialog.querySelector(SELECTOR_MODAL_BODY) : null; if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { @@ -277,23 +279,23 @@ this._element.setAttribute('role', 'dialog'); - if ($(this._dialog).hasClass(CLASS_NAME_SCROLLABLE) && modalBody) { + if ($__default['default'](this._dialog).hasClass(CLASS_NAME_SCROLLABLE) && modalBody) { modalBody.scrollTop = 0; } else { this._element.scrollTop = 0; } if (transition) { - Util.reflow(this._element); + Util__default['default'].reflow(this._element); } - $(this._element).addClass(CLASS_NAME_SHOW); + $__default['default'](this._element).addClass(CLASS_NAME_SHOW); if (this._config.focus) { this._enforceFocus(); } - var shownEvent = $.Event(EVENT_SHOWN, { + var shownEvent = $__default['default'].Event(EVENT_SHOWN, { relatedTarget: relatedTarget }); @@ -303,12 +305,12 @@ } _this4._isTransitioning = false; - $(_this4._element).trigger(shownEvent); + $__default['default'](_this4._element).trigger(shownEvent); }; if (transition) { - var transitionDuration = Util.getTransitionDurationFromElement(this._dialog); - $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration); + var transitionDuration = Util__default['default'].getTransitionDurationFromElement(this._dialog); + $__default['default'](this._dialog).one(Util__default['default'].TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration); } else { transitionComplete(); } @@ -317,9 +319,9 @@ _proto._enforceFocus = function _enforceFocus() { var _this5 = this; - $(document).off(EVENT_FOCUSIN) // Guard against infinite focus loop + $__default['default'](document).off(EVENT_FOCUSIN) // Guard against infinite focus loop .on(EVENT_FOCUSIN, function (event) { - if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) { + if (document !== event.target && _this5._element !== event.target && $__default['default'](_this5._element).has(event.target).length === 0) { _this5._element.focus(); } }); @@ -329,7 +331,7 @@ var _this6 = this; if (this._isShown) { - $(this._element).on(EVENT_KEYDOWN_DISMISS, function (event) { + $__default['default'](this._element).on(EVENT_KEYDOWN_DISMISS, function (event) { if (_this6._config.keyboard && event.which === ESCAPE_KEYCODE) { event.preventDefault(); @@ -339,7 +341,7 @@ } }); } else if (!this._isShown) { - $(this._element).off(EVENT_KEYDOWN_DISMISS); + $__default['default'](this._element).off(EVENT_KEYDOWN_DISMISS); } }; @@ -347,11 +349,11 @@ var _this7 = this; if (this._isShown) { - $(window).on(EVENT_RESIZE, function (event) { + $__default['default'](window).on(EVENT_RESIZE, function (event) { return _this7.handleUpdate(event); }); } else { - $(window).off(EVENT_RESIZE); + $__default['default'](window).off(EVENT_RESIZE); } }; @@ -369,19 +371,19 @@ this._isTransitioning = false; this._showBackdrop(function () { - $(document.body).removeClass(CLASS_NAME_OPEN); + $__default['default'](document.body).removeClass(CLASS_NAME_OPEN); _this8._resetAdjustments(); _this8._resetScrollbar(); - $(_this8._element).trigger(EVENT_HIDDEN); + $__default['default'](_this8._element).trigger(EVENT_HIDDEN); }); }; _proto._removeBackdrop = function _removeBackdrop() { if (this._backdrop) { - $(this._backdrop).remove(); + $__default['default'](this._backdrop).remove(); this._backdrop = null; } }; @@ -389,7 +391,7 @@ _proto._showBackdrop = function _showBackdrop(callback) { var _this9 = this; - var animate = $(this._element).hasClass(CLASS_NAME_FADE) ? CLASS_NAME_FADE : ''; + var animate = $__default['default'](this._element).hasClass(CLASS_NAME_FADE) ? CLASS_NAME_FADE : ''; if (this._isShown && this._config.backdrop) { this._backdrop = document.createElement('div'); @@ -399,8 +401,8 @@ this._backdrop.classList.add(animate); } - $(this._backdrop).appendTo(document.body); - $(this._element).on(EVENT_CLICK_DISMISS, function (event) { + $__default['default'](this._backdrop).appendTo(document.body); + $__default['default'](this._element).on(EVENT_CLICK_DISMISS, function (event) { if (_this9._ignoreBackdropClick) { _this9._ignoreBackdropClick = false; return; @@ -414,10 +416,10 @@ }); if (animate) { - Util.reflow(this._backdrop); + Util__default['default'].reflow(this._backdrop); } - $(this._backdrop).addClass(CLASS_NAME_SHOW); + $__default['default'](this._backdrop).addClass(CLASS_NAME_SHOW); if (!callback) { return; @@ -428,10 +430,10 @@ return; } - var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); - $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration); + var backdropTransitionDuration = Util__default['default'].getTransitionDurationFromElement(this._backdrop); + $__default['default'](this._backdrop).one(Util__default['default'].TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration); } else if (!this._isShown && this._backdrop) { - $(this._backdrop).removeClass(CLASS_NAME_SHOW); + $__default['default'](this._backdrop).removeClass(CLASS_NAME_SHOW); var callbackRemove = function callbackRemove() { _this9._removeBackdrop(); @@ -441,10 +443,10 @@ } }; - if ($(this._element).hasClass(CLASS_NAME_FADE)) { - var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); + if ($__default['default'](this._element).hasClass(CLASS_NAME_FADE)) { + var _backdropTransitionDuration = Util__default['default'].getTransitionDurationFromElement(this._backdrop); - $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration); + $__default['default'](this._backdrop).one(Util__default['default'].TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration); } else { callbackRemove(); } @@ -489,46 +491,46 @@ var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT)); var stickyContent = [].slice.call(document.querySelectorAll(SELECTOR_STICKY_CONTENT)); // Adjust fixed content padding - $(fixedContent).each(function (index, element) { + $__default['default'](fixedContent).each(function (index, element) { var actualPadding = element.style.paddingRight; - var calculatedPadding = $(element).css('padding-right'); - $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px"); + var calculatedPadding = $__default['default'](element).css('padding-right'); + $__default['default'](element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px"); }); // Adjust sticky content margin - $(stickyContent).each(function (index, element) { + $__default['default'](stickyContent).each(function (index, element) { var actualMargin = element.style.marginRight; - var calculatedMargin = $(element).css('margin-right'); - $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px"); + var calculatedMargin = $__default['default'](element).css('margin-right'); + $__default['default'](element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px"); }); // Adjust body padding var actualPadding = document.body.style.paddingRight; - var calculatedPadding = $(document.body).css('padding-right'); - $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px"); + var calculatedPadding = $__default['default'](document.body).css('padding-right'); + $__default['default'](document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px"); } - $(document.body).addClass(CLASS_NAME_OPEN); + $__default['default'](document.body).addClass(CLASS_NAME_OPEN); }; _proto._resetScrollbar = function _resetScrollbar() { // Restore fixed content padding var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT)); - $(fixedContent).each(function (index, element) { - var padding = $(element).data('padding-right'); - $(element).removeData('padding-right'); + $__default['default'](fixedContent).each(function (index, element) { + var padding = $__default['default'](element).data('padding-right'); + $__default['default'](element).removeData('padding-right'); element.style.paddingRight = padding ? padding : ''; }); // Restore sticky content var elements = [].slice.call(document.querySelectorAll("" + SELECTOR_STICKY_CONTENT)); - $(elements).each(function (index, element) { - var margin = $(element).data('margin-right'); + $__default['default'](elements).each(function (index, element) { + var margin = $__default['default'](element).data('margin-right'); if (typeof margin !== 'undefined') { - $(element).css('margin-right', margin).removeData('margin-right'); + $__default['default'](element).css('margin-right', margin).removeData('margin-right'); } }); // Restore body padding - var padding = $(document.body).data('padding-right'); - $(document.body).removeData('padding-right'); + var padding = $__default['default'](document.body).data('padding-right'); + $__default['default'](document.body).removeData('padding-right'); document.body.style.paddingRight = padding ? padding : ''; }; @@ -545,13 +547,13 @@ Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) { return this.each(function () { - var data = $(this).data(DATA_KEY); + var data = $__default['default'](this).data(DATA_KEY); - var _config = _extends({}, Default, $(this).data(), typeof config === 'object' && config ? config : {}); + var _config = _extends({}, Default, $__default['default'](this).data(), typeof config === 'object' && config ? config : {}); if (!data) { data = new Modal(this, _config); - $(this).data(DATA_KEY, data); + $__default['default'](this).data(DATA_KEY, data); } if (typeof config === 'string') { @@ -587,36 +589,36 @@ */ - $(document).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { + $__default['default'](document).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { var _this11 = this; var target; - var selector = Util.getSelectorFromElement(this); + var selector = Util__default['default'].getSelectorFromElement(this); if (selector) { target = document.querySelector(selector); } - var config = $(target).data(DATA_KEY) ? 'toggle' : _extends({}, $(target).data(), $(this).data()); + var config = $__default['default'](target).data(DATA_KEY) ? 'toggle' : _extends({}, $__default['default'](target).data(), $__default['default'](this).data()); if (this.tagName === 'A' || this.tagName === 'AREA') { event.preventDefault(); } - var $target = $(target).one(EVENT_SHOW, function (showEvent) { + var $target = $__default['default'](target).one(EVENT_SHOW, function (showEvent) { if (showEvent.isDefaultPrevented()) { // Only register focus restorer if modal will actually get shown return; } $target.one(EVENT_HIDDEN, function () { - if ($(_this11).is(':visible')) { + if ($__default['default'](_this11).is(':visible')) { _this11.focus(); } }); }); - Modal._jQueryInterface.call($(target), config, this); + Modal._jQueryInterface.call($__default['default'](target), config, this); }); /** * ------------------------------------------------------------------------ @@ -624,11 +626,11 @@ * ------------------------------------------------------------------------ */ - $.fn[NAME] = Modal._jQueryInterface; - $.fn[NAME].Constructor = Modal; + $__default['default'].fn[NAME] = Modal._jQueryInterface; + $__default['default'].fn[NAME].Constructor = Modal; - $.fn[NAME].noConflict = function () { - $.fn[NAME] = JQUERY_NO_CONFLICT; + $__default['default'].fn[NAME].noConflict = function () { + $__default['default'].fn[NAME] = JQUERY_NO_CONFLICT; return Modal._jQueryInterface; }; |