31
31
}
32
32
} ( function ( $ ) {
33
33
34
- // TODO Use uniqueId, if possible
35
- var idIncrement = 0 ,
36
- // TODO Move this to the instance
34
+ var widget ,
35
+ calendarOptions = [ "dateFormat" , "eachDay" , "max" , "min" , "numberOfMonths" , "showWeek" ] ,
36
+ // TODO Move this to the instance?
37
37
suppressExpandOnFocus = false ;
38
38
39
- $ . widget ( "ui.datepicker" , {
39
+ widget = $ . widget ( "ui.datepicker" , {
40
40
version : "@VERSION" ,
41
41
options : {
42
42
appendTo : null ,
43
- dateFormat : { date : "short" } ,
44
- // TODO Review
45
- eachDay : $ . noop ,
46
- max : null ,
47
- min : null ,
48
- numberOfMonths : 1 ,
49
43
position : {
50
44
my : "left top" ,
51
45
at : "left bottom"
52
46
} ,
53
- showWeek : false ,
54
47
show : true ,
55
48
hide : true ,
56
49
@@ -94,21 +87,15 @@ $.widget( "ui.datepicker", {
94
87
95
88
// Initialize calendar widget
96
89
this . calendarInstance = this . calendar
97
- . calendar ( {
98
- dateFormat : this . options . dateFormat ,
99
- eachDay : this . options . eachDay ,
100
- max : this . options . max ,
101
- min : this . options . min ,
102
- numberOfMonths : this . options . numberOfMonths ,
103
- showWeek : this . options . showWeek ,
90
+ . calendar ( $ . extend ( { } , this . options , {
104
91
value : this . _getParsedValue ( ) ,
105
92
select : function ( event ) {
106
93
that . element . val ( that . calendarInstance . value ( ) ) ;
107
94
that . close ( ) ;
108
95
that . _focusTrigger ( ) ;
109
96
that . _trigger ( "select" , event ) ;
110
97
}
111
- } )
98
+ } ) )
112
99
. calendar ( "instance" ) ;
113
100
114
101
this . _setHiddenPicker ( ) ;
@@ -322,7 +309,7 @@ $.widget( "ui.datepicker", {
322
309
_setOption : function ( key , value ) {
323
310
this . _super ( key , value ) ;
324
311
325
- if ( $ . inArray ( key , [ "showWeek" , "numberOfMonths" , "dateFormat" , "eachDay" , "min" , "max" ] ) !== - 1 ) {
312
+ if ( $ . inArray ( key , calendarOptions ) !== - 1 ) {
326
313
this . calendarInstance . option ( key , value ) ;
327
314
}
328
315
@@ -339,4 +326,11 @@ $.widget( "ui.datepicker", {
339
326
}
340
327
}
341
328
} ) ;
329
+
330
+ $ . each ( calendarOptions , function ( index , option ) {
331
+ $ . ui . datepicker . prototype . options [ option ] = $ . ui . calendar . prototype . options [ option ] ;
332
+ } ) ;
333
+
334
+ return widget ;
335
+
342
336
} ) ) ;
0 commit comments