aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/modal.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/modal.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/modal.js153
1 files changed, 94 insertions, 59 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/modal.js b/vendor/twbs/bootstrap/js/dist/modal.js
index 43b7e61be..dbdb64951 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.3.1 (https://getbootstrap.com/)
+ * Bootstrap modal.js v4.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
@@ -7,7 +7,7 @@
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
(global = global || self, global.Modal = factory(global.jQuery, global.Util));
-}(this, function ($, Util) { 'use strict';
+}(this, (function ($, Util) { 'use strict';
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
@@ -43,20 +43,35 @@
return obj;
}
- function _objectSpread(target) {
+ function ownKeys(object, enumerableOnly) {
+ var keys = Object.keys(object);
+
+ if (Object.getOwnPropertySymbols) {
+ var symbols = Object.getOwnPropertySymbols(object);
+ if (enumerableOnly) symbols = symbols.filter(function (sym) {
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
+ });
+ keys.push.apply(keys, symbols);
+ }
+
+ return keys;
+ }
+
+ function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
- var ownKeys = Object.keys(source);
- if (typeof Object.getOwnPropertySymbols === 'function') {
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
- }));
+ if (i % 2) {
+ ownKeys(Object(source), true).forEach(function (key) {
+ _defineProperty(target, key, source[key]);
+ });
+ } else if (Object.getOwnPropertyDescriptors) {
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
+ } else {
+ ownKeys(Object(source)).forEach(function (key) {
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
+ });
}
-
- ownKeys.forEach(function (key) {
- _defineProperty(target, key, source[key]);
- });
}
return target;
@@ -69,7 +84,7 @@
*/
var NAME = 'modal';
- var VERSION = '4.3.1';
+ var VERSION = '4.4.1';
var DATA_KEY = 'bs.modal';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
@@ -90,6 +105,7 @@
};
var Event = {
HIDE: "hide" + EVENT_KEY,
+ HIDE_PREVENTED: "hidePrevented" + EVENT_KEY,
HIDDEN: "hidden" + EVENT_KEY,
SHOW: "show" + EVENT_KEY,
SHOWN: "shown" + EVENT_KEY,
@@ -107,7 +123,8 @@
BACKDROP: 'modal-backdrop',
OPEN: 'modal-open',
FADE: 'fade',
- SHOW: 'show'
+ SHOW: 'show',
+ STATIC: 'modal-static'
};
var Selector = {
DIALOG: '.modal-dialog',
@@ -116,13 +133,12 @@
DATA_DISMISS: '[data-dismiss="modal"]',
FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
STICKY_CONTENT: '.sticky-top'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
-
};
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
var Modal =
/*#__PURE__*/
@@ -268,15 +284,40 @@
;
_proto._getConfig = function _getConfig(config) {
- config = _objectSpread({}, Default, config);
+ config = _objectSpread2({}, Default, {}, config);
Util.typeCheckConfig(NAME, config, DefaultType);
return config;
};
- _proto._showElement = function _showElement(relatedTarget) {
+ _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
var _this3 = this;
+ if (this._config.backdrop === 'static') {
+ var hideEventPrevented = $.Event(Event.HIDE_PREVENTED);
+ $(this._element).trigger(hideEventPrevented);
+
+ if (hideEventPrevented.defaultPrevented) {
+ return;
+ }
+
+ this._element.classList.add(ClassName.STATIC);
+
+ var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
+ $(this._element).one(Util.TRANSITION_END, function () {
+ _this3._element.classList.remove(ClassName.STATIC);
+ }).emulateTransitionEnd(modalTransitionDuration);
+
+ this._element.focus();
+ } else {
+ this.hide();
+ }
+ };
+
+ _proto._showElement = function _showElement(relatedTarget) {
+ var _this4 = this;
+
var transition = $(this._element).hasClass(ClassName.FADE);
+ var modalBody = this._dialog ? this._dialog.querySelector(Selector.MODAL_BODY) : null;
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
// Don't move modal's DOM position
@@ -289,8 +330,8 @@
this._element.setAttribute('aria-modal', true);
- if ($(this._dialog).hasClass(ClassName.SCROLLABLE)) {
- this._dialog.querySelector(Selector.MODAL_BODY).scrollTop = 0;
+ if ($(this._dialog).hasClass(ClassName.SCROLLABLE) && modalBody) {
+ modalBody.scrollTop = 0;
} else {
this._element.scrollTop = 0;
}
@@ -310,12 +351,12 @@
});
var transitionComplete = function transitionComplete() {
- if (_this3._config.focus) {
- _this3._element.focus();
+ if (_this4._config.focus) {
+ _this4._element.focus();
}
- _this3._isTransitioning = false;
- $(_this3._element).trigger(shownEvent);
+ _this4._isTransitioning = false;
+ $(_this4._element).trigger(shownEvent);
};
if (transition) {
@@ -327,25 +368,23 @@
};
_proto._enforceFocus = function _enforceFocus() {
- var _this4 = this;
+ var _this5 = this;
$(document).off(Event.FOCUSIN) // Guard against infinite focus loop
.on(Event.FOCUSIN, function (event) {
- if (document !== event.target && _this4._element !== event.target && $(_this4._element).has(event.target).length === 0) {
- _this4._element.focus();
+ if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
+ _this5._element.focus();
}
});
};
_proto._setEscapeEvent = function _setEscapeEvent() {
- var _this5 = this;
+ var _this6 = this;
if (this._isShown && this._config.keyboard) {
$(this._element).on(Event.KEYDOWN_DISMISS, function (event) {
if (event.which === ESCAPE_KEYCODE) {
- event.preventDefault();
-
- _this5.hide();
+ _this6._triggerBackdropTransition();
}
});
} else if (!this._isShown) {
@@ -354,11 +393,11 @@
};
_proto._setResizeEvent = function _setResizeEvent() {
- var _this6 = this;
+ var _this7 = this;
if (this._isShown) {
$(window).on(Event.RESIZE, function (event) {
- return _this6.handleUpdate(event);
+ return _this7.handleUpdate(event);
});
} else {
$(window).off(Event.RESIZE);
@@ -366,7 +405,7 @@
};
_proto._hideModal = function _hideModal() {
- var _this7 = this;
+ var _this8 = this;
this._element.style.display = 'none';
@@ -379,11 +418,11 @@
this._showBackdrop(function () {
$(document.body).removeClass(ClassName.OPEN);
- _this7._resetAdjustments();
+ _this8._resetAdjustments();
- _this7._resetScrollbar();
+ _this8._resetScrollbar();
- $(_this7._element).trigger(Event.HIDDEN);
+ $(_this8._element).trigger(Event.HIDDEN);
});
};
@@ -395,7 +434,7 @@
};
_proto._showBackdrop = function _showBackdrop(callback) {
- var _this8 = this;
+ var _this9 = this;
var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '';
@@ -409,8 +448,8 @@
$(this._backdrop).appendTo(document.body);
$(this._element).on(Event.CLICK_DISMISS, function (event) {
- if (_this8._ignoreBackdropClick) {
- _this8._ignoreBackdropClick = false;
+ if (_this9._ignoreBackdropClick) {
+ _this9._ignoreBackdropClick = false;
return;
}
@@ -418,11 +457,7 @@
return;
}
- if (_this8._config.backdrop === 'static') {
- _this8._element.focus();
- } else {
- _this8.hide();
- }
+ _this9._triggerBackdropTransition();
});
if (animate) {
@@ -446,7 +481,7 @@
$(this._backdrop).removeClass(ClassName.SHOW);
var callbackRemove = function callbackRemove() {
- _this8._removeBackdrop();
+ _this9._removeBackdrop();
if (callback) {
callback();
@@ -493,7 +528,7 @@
};
_proto._setScrollbar = function _setScrollbar() {
- var _this9 = this;
+ var _this10 = this;
if (this._isBodyOverflowing) {
// Note: DOMNode.style.paddingRight returns the actual value or '' if not set
@@ -504,13 +539,13 @@
$(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) + _this9._scrollbarWidth + "px");
+ $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
}); // Adjust sticky content margin
$(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) - _this9._scrollbarWidth + "px");
+ $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
}); // Adjust body padding
var actualPadding = document.body.style.paddingRight;
@@ -559,7 +594,7 @@
return this.each(function () {
var data = $(this).data(DATA_KEY);
- var _config = _objectSpread({}, Default, $(this).data(), typeof config === 'object' && config ? config : {});
+ var _config = _objectSpread2({}, Default, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
if (!data) {
data = new Modal(this, _config);
@@ -600,7 +635,7 @@
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
- var _this10 = this;
+ var _this11 = this;
var target;
var selector = Util.getSelectorFromElement(this);
@@ -609,7 +644,7 @@
target = document.querySelector(selector);
}
- var config = $(target).data(DATA_KEY) ? 'toggle' : _objectSpread({}, $(target).data(), $(this).data());
+ var config = $(target).data(DATA_KEY) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
if (this.tagName === 'A' || this.tagName === 'AREA') {
event.preventDefault();
@@ -622,8 +657,8 @@
}
$target.one(Event.HIDDEN, function () {
- if ($(_this10).is(':visible')) {
- _this10.focus();
+ if ($(_this11).is(':visible')) {
+ _this11.focus();
}
});
});
@@ -646,5 +681,5 @@
return Modal;
-}));
+})));
//# sourceMappingURL=modal.js.map