aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/modal.js
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-05-10 14:21:36 +0200
committerMario Vavti <mario@mariovavti.com>2019-05-10 14:21:36 +0200
commit9866053f0ce44721c11990c9f9407e7428757c99 (patch)
tree6e414efa36c3bda00205918cecb9122f951427e3 /vendor/twbs/bootstrap/js/dist/modal.js
parent89a2c1a09c896ac3a23df26a1783f5c682188a56 (diff)
downloadvolse-hubzilla-9866053f0ce44721c11990c9f9407e7428757c99.tar.gz
volse-hubzilla-9866053f0ce44721c11990c9f9407e7428757c99.tar.bz2
volse-hubzilla-9866053f0ce44721c11990c9f9407e7428757c99.zip
update bootstrap to version 4.3.1
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/modal.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/modal.js916
1 files changed, 466 insertions, 450 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/modal.js b/vendor/twbs/bootstrap/js/dist/modal.js
index ff5e82d5e..43b7e61be 100644
--- a/vendor/twbs/bootstrap/js/dist/modal.js
+++ b/vendor/twbs/bootstrap/js/dist/modal.js
@@ -1,8 +1,13 @@
+/*!
+ * Bootstrap modal.js v4.3.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)
+ */
(function (global, factory) {
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.Modal = factory(global.jQuery,global.Util));
-}(this, (function ($,Util) { 'use strict';
+ (global = global || self, global.Modal = factory(global.jQuery, global.Util));
+}(this, function ($, Util) { 'use strict';
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
@@ -58,577 +63,588 @@
}
/**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.1.3): modal.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
+ * ------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------
*/
- var Modal = function ($$$1) {
+ var NAME = 'modal';
+ var VERSION = '4.3.1';
+ var DATA_KEY = 'bs.modal';
+ var EVENT_KEY = "." + DATA_KEY;
+ var DATA_API_KEY = '.data-api';
+ var JQUERY_NO_CONFLICT = $.fn[NAME];
+ var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
+
+ var Default = {
+ backdrop: true,
+ keyboard: true,
+ focus: true,
+ show: true
+ };
+ var DefaultType = {
+ backdrop: '(boolean|string)',
+ keyboard: 'boolean',
+ focus: 'boolean',
+ show: 'boolean'
+ };
+ var Event = {
+ HIDE: "hide" + EVENT_KEY,
+ HIDDEN: "hidden" + EVENT_KEY,
+ SHOW: "show" + EVENT_KEY,
+ SHOWN: "shown" + EVENT_KEY,
+ FOCUSIN: "focusin" + EVENT_KEY,
+ RESIZE: "resize" + EVENT_KEY,
+ CLICK_DISMISS: "click.dismiss" + EVENT_KEY,
+ KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY,
+ MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY,
+ MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY,
+ CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
+ };
+ var ClassName = {
+ SCROLLABLE: 'modal-dialog-scrollable',
+ SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
+ BACKDROP: 'modal-backdrop',
+ OPEN: 'modal-open',
+ FADE: 'fade',
+ SHOW: 'show'
+ };
+ var Selector = {
+ DIALOG: '.modal-dialog',
+ MODAL_BODY: '.modal-body',
+ DATA_TOGGLE: '[data-toggle="modal"]',
+ DATA_DISMISS: '[data-dismiss="modal"]',
+ FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
+ STICKY_CONTENT: '.sticky-top'
/**
* ------------------------------------------------------------------------
- * Constants
+ * Class Definition
* ------------------------------------------------------------------------
*/
- var NAME = 'modal';
- var VERSION = '4.1.3';
- var DATA_KEY = 'bs.modal';
- var EVENT_KEY = "." + DATA_KEY;
- var DATA_API_KEY = '.data-api';
- var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
- var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
-
- var Default = {
- backdrop: true,
- keyboard: true,
- focus: true,
- show: true
- };
- var DefaultType = {
- backdrop: '(boolean|string)',
- keyboard: 'boolean',
- focus: 'boolean',
- show: 'boolean'
- };
- var Event = {
- HIDE: "hide" + EVENT_KEY,
- HIDDEN: "hidden" + EVENT_KEY,
- SHOW: "show" + EVENT_KEY,
- SHOWN: "shown" + EVENT_KEY,
- FOCUSIN: "focusin" + EVENT_KEY,
- RESIZE: "resize" + EVENT_KEY,
- CLICK_DISMISS: "click.dismiss" + EVENT_KEY,
- KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY,
- MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY,
- MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY,
- CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
- };
- var ClassName = {
- SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
- BACKDROP: 'modal-backdrop',
- OPEN: 'modal-open',
- FADE: 'fade',
- SHOW: 'show'
- };
- var Selector = {
- DIALOG: '.modal-dialog',
- DATA_TOGGLE: '[data-toggle="modal"]',
- DATA_DISMISS: '[data-dismiss="modal"]',
- FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
- STICKY_CONTENT: '.sticky-top'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ };
+
+ var Modal =
+ /*#__PURE__*/
+ function () {
+ function Modal(element, config) {
+ this._config = this._getConfig(config);
+ this._element = element;
+ this._dialog = element.querySelector(Selector.DIALOG);
+ this._backdrop = null;
+ this._isShown = false;
+ this._isBodyOverflowing = false;
+ this._ignoreBackdropClick = false;
+ this._isTransitioning = false;
+ this._scrollbarWidth = 0;
+ } // Getters
+
+
+ var _proto = Modal.prototype;
+
+ // Public
+ _proto.toggle = function toggle(relatedTarget) {
+ return this._isShown ? this.hide() : this.show(relatedTarget);
};
- var Modal =
- /*#__PURE__*/
- function () {
- function Modal(element, config) {
- this._config = this._getConfig(config);
- this._element = element;
- this._dialog = element.querySelector(Selector.DIALOG);
- this._backdrop = null;
- this._isShown = false;
- this._isBodyOverflowing = false;
- this._ignoreBackdropClick = false;
- this._scrollbarWidth = 0;
- } // Getters
-
-
- var _proto = Modal.prototype;
+ _proto.show = function show(relatedTarget) {
+ var _this = this;
- // Public
- _proto.toggle = function toggle(relatedTarget) {
- return this._isShown ? this.hide() : this.show(relatedTarget);
- };
+ if (this._isShown || this._isTransitioning) {
+ return;
+ }
- _proto.show = function show(relatedTarget) {
- var _this = this;
+ if ($(this._element).hasClass(ClassName.FADE)) {
+ this._isTransitioning = true;
+ }
- if (this._isTransitioning || this._isShown) {
- return;
- }
+ var showEvent = $.Event(Event.SHOW, {
+ relatedTarget: relatedTarget
+ });
+ $(this._element).trigger(showEvent);
- if ($$$1(this._element).hasClass(ClassName.FADE)) {
- this._isTransitioning = true;
- }
+ if (this._isShown || showEvent.isDefaultPrevented()) {
+ return;
+ }
- var showEvent = $$$1.Event(Event.SHOW, {
- relatedTarget: relatedTarget
- });
- $$$1(this._element).trigger(showEvent);
+ this._isShown = true;
- if (this._isShown || showEvent.isDefaultPrevented()) {
- return;
- }
+ this._checkScrollbar();
- this._isShown = true;
+ this._setScrollbar();
- this._checkScrollbar();
+ this._adjustDialog();
- this._setScrollbar();
+ this._setEscapeEvent();
- this._adjustDialog();
+ this._setResizeEvent();
- $$$1(document.body).addClass(ClassName.OPEN);
+ $(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)) {
+ _this._ignoreBackdropClick = true;
+ }
+ });
+ });
- this._setEscapeEvent();
+ this._showBackdrop(function () {
+ return _this._showElement(relatedTarget);
+ });
+ };
- this._setResizeEvent();
+ _proto.hide = function hide(event) {
+ var _this2 = this;
- $$$1(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function (event) {
- return _this.hide(event);
- });
- $$$1(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () {
- $$$1(_this._element).one(Event.MOUSEUP_DISMISS, function (event) {
- if ($$$1(event.target).is(_this._element)) {
- _this._ignoreBackdropClick = true;
- }
- });
- });
+ if (event) {
+ event.preventDefault();
+ }
- this._showBackdrop(function () {
- return _this._showElement(relatedTarget);
- });
- };
+ if (!this._isShown || this._isTransitioning) {
+ return;
+ }
- _proto.hide = function hide(event) {
- var _this2 = this;
+ var hideEvent = $.Event(Event.HIDE);
+ $(this._element).trigger(hideEvent);
- if (event) {
- event.preventDefault();
- }
+ if (!this._isShown || hideEvent.isDefaultPrevented()) {
+ return;
+ }
- if (this._isTransitioning || !this._isShown) {
- return;
- }
+ this._isShown = false;
+ var transition = $(this._element).hasClass(ClassName.FADE);
- var hideEvent = $$$1.Event(Event.HIDE);
- $$$1(this._element).trigger(hideEvent);
+ if (transition) {
+ this._isTransitioning = true;
+ }
- if (!this._isShown || hideEvent.isDefaultPrevented()) {
- return;
- }
+ this._setEscapeEvent();
- this._isShown = false;
- var transition = $$$1(this._element).hasClass(ClassName.FADE);
+ this._setResizeEvent();
- if (transition) {
- this._isTransitioning = true;
- }
+ $(document).off(Event.FOCUSIN);
+ $(this._element).removeClass(ClassName.SHOW);
+ $(this._element).off(Event.CLICK_DISMISS);
+ $(this._dialog).off(Event.MOUSEDOWN_DISMISS);
- this._setEscapeEvent();
+ if (transition) {
+ var transitionDuration = Util.getTransitionDurationFromElement(this._element);
+ $(this._element).one(Util.TRANSITION_END, function (event) {
+ return _this2._hideModal(event);
+ }).emulateTransitionEnd(transitionDuration);
+ } else {
+ this._hideModal();
+ }
+ };
- this._setResizeEvent();
+ _proto.dispose = function dispose() {
+ [window, this._element, this._dialog].forEach(function (htmlElement) {
+ return $(htmlElement).off(EVENT_KEY);
+ });
+ /**
+ * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
+ * Do not move `document` in `htmlElements` array
+ * It will remove `Event.CLICK_DATA_API` event that should remain
+ */
- $$$1(document).off(Event.FOCUSIN);
- $$$1(this._element).removeClass(ClassName.SHOW);
- $$$1(this._element).off(Event.CLICK_DISMISS);
- $$$1(this._dialog).off(Event.MOUSEDOWN_DISMISS);
+ $(document).off(Event.FOCUSIN);
+ $.removeData(this._element, DATA_KEY);
+ this._config = null;
+ this._element = null;
+ this._dialog = null;
+ this._backdrop = null;
+ this._isShown = null;
+ this._isBodyOverflowing = null;
+ this._ignoreBackdropClick = null;
+ this._isTransitioning = null;
+ this._scrollbarWidth = null;
+ };
- if (transition) {
- var transitionDuration = Util.getTransitionDurationFromElement(this._element);
- $$$1(this._element).one(Util.TRANSITION_END, function (event) {
- return _this2._hideModal(event);
- }).emulateTransitionEnd(transitionDuration);
- } else {
- this._hideModal();
- }
- };
+ _proto.handleUpdate = function handleUpdate() {
+ this._adjustDialog();
+ } // Private
+ ;
- _proto.dispose = function dispose() {
- $$$1.removeData(this._element, DATA_KEY);
- $$$1(window, document, this._element, this._backdrop).off(EVENT_KEY);
- this._config = null;
- this._element = null;
- this._dialog = null;
- this._backdrop = null;
- this._isShown = null;
- this._isBodyOverflowing = null;
- this._ignoreBackdropClick = null;
- this._scrollbarWidth = null;
- };
+ _proto._getConfig = function _getConfig(config) {
+ config = _objectSpread({}, Default, config);
+ Util.typeCheckConfig(NAME, config, DefaultType);
+ return config;
+ };
- _proto.handleUpdate = function handleUpdate() {
- this._adjustDialog();
- }; // Private
+ _proto._showElement = function _showElement(relatedTarget) {
+ var _this3 = this;
+ var transition = $(this._element).hasClass(ClassName.FADE);
- _proto._getConfig = function _getConfig(config) {
- config = _objectSpread({}, Default, config);
- Util.typeCheckConfig(NAME, config, DefaultType);
- return config;
- };
+ if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
+ // Don't move modal's DOM position
+ document.body.appendChild(this._element);
+ }
- _proto._showElement = function _showElement(relatedTarget) {
- var _this3 = this;
+ this._element.style.display = 'block';
- var transition = $$$1(this._element).hasClass(ClassName.FADE);
+ this._element.removeAttribute('aria-hidden');
- if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
- // Don't move modal's DOM position
- document.body.appendChild(this._element);
- }
+ this._element.setAttribute('aria-modal', true);
- this._element.style.display = 'block';
+ if ($(this._dialog).hasClass(ClassName.SCROLLABLE)) {
+ this._dialog.querySelector(Selector.MODAL_BODY).scrollTop = 0;
+ } else {
+ this._element.scrollTop = 0;
+ }
- this._element.removeAttribute('aria-hidden');
+ if (transition) {
+ Util.reflow(this._element);
+ }
- this._element.scrollTop = 0;
+ $(this._element).addClass(ClassName.SHOW);
- if (transition) {
- Util.reflow(this._element);
- }
+ if (this._config.focus) {
+ this._enforceFocus();
+ }
- $$$1(this._element).addClass(ClassName.SHOW);
+ var shownEvent = $.Event(Event.SHOWN, {
+ relatedTarget: relatedTarget
+ });
- if (this._config.focus) {
- this._enforceFocus();
+ var transitionComplete = function transitionComplete() {
+ if (_this3._config.focus) {
+ _this3._element.focus();
}
- var shownEvent = $$$1.Event(Event.SHOWN, {
- relatedTarget: relatedTarget
- });
+ _this3._isTransitioning = false;
+ $(_this3._element).trigger(shownEvent);
+ };
- var transitionComplete = function transitionComplete() {
- if (_this3._config.focus) {
- _this3._element.focus();
- }
+ if (transition) {
+ var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
+ $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
+ } else {
+ transitionComplete();
+ }
+ };
- _this3._isTransitioning = false;
- $$$1(_this3._element).trigger(shownEvent);
- };
+ _proto._enforceFocus = function _enforceFocus() {
+ var _this4 = this;
- if (transition) {
- var transitionDuration = Util.getTransitionDurationFromElement(this._element);
- $$$1(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
- } else {
- transitionComplete();
+ $(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();
}
- };
+ });
+ };
+
+ _proto._setEscapeEvent = function _setEscapeEvent() {
+ var _this5 = this;
- _proto._enforceFocus = function _enforceFocus() {
- var _this4 = this;
+ if (this._isShown && this._config.keyboard) {
+ $(this._element).on(Event.KEYDOWN_DISMISS, function (event) {
+ if (event.which === ESCAPE_KEYCODE) {
+ event.preventDefault();
- $$$1(document).off(Event.FOCUSIN) // Guard against infinite focus loop
- .on(Event.FOCUSIN, function (event) {
- if (document !== event.target && _this4._element !== event.target && $$$1(_this4._element).has(event.target).length === 0) {
- _this4._element.focus();
+ _this5.hide();
}
});
- };
-
- _proto._setEscapeEvent = function _setEscapeEvent() {
- var _this5 = this;
-
- if (this._isShown && this._config.keyboard) {
- $$$1(this._element).on(Event.KEYDOWN_DISMISS, function (event) {
- if (event.which === ESCAPE_KEYCODE) {
- event.preventDefault();
-
- _this5.hide();
- }
- });
- } else if (!this._isShown) {
- $$$1(this._element).off(Event.KEYDOWN_DISMISS);
- }
- };
-
- _proto._setResizeEvent = function _setResizeEvent() {
- var _this6 = this;
+ } else if (!this._isShown) {
+ $(this._element).off(Event.KEYDOWN_DISMISS);
+ }
+ };
- if (this._isShown) {
- $$$1(window).on(Event.RESIZE, function (event) {
- return _this6.handleUpdate(event);
- });
- } else {
- $$$1(window).off(Event.RESIZE);
- }
- };
+ _proto._setResizeEvent = function _setResizeEvent() {
+ var _this6 = this;
- _proto._hideModal = function _hideModal() {
- var _this7 = this;
+ if (this._isShown) {
+ $(window).on(Event.RESIZE, function (event) {
+ return _this6.handleUpdate(event);
+ });
+ } else {
+ $(window).off(Event.RESIZE);
+ }
+ };
- this._element.style.display = 'none';
+ _proto._hideModal = function _hideModal() {
+ var _this7 = this;
- this._element.setAttribute('aria-hidden', true);
+ this._element.style.display = 'none';
- this._isTransitioning = false;
+ this._element.setAttribute('aria-hidden', true);
- this._showBackdrop(function () {
- $$$1(document.body).removeClass(ClassName.OPEN);
+ this._element.removeAttribute('aria-modal');
- _this7._resetAdjustments();
+ this._isTransitioning = false;
- _this7._resetScrollbar();
+ this._showBackdrop(function () {
+ $(document.body).removeClass(ClassName.OPEN);
- $$$1(_this7._element).trigger(Event.HIDDEN);
- });
- };
+ _this7._resetAdjustments();
- _proto._removeBackdrop = function _removeBackdrop() {
- if (this._backdrop) {
- $$$1(this._backdrop).remove();
- this._backdrop = null;
- }
- };
+ _this7._resetScrollbar();
- _proto._showBackdrop = function _showBackdrop(callback) {
- var _this8 = this;
+ $(_this7._element).trigger(Event.HIDDEN);
+ });
+ };
- var animate = $$$1(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '';
+ _proto._removeBackdrop = function _removeBackdrop() {
+ if (this._backdrop) {
+ $(this._backdrop).remove();
+ this._backdrop = null;
+ }
+ };
- if (this._isShown && this._config.backdrop) {
- this._backdrop = document.createElement('div');
- this._backdrop.className = ClassName.BACKDROP;
+ _proto._showBackdrop = function _showBackdrop(callback) {
+ var _this8 = this;
- if (animate) {
- this._backdrop.classList.add(animate);
- }
+ var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '';
- $$$1(this._backdrop).appendTo(document.body);
- $$$1(this._element).on(Event.CLICK_DISMISS, function (event) {
- if (_this8._ignoreBackdropClick) {
- _this8._ignoreBackdropClick = false;
- return;
- }
-
- if (event.target !== event.currentTarget) {
- return;
- }
-
- if (_this8._config.backdrop === 'static') {
- _this8._element.focus();
- } else {
- _this8.hide();
- }
- });
-
- if (animate) {
- Util.reflow(this._backdrop);
- }
+ if (this._isShown && this._config.backdrop) {
+ this._backdrop = document.createElement('div');
+ this._backdrop.className = ClassName.BACKDROP;
- $$$1(this._backdrop).addClass(ClassName.SHOW);
+ if (animate) {
+ this._backdrop.classList.add(animate);
+ }
- if (!callback) {
+ $(this._backdrop).appendTo(document.body);
+ $(this._element).on(Event.CLICK_DISMISS, function (event) {
+ if (_this8._ignoreBackdropClick) {
+ _this8._ignoreBackdropClick = false;
return;
}
- if (!animate) {
- callback();
+ if (event.target !== event.currentTarget) {
return;
}
- var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
- $$$1(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
- } else if (!this._isShown && this._backdrop) {
- $$$1(this._backdrop).removeClass(ClassName.SHOW);
+ if (_this8._config.backdrop === 'static') {
+ _this8._element.focus();
+ } else {
+ _this8.hide();
+ }
+ });
- var callbackRemove = function callbackRemove() {
- _this8._removeBackdrop();
+ if (animate) {
+ Util.reflow(this._backdrop);
+ }
- if (callback) {
- callback();
- }
- };
+ $(this._backdrop).addClass(ClassName.SHOW);
- if ($$$1(this._element).hasClass(ClassName.FADE)) {
- var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
+ if (!callback) {
+ return;
+ }
- $$$1(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
- } else {
- callbackRemove();
- }
- } else if (callback) {
+ if (!animate) {
callback();
+ return;
}
- }; // ----------------------------------------------------------------------
- // the following methods are used to handle overflowing modals
- // todo (fat): these should probably be refactored out of modal.js
- // ----------------------------------------------------------------------
+ var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
+ $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
+ } else if (!this._isShown && this._backdrop) {
+ $(this._backdrop).removeClass(ClassName.SHOW);
- _proto._adjustDialog = function _adjustDialog() {
- var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
+ var callbackRemove = function callbackRemove() {
+ _this8._removeBackdrop();
- if (!this._isBodyOverflowing && isModalOverflowing) {
- this._element.style.paddingLeft = this._scrollbarWidth + "px";
- }
+ if (callback) {
+ callback();
+ }
+ };
+
+ if ($(this._element).hasClass(ClassName.FADE)) {
+ var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
- if (this._isBodyOverflowing && !isModalOverflowing) {
- this._element.style.paddingRight = this._scrollbarWidth + "px";
+ $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
+ } else {
+ callbackRemove();
}
- };
+ } else if (callback) {
+ callback();
+ }
+ } // ----------------------------------------------------------------------
+ // the following methods are used to handle overflowing modals
+ // todo (fat): these should probably be refactored out of modal.js
+ // ----------------------------------------------------------------------
+ ;
- _proto._resetAdjustments = function _resetAdjustments() {
- this._element.style.paddingLeft = '';
- this._element.style.paddingRight = '';
- };
+ _proto._adjustDialog = function _adjustDialog() {
+ var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
- _proto._checkScrollbar = function _checkScrollbar() {
- var rect = document.body.getBoundingClientRect();
- this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
- this._scrollbarWidth = this._getScrollbarWidth();
- };
+ if (!this._isBodyOverflowing && isModalOverflowing) {
+ this._element.style.paddingLeft = this._scrollbarWidth + "px";
+ }
- _proto._setScrollbar = function _setScrollbar() {
- var _this9 = this;
-
- if (this._isBodyOverflowing) {
- // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
- // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
- var fixedContent = [].slice.call(document.querySelectorAll(Selector.FIXED_CONTENT));
- var stickyContent = [].slice.call(document.querySelectorAll(Selector.STICKY_CONTENT)); // Adjust fixed content padding
-
- $$$1(fixedContent).each(function (index, element) {
- var actualPadding = element.style.paddingRight;
- var calculatedPadding = $$$1(element).css('padding-right');
- $$$1(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._scrollbarWidth + "px");
- }); // Adjust sticky content margin
-
- $$$1(stickyContent).each(function (index, element) {
- var actualMargin = element.style.marginRight;
- var calculatedMargin = $$$1(element).css('margin-right');
- $$$1(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this9._scrollbarWidth + "px");
- }); // Adjust body padding
-
- var actualPadding = document.body.style.paddingRight;
- var calculatedPadding = $$$1(document.body).css('padding-right');
- $$$1(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
- }
- };
+ if (this._isBodyOverflowing && !isModalOverflowing) {
+ this._element.style.paddingRight = this._scrollbarWidth + "px";
+ }
+ };
- _proto._resetScrollbar = function _resetScrollbar() {
- // Restore fixed content padding
- var fixedContent = [].slice.call(document.querySelectorAll(Selector.FIXED_CONTENT));
- $$$1(fixedContent).each(function (index, element) {
- var padding = $$$1(element).data('padding-right');
- $$$1(element).removeData('padding-right');
- element.style.paddingRight = padding ? padding : '';
- }); // Restore sticky content
-
- var elements = [].slice.call(document.querySelectorAll("" + Selector.STICKY_CONTENT));
- $$$1(elements).each(function (index, element) {
- var margin = $$$1(element).data('margin-right');
-
- if (typeof margin !== 'undefined') {
- $$$1(element).css('margin-right', margin).removeData('margin-right');
- }
- }); // Restore body padding
+ _proto._resetAdjustments = function _resetAdjustments() {
+ this._element.style.paddingLeft = '';
+ this._element.style.paddingRight = '';
+ };
- var padding = $$$1(document.body).data('padding-right');
- $$$1(document.body).removeData('padding-right');
- document.body.style.paddingRight = padding ? padding : '';
- };
+ _proto._checkScrollbar = function _checkScrollbar() {
+ var rect = document.body.getBoundingClientRect();
+ this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
+ this._scrollbarWidth = this._getScrollbarWidth();
+ };
- _proto._getScrollbarWidth = function _getScrollbarWidth() {
- // thx d.walsh
- var scrollDiv = document.createElement('div');
- scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
- document.body.appendChild(scrollDiv);
- var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
- document.body.removeChild(scrollDiv);
- return scrollbarWidth;
- }; // Static
+ _proto._setScrollbar = function _setScrollbar() {
+ var _this9 = this;
+ if (this._isBodyOverflowing) {
+ // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
+ // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
+ 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) {
+ var actualPadding = element.style.paddingRight;
+ var calculatedPadding = $(element).css('padding-right');
+ $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._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");
+ }); // 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");
+ }
- Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
- return this.each(function () {
- var data = $$$1(this).data(DATA_KEY);
+ $(document.body).addClass(ClassName.OPEN);
+ };
- var _config = _objectSpread({}, Default, $$$1(this).data(), typeof config === 'object' && config ? config : {});
+ _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');
+ 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');
+
+ if (typeof margin !== 'undefined') {
+ $(element).css('margin-right', margin).removeData('margin-right');
+ }
+ }); // Restore body padding
- if (!data) {
- data = new Modal(this, _config);
- $$$1(this).data(DATA_KEY, data);
- }
+ var padding = $(document.body).data('padding-right');
+ $(document.body).removeData('padding-right');
+ document.body.style.paddingRight = padding ? padding : '';
+ };
- if (typeof config === 'string') {
- if (typeof data[config] === 'undefined') {
- throw new TypeError("No method named \"" + config + "\"");
- }
+ _proto._getScrollbarWidth = function _getScrollbarWidth() {
+ // thx d.walsh
+ var scrollDiv = document.createElement('div');
+ scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
+ document.body.appendChild(scrollDiv);
+ var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
+ document.body.removeChild(scrollDiv);
+ return scrollbarWidth;
+ } // Static
+ ;
+
+ Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
+ return this.each(function () {
+ var data = $(this).data(DATA_KEY);
+
+ var _config = _objectSpread({}, Default, $(this).data(), typeof config === 'object' && config ? config : {});
+
+ if (!data) {
+ data = new Modal(this, _config);
+ $(this).data(DATA_KEY, data);
+ }
- data[config](relatedTarget);
- } else if (_config.show) {
- data.show(relatedTarget);
+ if (typeof config === 'string') {
+ if (typeof data[config] === 'undefined') {
+ throw new TypeError("No method named \"" + config + "\"");
}
- });
- };
- _createClass(Modal, null, [{
- key: "VERSION",
- get: function get() {
- return VERSION;
+ data[config](relatedTarget);
+ } else if (_config.show) {
+ data.show(relatedTarget);
}
- }, {
- key: "Default",
- get: function get() {
- return Default;
- }
- }]);
+ });
+ };
- return Modal;
- }();
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
+ _createClass(Modal, null, [{
+ key: "VERSION",
+ get: function get() {
+ return VERSION;
+ }
+ }, {
+ key: "Default",
+ get: function get() {
+ return Default;
+ }
+ }]);
+
+ return Modal;
+ }();
+ /**
+ * ------------------------------------------------------------------------
+ * Data Api implementation
+ * ------------------------------------------------------------------------
+ */
- $$$1(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
- var _this10 = this;
+ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
+ var _this10 = this;
- var target;
- var selector = Util.getSelectorFromElement(this);
+ var target;
+ var selector = Util.getSelectorFromElement(this);
- if (selector) {
- target = document.querySelector(selector);
- }
+ if (selector) {
+ target = document.querySelector(selector);
+ }
- var config = $$$1(target).data(DATA_KEY) ? 'toggle' : _objectSpread({}, $$$1(target).data(), $$$1(this).data());
+ var config = $(target).data(DATA_KEY) ? 'toggle' : _objectSpread({}, $(target).data(), $(this).data());
- if (this.tagName === 'A' || this.tagName === 'AREA') {
- event.preventDefault();
+ if (this.tagName === 'A' || this.tagName === 'AREA') {
+ event.preventDefault();
+ }
+
+ var $target = $(target).one(Event.SHOW, function (showEvent) {
+ if (showEvent.isDefaultPrevented()) {
+ // Only register focus restorer if modal will actually get shown
+ return;
}
- var $target = $$$1(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 ($(_this10).is(':visible')) {
+ _this10.focus();
}
-
- $target.one(Event.HIDDEN, function () {
- if ($$$1(_this10).is(':visible')) {
- _this10.focus();
- }
- });
});
-
- Modal._jQueryInterface.call($$$1(target), config, this);
});
- /**
- * ------------------------------------------------------------------------
- * jQuery
- * ------------------------------------------------------------------------
- */
- $$$1.fn[NAME] = Modal._jQueryInterface;
- $$$1.fn[NAME].Constructor = Modal;
+ Modal._jQueryInterface.call($(target), config, this);
+ });
+ /**
+ * ------------------------------------------------------------------------
+ * jQuery
+ * ------------------------------------------------------------------------
+ */
- $$$1.fn[NAME].noConflict = function () {
- $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
- return Modal._jQueryInterface;
- };
+ $.fn[NAME] = Modal._jQueryInterface;
+ $.fn[NAME].Constructor = Modal;
- return Modal;
- }($);
+ $.fn[NAME].noConflict = function () {
+ $.fn[NAME] = JQUERY_NO_CONFLICT;
+ return Modal._jQueryInterface;
+ };
return Modal;
-})));
+}));
//# sourceMappingURL=modal.js.map