Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
hide tooltips and popovers when a user clicks away
Browse files Browse the repository at this point in the history
hide triggers when a click occurs that does not target the
popover/tooltip link and does not target elements with the
popover/tooltip classes
  • Loading branch information
SystemDisc committed Sep 15, 2015
1 parent 7ba2527 commit 1504614
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,16 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;
}

// hide tooltips/popovers when click away
function bodyHideTooltipBind(e) {
var target_elem = angular.element(e.target);
if (e.target != element[0] && !target_elem.hasClass('popover') && !target_elem.hasClass('popover-inner') && !target_elem.hasClass('popover-title') && !target_elem.hasClass('popover-content') && !target_elem.hasClass('tooltip') && !target_elem.hasClass('tooltip-inner')) {
hideTooltipBind();
}
}

var unregisterTriggers = function() {
angular.element(document.getElementsByTagName('body')[0]).unbind('click', bodyHideTooltipBind);
triggers.show.forEach(function(trigger) {
element.unbind(trigger, showTooltipBind);
});
Expand All @@ -417,6 +426,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s

triggers = getTriggers(val);

document.getElementsByTagName('body')[0].addEventListener('click', bodyHideTooltipBind);
if (triggers.show !== 'none') {
triggers.show.forEach(function(trigger, idx) {
// Using raw addEventListener due to jqLite/jQuery bug - #4060
Expand Down

0 comments on commit 1504614

Please sign in to comment.