@@ -43,6 +43,7 @@ return $.widget( "ui.calendar", {
43
43
44
44
_create : function ( ) {
45
45
this . id = this . element . uniqueId ( ) . attr ( "id" ) ;
46
+ this . labels = Globalize . translate ( "datepicker" ) ;
46
47
47
48
this . date = $ . date ( this . options . value , this . options . dateFormat ) . select ( ) ;
48
49
this . date . eachDay = this . options . eachDay ;
@@ -73,7 +74,7 @@ return $.widget( "ui.calendar", {
73
74
"keydown .ui-calendar-calendar" : "_handleKeydown"
74
75
} ) ;
75
76
76
- this . element . on ( "mouseenter.calendar mouseleave.calendar" , ".ui-calendar-header a , .ui-calendar-calendar a" , function ( ) {
77
+ this . element . on ( "mouseenter.calendar mouseleave.calendar" , ".ui-calendar-header button , .ui-calendar-calendar a" , function ( ) {
77
78
$ ( this ) . toggleClass ( "ui-state-hover" ) ;
78
79
} ) ;
79
80
@@ -162,8 +163,6 @@ return $.widget( "ui.calendar", {
162
163
} )
163
164
. html ( pickerHtml ) ;
164
165
165
- this . element . find ( "button" ) . button ( ) ;
166
-
167
166
this . grid = this . element . find ( ".ui-calendar-calendar" ) ;
168
167
} ,
169
168
@@ -207,41 +206,39 @@ return $.widget( "ui.calendar", {
207
206
208
207
_buildHeader : function ( ) {
209
208
return "<div class='ui-calendar-header ui-widget-header ui-helper-clearfix ui-corner-all'>" +
210
- this . _buildPreviousLink ( ) +
211
- this . _buildNextLink ( ) +
212
- this . _buildTitlebar ( ) +
213
- "</div>" ;
209
+ this . _buildPreviousLink ( ) +
210
+ this . _buildNextLink ( ) +
211
+ this . _buildTitlebar ( ) +
212
+ "</div>" ;
214
213
} ,
215
214
216
215
_buildPreviousLink : function ( ) {
217
- var labels = Globalize . translate ( "datepicker" ) ;
218
-
219
- return "<button class='ui-calendar-prev ui-corner-all' title='" + labels . prevText + "'>" +
216
+ return "<button class='ui-calendar-prev ui-corner-all' title='" +
217
+ this . labels . prevText + "'>" +
220
218
"<span class='ui-icon ui-icon-circle-triangle-w'>" +
221
- labels . prevText +
219
+ this . labels . prevText +
222
220
"</span>" +
223
221
"</button>" ;
224
222
} ,
225
223
226
224
_buildNextLink : function ( ) {
227
- var labels = Globalize . translate ( "datepicker" ) ;
228
-
229
- return "<button class='ui-calendar-next ui-corner-all' title='" + labels . nextText + "'>" +
225
+ return "<button class='ui-calendar-next ui-corner-all' title='" +
226
+ this . labels . nextText + "'>" +
230
227
"<span class='ui-icon ui-icon-circle-triangle-e'>" +
231
- labels . nextText +
228
+ this . labels . nextText +
232
229
"</span>" +
233
230
"</button>" ;
234
231
} ,
235
232
236
233
_buildTitlebar : function ( ) {
237
- var labels = Globalize . translate ( "datepicker" ) ;
238
-
239
234
return "<div role='header' id='" + this . id + "-title'>" +
240
- "<div id='" + this . id + "-month-lbl' class='ui-calendar-title'>" +
241
- this . _buildTitle ( ) +
242
- "</div>" +
243
- "<span class='ui-helper-hidden-accessible'>, " + labels . datePickerRole + "</span>" +
244
- "</div>" ;
235
+ "<div id='" + this . id + "-month-lbl' class='ui-calendar-title'>" +
236
+ this . _buildTitle ( ) +
237
+ "</div>" +
238
+ "<span class='ui-helper-hidden-accessible'>, " +
239
+ this . labels . datePickerRole +
240
+ "</span>" +
241
+ "</div>" ;
245
242
} ,
246
243
247
244
_buildTitle : function ( ) {
@@ -255,36 +252,36 @@ return $.widget( "ui.calendar", {
255
252
256
253
_buildGrid : function ( ) {
257
254
return "<table class='ui-calendar-calendar' role='grid' aria-readonly='true' " +
258
- "aria-labelledby='" + this . id + "-month-lbl' tabindex='0' aria-activedescendant='" + this . id + "-" + this . date . day ( ) + "'>" +
259
- this . _buildGridHeading ( ) +
260
- this . _buildGridBody ( ) +
261
- "</table>" ;
255
+ "aria-labelledby='" + this . id + "-month-lbl' tabindex='0' " +
256
+ "aria-activedescendant='" + this . id + "-" + this . date . day ( ) + "'>" +
257
+ this . _buildGridHeading ( ) +
258
+ this . _buildGridBody ( ) +
259
+ "</table>" ;
262
260
} ,
263
261
264
262
_buildGridHeading : function ( ) {
265
263
var cells = "" ,
266
264
i = 0 ,
267
- labels = Globalize . translate ( "datepicker" ) ,
268
265
weekDayLength = this . date . weekdays ( ) . length ;
269
266
270
267
if ( this . options . showWeek ) {
271
- cells += "<th class='ui-calendar-week-col'>" + labels . weekHeader + "</th>" ;
268
+ cells += "<th class='ui-calendar-week-col'>" + this . labels . weekHeader + "</th>" ;
272
269
}
273
270
for ( ; i < weekDayLength ; i ++ ) {
274
271
cells += this . _buildGridHeaderCell ( this . date . weekdays ( ) [ i ] ) ;
275
272
}
276
273
277
274
return "<thead role='presentation'>" +
278
- "<tr role='row'>" + cells + "</tr>" +
279
- "</thead>" ;
275
+ "<tr role='row'>" + cells + "</tr>" +
276
+ "</thead>" ;
280
277
} ,
281
278
282
279
_buildGridHeaderCell : function ( day ) {
283
280
return "<th role='columnheader' abbr='" + day . fullname + "' aria-label='" + day . fullname + "'>" +
284
- "<span title='" + day . fullname + "'>" +
285
- day . shortname +
286
- "</span>" +
287
- "</th>" ;
281
+ "<span title='" + day . fullname + "'>" +
282
+ day . shortname +
283
+ "</span>" +
284
+ "</th>" ;
288
285
} ,
289
286
290
287
_buildGridBody : function ( ) {
@@ -339,7 +336,6 @@ return $.widget( "ui.calendar", {
339
336
340
337
_buildDayElement : function ( day , selectable ) {
341
338
var classes = [ "ui-state-default" ] ,
342
- labels = Globalize . translate ( "datepicker" ) ,
343
339
content = "" ;
344
340
345
341
if ( day === this . date && selectable ) {
@@ -364,18 +360,16 @@ return $.widget( "ui.calendar", {
364
360
}
365
361
366
362
if ( day . today ) {
367
- content += "<span class='ui-helper-hidden-accessible'>, " + labels . currentText + "</span>" ;
363
+ content += "<span class='ui-helper-hidden-accessible'>, " + this . labels . currentText + "</span>" ;
368
364
}
369
365
370
366
return content ;
371
367
} ,
372
368
373
369
_buildButtons : function ( ) {
374
- var labels = Globalize . translate ( "datepicker" ) ;
375
-
376
370
return "<div class='ui-calendar-buttonpane ui-widget-content'>" +
377
- "<button class='ui-calendar-current'>" + labels . currentText + "</button>" +
378
- "</div>" ;
371
+ "<button class='ui-calendar-current'>" + this . labels . currentText + "</button>" +
372
+ "</div>" ;
379
373
} ,
380
374
381
375
// Refreshing the entire calendar during interaction confuses screen readers, specifically
@@ -384,13 +378,18 @@ return $.widget( "ui.calendar", {
384
378
// with the prev and next links would cause loss of focus issues because the links being
385
379
// interacted with will disappear while focused.
386
380
refresh : function ( ) {
381
+ this . labels = Globalize . translate ( "datepicker" ) ;
387
382
388
383
// Determine which day gridcell to focus after refresh
389
384
// TODO: Prevent disabled cells from being focused
390
385
if ( this . options . numberOfMonths === 1 ) {
391
386
this . grid = $ ( this . _buildGrid ( ) ) ;
392
387
this . element . find ( ".ui-calendar-title" ) . html ( this . _buildTitle ( ) ) ;
393
388
this . element . find ( ".ui-calendar-calendar" ) . replaceWith ( this . grid ) ;
389
+ $ ( ".ui-calendar-prev" , this . element ) . attr ( "title" , this . labels . prevText )
390
+ . children ( ) . html ( this . labels . prevText ) ;
391
+ $ ( ".ui-calendar-next" , this . element ) . attr ( "title" , this . labels . nextText )
392
+ . children ( ) . html ( this . labels . nextText ) ;
394
393
} else {
395
394
this . _refreshMultiplePicker ( ) ;
396
395
}
0 commit comments