diff --git a/Readme.md b/Readme.md index f202b9c..44f93ec 100644 --- a/Readme.md +++ b/Readme.md @@ -152,6 +152,12 @@ You can set your tooltip to show/hide on specific event/events, you can use the Show tooltip on click and mouseover and hide tooltip only on click ``` +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 +Show tooltip on click and mouseover and hide tooltip only on click, with option to click on the X +Show tooltip on click and mouseover and hide tooltip only on click, with option to click on HTML button +``` + ####Tooltip CSS class You can set a custom CSS class or a set of, using the `tooltip-class=""` attribute: ```html diff --git a/index.html b/index.html index 6055d57..24c7197 100644 --- a/index.html +++ b/index.html @@ -90,6 +90,21 @@
+ +
+
+ + Close button: hover to open, click to close + +
+ +
+
+ + Close button: click to open and close + +
+
diff --git a/src/css/angular-tooltips.css b/src/css/angular-tooltips.css index b2a9f44..6d3f471 100644 --- a/src/css/angular-tooltips.css +++ b/src/css/angular-tooltips.css @@ -119,3 +119,6 @@ border-left-color: transparent; border-top-width: 0; } +._720kb-tooltip-close-button { + float: right; +} diff --git a/src/js/angular-tooltips.js b/src/js/angular-tooltips.js index 359f126..153ebc0 100644 --- a/src/js/angular-tooltips.js +++ b/src/js/angular-tooltips.js @@ -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 = - '
' + - '
' + title + '
' + - content + ' ' + - '
'; + , hasCloseButton = typeof attr.tooltipCloseButton !== 'undefined' && attr.tooltipCloseButton !== null + , closeButtonContent = attr.tooltipCloseButton || '' + , htmlTemplate = '
'; + + if (hasCloseButton) { + htmlTemplate = htmlTemplate + ' ' + closeButtonContent + ' '; + } + + htmlTemplate = htmlTemplate + '
' + title + '
' + + content + ' ' + + '
'; //parse the animation speed of tooltips $scope.parseSpeed = function parseSpeed () {