@@ -22,7 +22,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
22
22
var triggerMap = {
23
23
'mouseenter' : 'mouseleave' ,
24
24
'click' : 'click' ,
25
- 'focus' : 'blur'
25
+ 'focus' : 'blur' ,
26
+ 'none' : ''
26
27
} ;
27
28
28
29
// The options specified to the provider globally.
@@ -65,7 +66,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
65
66
* Returns the actual instance of the $tooltip service.
66
67
* TODO support multiple triggers
67
68
*/
68
- this . $get = [ '$window' , '$compile' , '$timeout' , '$document' , '$position' , '$interpolate' , '$rootScope' , function ( $window , $compile , $timeout , $document , $position , $interpolate , $rootScope ) {
69
+ this . $get = [ '$window' , '$compile' , '$timeout' , '$document' , '$position' , '$interpolate' , '$rootScope' , '$parse' , function ( $window , $compile , $timeout , $document , $position , $interpolate , $rootScope , $parse ) {
69
70
return function $tooltip ( type , prefix , defaultTriggerShow , options ) {
70
71
options = angular . extend ( { } , defaultOptions , globalOptions , options ) ;
71
72
@@ -127,6 +128,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
127
128
var hasEnableExp = angular . isDefined ( attrs [ prefix + 'Enable' ] ) ;
128
129
var ttScope = scope . $new ( true ) ;
129
130
var repositionScheduled = false ;
131
+ var isOpenExp = angular . isDefined ( attrs [ prefix + 'IsOpen' ] ) ? $parse ( attrs [ prefix + 'IsOpen' ] ) : false ;
130
132
131
133
var positionTooltip = function ( ) {
132
134
if ( ! tooltip ) { return ; }
@@ -211,7 +213,13 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
211
213
212
214
// And show the tooltip.
213
215
ttScope . isOpen = true ;
214
- ttScope . $apply ( ) ; // digest required as $apply is not called
216
+ if ( isOpenExp ) {
217
+ isOpenExp . assign ( ttScope . origScope , ttScope . isOpen ) ;
218
+ }
219
+
220
+ if ( ! $rootScope . $$phase ) {
221
+ ttScope . $apply ( ) ; // digest required as $apply is not called
222
+ }
215
223
216
224
// Return positioning function as promise callback for correct
217
225
// positioning after draw.
@@ -222,7 +230,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
222
230
function hide ( ) {
223
231
// First things first: we don't show it anymore.
224
232
ttScope . isOpen = false ;
225
-
233
+ if ( isOpenExp ) {
234
+ isOpenExp . assign ( ttScope . origScope , ttScope . isOpen ) ;
235
+ }
236
+
226
237
//if tooltip is going to be shown after delay, we must cancel this
227
238
$timeout . cancel ( popupTimeout ) ;
228
239
popupTimeout = null ;
@@ -265,7 +276,9 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
265
276
repositionScheduled = true ;
266
277
tooltipLinkedScope . $$postDigest ( function ( ) {
267
278
repositionScheduled = false ;
268
- positionTooltipAsync ( ) ;
279
+ if ( ttScope . isOpen ) {
280
+ positionTooltipAsync ( ) ;
281
+ }
269
282
} ) ;
270
283
}
271
284
} ) ;
@@ -333,6 +346,14 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
333
346
} , 0 , false ) ;
334
347
}
335
348
} ) ;
349
+
350
+ if ( isOpenExp ) {
351
+ scope . $watch ( isOpenExp , function ( val ) {
352
+ if ( val !== ttScope . isOpen ) {
353
+ toggleTooltipBind ( ) ;
354
+ }
355
+ } ) ;
356
+ }
336
357
337
358
function prepPopupClass ( ) {
338
359
ttScope . popupClass = attrs [ prefix + 'Class' ] ;
@@ -364,14 +385,16 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
364
385
365
386
triggers = getTriggers ( val ) ;
366
387
367
- triggers . show . forEach ( function ( trigger , idx ) {
368
- if ( trigger === triggers . hide [ idx ] ) {
369
- element . bind ( trigger , toggleTooltipBind ) ;
370
- } else if ( trigger ) {
371
- element . bind ( trigger , showTooltipBind ) ;
372
- element . bind ( triggers . hide [ idx ] , hideTooltipBind ) ;
373
- }
374
- } ) ;
388
+ if ( triggers . show !== 'none' ) {
389
+ triggers . show . forEach ( function ( trigger , idx ) {
390
+ if ( trigger === triggers . hide [ idx ] ) {
391
+ element . bind ( trigger , toggleTooltipBind ) ;
392
+ } else if ( trigger ) {
393
+ element . bind ( trigger , showTooltipBind ) ;
394
+ element . bind ( triggers . hide [ idx ] , hideTooltipBind ) ;
395
+ }
396
+ } ) ;
397
+ }
375
398
}
376
399
prepTriggers ( ) ;
377
400
0 commit comments