aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/src/tooltip.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/tooltip.js')
-rw-r--r--vendor/twbs/bootstrap/js/src/tooltip.js106
1 files changed, 42 insertions, 64 deletions
diff --git a/vendor/twbs/bootstrap/js/src/tooltip.js b/vendor/twbs/bootstrap/js/src/tooltip.js
index 26fa90603..6753c4c15 100644
--- a/vendor/twbs/bootstrap/js/src/tooltip.js
+++ b/vendor/twbs/bootstrap/js/src/tooltip.js
@@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.4.1): tooltip.js
+ * Bootstrap (v4.5.0): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -20,7 +20,7 @@ import Util from './util'
*/
const NAME = 'tooltip'
-const VERSION = '4.4.1'
+const VERSION = '4.5.0'
const DATA_KEY = 'bs.tooltip'
const EVENT_KEY = `.${DATA_KEY}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
@@ -76,10 +76,8 @@ const Default = {
popperConfig : null
}
-const HoverState = {
- SHOW : 'show',
- OUT : 'out'
-}
+const HOVER_STATE_SHOW = 'show'
+const HOVER_STATE_OUT = 'out'
const Event = {
HIDE : `hide${EVENT_KEY}`,
@@ -94,24 +92,16 @@ const Event = {
MOUSELEAVE : `mouseleave${EVENT_KEY}`
}
-const ClassName = {
- FADE : 'fade',
- SHOW : 'show'
-}
-
-const Selector = {
- TOOLTIP : '.tooltip',
- TOOLTIP_INNER : '.tooltip-inner',
- ARROW : '.arrow'
-}
+const CLASS_NAME_FADE = 'fade'
+const CLASS_NAME_SHOW = 'show'
-const Trigger = {
- HOVER : 'hover',
- FOCUS : 'focus',
- CLICK : 'click',
- MANUAL : 'manual'
-}
+const SELECTOR_TOOLTIP_INNER = '.tooltip-inner'
+const SELECTOR_ARROW = '.arrow'
+const TRIGGER_HOVER = 'hover'
+const TRIGGER_FOCUS = 'focus'
+const TRIGGER_CLICK = 'click'
+const TRIGGER_MANUAL = 'manual'
/**
* ------------------------------------------------------------------------
@@ -209,7 +199,7 @@ class Tooltip {
context._leave(null, context)
}
} else {
- if ($(this.getTipElement()).hasClass(ClassName.SHOW)) {
+ if ($(this.getTipElement()).hasClass(CLASS_NAME_SHOW)) {
this._leave(null, this)
return
}
@@ -272,7 +262,7 @@ class Tooltip {
this.setContent()
if (this.config.animation) {
- $(tip).addClass(ClassName.FADE)
+ $(tip).addClass(CLASS_NAME_FADE)
}
const placement = typeof this.config.placement === 'function'
@@ -293,7 +283,7 @@ class Tooltip {
this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment))
- $(tip).addClass(ClassName.SHOW)
+ $(tip).addClass(CLASS_NAME_SHOW)
// If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
@@ -312,12 +302,12 @@ class Tooltip {
$(this.element).trigger(this.constructor.Event.SHOWN)
- if (prevHoverState === HoverState.OUT) {
+ if (prevHoverState === HOVER_STATE_OUT) {
this._leave(null, this)
}
}
- if ($(this.tip).hasClass(ClassName.FADE)) {
+ if ($(this.tip).hasClass(CLASS_NAME_FADE)) {
const transitionDuration = Util.getTransitionDurationFromElement(this.tip)
$(this.tip)
@@ -333,7 +323,7 @@ class Tooltip {
const tip = this.getTipElement()
const hideEvent = $.Event(this.constructor.Event.HIDE)
const complete = () => {
- if (this._hoverState !== HoverState.SHOW && tip.parentNode) {
+ if (this._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
tip.parentNode.removeChild(tip)
}
@@ -355,7 +345,7 @@ class Tooltip {
return
}
- $(tip).removeClass(ClassName.SHOW)
+ $(tip).removeClass(CLASS_NAME_SHOW)
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
@@ -363,11 +353,11 @@ class Tooltip {
$(document.body).children().off('mouseover', null, $.noop)
}
- this._activeTrigger[Trigger.CLICK] = false
- this._activeTrigger[Trigger.FOCUS] = false
- this._activeTrigger[Trigger.HOVER] = false
+ this._activeTrigger[TRIGGER_CLICK] = false
+ this._activeTrigger[TRIGGER_FOCUS] = false
+ this._activeTrigger[TRIGGER_HOVER] = false
- if ($(this.tip).hasClass(ClassName.FADE)) {
+ if ($(this.tip).hasClass(CLASS_NAME_FADE)) {
const transitionDuration = Util.getTransitionDurationFromElement(tip)
$(tip)
@@ -403,8 +393,8 @@ class Tooltip {
setContent() {
const tip = this.getTipElement()
- this.setElementContent($(tip.querySelectorAll(Selector.TOOLTIP_INNER)), this.getTitle())
- $(tip).removeClass(`${ClassName.FADE} ${ClassName.SHOW}`)
+ this.setElementContent($(tip.querySelectorAll(SELECTOR_TOOLTIP_INNER)), this.getTitle())
+ $(tip).removeClass(`${CLASS_NAME_FADE} ${CLASS_NAME_SHOW}`)
}
setElementContent($element, content) {
@@ -455,7 +445,7 @@ class Tooltip {
behavior: this.config.fallbackPlacement
},
arrow: {
- element: Selector.ARROW
+ element: SELECTOR_ARROW
},
preventOverflow: {
boundariesElement: this.config.boundary
@@ -520,25 +510,17 @@ class Tooltip {
this.config.selector,
(event) => this.toggle(event)
)
- } else if (trigger !== Trigger.MANUAL) {
- const eventIn = trigger === Trigger.HOVER
+ } else if (trigger !== TRIGGER_MANUAL) {
+ const eventIn = trigger === TRIGGER_HOVER
? this.constructor.Event.MOUSEENTER
: this.constructor.Event.FOCUSIN
- const eventOut = trigger === Trigger.HOVER
+ const eventOut = trigger === TRIGGER_HOVER
? this.constructor.Event.MOUSELEAVE
: this.constructor.Event.FOCUSOUT
$(this.element)
- .on(
- eventIn,
- this.config.selector,
- (event) => this._enter(event)
- )
- .on(
- eventOut,
- this.config.selector,
- (event) => this._leave(event)
- )
+ .on(eventIn, this.config.selector, (event) => this._enter(event))
+ .on(eventOut, this.config.selector, (event) => this._leave(event))
}
})
@@ -548,10 +530,7 @@ class Tooltip {
}
}
- $(this.element).closest('.modal').on(
- 'hide.bs.modal',
- this._hideModalHandler
- )
+ $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler)
if (this.config.selector) {
this.config = {
@@ -591,18 +570,18 @@ class Tooltip {
if (event) {
context._activeTrigger[
- event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER
+ event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER
] = true
}
- if ($(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) {
- context._hoverState = HoverState.SHOW
+ if ($(context.getTipElement()).hasClass(CLASS_NAME_SHOW) || context._hoverState === HOVER_STATE_SHOW) {
+ context._hoverState = HOVER_STATE_SHOW
return
}
clearTimeout(context._timeout)
- context._hoverState = HoverState.SHOW
+ context._hoverState = HOVER_STATE_SHOW
if (!context.config.delay || !context.config.delay.show) {
context.show()
@@ -610,7 +589,7 @@ class Tooltip {
}
context._timeout = setTimeout(() => {
- if (context._hoverState === HoverState.SHOW) {
+ if (context._hoverState === HOVER_STATE_SHOW) {
context.show()
}
}, context.config.delay.show)
@@ -630,7 +609,7 @@ class Tooltip {
if (event) {
context._activeTrigger[
- event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER
+ event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER
] = false
}
@@ -640,7 +619,7 @@ class Tooltip {
clearTimeout(context._timeout)
- context._hoverState = HoverState.OUT
+ context._hoverState = HOVER_STATE_OUT
if (!context.config.delay || !context.config.delay.hide) {
context.hide()
@@ -648,7 +627,7 @@ class Tooltip {
}
context._timeout = setTimeout(() => {
- if (context._hoverState === HoverState.OUT) {
+ if (context._hoverState === HOVER_STATE_OUT) {
context.hide()
}
}, context.config.delay.hide)
@@ -731,8 +710,7 @@ class Tooltip {
}
_handlePopperPlacementChange(popperData) {
- const popperInstance = popperData.instance
- this.tip = popperInstance.popper
+ this.tip = popperData.instance.popper
this._cleanTipClass()
this.addAttachmentClass(this._getAttachment(popperData.placement))
}
@@ -745,7 +723,7 @@ class Tooltip {
return
}
- $(tip).removeClass(ClassName.FADE)
+ $(tip).removeClass(CLASS_NAME_FADE)
this.config.animation = false
this.hide()
this.show()