aboutsummaryrefslogtreecommitdiff
path: root/js/src/tooltip.js
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2017-04-07 13:20:34 +0200
committerJohann-S <[email protected]>2017-05-14 11:41:19 +0200
commitb40b1bc396adb80944b887f72d0ae616277c852d (patch)
tree87d170caace642d8f2b195ddad863d1d36902377 /js/src/tooltip.js
parent81e07ec05218d75d64454787449dcb870b5b66ec (diff)
downloadbootstrap-b40b1bc396adb80944b887f72d0ae616277c852d.tar.xz
bootstrap-b40b1bc396adb80944b887f72d0ae616277c852d.zip
Add attachment classes
Diffstat (limited to 'js/src/tooltip.js')
-rw-r--r--js/src/tooltip.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index 505a8d492..fb4ff131c 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -33,6 +33,8 @@ const Tooltip = (($) => {
const EVENT_KEY = `.${DATA_KEY}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const TRANSITION_DURATION = 150
+ const CLASS_PREFIX = 'bs-tooltip'
+ const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
const Default = {
animation : true,
@@ -269,6 +271,7 @@ const Tooltip = (($) => {
this.config.placement
const attachment = this._getAttachment(placement)
+ this.addAttachmentClass(attachment)
const container = this.config.container === false ? document.body : $(this.config.container)
@@ -332,6 +335,7 @@ const Tooltip = (($) => {
tip.parentNode.removeChild(tip)
}
+ this._cleanTipClass()
this.element.removeAttribute('aria-describedby')
$(this.element).trigger(this.constructor.Event.HIDDEN)
if (this._popper !== null) {
@@ -383,6 +387,10 @@ const Tooltip = (($) => {
return Boolean(this.getTitle())
}
+ addAttachmentClass(attachment) {
+ $(this.getTipElement()).addClass(`${CLASS_PREFIX}-${attachment}`)
+ }
+
getTipElement() {
return this.tip = this.tip || $(this.config.template)[0]
}
@@ -624,6 +632,14 @@ const Tooltip = (($) => {
return config
}
+ _cleanTipClass() {
+ const $tip = $(this.getTipElement())
+ const tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX)
+ if (tabClass !== null && tabClass.length > 0) {
+ $tip.removeClass(tabClass.join(''))
+ }
+ }
+
// static