2018-07-24 02:51:14 +02:00
|
|
|
(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.Alert = factory(global.jQuery,global.Util));
|
|
|
|
}(this, (function ($,Util) { 'use strict';
|
|
|
|
|
|
|
|
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
|
|
|
|
Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
|
|
|
|
|
|
|
|
function _defineProperties(target, props) {
|
|
|
|
for (var i = 0; i < props.length; i++) {
|
|
|
|
var descriptor = props[i];
|
|
|
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
|
|
descriptor.configurable = true;
|
|
|
|
if ("value" in descriptor) descriptor.writable = true;
|
|
|
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
|
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
|
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
|
|
return Constructor;
|
|
|
|
}
|
2017-09-06 06:05:12 +02:00
|
|
|
|
2015-05-08 01:34:28 +02:00
|
|
|
/**
|
2018-07-24 02:51:14 +02:00
|
|
|
* --------------------------------------------------------------------------
|
2018-07-24 04:25:52 +02:00
|
|
|
* Bootstrap (v4.1.3): alert.js
|
2018-07-24 02:51:14 +02:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
|
|
|
* --------------------------------------------------------------------------
|
2015-05-08 01:34:28 +02:00
|
|
|
*/
|
2018-07-24 02:51:14 +02:00
|
|
|
|
|
|
|
var Alert = function ($$$1) {
|
2017-09-13 07:24:15 +02:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
2018-07-24 02:51:14 +02:00
|
|
|
* Constants
|
2017-09-13 07:24:15 +02:00
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2018-07-24 02:51:14 +02:00
|
|
|
var NAME = 'alert';
|
2018-07-24 04:25:52 +02:00
|
|
|
var VERSION = '4.1.3';
|
2018-07-24 02:51:14 +02:00
|
|
|
var DATA_KEY = 'bs.alert';
|
|
|
|
var EVENT_KEY = "." + DATA_KEY;
|
|
|
|
var DATA_API_KEY = '.data-api';
|
|
|
|
var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
|
|
|
|
var Selector = {
|
|
|
|
DISMISS: '[data-dismiss="alert"]'
|
|
|
|
};
|
|
|
|
var Event = {
|
|
|
|
CLOSE: "close" + EVENT_KEY,
|
|
|
|
CLOSED: "closed" + EVENT_KEY,
|
|
|
|
CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
|
|
|
|
};
|
|
|
|
var ClassName = {
|
|
|
|
ALERT: 'alert',
|
|
|
|
FADE: 'fade',
|
|
|
|
SHOW: 'show'
|
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Class Definition
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-08 01:34:28 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
};
|
2015-05-08 01:34:28 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
var Alert =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
|
|
|
function Alert(element) {
|
|
|
|
this._element = element;
|
|
|
|
} // Getters
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
var _proto = Alert.prototype;
|
2015-08-13 06:12:03 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
// Public
|
|
|
|
_proto.close = function close(element) {
|
|
|
|
var rootElement = this._element;
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
if (element) {
|
|
|
|
rootElement = this._getRootElement(element);
|
|
|
|
}
|
2015-05-08 02:07:38 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
var customEvent = this._triggerCloseEvent(rootElement);
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
if (customEvent.isDefaultPrevented()) {
|
|
|
|
return;
|
|
|
|
}
|
2016-10-10 02:26:51 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
this._removeElement(rootElement);
|
|
|
|
};
|
2016-10-10 02:26:51 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
_proto.dispose = function dispose() {
|
|
|
|
$$$1.removeData(this._element, DATA_KEY);
|
|
|
|
this._element = null;
|
|
|
|
}; // Private
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
_proto._getRootElement = function _getRootElement(element) {
|
|
|
|
var selector = Util.getSelectorFromElement(element);
|
|
|
|
var parent = false;
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
if (selector) {
|
|
|
|
parent = document.querySelector(selector);
|
|
|
|
}
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
if (!parent) {
|
|
|
|
parent = $$$1(element).closest("." + ClassName.ALERT)[0];
|
|
|
|
}
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
return parent;
|
|
|
|
};
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
_proto._triggerCloseEvent = function _triggerCloseEvent(element) {
|
|
|
|
var closeEvent = $$$1.Event(Event.CLOSE);
|
|
|
|
$$$1(element).trigger(closeEvent);
|
|
|
|
return closeEvent;
|
|
|
|
};
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
_proto._removeElement = function _removeElement(element) {
|
|
|
|
var _this = this;
|
2016-11-01 05:36:10 +01:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
$$$1(element).removeClass(ClassName.SHOW);
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
if (!$$$1(element).hasClass(ClassName.FADE)) {
|
|
|
|
this._destroyElement(element);
|
2015-08-19 05:28:28 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
var transitionDuration = Util.getTransitionDurationFromElement(element);
|
|
|
|
$$$1(element).one(Util.TRANSITION_END, function (event) {
|
|
|
|
return _this._destroyElement(element, event);
|
|
|
|
}).emulateTransitionEnd(transitionDuration);
|
|
|
|
};
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
_proto._destroyElement = function _destroyElement(element) {
|
|
|
|
$$$1(element).detach().trigger(Event.CLOSED).remove();
|
|
|
|
}; // Static
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2016-10-10 02:26:51 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
Alert._jQueryInterface = function _jQueryInterface(config) {
|
|
|
|
return this.each(function () {
|
|
|
|
var $element = $$$1(this);
|
|
|
|
var data = $element.data(DATA_KEY);
|
2017-09-06 06:05:12 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
if (!data) {
|
|
|
|
data = new Alert(this);
|
|
|
|
$element.data(DATA_KEY, data);
|
|
|
|
}
|
2016-10-10 02:26:51 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
if (config === 'close') {
|
|
|
|
data[config](this);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2016-10-10 02:26:51 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
Alert._handleDismiss = function _handleDismiss(alertInstance) {
|
|
|
|
return function (event) {
|
|
|
|
if (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
alertInstance.close(this);
|
|
|
|
};
|
2017-09-30 23:28:03 +02:00
|
|
|
};
|
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
_createClass(Alert, null, [{
|
|
|
|
key: "VERSION",
|
|
|
|
get: function get() {
|
|
|
|
return VERSION;
|
|
|
|
}
|
|
|
|
}]);
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
return Alert;
|
|
|
|
}();
|
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Data Api implementation
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-07 21:48:22 +02:00
|
|
|
|
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
$$$1(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
|
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* jQuery
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
$$$1.fn[NAME] = Alert._jQueryInterface;
|
|
|
|
$$$1.fn[NAME].Constructor = Alert;
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2018-07-24 02:51:14 +02:00
|
|
|
$$$1.fn[NAME].noConflict = function () {
|
|
|
|
$$$1.fn[NAME] = JQUERY_NO_CONFLICT;
|
|
|
|
return Alert._jQueryInterface;
|
|
|
|
};
|
|
|
|
|
|
|
|
return Alert;
|
|
|
|
}($);
|
2015-05-07 21:48:22 +02:00
|
|
|
|
2015-05-08 01:34:28 +02:00
|
|
|
return Alert;
|
2018-07-24 02:51:14 +02:00
|
|
|
|
|
|
|
})));
|
|
|
|
//# sourceMappingURL=alert.js.map
|