diff options
author | Mario Vavti <mario@mariovavti.com> | 2019-05-10 14:21:36 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2019-05-10 14:21:36 +0200 |
commit | 9866053f0ce44721c11990c9f9407e7428757c99 (patch) | |
tree | 6e414efa36c3bda00205918cecb9122f951427e3 /vendor/twbs/bootstrap/js/src/alert.js | |
parent | 89a2c1a09c896ac3a23df26a1783f5c682188a56 (diff) | |
download | volse-hubzilla-9866053f0ce44721c11990c9f9407e7428757c99.tar.gz volse-hubzilla-9866053f0ce44721c11990c9f9407e7428757c99.tar.bz2 volse-hubzilla-9866053f0ce44721c11990c9f9407e7428757c99.zip |
update bootstrap to version 4.3.1
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/alert.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/src/alert.js | 270 |
1 files changed, 133 insertions, 137 deletions
diff --git a/vendor/twbs/bootstrap/js/src/alert.js b/vendor/twbs/bootstrap/js/src/alert.js index f39d9d931..64e8e3843 100644 --- a/vendor/twbs/bootstrap/js/src/alert.js +++ b/vendor/twbs/bootstrap/js/src/alert.js @@ -1,183 +1,179 @@ -import $ from 'jquery' -import Util from './util' - /** * -------------------------------------------------------------------------- - * Bootstrap (v4.1.3): alert.js + * Bootstrap (v4.3.1): alert.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ -const Alert = (($) => { - /** - * ------------------------------------------------------------------------ - * Constants - * ------------------------------------------------------------------------ - */ - - const NAME = 'alert' - const VERSION = '4.1.3' - const DATA_KEY = 'bs.alert' - const EVENT_KEY = `.${DATA_KEY}` - const DATA_API_KEY = '.data-api' - const JQUERY_NO_CONFLICT = $.fn[NAME] - - const Selector = { - DISMISS : '[data-dismiss="alert"]' - } +import $ from 'jquery' +import Util from './util' + +/** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + +const NAME = 'alert' +const VERSION = '4.3.1' +const DATA_KEY = 'bs.alert' +const EVENT_KEY = `.${DATA_KEY}` +const DATA_API_KEY = '.data-api' +const JQUERY_NO_CONFLICT = $.fn[NAME] + +const Selector = { + DISMISS : '[data-dismiss="alert"]' +} + +const Event = { + CLOSE : `close${EVENT_KEY}`, + CLOSED : `closed${EVENT_KEY}`, + CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}` +} + +const ClassName = { + ALERT : 'alert', + FADE : 'fade', + SHOW : 'show' +} + +/** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - const Event = { - CLOSE : `close${EVENT_KEY}`, - CLOSED : `closed${EVENT_KEY}`, - CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}` +class Alert { + constructor(element) { + this._element = element } - const ClassName = { - ALERT : 'alert', - FADE : 'fade', - SHOW : 'show' + // Getters + + static get VERSION() { + return VERSION } - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ + // Public - class Alert { - constructor(element) { - this._element = element + close(element) { + let rootElement = this._element + if (element) { + rootElement = this._getRootElement(element) } - // Getters + const customEvent = this._triggerCloseEvent(rootElement) - static get VERSION() { - return VERSION + if (customEvent.isDefaultPrevented()) { + return } - // Public + this._removeElement(rootElement) + } - close(element) { - let rootElement = this._element - if (element) { - rootElement = this._getRootElement(element) - } + dispose() { + $.removeData(this._element, DATA_KEY) + this._element = null + } - const customEvent = this._triggerCloseEvent(rootElement) + // Private - if (customEvent.isDefaultPrevented()) { - return - } + _getRootElement(element) { + const selector = Util.getSelectorFromElement(element) + let parent = false - this._removeElement(rootElement) + if (selector) { + parent = document.querySelector(selector) } - dispose() { - $.removeData(this._element, DATA_KEY) - this._element = null + if (!parent) { + parent = $(element).closest(`.${ClassName.ALERT}`)[0] } - // Private + return parent + } - _getRootElement(element) { - const selector = Util.getSelectorFromElement(element) - let parent = false + _triggerCloseEvent(element) { + const closeEvent = $.Event(Event.CLOSE) - if (selector) { - parent = document.querySelector(selector) - } - - if (!parent) { - parent = $(element).closest(`.${ClassName.ALERT}`)[0] - } - - return parent - } + $(element).trigger(closeEvent) + return closeEvent + } - _triggerCloseEvent(element) { - const closeEvent = $.Event(Event.CLOSE) + _removeElement(element) { + $(element).removeClass(ClassName.SHOW) - $(element).trigger(closeEvent) - return closeEvent + if (!$(element).hasClass(ClassName.FADE)) { + this._destroyElement(element) + return } - _removeElement(element) { - $(element).removeClass(ClassName.SHOW) + const transitionDuration = Util.getTransitionDurationFromElement(element) - if (!$(element).hasClass(ClassName.FADE)) { - this._destroyElement(element) - return - } + $(element) + .one(Util.TRANSITION_END, (event) => this._destroyElement(element, event)) + .emulateTransitionEnd(transitionDuration) + } - const transitionDuration = Util.getTransitionDurationFromElement(element) + _destroyElement(element) { + $(element) + .detach() + .trigger(Event.CLOSED) + .remove() + } - $(element) - .one(Util.TRANSITION_END, (event) => this._destroyElement(element, event)) - .emulateTransitionEnd(transitionDuration) - } + // Static - _destroyElement(element) { - $(element) - .detach() - .trigger(Event.CLOSED) - .remove() - } + static _jQueryInterface(config) { + return this.each(function () { + const $element = $(this) + let data = $element.data(DATA_KEY) - // Static + if (!data) { + data = new Alert(this) + $element.data(DATA_KEY, data) + } - static _jQueryInterface(config) { - return this.each(function () { - const $element = $(this) - let data = $element.data(DATA_KEY) + if (config === 'close') { + data[config](this) + } + }) + } - if (!data) { - data = new Alert(this) - $element.data(DATA_KEY, data) - } + static _handleDismiss(alertInstance) { + return function (event) { + if (event) { + event.preventDefault() + } - if (config === 'close') { - data[config](this) - } - }) + alertInstance.close(this) } + } +} - static _handleDismiss(alertInstance) { - return function (event) { - if (event) { - event.preventDefault() - } +/** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ - alertInstance.close(this) - } - } - } +$(document).on( + Event.CLICK_DATA_API, + Selector.DISMISS, + Alert._handleDismiss(new 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 - } +/** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ - return Alert -})($) +$.fn[NAME] = Alert._jQueryInterface +$.fn[NAME].Constructor = Alert +$.fn[NAME].noConflict = () => { + $.fn[NAME] = JQUERY_NO_CONFLICT + return Alert._jQueryInterface +} export default Alert |