@@ -20,7 +20,7 @@ angular.module( 'ui.bootstrap.tooltip', [] )
20
20
var globalOptions = { } ;
21
21
22
22
/**
23
- * The `options({})` allows global configuration of all dialogs in the
23
+ * `options({})` allows global configuration of all tooltips in the
24
24
* application.
25
25
*
26
26
* var app = angular.module( 'App', ['ui.bootstrap.tooltip'], function( $tooltipProvider ) {
@@ -36,7 +36,7 @@ angular.module( 'ui.bootstrap.tooltip', [] )
36
36
* Returns the actual instance of the $tooltip service.
37
37
* TODO support multiple triggers
38
38
*/
39
- this . $get = [ '$window' , '$compile' , '$timeout' , '$parse' , function ( $window , $compile , $timeout , $parse ) {
39
+ this . $get = [ '$window' , '$compile' , '$timeout' , '$parse' , '$document' , function ( $window , $compile , $timeout , $parse , $document ) {
40
40
return function $tooltip ( type , defaultTriggerShow , defaultTriggerHide ) {
41
41
var options = angular . extend ( { } , defaultOptions , globalOptions ) ;
42
42
@@ -65,8 +65,9 @@ angular.module( 'ui.bootstrap.tooltip', [] )
65
65
restrict : 'EA' ,
66
66
scope : true ,
67
67
link : function link ( scope , element , attrs ) {
68
- var tooltip = $compile ( template ) ( scope ) ,
69
- transitionTimeout ;
68
+ var tooltip = $compile ( template ) ( scope ) ;
69
+ var transitionTimeout ;
70
+ var $body ;
70
71
71
72
attrs . $observe ( type , function ( val ) {
72
73
scope . tt_content = val ;
@@ -111,7 +112,12 @@ angular.module( 'ui.bootstrap.tooltip', [] )
111
112
112
113
// Now we add it to the DOM because need some info about it. But it's not
113
114
// visible yet anyway.
114
- element . after ( tooltip ) ;
115
+ if ( options . appendToBody ) {
116
+ $body = $body || $document . find ( 'body' ) ;
117
+ $body . append ( tooltip ) ;
118
+ } else {
119
+ element . after ( tooltip ) ;
120
+ }
115
121
116
122
// Get the position of the directive element.
117
123
position = getPosition ( element ) ;
0 commit comments