Skip to content

Commit

Permalink
Show and hide triggers can now be set to the same event.
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard-thieu committed May 23, 2017
1 parent 2e57ad7 commit 6ac9cf6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
18 changes: 18 additions & 0 deletions index.html
Expand Up @@ -423,6 +423,24 @@
</span>
</div>

<div>
<span tooltips
tooltip-show-trigger="click"
tooltip-hide-trigger="click"
tooltip-template="Click again to close">
Tooltip with same trigger (click) for show and hide
</span>
</div>

<div>
<span tooltips
tooltip-show-trigger="mouseenter"
tooltip-hide-trigger="mouseenter"
tooltip-template="Mouseover again to close">
Tooltip with same trigger (mouseover) for show and hide
</span>
</div>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js"></script>
<script type="text/javascript" src="lib/angular-tooltips.js"></script>
<script type="text/javascript" src="demo/js/index.js"></script>
Expand Down
12 changes: 11 additions & 1 deletion lib/angular-tooltips.js
Expand Up @@ -328,6 +328,11 @@
}
, onTooltipShow = function onTooltipShow(event) {

if (event && !tooltipElement.hasClass('active')) {

event.stopImmediatePropagation();

This comment has been minimized.

Copy link
@nomnomnomnom

nomnomnomnom Sep 5, 2017

This appears to call stopImmediatePropagation when event is the boolean true, which is the case down on line 501

}

tipElement.addClass('_hidden');
if ($attrs.tooltipSmart) {

Expand Down Expand Up @@ -448,7 +453,12 @@
}
}
}
, onTooltipHide = function onTooltipHide() {
, onTooltipHide = function onTooltipHide(event) {

if (event && tooltipElement.hasClass('active')) {

event.stopImmediatePropagation();
}

if ($attrs.tooltipAppendToBody) {

Expand Down

0 comments on commit 6ac9cf6

Please sign in to comment.