1 (function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
3 typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
4 (global.Alert = factory(global.jQuery,global.Util));
5 }(this, (function ($,Util) { 'use strict';
7 $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
8 Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
10 function _defineProperties(target, props) {
11 for (var i = 0; i < props.length; i++) {
12 var descriptor = props[i];
13 descriptor.enumerable = descriptor.enumerable || false;
14 descriptor.configurable = true;
15 if ("value" in descriptor) descriptor.writable = true;
16 Object.defineProperty(target, descriptor.key, descriptor);
20 function _createClass(Constructor, protoProps, staticProps) {
21 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
22 if (staticProps) _defineProperties(Constructor, staticProps);
27 * --------------------------------------------------------------------------
28 * Bootstrap (v4.1.3): alert.js
29 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
30 * --------------------------------------------------------------------------
33 var Alert = function ($$$1) {
35 * ------------------------------------------------------------------------
37 * ------------------------------------------------------------------------
40 var VERSION = '4.1.3';
41 var DATA_KEY = 'bs.alert';
42 var EVENT_KEY = "." + DATA_KEY;
43 var DATA_API_KEY = '.data-api';
44 var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
46 DISMISS: '[data-dismiss="alert"]'
49 CLOSE: "close" + EVENT_KEY,
50 CLOSED: "closed" + EVENT_KEY,
51 CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
58 * ------------------------------------------------------------------------
60 * ------------------------------------------------------------------------
68 function Alert(element) {
69 this._element = element;
73 var _proto = Alert.prototype;
76 _proto.close = function close(element) {
77 var rootElement = this._element;
80 rootElement = this._getRootElement(element);
83 var customEvent = this._triggerCloseEvent(rootElement);
85 if (customEvent.isDefaultPrevented()) {
89 this._removeElement(rootElement);
92 _proto.dispose = function dispose() {
93 $$$1.removeData(this._element, DATA_KEY);
98 _proto._getRootElement = function _getRootElement(element) {
99 var selector = Util.getSelectorFromElement(element);
103 parent = document.querySelector(selector);
107 parent = $$$1(element).closest("." + ClassName.ALERT)[0];
113 _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
114 var closeEvent = $$$1.Event(Event.CLOSE);
115 $$$1(element).trigger(closeEvent);
119 _proto._removeElement = function _removeElement(element) {
122 $$$1(element).removeClass(ClassName.SHOW);
124 if (!$$$1(element).hasClass(ClassName.FADE)) {
125 this._destroyElement(element);
130 var transitionDuration = Util.getTransitionDurationFromElement(element);
131 $$$1(element).one(Util.TRANSITION_END, function (event) {
132 return _this._destroyElement(element, event);
133 }).emulateTransitionEnd(transitionDuration);
136 _proto._destroyElement = function _destroyElement(element) {
137 $$$1(element).detach().trigger(Event.CLOSED).remove();
141 Alert._jQueryInterface = function _jQueryInterface(config) {
142 return this.each(function () {
143 var $element = $$$1(this);
144 var data = $element.data(DATA_KEY);
147 data = new Alert(this);
148 $element.data(DATA_KEY, data);
151 if (config === 'close') {
157 Alert._handleDismiss = function _handleDismiss(alertInstance) {
158 return function (event) {
160 event.preventDefault();
163 alertInstance.close(this);
167 _createClass(Alert, null, [{
169 get: function get() {
177 * ------------------------------------------------------------------------
178 * Data Api implementation
179 * ------------------------------------------------------------------------
183 $$$1(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
185 * ------------------------------------------------------------------------
187 * ------------------------------------------------------------------------
190 $$$1.fn[NAME] = Alert._jQueryInterface;
191 $$$1.fn[NAME].Constructor = Alert;
193 $$$1.fn[NAME].noConflict = function () {
194 $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
195 return Alert._jQueryInterface;
204 //# sourceMappingURL=alert.js.map