123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.4): alert.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
- */
- var Alert = function ($) {
- /**
- * ------------------------------------------------------------------------
- * Constants
- * ------------------------------------------------------------------------
- */
- var NAME = 'alert';
- var VERSION = '4.0.0-alpha.4';
- var DATA_KEY = 'bs.alert';
- var EVENT_KEY = '.' + DATA_KEY;
- var DATA_API_KEY = '.data-api';
- var JQUERY_NO_CONFLICT = $.fn[NAME];
- var TRANSITION_DURATION = 150;
- 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',
- IN: 'in'
- };
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
- var Alert = function () {
- function Alert(element) {
- _classCallCheck(this, Alert);
- this._element = element;
- }
- // getters
- // public
- Alert.prototype.close = function close(element) {
- element = element || this._element;
- var rootElement = this._getRootElement(element);
- var customEvent = this._triggerCloseEvent(rootElement);
- if (customEvent.isDefaultPrevented()) {
- return;
- }
- this._removeElement(rootElement);
- };
- Alert.prototype.dispose = function dispose() {
- $.removeData(this._element, DATA_KEY);
- this._element = null;
- };
- // private
- Alert.prototype._getRootElement = function _getRootElement(element) {
- var selector = Util.getSelectorFromElement(element);
- var parent = false;
- if (selector) {
- parent = $(selector)[0];
- }
- if (!parent) {
- parent = $(element).closest('.' + ClassName.ALERT)[0];
- }
- return parent;
- };
- Alert.prototype._triggerCloseEvent = function _triggerCloseEvent(element) {
- var closeEvent = $.Event(Event.CLOSE);
- $(element).trigger(closeEvent);
- return closeEvent;
- };
- Alert.prototype._removeElement = function _removeElement(element) {
- $(element).removeClass(ClassName.IN);
- if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) {
- this._destroyElement(element);
- return;
- }
- $(element).one(Util.TRANSITION_END, $.proxy(this._destroyElement, this, element)).emulateTransitionEnd(TRANSITION_DURATION);
- };
- Alert.prototype._destroyElement = function _destroyElement(element) {
- $(element).detach().trigger(Event.CLOSED).remove();
- };
- // static
- Alert._jQueryInterface = function _jQueryInterface(config) {
- return this.each(function () {
- var $element = $(this);
- var data = $element.data(DATA_KEY);
- if (!data) {
- data = new Alert(this);
- $element.data(DATA_KEY, data);
- }
- if (config === 'close') {
- data[config](this);
- }
- });
- };
- Alert._handleDismiss = function _handleDismiss(alertInstance) {
- return function (event) {
- if (event) {
- event.preventDefault();
- }
- alertInstance.close(this);
- };
- };
- _createClass(Alert, null, [{
- key: 'VERSION',
- get: function get() {
- return VERSION;
- }
- }]);
- return Alert;
- }();
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
- $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
- /**
- * ------------------------------------------------------------------------
- * jQuery
- * ------------------------------------------------------------------------
- */
- $.fn[NAME] = Alert._jQueryInterface;
- $.fn[NAME].Constructor = Alert;
- $.fn[NAME].noConflict = function () {
- $.fn[NAME] = JQUERY_NO_CONFLICT;
- return Alert._jQueryInterface;
- };
- return Alert;
- }(jQuery);
- //# sourceMappingURL=alert.js.map
|