1
1
angular . module ( 'ui.bootstrap.modal' , [ ] )
2
2
3
+ . constant ( 'modalConfig' , {
4
+ animation : true
5
+ } )
6
+
3
7
/**
4
8
* A helper, internal data structure that acts as a map but also allows getting / removing
5
9
* elements in the LIFO order
@@ -57,22 +61,29 @@ angular.module('ui.bootstrap.modal', [])
57
61
/**
58
62
* A helper directive for the $modal service. It creates a backdrop element.
59
63
*/
60
- . directive ( 'modalBackdrop' , [ '$timeout' , function ( $timeout ) {
64
+ . directive ( 'modalBackdrop' , [ '$timeout' , 'modalConfig' , function ( $timeout , modalConfig ) {
61
65
return {
62
66
restrict : 'EA' ,
63
67
replace : true ,
64
68
templateUrl : 'template/modal/backdrop.html' ,
65
- link : function ( scope , element , attrs ) {
66
- scope . backdropClass = attrs . backdropClass || '' ;
69
+ compile : function ( tElement , tAttrs ) {
70
+ tElement . addClass ( tAttrs . backdropClass ) ;
71
+ return linkFn ;
72
+ } ,
73
+ } ;
67
74
75
+ function linkFn ( scope , element , attrs ) {
76
+ if ( modalConfig . animation ) {
68
77
scope . animate = false ;
69
78
70
79
//trigger CSS transitions
71
80
$timeout ( function ( ) {
72
81
scope . animate = true ;
73
82
} ) ;
83
+ } else {
84
+ scope . animate = true ;
74
85
}
75
- } ;
86
+ }
76
87
} ] )
77
88
78
89
. directive ( 'modalWindow' , [ '$modalStack' , '$timeout' , function ( $modalStack , $timeout ) {
@@ -120,6 +131,18 @@ angular.module('ui.bootstrap.modal', [])
120
131
} ;
121
132
} ] )
122
133
134
+ . directive ( 'modalAnimationClass' , [
135
+ 'modalConfig' ,
136
+ function ( modalConfig ) {
137
+ return {
138
+ compile : function ( tElement , tAttrs ) {
139
+ if ( modalConfig . animation ) {
140
+ tElement . addClass ( tAttrs . modalAnimationClass ) ;
141
+ }
142
+ }
143
+ } ;
144
+ } ] )
145
+
123
146
. directive ( 'modalTransclude' , function ( ) {
124
147
return {
125
148
link : function ( $scope , $element , $attrs , controller , $transclude ) {
@@ -131,8 +154,8 @@ angular.module('ui.bootstrap.modal', [])
131
154
} ;
132
155
} )
133
156
134
- . factory ( '$modalStack' , [ '$animate' , '$timeout' , '$document' , '$compile' , '$rootScope' , '$$stackedMap' ,
135
- function ( $animate , $timeout , $document , $compile , $rootScope , $$stackedMap ) {
157
+ . factory ( '$modalStack' , [ '$animate' , '$timeout' , '$document' , '$compile' , '$rootScope' , '$$stackedMap' , 'modalConfig' ,
158
+ function ( $animate , $timeout , $document , $compile , $rootScope , $$stackedMap , modalConfig ) {
136
159
137
160
var OPENED_MODAL_CLASS = 'modal-open' ;
138
161
@@ -185,10 +208,10 @@ angular.module('ui.bootstrap.modal', [])
185
208
}
186
209
187
210
function removeAfterAnimate ( domEl , scope , done ) {
188
- // Closing animation
189
- scope . animate = false ;
211
+ if ( modalConfig . animation && $animate . enabled ( ) ) {
212
+ // Closing animation
213
+ scope . animate = false ;
190
214
191
- if ( $animate . enabled ( ) ) {
192
215
// transition out
193
216
domEl . on ( '$animate:close' , function closeFn ( ) {
194
217
afterAnimating ( ) ;
0 commit comments