10
10
11
11
angular . module ( 'ui.calendar' , [ ] )
12
12
. constant ( 'uiCalendarConfig' , { } )
13
- . controller ( 'uiCalendarCtrl' , [ '$scope' , '$timeout' , function ( $scope , $timeout ) {
13
+ . controller ( 'uiCalendarCtrl' , [ '$scope' , '$timeout' , '$locale' , function ( $scope , $timeout , $locale ) {
14
14
15
15
var sourceSerialId = 1 ,
16
16
eventSerialId = 1 ,
@@ -165,26 +165,31 @@ angular.module('ui.calendar', [])
165
165
166
166
return config ;
167
167
} ;
168
- } ] )
169
- . directive ( 'uiCalendar' , [ 'uiCalendarConfig' , '$locale' , function ( uiCalendarConfig , $locale ) {
170
- // Configure to use locale names by default
171
- var tValues = function ( data ) {
172
- // convert {0: "Jan", 1: "Feb", ...} to ["Jan", "Feb", ...]
173
- var r , k ;
174
- r = [ ] ;
175
- for ( k in data ) {
176
- r [ k ] = data [ k ] ;
168
+
169
+ this . getLocaleConfig = function ( fullCalendarConfig ) {
170
+ if ( ! fullCalendarConfig . lang || fullCalendarConfig . useNgLocale ) {
171
+ // Configure to use locale names by default
172
+ var tValues = function ( data ) {
173
+ // convert {0: "Jan", 1: "Feb", ...} to ["Jan", "Feb", ...]
174
+ var r , k ;
175
+ r = [ ] ;
176
+ for ( k in data ) {
177
+ r [ k ] = data [ k ] ;
178
+ }
179
+ return r ;
180
+ } ;
181
+ var dtf = $locale . DATETIME_FORMATS ;
182
+ return {
183
+ monthNames : tValues ( dtf . MONTH ) ,
184
+ monthNamesShort : tValues ( dtf . SHORTMONTH ) ,
185
+ dayNames : tValues ( dtf . DAY ) ,
186
+ dayNamesShort : tValues ( dtf . SHORTDAY )
187
+ } ;
177
188
}
178
- return r ;
189
+ return { } ;
179
190
} ;
180
- var dtf = $locale . DATETIME_FORMATS ;
181
- uiCalendarConfig = angular . extend ( {
182
- monthNames : tValues ( dtf . MONTH ) ,
183
- monthNamesShort : tValues ( dtf . SHORTMONTH ) ,
184
- dayNames : tValues ( dtf . DAY ) ,
185
- dayNamesShort : tValues ( dtf . SHORTDAY )
186
- } , uiCalendarConfig || { } ) ;
187
-
191
+ } ] )
192
+ . directive ( 'uiCalendar' , [ 'uiCalendarConfig' , function ( uiCalendarConfig ) {
188
193
return {
189
194
restrict : 'A' ,
190
195
scope : { eventSources :'=ngModel' , calendarWatchEvent : '&' } ,
@@ -203,8 +208,11 @@ angular.module('ui.calendar', [])
203
208
204
209
fullCalendarConfig = controller . getFullCalendarConfig ( calendarSettings , uiCalendarConfig ) ;
205
210
211
+ var localeFullCalendarConfig = controller . getLocaleConfig ( fullCalendarConfig ) ;
212
+ angular . extend ( localeFullCalendarConfig , fullCalendarConfig ) ;
213
+
206
214
options = { eventSources : sources } ;
207
- angular . extend ( options , fullCalendarConfig ) ;
215
+ angular . extend ( options , localeFullCalendarConfig ) ;
208
216
209
217
var options2 = { } ;
210
218
for ( var o in options ) {
0 commit comments