Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ You can set your tooltip to show/hide on specific event/events, you can use the
<a href="#" tooltips tooltip-title="tip" tooltip-show-trigger="mouseover click" tooltip-hide-trigger="click" tooltip-side="left">Show tooltip on click and mouseover and hide tooltip only on click</a>
```

If you want to hide on click, you can configure a close button using text or HTML. This allows your users to click the button inside the tooltip instead of clicking on the original trigger.
```html
<a href="#" tooltips tooltip-title="tip" tooltip-show-trigger="mouseover click" tooltip-hide-trigger="click" tooltip-close-button="x" tooltip-side="left">Show tooltip on click and mouseover and hide tooltip only on click, with option to click on the X</a>
<a href="#" tooltips tooltip-title="tip" tooltip-show-trigger="mouseover click" tooltip-hide-trigger="click" tooltip-close-button='<button type="button">Close Me!</button>' tooltip-side="left">Show tooltip on click and mouseover and hide tooltip only on click, with option to click on HTML button</a>
```

####Tooltip CSS class
You can set a custom CSS class or a set of, using the `tooltip-class=""` attribute:
```html
Expand Down
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@
</a>
</div>
<div class="separator100"></div>

<div class="separator30"></div>
<div>
<a class="btn btn-medium bg-info color-white font-bold" tooltips tooltip-content="Yeo man!" tooltip-show-trigger="mouseover click" tooltip-hide-trigger="click" tooltip-close-button='<button type="button">Close Me!</button>' tooltip-side="top">
Close button: hover to open, click to close
</a>
</div>

<div class="separator30"></div>
<div>
<a class="btn btn-medium bg-info color-white font-bold" tooltips tooltip-content="Yeo man! I have some more to say to show the positioning of the close button" tooltip-show-trigger="click" tooltip-hide-trigger="click" tooltip-close-button='<button type="button">Close Me!</button>' tooltip-side="bottom">
Close button: click to open and close
</a>
</div>
<div class="separator100"></div>
</div>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular-route.min.js"></script>
Expand Down
3 changes: 3 additions & 0 deletions src/css/angular-tooltips.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,6 @@
border-left-color: transparent;
border-top-width: 0;
}
._720kb-tooltip-close-button {
float: right;
}
16 changes: 11 additions & 5 deletions src/js/angular-tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@
, className = attr.tooltipClass || ''
, speed = (attr.tooltipSpeed || 'medium').toLowerCase()
, lazyMode = typeof attr.tooltipLazy !== 'undefined' && attr.tooltipLazy !== null ? $scope.$eval(attr.tooltipLazy) : true
, htmlTemplate =
'<div class="_720kb-tooltip ' + CSS_PREFIX + size + '">' +
'<div class="' + CSS_PREFIX + 'title"> ' + title + '</div>' +
content + ' <span class="' + CSS_PREFIX + 'caret"></span>' +
'</div>';
, hasCloseButton = typeof attr.tooltipCloseButton !== 'undefined' && attr.tooltipCloseButton !== null
, closeButtonContent = attr.tooltipCloseButton || ''
, htmlTemplate = '<div class="_720kb-tooltip ' + CSS_PREFIX + size + '">';

if (hasCloseButton) {
htmlTemplate = htmlTemplate + '<span class="' + CSS_PREFIX + 'close-button" ng-click="hideTooltip()"> ' + closeButtonContent + ' </span>';
}

htmlTemplate = htmlTemplate + '<div class="' + CSS_PREFIX + 'title"> ' + title + '</div>' +
content + ' <span class="' + CSS_PREFIX + 'caret"></span>' +
'</div>';

//parse the animation speed of tooltips
$scope.parseSpeed = function parseSpeed () {
Expand Down