2018-11-13 01:41:12 -05:00
|
|
|
/*!
|
2019-02-11 14:15:34 -05:00
|
|
|
* Bootstrap alert.js v4.3.0 (https://getbootstrap.com/)
|
2019-01-04 11:29:45 -05:00
|
|
|
* Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
2018-11-13 01:41:12 -05:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
|
|
|
*/
|
2018-07-23 20:51:14 -04: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) :
|
2019-01-04 11:29:45 -05:00
|
|
|
(global = global || self, global.Alert = factory(global.jQuery, global.Util));
|
|
|
|
}(this, function ($, Util) { 'use strict';
|
2018-07-23 20:51:14 -04:00
|
|
|
|
|
|
|
$ = $ && $.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 00:05:12 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Constants
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
var NAME = 'alert';
|
2019-02-11 14:15:34 -05:00
|
|
|
var VERSION = '4.3.0';
|
2018-11-13 01:41:12 -05:00
|
|
|
var DATA_KEY = 'bs.alert';
|
|
|
|
var EVENT_KEY = "." + DATA_KEY;
|
|
|
|
var DATA_API_KEY = '.data-api';
|
|
|
|
var JQUERY_NO_CONFLICT = $.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'
|
2017-09-13 01:24:15 -04:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
2018-11-13 01:41:12 -05:00
|
|
|
* Class Definition
|
2017-09-13 01:24:15 -04:00
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-07 19:34:28 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
};
|
2015-05-07 19:34:28 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
var Alert =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
|
|
|
function Alert(element) {
|
|
|
|
this._element = element;
|
|
|
|
} // Getters
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
var _proto = Alert.prototype;
|
2015-08-13 00:12:03 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
// Public
|
|
|
|
_proto.close = function close(element) {
|
|
|
|
var rootElement = this._element;
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (element) {
|
|
|
|
rootElement = this._getRootElement(element);
|
|
|
|
}
|
2015-05-07 20:07:38 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
var customEvent = this._triggerCloseEvent(rootElement);
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (customEvent.isDefaultPrevented()) {
|
|
|
|
return;
|
|
|
|
}
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
this._removeElement(rootElement);
|
|
|
|
};
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
_proto.dispose = function dispose() {
|
|
|
|
$.removeData(this._element, DATA_KEY);
|
|
|
|
this._element = null;
|
2019-01-04 11:29:45 -05:00
|
|
|
} // Private
|
|
|
|
;
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
_proto._getRootElement = function _getRootElement(element) {
|
|
|
|
var selector = Util.getSelectorFromElement(element);
|
|
|
|
var parent = false;
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (selector) {
|
|
|
|
parent = document.querySelector(selector);
|
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (!parent) {
|
|
|
|
parent = $(element).closest("." + ClassName.ALERT)[0];
|
|
|
|
}
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
return parent;
|
|
|
|
};
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
_proto._triggerCloseEvent = function _triggerCloseEvent(element) {
|
|
|
|
var closeEvent = $.Event(Event.CLOSE);
|
|
|
|
$(element).trigger(closeEvent);
|
|
|
|
return closeEvent;
|
|
|
|
};
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
_proto._removeElement = function _removeElement(element) {
|
|
|
|
var _this = this;
|
2016-11-01 00:36:10 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
$(element).removeClass(ClassName.SHOW);
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (!$(element).hasClass(ClassName.FADE)) {
|
|
|
|
this._destroyElement(element);
|
2015-08-18 23:28:28 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
return;
|
|
|
|
}
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
var transitionDuration = Util.getTransitionDurationFromElement(element);
|
|
|
|
$(element).one(Util.TRANSITION_END, function (event) {
|
|
|
|
return _this._destroyElement(element, event);
|
|
|
|
}).emulateTransitionEnd(transitionDuration);
|
|
|
|
};
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
_proto._destroyElement = function _destroyElement(element) {
|
|
|
|
$(element).detach().trigger(Event.CLOSED).remove();
|
2019-01-04 11:29:45 -05:00
|
|
|
} // Static
|
|
|
|
;
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
Alert._jQueryInterface = function _jQueryInterface(config) {
|
|
|
|
return this.each(function () {
|
|
|
|
var $element = $(this);
|
|
|
|
var data = $element.data(DATA_KEY);
|
2017-09-06 00:05:12 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (!data) {
|
|
|
|
data = new Alert(this);
|
|
|
|
$element.data(DATA_KEY, data);
|
|
|
|
}
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (config === 'close') {
|
|
|
|
data[config](this);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
Alert._handleDismiss = function _handleDismiss(alertInstance) {
|
|
|
|
return function (event) {
|
|
|
|
if (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
alertInstance.close(this);
|
2017-09-30 17:28:03 -04:00
|
|
|
};
|
2018-11-13 01:41:12 -05:00
|
|
|
};
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
_createClass(Alert, null, [{
|
|
|
|
key: "VERSION",
|
|
|
|
get: function get() {
|
|
|
|
return VERSION;
|
|
|
|
}
|
|
|
|
}]);
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
return Alert;
|
|
|
|
}();
|
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Data Api implementation
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-07 15:48:22 -04:00
|
|
|
|
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
$(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
|
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* jQuery
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
$.fn[NAME] = Alert._jQueryInterface;
|
|
|
|
$.fn[NAME].Constructor = Alert;
|
2018-07-23 20:51:14 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
$.fn[NAME].noConflict = function () {
|
|
|
|
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
|
|
|
return Alert._jQueryInterface;
|
|
|
|
};
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2015-05-07 19:34:28 -04:00
|
|
|
return Alert;
|
2018-07-23 20:51:14 -04:00
|
|
|
|
2019-01-04 11:29:45 -05:00
|
|
|
}));
|
2018-07-23 20:51:14 -04:00
|
|
|
//# sourceMappingURL=alert.js.map
|