@@ -541,7 +541,7 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi
541
541
dateFormat = datepickerPopupConfig . html5Types [ attrs . type ] ;
542
542
isHtml5DateInput = true ;
543
543
} else {
544
- dateFormat = attrs . datepickerPopup || attrs . uibDatepickerPopup || datepickerPopupConfig . datepickerPopup ;
544
+ dateFormat = attrs . uibDatepickerPopup || datepickerPopupConfig . datepickerPopup ;
545
545
attrs . $observe ( 'uibDatepickerPopup' , function ( value , oldValue ) {
546
546
var newDateFormat = value || datepickerPopupConfig . datepickerPopup ;
547
547
// Invalidate the $modelValue to ensure that formatters re-run
@@ -860,327 +860,3 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi
860
860
}
861
861
} ;
862
862
} ) ;
863
-
864
- /* Deprecated datepicker below */
865
-
866
- angular . module ( 'ui.bootstrap.datepicker' )
867
-
868
- . value ( '$datepickerSuppressWarning' , false )
869
-
870
- . controller ( 'DatepickerController' , [ '$scope' , '$attrs' , '$parse' , '$interpolate' , '$log' , 'dateFilter' , 'uibDatepickerConfig' , '$datepickerSuppressError' , '$datepickerSuppressWarning' , function ( $scope , $attrs , $parse , $interpolate , $log , dateFilter , datepickerConfig , $datepickerSuppressError , $datepickerSuppressWarning ) {
871
- if ( ! $datepickerSuppressWarning ) {
872
- $log . warn ( 'DatepickerController is now deprecated. Use UibDatepickerController instead.' ) ;
873
- }
874
-
875
- var self = this ,
876
- ngModelCtrl = { $setViewValue : angular . noop } ; // nullModelCtrl;
877
-
878
- this . modes = [ 'day' , 'month' , 'year' ] ;
879
-
880
- angular . forEach ( [ 'formatDay' , 'formatMonth' , 'formatYear' , 'formatDayHeader' , 'formatDayTitle' , 'formatMonthTitle' ,
881
- 'showWeeks' , 'startingDay' , 'yearRange' , 'shortcutPropagation' ] , function ( key , index ) {
882
- self [ key ] = angular . isDefined ( $attrs [ key ] ) ? ( index < 6 ? $interpolate ( $attrs [ key ] ) ( $scope . $parent ) : $scope . $parent . $eval ( $attrs [ key ] ) ) : datepickerConfig [ key ] ;
883
- } ) ;
884
-
885
- angular . forEach ( [ 'minDate' , 'maxDate' ] , function ( key ) {
886
- if ( $attrs [ key ] ) {
887
- $scope . $parent . $watch ( $parse ( $attrs [ key ] ) , function ( value ) {
888
- self [ key ] = value ? new Date ( value ) : null ;
889
- self . refreshView ( ) ;
890
- } ) ;
891
- } else {
892
- self [ key ] = datepickerConfig [ key ] ? new Date ( datepickerConfig [ key ] ) : null ;
893
- }
894
- } ) ;
895
-
896
- angular . forEach ( [ 'minMode' , 'maxMode' ] , function ( key ) {
897
- if ( $attrs [ key ] ) {
898
- $scope . $parent . $watch ( $parse ( $attrs [ key ] ) , function ( value ) {
899
- self [ key ] = angular . isDefined ( value ) ? value : $attrs [ key ] ;
900
- $scope [ key ] = self [ key ] ;
901
- if ( ( key == 'minMode' && self . modes . indexOf ( $scope . datepickerMode ) < self . modes . indexOf ( self [ key ] ) ) || ( key == 'maxMode' && self . modes . indexOf ( $scope . datepickerMode ) > self . modes . indexOf ( self [ key ] ) ) ) {
902
- $scope . datepickerMode = self [ key ] ;
903
- }
904
- } ) ;
905
- } else {
906
- self [ key ] = datepickerConfig [ key ] || null ;
907
- $scope [ key ] = self [ key ] ;
908
- }
909
- } ) ;
910
-
911
- $scope . datepickerMode = $scope . datepickerMode || datepickerConfig . datepickerMode ;
912
- $scope . uniqueId = 'datepicker-' + $scope . $id + '-' + Math . floor ( Math . random ( ) * 10000 ) ;
913
-
914
- if ( angular . isDefined ( $attrs . initDate ) ) {
915
- this . activeDate = $scope . $parent . $eval ( $attrs . initDate ) || new Date ( ) ;
916
- $scope . $parent . $watch ( $attrs . initDate , function ( initDate ) {
917
- if ( initDate && ( ngModelCtrl . $isEmpty ( ngModelCtrl . $modelValue ) || ngModelCtrl . $invalid ) ) {
918
- self . activeDate = initDate ;
919
- self . refreshView ( ) ;
920
- }
921
- } ) ;
922
- } else {
923
- this . activeDate = new Date ( ) ;
924
- }
925
-
926
- $scope . isActive = function ( dateObject ) {
927
- if ( self . compare ( dateObject . date , self . activeDate ) === 0 ) {
928
- $scope . activeDateId = dateObject . uid ;
929
- return true ;
930
- }
931
- return false ;
932
- } ;
933
-
934
- this . init = function ( ngModelCtrl_ ) {
935
- ngModelCtrl = ngModelCtrl_ ;
936
-
937
- ngModelCtrl . $render = function ( ) {
938
- self . render ( ) ;
939
- } ;
940
- } ;
941
-
942
- this . render = function ( ) {
943
- if ( ngModelCtrl . $viewValue ) {
944
- var date = new Date ( ngModelCtrl . $viewValue ) ,
945
- isValid = ! isNaN ( date ) ;
946
-
947
- if ( isValid ) {
948
- this . activeDate = date ;
949
- } else if ( ! $datepickerSuppressError ) {
950
- $log . error ( 'Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.' ) ;
951
- }
952
- }
953
- this . refreshView ( ) ;
954
- } ;
955
-
956
- this . refreshView = function ( ) {
957
- if ( this . element ) {
958
- this . _refreshView ( ) ;
959
-
960
- var date = ngModelCtrl . $viewValue ? new Date ( ngModelCtrl . $viewValue ) : null ;
961
- ngModelCtrl . $setValidity ( 'dateDisabled' , ! date || ( this . element && ! this . isDisabled ( date ) ) ) ;
962
- }
963
- } ;
964
-
965
- this . createDateObject = function ( date , format ) {
966
- var model = ngModelCtrl . $viewValue ? new Date ( ngModelCtrl . $viewValue ) : null ;
967
- return {
968
- date : date ,
969
- label : dateFilter ( date , format ) ,
970
- selected : model && this . compare ( date , model ) === 0 ,
971
- disabled : this . isDisabled ( date ) ,
972
- current : this . compare ( date , new Date ( ) ) === 0 ,
973
- customClass : this . customClass ( date )
974
- } ;
975
- } ;
976
-
977
- this . isDisabled = function ( date ) {
978
- return ( ( this . minDate && this . compare ( date , this . minDate ) < 0 ) || ( this . maxDate && this . compare ( date , this . maxDate ) > 0 ) || ( $attrs . dateDisabled && $scope . dateDisabled ( { date : date , mode : $scope . datepickerMode } ) ) ) ;
979
- } ;
980
-
981
- this . customClass = function ( date ) {
982
- return $scope . customClass ( { date : date , mode : $scope . datepickerMode } ) ;
983
- } ;
984
-
985
- // Split array into smaller arrays
986
- this . split = function ( arr , size ) {
987
- var arrays = [ ] ;
988
- while ( arr . length > 0 ) {
989
- arrays . push ( arr . splice ( 0 , size ) ) ;
990
- }
991
- return arrays ;
992
- } ;
993
-
994
- this . fixTimeZone = function ( date ) {
995
- var hours = date . getHours ( ) ;
996
- date . setHours ( hours === 23 ? hours + 2 : 0 ) ;
997
- } ;
998
-
999
- $scope . select = function ( date ) {
1000
- if ( $scope . datepickerMode === self . minMode ) {
1001
- var dt = ngModelCtrl . $viewValue ? new Date ( ngModelCtrl . $viewValue ) : new Date ( 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ;
1002
- dt . setFullYear ( date . getFullYear ( ) , date . getMonth ( ) , date . getDate ( ) ) ;
1003
- ngModelCtrl . $setViewValue ( dt ) ;
1004
- ngModelCtrl . $render ( ) ;
1005
- } else {
1006
- self . activeDate = date ;
1007
- $scope . datepickerMode = self . modes [ self . modes . indexOf ( $scope . datepickerMode ) - 1 ] ;
1008
- }
1009
- } ;
1010
-
1011
- $scope . move = function ( direction ) {
1012
- var year = self . activeDate . getFullYear ( ) + direction * ( self . step . years || 0 ) ,
1013
- month = self . activeDate . getMonth ( ) + direction * ( self . step . months || 0 ) ;
1014
- self . activeDate . setFullYear ( year , month , 1 ) ;
1015
- self . refreshView ( ) ;
1016
- } ;
1017
-
1018
- $scope . toggleMode = function ( direction ) {
1019
- direction = direction || 1 ;
1020
-
1021
- if ( ( $scope . datepickerMode === self . maxMode && direction === 1 ) || ( $scope . datepickerMode === self . minMode && direction === - 1 ) ) {
1022
- return ;
1023
- }
1024
-
1025
- $scope . datepickerMode = self . modes [ self . modes . indexOf ( $scope . datepickerMode ) + direction ] ;
1026
- } ;
1027
-
1028
- // Key event mapper
1029
- $scope . keys = { 13 : 'enter' , 32 : 'space' , 33 : 'pageup' , 34 : 'pagedown' , 35 : 'end' , 36 : 'home' , 37 : 'left' , 38 : 'up' , 39 : 'right' , 40 : 'down' } ;
1030
-
1031
- var focusElement = function ( ) {
1032
- self . element [ 0 ] . focus ( ) ;
1033
- } ;
1034
-
1035
- $scope . $on ( 'uib:datepicker.focus' , focusElement ) ;
1036
-
1037
- $scope . keydown = function ( evt ) {
1038
- var key = $scope . keys [ evt . which ] ;
1039
-
1040
- if ( ! key || evt . shiftKey || evt . altKey ) {
1041
- return ;
1042
- }
1043
-
1044
- evt . preventDefault ( ) ;
1045
- if ( ! self . shortcutPropagation ) {
1046
- evt . stopPropagation ( ) ;
1047
- }
1048
-
1049
- if ( key === 'enter' || key === 'space' ) {
1050
- if ( self . isDisabled ( self . activeDate ) ) {
1051
- return ; // do nothing
1052
- }
1053
- $scope . select ( self . activeDate ) ;
1054
- } else if ( evt . ctrlKey && ( key === 'up' || key === 'down' ) ) {
1055
- $scope . toggleMode ( key === 'up' ? 1 : - 1 ) ;
1056
- } else {
1057
- self . handleKeyDown ( key , evt ) ;
1058
- self . refreshView ( ) ;
1059
- }
1060
- } ;
1061
- } ] )
1062
-
1063
- . directive ( 'datepicker' , [ '$log' , '$datepickerSuppressWarning' , function ( $log , $datepickerSuppressWarning ) {
1064
- return {
1065
- replace : true ,
1066
- templateUrl : function ( element , attrs ) {
1067
- return attrs . templateUrl || 'template/datepicker/datepicker.html' ;
1068
- } ,
1069
- scope : {
1070
- datepickerMode : '=?' ,
1071
- dateDisabled : '&' ,
1072
- customClass : '&' ,
1073
- shortcutPropagation : '&?'
1074
- } ,
1075
- require : [ 'datepicker' , '^ngModel' ] ,
1076
- controller : 'DatepickerController' ,
1077
- controllerAs : 'datepicker' ,
1078
- link : function ( scope , element , attrs , ctrls ) {
1079
- if ( ! $datepickerSuppressWarning ) {
1080
- $log . warn ( 'datepicker is now deprecated. Use uib-datepicker instead.' ) ;
1081
- }
1082
-
1083
- var datepickerCtrl = ctrls [ 0 ] , ngModelCtrl = ctrls [ 1 ] ;
1084
-
1085
- datepickerCtrl . init ( ngModelCtrl ) ;
1086
- }
1087
- } ;
1088
- } ] )
1089
-
1090
- . directive ( 'daypicker' , [ '$log' , '$datepickerSuppressWarning' , function ( $log , $datepickerSuppressWarning ) {
1091
- return {
1092
- replace : true ,
1093
- templateUrl : 'template/datepicker/day.html' ,
1094
- require : [ '^datepicker' , 'daypicker' ] ,
1095
- controller : 'UibDaypickerController' ,
1096
- link : function ( scope , element , attrs , ctrls ) {
1097
- if ( ! $datepickerSuppressWarning ) {
1098
- $log . warn ( 'daypicker is now deprecated. Use uib-daypicker instead.' ) ;
1099
- }
1100
-
1101
- var datepickerCtrl = ctrls [ 0 ] ,
1102
- daypickerCtrl = ctrls [ 1 ] ;
1103
-
1104
- daypickerCtrl . init ( datepickerCtrl ) ;
1105
- }
1106
- } ;
1107
- } ] )
1108
-
1109
- . directive ( 'monthpicker' , [ '$log' , '$datepickerSuppressWarning' , function ( $log , $datepickerSuppressWarning ) {
1110
- return {
1111
- replace : true ,
1112
- templateUrl : 'template/datepicker/month.html' ,
1113
- require : [ '^datepicker' , 'monthpicker' ] ,
1114
- controller : 'UibMonthpickerController' ,
1115
- link : function ( scope , element , attrs , ctrls ) {
1116
- if ( ! $datepickerSuppressWarning ) {
1117
- $log . warn ( 'monthpicker is now deprecated. Use uib-monthpicker instead.' ) ;
1118
- }
1119
-
1120
- var datepickerCtrl = ctrls [ 0 ] ,
1121
- monthpickerCtrl = ctrls [ 1 ] ;
1122
-
1123
- monthpickerCtrl . init ( datepickerCtrl ) ;
1124
- }
1125
- } ;
1126
- } ] )
1127
-
1128
- . directive ( 'yearpicker' , [ '$log' , '$datepickerSuppressWarning' , function ( $log , $datepickerSuppressWarning ) {
1129
- return {
1130
- replace : true ,
1131
- templateUrl : 'template/datepicker/year.html' ,
1132
- require : [ '^datepicker' , 'yearpicker' ] ,
1133
- controller : 'UibYearpickerController' ,
1134
- link : function ( scope , element , attrs , ctrls ) {
1135
- if ( ! $datepickerSuppressWarning ) {
1136
- $log . warn ( 'yearpicker is now deprecated. Use uib-yearpicker instead.' ) ;
1137
- }
1138
-
1139
- var ctrl = ctrls [ 0 ] ;
1140
- angular . extend ( ctrl , ctrls [ 1 ] ) ;
1141
- ctrl . yearpickerInit ( ) ;
1142
-
1143
- ctrl . refreshView ( ) ;
1144
- }
1145
- } ;
1146
- } ] )
1147
-
1148
- . directive ( 'datepickerPopup' , [ '$log' , '$datepickerSuppressWarning' , function ( $log , $datepickerSuppressWarning ) {
1149
- return {
1150
- require : [ 'ngModel' , 'datepickerPopup' ] ,
1151
- controller : 'UibDatepickerPopupController' ,
1152
- scope : {
1153
- isOpen : '=?' ,
1154
- currentText : '@' ,
1155
- clearText : '@' ,
1156
- closeText : '@' ,
1157
- dateDisabled : '&' ,
1158
- customClass : '&'
1159
- } ,
1160
- link : function ( scope , element , attrs , ctrls ) {
1161
- if ( ! $datepickerSuppressWarning ) {
1162
- $log . warn ( 'datepicker-popup is now deprecated. Use uib-datepicker-popup instead.' ) ;
1163
- }
1164
-
1165
- var ngModel = ctrls [ 0 ] ,
1166
- ctrl = ctrls [ 1 ] ;
1167
-
1168
- ctrl . init ( ngModel ) ;
1169
- }
1170
- } ;
1171
- } ] )
1172
-
1173
- . directive ( 'datepickerPopupWrap' , [ '$log' , '$datepickerSuppressWarning' , function ( $log , $datepickerSuppressWarning ) {
1174
- return {
1175
- replace : true ,
1176
- transclude : true ,
1177
- templateUrl : function ( element , attrs ) {
1178
- return attrs . templateUrl || 'template/datepicker/popup.html' ;
1179
- } ,
1180
- link : function ( ) {
1181
- if ( ! $datepickerSuppressWarning ) {
1182
- $log . warn ( 'datepicker-popup-wrap is now deprecated. Use uib-datepicker-popup-wrap instead.' ) ;
1183
- }
1184
- }
1185
- } ;
1186
- } ] ) ;
0 commit comments