Skip to content

Commit c0a96a7

Browse files
committed
Fix autoClose api issues
1 parent b382bf4 commit c0a96a7

3 files changed

Lines changed: 7 additions & 21 deletions

File tree

dist/isotip.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,10 @@ module.exports = {
9292
var trigger = evt.target || evt.srcElement
9393

9494
// If there's already a tooltip open, close that one...
95-
if (self.currentTooltip) {
95+
if (self.currentTooltip && self.currentTooltip.getAttribute('data-autoclose') !== 'false') {
9696
// ...unless the user is clicking on the tooltip itself...
9797
if (trigger === self.currentTooltip) {
9898
return
99-
// ...or if the tooltip shouldn't automatically close
100-
} else if (self.currentTooltip.getAttribute('data-autoclose') === 'false') {
101-
return
10299
// ...or if the user if clicking on the original trigger for that tooltip
103100
} else if (trigger === self.currentTrigger) {
104101
self.close(self.currentTooltip)
@@ -137,13 +134,10 @@ module.exports = {
137134
}
138135

139136
// If there's already a tooltip open, close that one...
140-
if (self.currentTooltip) {
137+
if (self.currentTooltip && self.currentTooltip.getAttribute('data-autoclose') !== 'false') {
141138
// ...unless the user is hovering over the tooltip itself...
142139
if (trigger === self.currentTooltip) {
143140
return
144-
// ...or if the tooltip shouldn't autoclose
145-
} else if (self.currentTooltip.getAttribute('data-autoclose') === 'false') {
146-
return
147141
} else {
148142
// loop through the child elements in the tooltip to see if one of them has been clicked
149143
if (self.hasParent(trigger, self.currentTooltip)) {
@@ -279,7 +273,6 @@ module.exports = {
279273
var placement = options.placement || trigger.getAttribute('data-tooltip-placement')
280274
var container = options.container || trigger.getAttribute('data-tooltip-container')
281275
var scrollContainer = options.container || trigger.getAttribute('data-tooltip-scrollContainer')
282-
var autoClose = options.autoClose || trigger.getAttribute('data-tooltip-autoclose') !== 'false'
283276
var preExistingTooltip = document.querySelector('.tooltip')
284277
var tooltip = this.createDOMElement(this.options.template)
285278
var tooltipTitle
@@ -341,7 +334,7 @@ module.exports = {
341334
}
342335

343336
// If autoClose is set to false, add an attribute for the event handler to look for
344-
if (!autoClose) {
337+
if (options.autoClose === false || trigger.getAttribute('data-tooltip-autoclose') === 'false') {
345338
tooltip.setAttribute('data-autoclose', 'false')
346339
}
347340

0 commit comments

Comments
 (0)