27
27
} ( function ( $ ) {
28
28
29
29
var widget ,
30
- calendarOptions = [ "dateFormat" , "eachDay" , "max" , "min" , "numberOfMonths" , "showWeek" ] ,
31
- // TODO Move this to the instance?
32
- suppressExpandOnFocus = false ;
30
+ calendarOptions = [ "dateFormat" , "eachDay" , "max" , "min" , "numberOfMonths" , "showWeek" ] ;
33
31
34
32
widget = $ . widget ( "ui.datepicker" , {
35
33
version : "@VERSION" ,
@@ -50,6 +48,7 @@ widget = $.widget( "ui.datepicker", {
50
48
} ,
51
49
52
50
_create : function ( ) {
51
+ this . suppressExpandOnFocus = false ;
53
52
this . _createCalendar ( ) ;
54
53
55
54
this . _on ( this . _inputEvents ) ;
@@ -92,9 +91,10 @@ widget = $.widget( "ui.datepicker", {
92
91
93
92
this . _setHiddenPicker ( ) ;
94
93
95
- this . element
96
- . attr ( "aria-haspopup" , "true" )
97
- . attr ( "aria-owns" , this . calendar . attr ( "id" ) ) ;
94
+ this . element . attr ( {
95
+ "aria-haspopup" : true ,
96
+ "aria-owns" : this . calendar . attr ( "id" )
97
+ } ) ;
98
98
} ,
99
99
100
100
_inputEvents : {
@@ -141,27 +141,25 @@ widget = $.widget( "ui.datepicker", {
141
141
} ,
142
142
mousedown : function ( event ) {
143
143
if ( this . isOpen ) {
144
- suppressExpandOnFocus = true ;
144
+ this . suppressExpandOnFocus = true ;
145
145
this . close ( ) ;
146
146
return ;
147
147
}
148
148
this . open ( event ) ;
149
149
clearTimeout ( this . closeTimer ) ;
150
150
} ,
151
151
focus : function ( event ) {
152
- if ( ! suppressExpandOnFocus ) {
152
+ if ( ! this . suppressExpandOnFocus && ! this . isOpen ) {
153
153
this . _delay ( function ( ) {
154
- if ( ! this . isOpen ) {
155
- this . open ( event ) ;
156
- }
154
+ this . open ( event ) ;
157
155
} , 1 ) ;
158
156
}
159
157
this . _delay ( function ( ) {
160
- suppressExpandOnFocus = false ;
158
+ this . suppressExpandOnFocus = false ;
161
159
} , 100 ) ;
162
160
} ,
163
161
blur : function ( ) {
164
- suppressExpandOnFocus = false ;
162
+ this . suppressExpandOnFocus = false ;
165
163
}
166
164
} ,
167
165
@@ -222,7 +220,7 @@ widget = $.widget( "ui.datepicker", {
222
220
} ,
223
221
224
222
_focusTrigger : function ( ) {
225
- suppressExpandOnFocus = true ;
223
+ this . suppressExpandOnFocus = true ;
226
224
this . element . focus ( ) ;
227
225
} ,
228
226
@@ -240,14 +238,14 @@ widget = $.widget( "ui.datepicker", {
240
238
}
241
239
242
240
this . calendarInstance . refresh ( ) ;
243
-
244
241
this . calendar
245
- . attr ( "aria-hidden" , "false" )
246
- . attr ( "aria-expanded" , "true" )
242
+ . attr ( {
243
+ "aria-hidden" : false ,
244
+ "aria-expanded" : true
245
+ } )
247
246
. show ( )
248
247
. position ( this . _buildPosition ( ) )
249
248
. hide ( ) ;
250
-
251
249
this . _show ( this . calendar , this . options . show ) ;
252
250
253
251
// Take trigger out of tab order to allow shift-tab to skip trigger
@@ -269,9 +267,10 @@ widget = $.widget( "ui.datepicker", {
269
267
} ,
270
268
271
269
_setHiddenPicker : function ( ) {
272
- this . calendar
273
- . attr ( "aria-hidden" , "true" )
274
- . attr ( "aria-expanded" , "false" ) ;
270
+ this . calendar . attr ( {
271
+ "aria-hidden" : true ,
272
+ "aria-expanded" : false
273
+ } ) ;
275
274
} ,
276
275
277
276
_buildPosition : function ( ) {
@@ -304,9 +303,7 @@ widget = $.widget( "ui.datepicker", {
304
303
_destroy : function ( ) {
305
304
this . calendarInstance . destroy ( ) ;
306
305
this . calendar . remove ( ) ;
307
- this . element
308
- . removeAttr ( "aria-haspopup" )
309
- . removeAttr ( "aria-owns" ) ;
306
+ this . element . removeAttr ( "aria-haspopup aria-owns" ) ;
310
307
} ,
311
308
312
309
widget : function ( ) {
@@ -337,7 +334,7 @@ widget = $.widget( "ui.datepicker", {
337
334
}
338
335
}
339
336
} ) ;
340
-
337
+
341
338
$ . each ( calendarOptions , function ( index , option ) {
342
339
$ . ui . datepicker . prototype . options [ option ] = $ . ui . calendar . prototype . options [ option ] ;
343
340
} ) ;
0 commit comments