@@ -192,6 +192,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
192
192
return ;
193
193
}
194
194
195
+ cancelHide ( ) ;
195
196
prepareTooltip ( ) ;
196
197
197
198
if ( ttScope . popupDelay ) {
@@ -206,30 +207,21 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
206
207
}
207
208
208
209
function hideTooltipBind ( ) {
210
+ cancelShow ( ) ;
211
+
209
212
if ( ttScope . popupCloseDelay ) {
210
- hideTimeout = $timeout ( hide , ttScope . popupCloseDelay , false ) ;
213
+ if ( ! hideTimeout ) {
214
+ hideTimeout = $timeout ( hide , ttScope . popupCloseDelay , false ) ;
215
+ }
211
216
} else {
212
217
hide ( ) ;
213
218
}
214
219
}
215
220
216
221
// Show the tooltip popup element.
217
222
function show ( ) {
218
- if ( showTimeout ) {
219
- $timeout . cancel ( showTimeout ) ;
220
- showTimeout = null ;
221
- }
222
-
223
- // If there is a pending remove transition, we must cancel it, lest the
224
- // tooltip be mysteriously removed.
225
- if ( hideTimeout ) {
226
- $timeout . cancel ( hideTimeout ) ;
227
- hideTimeout = null ;
228
- }
229
- if ( transitionTimeout ) {
230
- $timeout . cancel ( transitionTimeout ) ;
231
- transitionTimeout = null ;
232
- }
223
+ cancelShow ( ) ;
224
+ cancelHide ( ) ;
233
225
234
226
// Don't show empty tooltips.
235
227
if ( ! ttScope . content ) {
@@ -246,13 +238,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
246
238
} ) ;
247
239
}
248
240
249
- // Hide the tooltip popup element.
250
- function hide ( ) {
251
- if ( ! ttScope ) {
252
- return ;
253
- }
254
-
255
- //if tooltip is going to be shown after delay, we must cancel this
241
+ function cancelShow ( ) {
256
242
if ( showTimeout ) {
257
243
$timeout . cancel ( showTimeout ) ;
258
244
showTimeout = null ;
@@ -262,6 +248,16 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
262
248
$timeout . cancel ( positionTimeout ) ;
263
249
positionTimeout = null ;
264
250
}
251
+ }
252
+
253
+ // Hide the tooltip popup element.
254
+ function hide ( ) {
255
+ cancelShow ( ) ;
256
+ cancelHide ( ) ;
257
+
258
+ if ( ! ttScope ) {
259
+ return ;
260
+ }
265
261
266
262
// First things first: we don't show it anymore.
267
263
ttScope . $evalAsync ( function ( ) {
@@ -281,6 +277,17 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
281
277
} ) ;
282
278
}
283
279
280
+ function cancelHide ( ) {
281
+ if ( hideTimeout ) {
282
+ $timeout . cancel ( hideTimeout ) ;
283
+ hideTimeout = null ;
284
+ }
285
+ if ( transitionTimeout ) {
286
+ $timeout . cancel ( transitionTimeout ) ;
287
+ transitionTimeout = null ;
288
+ }
289
+ }
290
+
284
291
function createTooltip ( ) {
285
292
// There can only be one tooltip element per directive shown at once.
286
293
if ( tooltip ) {
@@ -349,9 +356,8 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
349
356
* Observe the relevant attributes.
350
357
*/
351
358
attrs . $observe ( 'disabled' , function ( val ) {
352
- if ( showTimeout && val ) {
353
- $timeout . cancel ( showTimeout ) ;
354
- showTimeout = null ;
359
+ if ( val ) {
360
+ cancelShow ( ) ;
355
361
}
356
362
357
363
if ( val && ttScope . isOpen ) {
@@ -495,10 +501,8 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
495
501
496
502
// Make sure tooltip is destroyed and removed.
497
503
scope . $on ( '$destroy' , function onDestroyTooltip ( ) {
498
- $timeout . cancel ( transitionTimeout ) ;
499
- $timeout . cancel ( showTimeout ) ;
500
- $timeout . cancel ( hideTimeout ) ;
501
- $timeout . cancel ( positionTimeout ) ;
504
+ cancelShow ( ) ;
505
+ cancelHide ( ) ;
502
506
unregisterTriggers ( ) ;
503
507
removeTooltip ( ) ;
504
508
openedTooltips . remove ( ttScope ) ;
0 commit comments