diff options
Diffstat (limited to 'js/dist/alert.js')
-rw-r--r-- | js/dist/alert.js | 270 |
1 files changed, 138 insertions, 132 deletions
diff --git a/js/dist/alert.js b/js/dist/alert.js index 0dbfe767b7..76b280a0c3 100644 --- a/js/dist/alert.js +++ b/js/dist/alert.js @@ -6,165 +6,171 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons /** * -------------------------------------------------------------------------- - * Constants - * -------------------------------------------------------------------------- - */ - -var NAME = 'alert'; -var VERSION = '4.0.0'; -var DATA_KEY = 'bs.alert'; -var JQUERY_NO_CONFLICT = $.fn[NAME]; -var TRANSITION_DURATION = 150; - -var Selector = { - DISMISS: '[data-dismiss="alert"]' -}; - -var Event = { - CLOSE: 'close.bs.alert', - CLOSED: 'closed.bs.alert', - CLICK: 'click.bs.alert.data-api' -}; - -var ClassName = { - ALERT: 'alert', - FADE: 'fade', - IN: 'in' -}; - -/** - * -------------------------------------------------------------------------- - * Class Definition + * Bootstrap (v4.0.0): alert.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Alert = (function () { - function Alert(element) { - _classCallCheck(this, Alert); - if (element) { - this.element = element; + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'alert'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.alert'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + + var Selector = { + DISMISS: '[data-dismiss="alert"]' + }; + + var Event = { + CLOSE: 'close.bs.alert', + CLOSED: 'closed.bs.alert', + CLICK: 'click.bs.alert.data-api' + }; + + var ClassName = { + ALERT: 'alert', + FADE: 'fade', + IN: 'in' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Alert = (function () { + function Alert(element) { + _classCallCheck(this, Alert); + + if (element) { + this.element = element; + } } - } - _createClass(Alert, [{ - key: 'close', + _createClass(Alert, [{ + key: 'close', + + // public - // public + value: function close(element) { + var rootElement = this._getRootElement(element); + var customEvent = this._triggerCloseEvent(rootElement); - value: function close(element) { - var rootElement = this._getRootElement(element); - var customEvent = this._triggerCloseEvent(rootElement); + if (customEvent.isDefaultPrevented()) { + return; + } - if (customEvent.isDefaultPrevented()) { - return; + this._removeElement(rootElement); } + }, { + key: '_getRootElement', - this._removeElement(rootElement); - } - }, { - key: '_getRootElement', + // private - // private + value: function _getRootElement(element) { + var parent = false; + var selector = Util.getSelectorFromElement(element); - value: function _getRootElement(element) { - var parent = false; - var selector = Util.getSelectorFromElement(element); + if (selector) { + parent = $(selector)[0]; + } - if (selector) { - parent = $(selector)[0]; - } + if (!parent) { + parent = $(element).closest('.' + ClassName.ALERT)[0]; + } - if (!parent) { - parent = $(element).closest('.' + ClassName.ALERT)[0]; + return parent; + } + }, { + key: '_triggerCloseEvent', + value: function _triggerCloseEvent(element) { + var closeEvent = $.Event(Event.CLOSE); + $(element).trigger(closeEvent); + return closeEvent; } + }, { + key: '_removeElement', + value: function _removeElement(element) { + $(element).removeClass(ClassName.IN); + + if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { + this._destroyElement(element); + return; + } - return parent; - } - }, { - key: '_triggerCloseEvent', - value: function _triggerCloseEvent(element) { - var closeEvent = $.Event(Event.CLOSE); - $(element).trigger(closeEvent); - return closeEvent; - } - }, { - key: '_removeElement', - value: function _removeElement(element) { - $(element).removeClass(ClassName.IN); - - if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { - this._destroyElement(element); - return; + $(element).one(Util.TRANSITION_END, this._destroyElement.bind(this, element)).emulateTransitionEnd(TRANSITION_DURATION); + } + }, { + key: '_destroyElement', + value: function _destroyElement(element) { + $(element).detach().trigger(Event.CLOSED).remove(); } + }], [{ + key: '_jQueryInterface', - $(element).one(Util.TRANSITION_END, this._destroyElement.bind(this, element)).emulateTransitionEnd(TRANSITION_DURATION); - } - }, { - key: '_destroyElement', - value: function _destroyElement(element) { - $(element).detach().trigger(Event.CLOSED).remove(); - } - }], [{ - key: '_jQueryInterface', + // static - // static + value: function _jQueryInterface(config) { + return this.each(function () { + var $element = $(this); + var data = $element.data(DATA_KEY); - 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); + } + }); + } + }, { + key: '_handleDismiss', + value: function _handleDismiss(alertInstance) { + return function (event) { + if (event) { + event.preventDefault(); + } + + alertInstance.close(this); + }; + } + }]); - if (config === 'close') { - data[config](this); - } - }); - } - }, { - key: '_handleDismiss', - value: function _handleDismiss(alertInstance) { - return function (event) { - if (event) { - event.preventDefault(); - } + return Alert; + })(); - alertInstance.close(this); - }; - } - }]); + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ - return Alert; -})(); + $(document).on(Event.CLICK, Selector.DISMISS, Alert._handleDismiss(new Alert())); -/** - * -------------------------------------------------------------------------- - * Data Api implementation - * -------------------------------------------------------------------------- - */ + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ -$(document).on(Event.CLICK, Selector.DISMISS, Alert._handleDismiss(new Alert())); + $.fn[NAME] = Alert._jQueryInterface; + $.fn[NAME].Constructor = Alert; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = Alert._JQUERY_NO_CONFLICT; + return Alert._jQueryInterface; + }; -/** - * -------------------------------------------------------------------------- - * jQuery - * -------------------------------------------------------------------------- - */ - -$.fn[NAME] = Alert._jQueryInterface; -$.fn[NAME].Constructor = Alert; -$.fn[NAME].noConflict = function () { - $.fn[NAME] = Alert._JQUERY_NO_CONFLICT; - return Alert._jQueryInterface; -}; -/** - * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): alert.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * -------------------------------------------------------------------------- - */ + return Alert; +})(); //# sourceMappingURL=alert.js.map
\ No newline at end of file |