@@ -57,8 +57,8 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
57
57
/**
58
58
* A helper directive for the $modal service. It creates a backdrop element.
59
59
*/
60
- . directive ( 'modalBackdrop ' , [
61
- '$animate' , '$injector' , '$modalStack ' ,
60
+ . directive ( 'uibModalBackdrop ' , [
61
+ '$animate' , '$injector' , '$uibModalStack ' ,
62
62
function ( $animate , $injector , $modalStack ) {
63
63
var $animateCss = null ;
64
64
@@ -100,8 +100,8 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
100
100
}
101
101
} ] )
102
102
103
- . directive ( 'modalWindow ' , [
104
- '$modalStack ' , '$q' , '$animate' , '$injector' ,
103
+ . directive ( 'uibModalWindow ' , [
104
+ '$uibModalStack ' , '$q' , '$animate' , '$injector' ,
105
105
function ( $modalStack , $q , $animate , $injector ) {
106
106
var $animateCss = null ;
107
107
@@ -203,18 +203,18 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
203
203
} ;
204
204
} ] )
205
205
206
- . directive ( 'modalAnimationClass ' , [
206
+ . directive ( 'uibModalAnimationClass ' , [
207
207
function ( ) {
208
208
return {
209
209
compile : function ( tElement , tAttrs ) {
210
210
if ( tAttrs . modalAnimation ) {
211
- tElement . addClass ( tAttrs . modalAnimationClass ) ;
211
+ tElement . addClass ( tAttrs . uibModalAnimationClass ) ;
212
212
}
213
213
}
214
214
} ;
215
215
} ] )
216
216
217
- . directive ( 'modalTransclude ' , function ( ) {
217
+ . directive ( 'uibModalTransclude ' , function ( ) {
218
218
return {
219
219
link : function ( $scope , $element , $attrs , controller , $transclude ) {
220
220
$transclude ( $scope . $parent , function ( clone ) {
@@ -225,7 +225,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
225
225
} ;
226
226
} )
227
227
228
- . factory ( '$modalStack ' , [
228
+ . factory ( '$uibModalStack ' , [
229
229
'$animate' , '$timeout' , '$document' , '$compile' , '$rootScope' ,
230
230
'$q' ,
231
231
'$injector' ,
@@ -424,7 +424,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
424
424
if ( currBackdropIndex >= 0 && ! backdropDomEl ) {
425
425
backdropScope = $rootScope . $new ( true ) ;
426
426
backdropScope . index = currBackdropIndex ;
427
- var angularBackgroundDomEl = angular . element ( '<div modal-backdrop="modal-backdrop"></div>' ) ;
427
+ var angularBackgroundDomEl = angular . element ( '<div uib- modal-backdrop="modal-backdrop"></div>' ) ;
428
428
angularBackgroundDomEl . attr ( 'backdrop-class' , modal . backdropClass ) ;
429
429
if ( modal . animation ) {
430
430
angularBackgroundDomEl . attr ( 'modal-animation' , 'true' ) ;
@@ -433,7 +433,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
433
433
body . append ( backdropDomEl ) ;
434
434
}
435
435
436
- var angularDomEl = angular . element ( '<div modal-window="modal-window"></div>' ) ;
436
+ var angularDomEl = angular . element ( '<div uib- modal-window="modal-window"></div>' ) ;
437
437
angularDomEl . attr ( {
438
438
'template-url' : modal . windowTemplateUrl ,
439
439
'window-class' : modal . windowClass ,
@@ -547,14 +547,14 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
547
547
return $modalStack ;
548
548
} ] )
549
549
550
- . provider ( '$modal ' , function ( ) {
550
+ . provider ( '$uibModal ' , function ( ) {
551
551
var $modalProvider = {
552
552
options : {
553
553
animation : true ,
554
554
backdrop : true , //can also be false or 'static'
555
555
keyboard : true
556
556
} ,
557
- $get : [ '$injector' , '$rootScope' , '$q' , '$templateRequest' , '$controller' , '$modalStack ' ,
557
+ $get : [ '$injector' , '$rootScope' , '$q' , '$templateRequest' , '$controller' , '$uibModalStack ' ,
558
558
function ( $injector , $rootScope , $q , $templateRequest , $controller , $modalStack ) {
559
559
var $modal = { } ;
560
560
@@ -689,3 +689,232 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
689
689
690
690
return $modalProvider ;
691
691
} ) ;
692
+
693
+ /* deprecated modal below */
694
+
695
+ angular . module ( 'ui.bootstrap.modal' )
696
+
697
+ . value ( '$modalSuppressWarning' , false )
698
+
699
+ /**
700
+ * A helper directive for the $modal service. It creates a backdrop element.
701
+ */
702
+ . directive ( 'modalBackdrop' , [
703
+ '$animate' , '$injector' , '$modalStack' , '$log' , '$modalSuppressWarning' ,
704
+ function ( $animate , $injector , $modalStack , $log , $modalSuppressWarning ) {
705
+ var $animateCss = null ;
706
+
707
+ if ( $injector . has ( '$animateCss' ) ) {
708
+ $animateCss = $injector . get ( '$animateCss' ) ;
709
+ }
710
+
711
+ return {
712
+ restrict : 'EA' ,
713
+ replace : true ,
714
+ templateUrl : 'template/modal/backdrop.html' ,
715
+ compile : function ( tElement , tAttrs ) {
716
+ tElement . addClass ( tAttrs . backdropClass ) ;
717
+ return linkFn ;
718
+ }
719
+ } ;
720
+
721
+ function linkFn ( scope , element , attrs ) {
722
+ if ( ! $modalSuppressWarning ) {
723
+ $log . warn ( 'modal-backdrop is now deprecated. Use uib-modal-backdrop instead.' ) ;
724
+ }
725
+ if ( attrs . modalInClass ) {
726
+ if ( $animateCss ) {
727
+ $animateCss ( element , {
728
+ addClass : attrs . modalInClass
729
+ } ) . start ( ) ;
730
+ } else {
731
+ $animate . addClass ( element , attrs . modalInClass ) ;
732
+ }
733
+
734
+ scope . $on ( $modalStack . NOW_CLOSING_EVENT , function ( e , setIsAsync ) {
735
+ var done = setIsAsync ( ) ;
736
+ if ( $animateCss ) {
737
+ $animateCss ( element , {
738
+ removeClass : attrs . modalInClass
739
+ } ) . start ( ) . then ( done ) ;
740
+ } else {
741
+ $animate . removeClass ( element , attrs . modalInClass ) . then ( done ) ;
742
+ }
743
+ } ) ;
744
+ }
745
+ }
746
+ } ] )
747
+
748
+ . directive ( 'modalWindow' , [
749
+ '$modalStack' , '$q' , '$animate' , '$injector' , '$log' , '$modalSuppressWarning' ,
750
+ function ( $modalStack , $q , $animate , $injector , $log , $modalSuppressWarning ) {
751
+ var $animateCss = null ;
752
+
753
+ if ( $injector . has ( '$animateCss' ) ) {
754
+ $animateCss = $injector . get ( '$animateCss' ) ;
755
+ }
756
+
757
+ return {
758
+ restrict : 'EA' ,
759
+ scope : {
760
+ index : '@'
761
+ } ,
762
+ replace : true ,
763
+ transclude : true ,
764
+ templateUrl : function ( tElement , tAttrs ) {
765
+ return tAttrs . templateUrl || 'template/modal/window.html' ;
766
+ } ,
767
+ link : function ( scope , element , attrs ) {
768
+ if ( ! $modalSuppressWarning ) {
769
+ $log . warn ( 'modal-window is now deprecated. Use uib-modal-window instead.' ) ;
770
+ }
771
+ element . addClass ( attrs . windowClass || '' ) ;
772
+ element . addClass ( attrs . windowTopClass || '' ) ;
773
+ scope . size = attrs . size ;
774
+
775
+ scope . close = function ( evt ) {
776
+ var modal = $modalStack . getTop ( ) ;
777
+ if ( modal && modal . value . backdrop && modal . value . backdrop !== 'static' && ( evt . target === evt . currentTarget ) ) {
778
+ evt . preventDefault ( ) ;
779
+ evt . stopPropagation ( ) ;
780
+ $modalStack . dismiss ( modal . key , 'backdrop click' ) ;
781
+ }
782
+ } ;
783
+
784
+ // moved from template to fix issue #2280
785
+ element . on ( 'click' , scope . close ) ;
786
+
787
+ // This property is only added to the scope for the purpose of detecting when this directive is rendered.
788
+ // We can detect that by using this property in the template associated with this directive and then use
789
+ // {@link Attribute#$observe } on it. For more details please see {@link TableColumnResize }.
790
+ scope . $isRendered = true ;
791
+
792
+ // Deferred object that will be resolved when this modal is render.
793
+ var modalRenderDeferObj = $q . defer ( ) ;
794
+ // Observe function will be called on next digest cycle after compilation, ensuring that the DOM is ready.
795
+ // In order to use this way of finding whether DOM is ready, we need to observe a scope property used in modal's template.
796
+ attrs . $observe ( 'modalRender' , function ( value ) {
797
+ if ( value == 'true' ) {
798
+ modalRenderDeferObj . resolve ( ) ;
799
+ }
800
+ } ) ;
801
+
802
+ modalRenderDeferObj . promise . then ( function ( ) {
803
+ var animationPromise = null ;
804
+
805
+ if ( attrs . modalInClass ) {
806
+ if ( $animateCss ) {
807
+ animationPromise = $animateCss ( element , {
808
+ addClass : attrs . modalInClass
809
+ } ) . start ( ) ;
810
+ } else {
811
+ animationPromise = $animate . addClass ( element , attrs . modalInClass ) ;
812
+ }
813
+
814
+ scope . $on ( $modalStack . NOW_CLOSING_EVENT , function ( e , setIsAsync ) {
815
+ var done = setIsAsync ( ) ;
816
+ if ( $animateCss ) {
817
+ $animateCss ( element , {
818
+ removeClass : attrs . modalInClass
819
+ } ) . start ( ) . then ( done ) ;
820
+ } else {
821
+ $animate . removeClass ( element , attrs . modalInClass ) . then ( done ) ;
822
+ }
823
+ } ) ;
824
+ }
825
+
826
+
827
+ $q . when ( animationPromise ) . then ( function ( ) {
828
+ var inputsWithAutofocus = element [ 0 ] . querySelectorAll ( '[autofocus]' ) ;
829
+ /**
830
+ * Auto-focusing of a freshly-opened modal element causes any child elements
831
+ * with the autofocus attribute to lose focus. This is an issue on touch
832
+ * based devices which will show and then hide the onscreen keyboard.
833
+ * Attempts to refocus the autofocus element via JavaScript will not reopen
834
+ * the onscreen keyboard. Fixed by updated the focusing logic to only autofocus
835
+ * the modal element if the modal does not contain an autofocus element.
836
+ */
837
+ if ( inputsWithAutofocus . length ) {
838
+ inputsWithAutofocus [ 0 ] . focus ( ) ;
839
+ } else {
840
+ element [ 0 ] . focus ( ) ;
841
+ }
842
+ } ) ;
843
+
844
+ // Notify {@link $modalStack } that modal is rendered.
845
+ var modal = $modalStack . getTop ( ) ;
846
+ if ( modal ) {
847
+ $modalStack . modalRendered ( modal . key ) ;
848
+ }
849
+ } ) ;
850
+ }
851
+ } ;
852
+ } ] )
853
+
854
+ . directive ( 'modalAnimationClass' , [
855
+ '$log' , '$modalSuppressWarning' ,
856
+ function ( $log , $modalSuppressWarning ) {
857
+ return {
858
+ compile : function ( tElement , tAttrs ) {
859
+ if ( ! $modalSuppressWarning ) {
860
+ $log . warn ( 'modal-animation-class is now deprecated. Use uib-modal-animation-class instead.' ) ;
861
+ }
862
+ if ( tAttrs . modalAnimation ) {
863
+ tElement . addClass ( tAttrs . modalAnimationClass ) ;
864
+ }
865
+ }
866
+ } ;
867
+ } ] )
868
+
869
+ . directive ( 'modalTransclude' , [
870
+ '$log' , '$modalSuppressWarning' ,
871
+ function ( $log , $modalSuppressWarning ) {
872
+ return {
873
+ link : function ( $scope , $element , $attrs , controller , $transclude ) {
874
+ if ( ! $modalSuppressWarning ) {
875
+ $log . warn ( 'modal-transclude is now deprecated. Use uib-modal-transclude instead.' ) ;
876
+ }
877
+ $transclude ( $scope . $parent , function ( clone ) {
878
+ $element . empty ( ) ;
879
+ $element . append ( clone ) ;
880
+ } ) ;
881
+ }
882
+ } ;
883
+ } ] )
884
+
885
+ . service ( '$modalStack' , [
886
+ '$animate' , '$timeout' , '$document' , '$compile' , '$rootScope' ,
887
+ '$q' ,
888
+ '$injector' ,
889
+ '$$multiMap' ,
890
+ '$$stackedMap' ,
891
+ '$uibModalStack' ,
892
+ '$log' ,
893
+ '$modalSuppressWarning' ,
894
+ function ( $animate , $timeout , $document , $compile , $rootScope ,
895
+ $q ,
896
+ $injector ,
897
+ $$multiMap ,
898
+ $$stackedMap ,
899
+ $uibModalStack ,
900
+ $log ,
901
+ $modalSuppressWarning ) {
902
+ if ( ! $modalSuppressWarning ) {
903
+ $log . warn ( '$modalStack is now deprecated. Use $uibModalStack instead.' ) ;
904
+ }
905
+
906
+ angular . extend ( this , $uibModalStack ) ;
907
+ } ] )
908
+
909
+ . provider ( '$modal' , [ '$uibModalProvider' , function ( $uibModalProvider ) {
910
+ angular . extend ( this , $uibModalProvider ) ;
911
+
912
+ this . $get = [ '$injector' , '$log' , '$modalSuppressWarning' ,
913
+ function ( $injector , $log , $modalSuppressWarning ) {
914
+ if ( ! $modalSuppressWarning ) {
915
+ $log . warn ( '$modal is now deprecated. Use $uibModal instead.' ) ;
916
+ }
917
+
918
+ return $injector . invoke ( $uibModalProvider . $get ) ;
919
+ } ] ;
920
+ } ] ) ;
0 commit comments