26
26
}
27
27
} ( function ( $ ) {
28
28
29
- // TODO Use uniqueId, if possible
30
- var idIncrement = 0 ,
31
- // TODO Move this to the instance
29
+ var widget ,
30
+ calendarOptions = [ "dateFormat" , "eachDay" , "max" , "min" , "numberOfMonths" , "showWeek" ] ,
31
+ // TODO Move this to the instance?
32
32
suppressExpandOnFocus = false ;
33
33
34
- $ . widget ( "ui.datepicker" , {
34
+ widget = $ . widget ( "ui.datepicker" , {
35
35
version : "@VERSION" ,
36
36
options : {
37
37
appendTo : null ,
38
- dateFormat : { date : "short" } ,
39
- // TODO Review
40
- eachDay : $ . noop ,
41
- max : null ,
42
- min : null ,
43
- numberOfMonths : 1 ,
44
38
position : {
45
39
my : "left top" ,
46
40
at : "left bottom"
47
41
} ,
48
- showWeek : false ,
49
42
show : true ,
50
43
hide : true ,
51
44
@@ -86,21 +79,15 @@ $.widget( "ui.datepicker", {
86
79
87
80
// Initialize calendar widget
88
81
this . calendarInstance = this . calendar
89
- . calendar ( {
90
- dateFormat : this . options . dateFormat ,
91
- eachDay : this . options . eachDay ,
92
- max : this . options . max ,
93
- min : this . options . min ,
94
- numberOfMonths : this . options . numberOfMonths ,
95
- showWeek : this . options . showWeek ,
82
+ . calendar ( $ . extend ( { } , this . options , {
96
83
value : this . _getParsedValue ( ) ,
97
84
select : function ( event ) {
98
85
that . element . val ( that . calendarInstance . value ( ) ) ;
99
86
that . close ( ) ;
100
87
that . _focusTrigger ( ) ;
101
88
that . _trigger ( "select" , event ) ;
102
89
}
103
- } )
90
+ } ) )
104
91
. calendar ( "instance" ) ;
105
92
106
93
this . _setHiddenPicker ( ) ;
@@ -329,7 +316,7 @@ $.widget( "ui.datepicker", {
329
316
_setOption : function ( key , value ) {
330
317
this . _super ( key , value ) ;
331
318
332
- if ( $ . inArray ( key , [ "showWeek" , "numberOfMonths" , "dateFormat" , "eachDay" , "min" , "max" ] ) !== - 1 ) {
319
+ if ( $ . inArray ( key , calendarOptions ) !== - 1 ) {
333
320
this . calendarInstance . _setOption ( key , value ) ;
334
321
}
335
322
@@ -346,4 +333,11 @@ $.widget( "ui.datepicker", {
346
333
}
347
334
}
348
335
} ) ;
336
+
337
+ $ . each ( calendarOptions , function ( index , option ) {
338
+ $ . ui . datepicker . prototype . options [ option ] = $ . ui . calendar . prototype . options [ option ] ;
339
+ } ) ;
340
+
341
+ return widget ;
342
+
349
343
} ) ) ;
0 commit comments