From 825c6a74c9e0235694bd538d5d26d7979dc15224 Mon Sep 17 00:00:00 2001 From: varun Date: Sun, 4 Aug 2013 05:29:20 +0800 Subject: [PATCH] feat(tooltip): Setting to show only single popup Can be invoked using: $tooltipProvider.options({ popoverMode: 'single'}); The code is big, but it's mostly comments. I think it would be good idea to do this globally. The popovergroup directive is also an interesting idea, but this is much simpler to use for the end user. No? --- src/tooltip/tooltip.js | 96 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 28eb9e513e..e717f45fac 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -91,6 +91,87 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) }; } + //if the child DOM element a descendent od the parent jqLite element + function isDescendent(parentElement, childDom) { + var isDescendentResult = false; + var el = parentElement.find(childDom.tagName); + + for(var i=0; i'+ ''; @@ -117,6 +199,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) var triggers = getTriggers( undefined ); var hasRegisteredTriggers = false; + scope.tooltip = tooltip; + // By default, the tooltip is not open. // TODO add ability to start tooltip opened scope.tt_isOpen = false; @@ -143,6 +227,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) hide(); }); } + + //Need to expose above function so that we can globally hide tooltips + scope.hideTooltipBind = hideTooltipBind; + scope.hide = hide; // Show the tooltip popup element. function show() { @@ -155,6 +243,12 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) if ( ! scope.tt_content ) { return; } + + var popoverMode = angular.isDefined(options.popoverMode) ? options.popoverMode : 'multi'; + //If this is a popover and mode in options is set to single, then hide other popovers + if (type == 'popover' && popoverMode == 'single') { + hideOthers(element[0]); + } // If there is a pending remove transition, we must cancel it, lest the // tooltip be mysteriously removed.