diff options
author | Mark Otto <markdotto@gmail.com> | 2017-10-01 00:28:03 +0300 |
---|---|---|
committer | Mark Otto <markdotto@gmail.com> | 2017-10-01 00:28:03 +0300 |
commit | f5ad6e3987788ae5903a39384c49171bf52bd7b8 (patch) | |
tree | 4ef5356be5901c7b6933781cce13f26b02fb9353 /js/dist/alert.js | |
parent | 136c49a13fc347752674d57442eefc10f050aee0 (diff) |
dist
Diffstat (limited to 'js/dist/alert.js')
-rw-r--r-- | js/dist/alert.js | 189 |
1 files changed, 84 insertions, 105 deletions
diff --git a/js/dist/alert.js b/js/dist/alert.js index 4420d463be..69c3625eb9 100644 --- a/js/dist/alert.js +++ b/js/dist/alert.js @@ -1,8 +1,6 @@ -'use strict'; +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); } } -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"); } } +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * -------------------------------------------------------------------------- @@ -10,38 +8,31 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ - var Alert = function () { - /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ - var NAME = 'alert'; var VERSION = '4.0.0-beta'; var DATA_KEY = 'bs.alert'; - var EVENT_KEY = '.' + DATA_KEY; + 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 + 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 @@ -49,120 +40,108 @@ var Alert = function () { */ }; - var Alert = function () { - function Alert(element) { - _classCallCheck(this, Alert); + var Alert = + /*#__PURE__*/ + function () { + function Alert(element) { this._element = element; - } + } // getters + - // getters + var _proto = Alert.prototype; - _createClass(Alert, [{ - key: 'close', + // public + _proto.close = function close(element) { + element = element || this._element; + var rootElement = this._getRootElement(element); - // public + var customEvent = this._triggerCloseEvent(rootElement); - value: function close(element) { - element = element || this._element; + if (customEvent.isDefaultPrevented()) { + return; + } - var rootElement = this._getRootElement(element); - var customEvent = this._triggerCloseEvent(rootElement); + this._removeElement(rootElement); + }; - if (customEvent.isDefaultPrevented()) { - return; - } + _proto.dispose = function dispose() { + $.removeData(this._element, DATA_KEY); + this._element = null; + }; // private - this._removeElement(rootElement); + + _proto._getRootElement = function _getRootElement(element) { + var selector = Util.getSelectorFromElement(element); + var parent = false; + + if (selector) { + parent = $(selector)[0]; } - }, { - key: 'dispose', - value: function dispose() { - $.removeData(this._element, DATA_KEY); - this._element = null; + + if (!parent) { + parent = $(element).closest("." + ClassName.ALERT)[0]; } - // private + return parent; + }; - }, { - key: '_getRootElement', - value: function _getRootElement(element) { - var selector = Util.getSelectorFromElement(element); - var parent = false; + _proto._triggerCloseEvent = function _triggerCloseEvent(element) { + var closeEvent = $.Event(Event.CLOSE); + $(element).trigger(closeEvent); + return closeEvent; + }; - if (selector) { - parent = $(selector)[0]; - } + _proto._removeElement = function _removeElement(element) { + var _this = this; - if (!parent) { - parent = $(element).closest('.' + ClassName.ALERT)[0]; - } + $(element).removeClass(ClassName.SHOW); - return parent; - } - }, { - key: '_triggerCloseEvent', - value: function _triggerCloseEvent(element) { - var closeEvent = $.Event(Event.CLOSE); + if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { + this._destroyElement(element); - $(element).trigger(closeEvent); - return closeEvent; + return; } - }, { - key: '_removeElement', - value: function _removeElement(element) { - var _this = this; - $(element).removeClass(ClassName.SHOW); + $(element).one(Util.TRANSITION_END, function (event) { + return _this._destroyElement(element, event); + }).emulateTransitionEnd(TRANSITION_DURATION); + }; - if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { - this._destroyElement(element); - return; - } + _proto._destroyElement = function _destroyElement(element) { + $(element).detach().trigger(Event.CLOSED).remove(); + }; // static - $(element).one(Util.TRANSITION_END, function (event) { - return _this._destroyElement(element, event); - }).emulateTransitionEnd(TRANSITION_DURATION); - } - }, { - key: '_destroyElement', - value: 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); - }], [{ - key: '_jQueryInterface', - value: 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 (!data) { - data = new Alert(this); - $element.data(DATA_KEY, data); - } + if (config === 'close') { + data[config](this); + } + }); + }; - if (config === 'close') { - data[config](this); - } - }); - } - }, { - key: '_handleDismiss', - value: function _handleDismiss(alertInstance) { - return function (event) { - if (event) { - event.preventDefault(); - } - - alertInstance.close(this); - }; - } - }, { - key: 'VERSION', + 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; } @@ -170,15 +149,14 @@ var Alert = function () { return Alert; }(); - /** * ------------------------------------------------------------------------ * Data Api implementation * ------------------------------------------------------------------------ */ - $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())); + $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())); /** * ------------------------------------------------------------------------ * jQuery @@ -187,6 +165,7 @@ var Alert = function () { $.fn[NAME] = Alert._jQueryInterface; $.fn[NAME].Constructor = Alert; + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT; return Alert._jQueryInterface; |