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

Commit

Permalink
only hide tooltips and popovers on "clickaway" when trigger is set
Browse files Browse the repository at this point in the history
  • Loading branch information
SystemDisc committed Sep 15, 2015
1 parent 1504614 commit b00a550
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
var triggerMap = {
'mouseenter': 'mouseleave',
'click': 'click',
'clickaway': 'clickaway',
'focus': 'blur',
'none': ''
};
Expand Down Expand Up @@ -409,13 +410,18 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
}

var unregisterTriggers = function() {
angular.element(document.getElementsByTagName('body')[0]).unbind('click', bodyHideTooltipBind);
triggers.show.forEach(function(trigger) {
element.unbind(trigger, showTooltipBind);
});
triggers.hide.forEach(function(trigger) {
trigger.split(' ').forEach(function(hideTrigger) {
element[0].removeEventListener(hideTrigger, hideTooltipBind);
if (trigger === 'clickaway') {
angular.element(document.getElementsByTagName('body')[0]).unbind('click', bodyHideTooltipBind);
}
else
{
element[0].removeEventListener(hideTrigger, hideTooltipBind);
}
});
});
};
Expand All @@ -426,12 +432,17 @@ 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
if (trigger === triggers.hide[idx]) {
element[0].addEventListener(trigger, toggleTooltipBind);
if (trigger === 'clickaway') {
document.getElementsByTagName('body')[0].addEventListener('click', bodyHideTooltipBind);
}
else
{
element[0].addEventListener(trigger, toggleTooltipBind);
}
} else if (trigger) {
element[0].addEventListener(trigger, showTooltipBind);
triggers.hide[idx].split(' ').forEach(function(trigger) {
Expand Down

0 comments on commit b00a550

Please sign in to comment.