-
Notifications
You must be signed in to change notification settings - Fork 0
/
modal.min.js
25 lines (25 loc) · 10.2 KB
/
modal.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*!
* Bootstrap modal.js v4.5.0 (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/master/LICENSE)
*/
(function(b,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e(require("jquery"),require("./util.js")):"function"===typeof define&&define.amd?define(["jquery","./util.js"],e):(b=b||self,b.Modal=e(b.jQuery,b.Util))})(this,function(b,e){function m(b,c){for(var a=0;a<c.length;a++){var d=c[a];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(b,d.key,d)}}function p(b,c,a){c&&m(b.prototype,c);a&&m(b,a);return b}function n(b,c){var a=
Object.keys(b);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(b);c&&(d=d.filter(function(a){return Object.getOwnPropertyDescriptor(b,a).enumerable}));a.push.apply(a,d)}return a}function h(b){for(var c=1;c<arguments.length;c++){var a=null!=arguments[c]?arguments[c]:{};c%2?n(Object(a),!0).forEach(function(d){var f=a[d];d in b?Object.defineProperty(b,d,{value:f,enumerable:!0,configurable:!0,writable:!0}):b[d]=f}):Object.getOwnPropertyDescriptors?Object.defineProperties(b,Object.getOwnPropertyDescriptors(a)):
n(Object(a)).forEach(function(d){Object.defineProperty(b,d,Object.getOwnPropertyDescriptor(a,d))})}return b}b=b&&Object.prototype.hasOwnProperty.call(b,"default")?b["default"]:b;e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e;var q=b.fn.modal,l={backdrop:!0,keyboard:!0,focus:!0,show:!0},r={backdrop:"(boolean|string)",keyboard:"boolean",focus:"boolean",show:"boolean"},k=function(){function g(a,b){this._config=this._getConfig(b);this._element=a;this._dialog=a.querySelector(".modal-dialog");
this._backdrop=null;this._isTransitioning=this._ignoreBackdropClick=this._isBodyOverflowing=this._isShown=!1;this._scrollbarWidth=0}var c=g.prototype;c.toggle=function(a){return this._isShown?this.hide():this.show(a)};c.show=function(a){var d=this;if(!this._isShown&&!this._isTransitioning){b(this._element).hasClass("fade")&&(this._isTransitioning=!0);var f=b.Event("show.bs.modal",{relatedTarget:a});b(this._element).trigger(f);this._isShown||f.isDefaultPrevented()||(this._isShown=!0,this._checkScrollbar(),
this._setScrollbar(),this._adjustDialog(),this._setEscapeEvent(),this._setResizeEvent(),b(this._element).on("click.dismiss.bs.modal",'[data-dismiss="modal"]',function(a){return d.hide(a)}),b(this._dialog).on("mousedown.dismiss.bs.modal",function(){b(d._element).one("mouseup.dismiss.bs.modal",function(a){b(a.target).is(d._element)&&(d._ignoreBackdropClick=!0)})}),this._showBackdrop(function(){return d._showElement(a)}))}};c.hide=function(a){var d=this;a&&a.preventDefault();if(this._isShown&&!this._isTransitioning&&
(a=b.Event("hide.bs.modal"),b(this._element).trigger(a),this._isShown&&!a.isDefaultPrevented())){this._isShown=!1;if(a=b(this._element).hasClass("fade"))this._isTransitioning=!0;this._setEscapeEvent();this._setResizeEvent();b(document).off("focusin.bs.modal");b(this._element).removeClass("show");b(this._element).off("click.dismiss.bs.modal");b(this._dialog).off("mousedown.dismiss.bs.modal");a?(a=e.getTransitionDurationFromElement(this._element),b(this._element).one(e.TRANSITION_END,function(a){return d._hideModal(a)}).emulateTransitionEnd(a)):
this._hideModal()}};c.dispose=function(){[window,this._element,this._dialog].forEach(function(a){return b(a).off(".bs.modal")});b(document).off("focusin.bs.modal");b.removeData(this._element,"bs.modal");this._scrollbarWidth=this._isTransitioning=this._ignoreBackdropClick=this._isBodyOverflowing=this._isShown=this._backdrop=this._dialog=this._element=this._config=null};c.handleUpdate=function(){this._adjustDialog()};c._getConfig=function(a){a=h(h({},l),a);e.typeCheckConfig("modal",a,r);return a};c._triggerBackdropTransition=
function(){var a=this;if("static"===this._config.backdrop){var d=b.Event("hidePrevented.bs.modal");b(this._element).trigger(d);d.defaultPrevented||(this._element.classList.add("modal-static"),d=e.getTransitionDurationFromElement(this._element),b(this._element).one(e.TRANSITION_END,function(){a._element.classList.remove("modal-static")}).emulateTransitionEnd(d),this._element.focus())}else this.hide()};c._showElement=function(a){var d=this,f=b(this._element).hasClass("fade"),c=this._dialog?this._dialog.querySelector(".modal-body"):
null;this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE||document.body.appendChild(this._element);this._element.style.display="block";this._element.removeAttribute("aria-hidden");this._element.setAttribute("aria-modal",!0);b(this._dialog).hasClass("modal-dialog-scrollable")&&c?c.scrollTop=0:this._element.scrollTop=0;f&&e.reflow(this._element);b(this._element).addClass("show");this._config.focus&&this._enforceFocus();var u=b.Event("shown.bs.modal",{relatedTarget:a});a=
function(){d._config.focus&&d._element.focus();d._isTransitioning=!1;b(d._element).trigger(u)};f?(f=e.getTransitionDurationFromElement(this._dialog),b(this._dialog).one(e.TRANSITION_END,a).emulateTransitionEnd(f)):a()};c._enforceFocus=function(){var a=this;b(document).off("focusin.bs.modal").on("focusin.bs.modal",function(d){document!==d.target&&a._element!==d.target&&0===b(a._element).has(d.target).length&&a._element.focus()})};c._setEscapeEvent=function(){var a=this;if(this._isShown)b(this._element).on("keydown.dismiss.bs.modal",
function(b){a._config.keyboard&&27===b.which?(b.preventDefault(),a.hide()):a._config.keyboard||27!==b.which||a._triggerBackdropTransition()});else this._isShown||b(this._element).off("keydown.dismiss.bs.modal")};c._setResizeEvent=function(){var a=this;if(this._isShown)b(window).on("resize.bs.modal",function(b){return a.handleUpdate(b)});else b(window).off("resize.bs.modal")};c._hideModal=function(){var a=this;this._element.style.display="none";this._element.setAttribute("aria-hidden",!0);this._element.removeAttribute("aria-modal");
this._isTransitioning=!1;this._showBackdrop(function(){b(document.body).removeClass("modal-open");a._resetAdjustments();a._resetScrollbar();b(a._element).trigger("hidden.bs.modal")})};c._removeBackdrop=function(){this._backdrop&&(b(this._backdrop).remove(),this._backdrop=null)};c._showBackdrop=function(a){var d=this,c=b(this._element).hasClass("fade")?"fade":"";if(this._isShown&&this._config.backdrop)this._backdrop=document.createElement("div"),this._backdrop.className="modal-backdrop",c&&this._backdrop.classList.add(c),
b(this._backdrop).appendTo(document.body),b(this._element).on("click.dismiss.bs.modal",function(a){d._ignoreBackdropClick?d._ignoreBackdropClick=!1:a.target===a.currentTarget&&d._triggerBackdropTransition()}),c&&e.reflow(this._backdrop),b(this._backdrop).addClass("show"),a&&(c?(c=e.getTransitionDurationFromElement(this._backdrop),b(this._backdrop).one(e.TRANSITION_END,a).emulateTransitionEnd(c)):a());else if(!this._isShown&&this._backdrop)if(b(this._backdrop).removeClass("show"),c=function(){d._removeBackdrop();
a&&a()},b(this._element).hasClass("fade")){var t=e.getTransitionDurationFromElement(this._backdrop);b(this._backdrop).one(e.TRANSITION_END,c).emulateTransitionEnd(t)}else c();else a&&a()};c._adjustDialog=function(){var a=this._element.scrollHeight>document.documentElement.clientHeight;!this._isBodyOverflowing&&a&&(this._element.style.paddingLeft=this._scrollbarWidth+"px");this._isBodyOverflowing&&!a&&(this._element.style.paddingRight=this._scrollbarWidth+"px")};c._resetAdjustments=function(){this._element.style.paddingLeft=
"";this._element.style.paddingRight=""};c._checkScrollbar=function(){var a=document.body.getBoundingClientRect();this._isBodyOverflowing=Math.round(a.left+a.right)<window.innerWidth;this._scrollbarWidth=this._getScrollbarWidth()};c._setScrollbar=function(){var a=this;if(this._isBodyOverflowing){var d=[].slice.call(document.querySelectorAll(".fixed-top, .fixed-bottom, .is-fixed, .sticky-top")),c=[].slice.call(document.querySelectorAll(".sticky-top"));b(d).each(function(d,c){var f=c.style.paddingRight,
e=b(c).css("padding-right");b(c).data("padding-right",f).css("padding-right",parseFloat(e)+a._scrollbarWidth+"px")});b(c).each(function(d,c){var f=c.style.marginRight,e=b(c).css("margin-right");b(c).data("margin-right",f).css("margin-right",parseFloat(e)-a._scrollbarWidth+"px")});d=document.body.style.paddingRight;c=b(document.body).css("padding-right");b(document.body).data("padding-right",d).css("padding-right",parseFloat(c)+this._scrollbarWidth+"px")}b(document.body).addClass("modal-open")};c._resetScrollbar=
function(){var a=[].slice.call(document.querySelectorAll(".fixed-top, .fixed-bottom, .is-fixed, .sticky-top"));b(a).each(function(a,c){var d=b(c).data("padding-right");b(c).removeData("padding-right");c.style.paddingRight=d?d:""});a=[].slice.call(document.querySelectorAll(".sticky-top"));b(a).each(function(a,c){var d=b(c).data("margin-right");"undefined"!==typeof d&&b(c).css("margin-right",d).removeData("margin-right")});a=b(document.body).data("padding-right");b(document.body).removeData("padding-right");
document.body.style.paddingRight=a?a:""};c._getScrollbarWidth=function(){var a=document.createElement("div");a.className="modal-scrollbar-measure";document.body.appendChild(a);var b=a.getBoundingClientRect().width-a.clientWidth;document.body.removeChild(a);return b};g._jQueryInterface=function(a,c){return this.each(function(){var d=b(this).data("bs.modal"),e=h(h(h({},l),b(this).data()),"object"===typeof a&&a?a:{});d||(d=new g(this,e),b(this).data("bs.modal",d));if("string"===typeof a){if("undefined"===
typeof d[a])throw new TypeError('No method named "'+a+'"');d[a](c)}else e.show&&d.show(c)})};p(g,null,[{key:"VERSION",get:function(){return"4.5.0"}},{key:"Default",get:function(){return l}}]);return g}();b(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(g){var c=this,a,d=e.getSelectorFromElement(this);d&&(a=document.querySelector(d));d=b(a).data("bs.modal")?"toggle":h(h({},b(a).data()),b(this).data());"A"!==this.tagName&&"AREA"!==this.tagName||g.preventDefault();var f=b(a).one("show.bs.modal",
function(a){if(!a.isDefaultPrevented())f.one("hidden.bs.modal",function(){b(c).is(":visible")&&c.focus()})});k._jQueryInterface.call(b(a),d,this)});b.fn.modal=k._jQueryInterface;b.fn.modal.Constructor=k;b.fn.modal.noConflict=function(){b.fn.modal=q;return k._jQueryInterface};return k});