---
+## Tooltip clicking
+By default, clicking on a tooltip will leave it open until you click somewhere else. However, you can disable that by adding data-click-open="false"
+
+```html_example
+<p>
+this
+<span data-tooltip aria-haspopup="true" class="has-tip top" data-disable-hover="false" tabindex="2" title="You see? I'm open!">tooltip will stay open</span>
+
+while
+<span data-tooltip aria-haspopup="true" class="has-tip top" data-click-open="false" data-disable-hover="false" tabindex="2" title="I don't stay open">this one will only be open when hovered</span>
+</p>
+```
+
+---
+
## Tooltip Right and Left
You can also position the tooltips to the right and left of the word by adding the classes `.right` or `.left` to the `<span>` element.
})
.on('mouseleave.zf.tooltip', function(e) {
clearTimeout(_this.timeout);
- if (!isFocus || (!_this.isClick && _this.options.clickOpen)) {
+ if (!isFocus || (_this.isClick && !_this.options.clickOpen)) {
_this.hide();
}
});
}
}
});
+ } else {
+ this.$element.on('mousedown.zf.tooltip', function(e) {
+ e.stopImmediatePropagation();
+ _this.isClick = true;
+ });
}
if (!this.options.disableForTouch) {
this.$element
.on('focus.zf.tooltip', function(e) {
isFocus = true;
- // console.log(_this.isClick);
if (_this.isClick) {
+ // If we're not showing open on clicks, we need to pretend a click-launched focus isn't
+ // a real focus, otherwise on hover and come back we get bad behavior
+ if(!_this.options.clickOpen) { isFocus = false; }
return false;
} else {
- // $(window)
_this.show();
}
})