@@ -39,6 +39,7 @@ return $.widget( "ui.calendar", {
39
39
version : "@VERSION" ,
40
40
options : {
41
41
buttons : [ ] ,
42
+ dateFormat : { date : "short" } ,
42
43
eachDay : $ . noop ,
43
44
labels : {
44
45
"datePickerRole" : "date picker" ,
@@ -58,7 +59,9 @@ return $.widget( "ui.calendar", {
58
59
} ,
59
60
60
61
refreshRelatedOptions : {
62
+ dateFormat : true ,
61
63
eachDay : true ,
64
+ locale : true ,
62
65
max : true ,
63
66
min : true ,
64
67
showWeek : true ,
@@ -70,7 +73,7 @@ return $.widget( "ui.calendar", {
70
73
this . labels = this . options . labels ;
71
74
this . buttonClickContext = this . element [ 0 ] ;
72
75
73
- this . _setLocale ( this . options . locale ) ;
76
+ this . _setLocale ( this . options . locale , this . options . dateFormat ) ;
74
77
75
78
this . date = new $ . ui . calendarDate ( this . options . value , this . _calendarDateOptions ) ;
76
79
this . viewDate = this . date . clone ( ) ;
@@ -177,13 +180,13 @@ return $.widget( "ui.calendar", {
177
180
) . addClass ( "ui-state-focus" ) ;
178
181
} ,
179
182
180
- _setLocale : function ( locale ) {
183
+ _setLocale : function ( locale , dateFormat ) {
181
184
var globalize = new Globalize ( locale ) ,
182
185
weekdayShortFormatter = globalize . dateFormatter ( { raw : "EEEEEE" } ) ,
183
186
weekdayNarrowFormatter = globalize . dateFormatter ( { raw : "EEEEE" } ) ;
184
187
185
- this . _format = globalize . dateFormatter ( { date : "short" } ) ;
186
- this . _parse = globalize . dateParser ( { date : "short" } ) ;
188
+ this . _format = globalize . dateFormatter ( dateFormat ) ;
189
+ this . _parse = globalize . dateParser ( dateFormat ) ;
187
190
this . _calendarDateOptions = {
188
191
firstDay : globalize . cldr . supplemental . weekData . firstDay ( ) ,
189
192
formatWeekdayShort : function ( date ) {
@@ -590,16 +593,25 @@ return $.widget( "ui.calendar", {
590
593
591
594
_setOptions : function ( options ) {
592
595
var that = this ,
593
- refresh = false ;
596
+ refresh = false ,
597
+ dateAttributes = false ;
594
598
595
599
$ . each ( options , function ( key , value ) {
596
600
that . _setOption ( key , value ) ;
597
601
598
602
if ( key in that . refreshRelatedOptions ) {
599
603
refresh = true ;
600
604
}
605
+ if ( key === "dateFormat" || key === "locale" ) {
606
+ dateAttributes = true ;
607
+ }
601
608
} ) ;
602
609
610
+ if ( dateAttributes ) {
611
+ this . _setLocale ( this . options . locale , this . options . dateFormat ) ;
612
+ this . date . setAttributes ( this . _calendarDateOptions ) ;
613
+ this . viewDate . setAttributes ( this . _calendarDateOptions ) ;
614
+ }
603
615
if ( refresh ) {
604
616
this . _refresh ( ) ;
605
617
}
@@ -636,12 +648,6 @@ return $.widget( "ui.calendar", {
636
648
if ( key === "eachDay" ) {
637
649
this . viewDate . eachDay = value ;
638
650
}
639
-
640
- if ( key === "locale" ) {
641
- this . _setLocale ( value ) ;
642
- this . date . setAttributes ( this . _calendarDateOptions ) ;
643
- this . refresh ( ) ;
644
- }
645
651
}
646
652
} ) ;
647
653
0 commit comments