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

Fix for issue #96. Refresh tooltip after any change in the content. #1373

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
* Returns the actual instance of the $tooltip service.
* TODO support multiple triggers
*/
this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', '$interpolate', function ( $window, $compile, $timeout, $parse, $document, $position, $interpolate ) {
this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', '$interpolate', '$q', function ( $window, $compile, $timeout, $parse, $document, $position, $interpolate, $q ) {
return function $tooltip ( type, prefix, defaultTriggerShow ) {
var options = angular.extend( {}, defaultOptions, globalOptions );

Expand Down Expand Up @@ -225,32 +225,44 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap

// Hide the tooltip popup element.
function hide() {
var deferred = $q.defer();

// First things first: we don't show it anymore.
scope.tt_isOpen = false;

//if tooltip is going to be shown after delay, we must cancel this
$timeout.cancel( popupTimeout );

// And now we remove it from the DOM. However, if we have animation, we
// need to wait for it to expire beforehand.
// FIXME: this is a placeholder for a port of the transitions library.
if ( scope.tt_animation ) {
transitionTimeout = $timeout(function () {
tooltip.remove();
deferred.resolve();
}, 500);
} else {
tooltip.remove();
deferred.resolve();
}

return deferred.promise;
}

/**
* Observe the relevant attributes.
*/
attrs.$observe( type, function ( val ) {
scope.tt_content = val;

if (!val && scope.tt_isOpen ) {
hide();
if (scope.tt_isOpen){
hide().then(function(){
scope.tt_content = val;
if (val){
$timeout(show, 0);
}
});
}
else {
scope.tt_content = val;
}
});

Expand Down