@@ -215,22 +215,22 @@ angular.module('ui.bootstrap.modal', [])
215
215
216
216
function removeModalWindow ( modalInstance , elementToReceiveFocus ) {
217
217
218
- var body = $document . find ( 'body' ) . eq ( 0 ) ;
219
218
var modalWindow = openedWindows . get ( modalInstance ) . value ;
219
+ var container = modalWindow . container ;
220
220
221
221
//clean up the stack
222
222
openedWindows . remove ( modalInstance ) ;
223
223
224
224
removeAfterAnimate ( modalWindow . modalDomEl , modalWindow . modalScope , function ( ) {
225
- body . toggleClass ( OPENED_MODAL_CLASS , openedWindows . length ( ) > 0 ) ;
225
+ container . toggleClass ( OPENED_MODAL_CLASS , openedWindows . length ( ) > 0 ) ;
226
226
checkRemoveBackdrop ( ) ;
227
227
} ) ;
228
228
229
- //move focus to specified element if available, or else to body
229
+ //move focus to specified element if available, or else to modal container
230
230
if ( elementToReceiveFocus && elementToReceiveFocus . focus ) {
231
231
elementToReceiveFocus . focus ( ) ;
232
232
} else {
233
- body . focus ( ) ;
233
+ container . focus ( ) ;
234
234
}
235
235
}
236
236
@@ -303,10 +303,11 @@ angular.module('ui.bootstrap.modal', [])
303
303
renderDeferred : modal . renderDeferred ,
304
304
modalScope : modal . scope ,
305
305
backdrop : modal . backdrop ,
306
- keyboard : modal . keyboard
306
+ keyboard : modal . keyboard ,
307
+ container : modal . container
307
308
} ) ;
308
309
309
- var body = $document . find ( 'body' ) . eq ( 0 ) ,
310
+ var container = modal . container ,
310
311
currBackdropIndex = backdropIndex ( ) ;
311
312
312
313
if ( currBackdropIndex >= 0 && ! backdropDomEl ) {
@@ -318,7 +319,7 @@ angular.module('ui.bootstrap.modal', [])
318
319
angularBackgroundDomEl . attr ( 'modal-animation' , 'true' ) ;
319
320
}
320
321
backdropDomEl = $compile ( angularBackgroundDomEl ) ( backdropScope ) ;
321
- body . append ( backdropDomEl ) ;
322
+ container . append ( backdropDomEl ) ;
322
323
}
323
324
324
325
var angularDomEl = angular . element ( '<div modal-window="modal-window"></div>' ) ;
@@ -336,8 +337,8 @@ angular.module('ui.bootstrap.modal', [])
336
337
var modalDomEl = $compile ( angularDomEl ) ( modal . scope ) ;
337
338
openedWindows . top ( ) . value . modalDomEl = modalDomEl ;
338
339
openedWindows . top ( ) . value . modalOpener = modalOpener ;
339
- body . append ( modalDomEl ) ;
340
- body . addClass ( OPENED_MODAL_CLASS ) ;
340
+ container . append ( modalDomEl ) ;
341
+ container . addClass ( OPENED_MODAL_CLASS ) ;
341
342
} ;
342
343
343
344
function broadcastClosing ( modalWindow , resultOrReason , closing ) {
@@ -393,9 +394,9 @@ angular.module('ui.bootstrap.modal', [])
393
394
backdrop : true , //can also be false or 'static'
394
395
keyboard : true
395
396
} ,
397
+ defaultContainer : angular . element ( document ) . find ( 'body' ) . eq ( 0 ) ,
396
398
$get : [ '$injector' , '$rootScope' , '$q' , '$templateRequest' , '$controller' , '$modalStack' ,
397
399
function ( $injector , $rootScope , $q , $templateRequest , $controller , $modalStack ) {
398
-
399
400
var $modal = { } ;
400
401
401
402
function getTemplatePromise ( options ) {
@@ -483,6 +484,7 @@ angular.module('ui.bootstrap.modal', [])
483
484
backdropClass : modalOptions . backdropClass ,
484
485
windowClass : modalOptions . windowClass ,
485
486
windowTemplateUrl : modalOptions . windowTemplateUrl ,
487
+ container : $modalProvider . defaultContainer ,
486
488
size : modalOptions . size
487
489
} ) ;
488
490
0 commit comments