@@ -60,7 +60,7 @@ return $.widget( "ui.calendar", {
60
60
61
61
this . _setLocale ( this . options . locale ) ;
62
62
63
- this . date = new $ . ui . calendarDate ( this . options . value , this . options . locale ) . select ( ) ;
63
+ this . date = new $ . ui . calendarDate ( this . options . value , this . _calendarDateOptions ) . select ( ) ;
64
64
this . date . eachDay = this . options . eachDay ;
65
65
66
66
this . _on ( this . element , {
@@ -158,45 +158,37 @@ return $.widget( "ui.calendar", {
158
158
} ,
159
159
160
160
_setLocale : function ( locale ) {
161
- var globalize ;
162
-
163
- if ( typeof locale === "string" ) {
164
- globalize = new Globalize ( locale ) ;
165
- locale = {
166
- format : function ( date ) {
167
- return globalize . formatDate ( date , { date : "short" } ) ;
168
- } ,
169
- parse : function ( stringDate ) {
170
- return globalize . parseDate ( stringDate , { date : "short" } ) ;
171
- }
172
- } ;
173
- }
161
+ var globalize = new Globalize ( locale ) ;
174
162
175
- if ( ! locale . firstDay ) {
176
- globalize = globalize || new Globalize ( locale . _locale ) ;
177
- $ . extend ( locale , {
178
- firstDay : globalize . cldr . supplemental . weekData . firstDay ( ) ,
179
- formatWeekdayShort : function ( date ) {
163
+ this . _format = function ( date ) {
164
+ return globalize . formatDate ( date , { date : "short" } ) ;
165
+ } ;
180
166
181
- // Return the short weekday if its length is < 3. Otherwise, its narrow form.
182
- var shortWeekday = globalize . formatDate ( date , { pattern : "EEEEEE" } ) ;
183
- return shortWeekday . length > 3 ?
184
- globalize . formatDate ( date , { pattern : "EEEEE" } ) :
185
- shortWeekday ;
186
- } ,
187
- formatWeekdayFull : function ( date ) {
188
- return globalize . formatDate ( date , { pattern : "EEEE" } ) ;
189
- } ,
190
- formatMonth : function ( date ) {
191
- return globalize . formatDate ( date , { pattern : "MMMM" } ) ;
192
- } ,
193
- formatWeekOfYear : function ( date ) {
194
- return globalize . formatDate ( date , { pattern : "w" } ) ;
195
- }
196
- } ) ;
197
- }
167
+ this . _parse = function ( stringDate ) {
168
+ return globalize . parseDate ( stringDate , { date : "short" } ) ;
169
+ } ;
170
+
171
+ this . _calendarDateOptions = {
172
+ firstDay : globalize . cldr . supplemental . weekData . firstDay ( ) ,
173
+ formatWeekdayShort : function ( date ) {
198
174
199
- this . options . locale = locale ;
175
+ // Return the short weekday if its length is < 3. Otherwise, its narrow form.
176
+ var shortWeekday = globalize . formatDate ( date , { pattern : "EEEEEE" } ) ;
177
+ return shortWeekday . length > 3 ?
178
+ globalize . formatDate ( date , { pattern : "EEEEE" } ) :
179
+ shortWeekday ;
180
+ } ,
181
+ formatWeekdayFull : function ( date ) {
182
+ return globalize . formatDate ( date , { pattern : "EEEE" } ) ;
183
+ } ,
184
+ formatMonth : function ( date ) {
185
+ return globalize . formatDate ( date , { pattern : "MMMM" } ) ;
186
+ } ,
187
+ formatWeekOfYear : function ( date ) {
188
+ return globalize . formatDate ( date , { pattern : "w" } ) ;
189
+ } ,
190
+ parse : this . _parse
191
+ } ;
200
192
} ,
201
193
202
194
_createCalendar : function ( ) {
@@ -527,11 +519,10 @@ return $.widget( "ui.calendar", {
527
519
} ,
528
520
529
521
value : function ( value ) {
530
- var locale = this . options . locale ;
531
522
if ( arguments . length ) {
532
- this . _setOption ( "value" , locale . parse ( value ) ) ;
523
+ this . _setOption ( "value" , this . _parse ( value ) ) ;
533
524
} else {
534
- return locale . format ( this . option ( "value" ) ) ;
525
+ return this . _format ( this . option ( "value" ) ) ;
535
526
}
536
527
} ,
537
528
@@ -615,7 +606,7 @@ return $.widget( "ui.calendar", {
615
606
616
607
if ( key === "locale" ) {
617
608
this . _setLocale ( value ) ;
618
- this . date . setAttributes ( this . options . locale ) ;
609
+ this . date . setAttributes ( this . _calendarDateOptions ) ;
619
610
this . refresh ( ) ;
620
611
}
621
612
0 commit comments