Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit d7ca74a

Browse files
committed
Add ability to control whether to show a tooltip based on a bool
1 parent 2a1d300 commit d7ca74a

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ tooltip-size="" | String('large', 'small') | 'medium' | Set your tooltip dimensi
9797
tooltip-speed="" | String('fast', 'slow', 'medium') | 'medium' | Set your tooltip show & hide transition speed
9898
tooltip-hidden="" | String(Boolean) | false | Hide (at all) the tooltip
9999
tooltip-append-to-body="" | String(Boolean) | false | This attribute clones the tooltip and append this directly on body. This enables the tooltip position also, for instance, if you have an scrolling area. **This option does heavy javascript calculation.**
100+
tooltip-show-tooltip="" | String(Boolean) | false | Show/Hide the tooltip "manually"
100101

101102

102103
## Globals

lib/angular-tooltips.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@
111111
element.removeAttr('tooltip-class');
112112
}
113113

114+
if (element.attr('tooltip-show-tooltip') !== undefined) {
115+
attributesToAdd['tooltip-show-tooltip'] = element.attr('tooltip-show-tooltip');
116+
element.removeAttr('tooltip-show-tooltip');
117+
}
118+
114119
if (element.attr('tooltip-close-button') !== undefined) {
115120

116121
attributesToAdd['tooltip-close-button'] = element.attr('tooltip-close-button');
@@ -209,7 +214,8 @@
209214
'closeButton': false,
210215
'size': '',
211216
'speed': 'steady',
212-
'tooltipTemplateUrlCache': false
217+
'tooltipTemplateUrlCache': false,
218+
'tooltipShowTooltip': null
213219
};
214220

215221
return {
@@ -263,6 +269,7 @@
263269
$attrs.tooltipSide = $attrs.tooltipSide || tooltipsConf.side;
264270
$attrs.tooltipShowTrigger = $attrs.tooltipShowTrigger || tooltipsConf.showTrigger;
265271
$attrs.tooltipHideTrigger = $attrs.tooltipHideTrigger || tooltipsConf.hideTrigger;
272+
$attrs.tooltipShowTooltip = $attrs.tooltipShowTooltip || tooltipsConf.showTooltip;
266273
$attrs.tooltipClass = $attrs.tooltipClass || tooltipsConf.class;
267274
$attrs.tooltipSmart = $attrs.tooltipSmart === 'true' || tooltipsConf.smart;
268275
$attrs.tooltipCloseButton = $attrs.tooltipCloseButton || tooltipsConf.closeButton.toString();
@@ -650,6 +657,15 @@
650657
oldTooltipHideTrigger = newValue;
651658
}
652659
}
660+
, onTooltipShowTooltip = function onTooltipShowTooltip(newValue) {
661+
662+
if (newValue === 'true') {
663+
664+
tooltipElement.addClass('active');
665+
} else {
666+
tooltipElement.removeClass('active');
667+
}
668+
}
653669
, onTooltipClassChange = function onTooltipClassChange(newValue) {
654670

655671
if (newValue) {
@@ -738,6 +754,7 @@
738754
, unregisterOnTooltipSideChangeObserver = $attrs.$observe('tooltipSide', onTooltipSideChange)
739755
, unregisterOnTooltipShowTrigger = $attrs.$observe('tooltipShowTrigger', onTooltipShowTrigger)
740756
, unregisterOnTooltipHideTrigger = $attrs.$observe('tooltipHideTrigger', onTooltipHideTrigger)
757+
, unregisterOnTooltipShowTooltip = $attrs.$observe('tooltipShowTooltip', onTooltipShowTooltip)
741758
, unregisterOnTooltipClassChange = $attrs.$observe('tooltipClass', onTooltipClassChange)
742759
, unregisterOnTooltipSmartChange = $attrs.$observe('tooltipSmart', onTooltipSmartChange)
743760
, unregisterOnTooltipCloseButtonChange = $attrs.$observe('tooltipCloseButton', onTooltipCloseButtonChange)
@@ -796,6 +813,7 @@
796813
unregisterOnTooltipSideChangeObserver();
797814
unregisterOnTooltipShowTrigger();
798815
unregisterOnTooltipHideTrigger();
816+
unregisterOnTooltipShowTooltip();
799817
unregisterOnTooltipClassChange();
800818
unregisterOnTooltipSmartChange();
801819
unregisterOnTooltipCloseButtonChange();

0 commit comments

Comments
 (0)