aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/src/alert.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/alert.js')
-rw-r--r--vendor/twbs/bootstrap/js/src/alert.js270
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