From b00a550ea301e2e564a2ee720a185ec6b42f5252 Mon Sep 17 00:00:00 2001 From: Timothy Zorn Date: Tue, 15 Sep 2015 17:23:05 -0400 Subject: [PATCH] only hide tooltips and popovers on "clickaway" when trigger is set --- src/tooltip/tooltip.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 0b024302f7..efb324da60 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -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': '' }; @@ -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); + } }); }); }; @@ -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) {