@@ -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 ;
@@ -198,41 +199,43 @@ return $.widget( "ui.calendar", {
198
199
199
200
_buildHeader : function ( ) {
200
201
return "<div class='ui-calendar-header ui-widget-header ui-helper-clearfix ui-corner-all'>" +
201
- this . _buildPreviousLink ( ) +
202
- this . _buildNextLink ( ) +
203
- this . _buildTitlebar ( ) +
204
- "</div>" ;
202
+ this . _buildPreviousLink ( ) +
203
+ this . _buildNextLink ( ) +
204
+ this . _buildTitlebar ( ) +
205
+ "</div>" ;
205
206
} ,
206
207
207
208
_buildPreviousLink : function ( ) {
208
- var labels = Globalize . translate ( "datepicker " ) ;
209
+ var prevText = this . _getTranslation ( "prevText " ) ;
209
210
210
- return "<button class='ui-calendar-prev ui-corner-all' title='" + labels . prevText + "'>" +
211
+ return "<button class='ui-calendar-prev ui-corner-all' title='" +
212
+ prevText + "'>" +
211
213
"<span class='ui-icon ui-icon-circle-triangle-w'>" +
212
- labels . prevText +
214
+ prevText +
213
215
"</span>" +
214
216
"</button>" ;
215
217
} ,
216
218
217
219
_buildNextLink : function ( ) {
218
- var labels = Globalize . translate ( "datepicker " ) ;
220
+ var nextText = this . _getTranslation ( "nextText " ) ;
219
221
220
- return "<button class='ui-calendar-next ui-corner-all' title='" + labels . nextText + "'>" +
222
+ return "<button class='ui-calendar-next ui-corner-all' title='" +
223
+ nextText + "'>" +
221
224
"<span class='ui-icon ui-icon-circle-triangle-e'>" +
222
- labels . nextText +
225
+ nextText +
223
226
"</span>" +
224
227
"</button>" ;
225
228
} ,
226
229
227
230
_buildTitlebar : function ( ) {
228
- var labels = Globalize . translate ( "datepicker" ) ;
229
-
230
231
return "<div role='header' id='" + this . id + "-title'>" +
231
232
"<div id='" + this . id + "-month-label' class='ui-calendar-title'>" +
232
- this . _buildTitle ( ) +
233
- "</div>" +
234
- "<span class='ui-helper-hidden-accessible'>, " + labels . datePickerRole + "</span>" +
235
- "</div>" ;
233
+ this . _buildTitle ( ) +
234
+ "</div>" +
235
+ "<span class='ui-helper-hidden-accessible'>, " +
236
+ this . _getTranslation ( "datePickerRole" ) +
237
+ "</span>" +
238
+ "</div>" ;
236
239
} ,
237
240
238
241
_buildTitle : function ( ) {
@@ -246,36 +249,36 @@ return $.widget( "ui.calendar", {
246
249
247
250
_buildGrid : function ( ) {
248
251
return "<table class='ui-calendar-calendar' role='grid' aria-readonly='true' " +
249
- "aria-labelledby='" + this . id + "-month-label' tabindex='0' aria-activedescendant='" + this . id + "-" + this . date . day ( ) + "'>" +
250
- this . _buildGridHeading ( ) +
251
- this . _buildGridBody ( ) +
252
- "</table>" ;
252
+ "aria-labelledby='" + this . id + "-month-label' tabindex='0' " +
253
+ "aria-activedescendant='" + this . id + "-" + this . date . day ( ) + "'>" +
254
+ this . _buildGridHeading ( ) +
255
+ this . _buildGridBody ( ) +
256
+ "</table>" ;
253
257
} ,
254
258
255
259
_buildGridHeading : function ( ) {
256
260
var cells = "" ,
257
261
i = 0 ,
258
- labels = Globalize . translate ( "datepicker" ) ,
259
262
weekDayLength = this . date . weekdays ( ) . length ;
260
263
261
264
if ( this . options . showWeek ) {
262
- cells += "<th class='ui-calendar-week-col'>" + labels . weekHeader + "</th>" ;
265
+ cells += "<th class='ui-calendar-week-col'>" + this . _getTranslation ( " weekHeader" ) + "</th>" ;
263
266
}
264
267
for ( ; i < weekDayLength ; i ++ ) {
265
268
cells += this . _buildGridHeaderCell ( this . date . weekdays ( ) [ i ] ) ;
266
269
}
267
270
268
271
return "<thead role='presentation'>" +
269
- "<tr role='row'>" + cells + "</tr>" +
270
- "</thead>" ;
272
+ "<tr role='row'>" + cells + "</tr>" +
273
+ "</thead>" ;
271
274
} ,
272
275
273
276
_buildGridHeaderCell : function ( day ) {
274
277
return "<th role='columnheader' abbr='" + day . fullname + "' aria-label='" + day . fullname + "'>" +
275
- "<span title='" + day . fullname + "'>" +
276
- day . shortname +
277
- "</span>" +
278
- "</th>" ;
278
+ "<span title='" + day . fullname + "'>" +
279
+ day . shortname +
280
+ "</span>" +
281
+ "</th>" ;
279
282
} ,
280
283
281
284
_buildGridBody : function ( ) {
@@ -330,7 +333,6 @@ return $.widget( "ui.calendar", {
330
333
331
334
_buildDayElement : function ( day , selectable ) {
332
335
var classes = [ "ui-state-default" ] ,
333
- labels = Globalize . translate ( "datepicker" ) ,
334
336
content = "" ;
335
337
336
338
if ( day === this . date && selectable ) {
@@ -355,18 +357,18 @@ return $.widget( "ui.calendar", {
355
357
}
356
358
357
359
if ( day . today ) {
358
- content += "<span class='ui-helper-hidden-accessible'>, " + labels . currentText + "</span>" ;
360
+ content += "<span class='ui-helper-hidden-accessible'>, " + this . _getTranslation ( " currentText" ) + "</span>" ;
359
361
}
360
362
361
363
return content ;
362
364
} ,
363
365
364
366
_buildButtons : function ( ) {
365
- var labels = Globalize . translate ( "datepicker" ) ;
366
-
367
367
return "<div class='ui-calendar-buttonpane ui-widget-content'>" +
368
- "<button class='ui-calendar-current'>" + labels . currentText + "</button>" +
369
- "</div>" ;
368
+ "<button class='ui-calendar-current'>" +
369
+ this . _getTranslation ( "currentText" ) +
370
+ "</button>" +
371
+ "</div>" ;
370
372
} ,
371
373
372
374
// Refreshing the entire calendar during interaction confuses screen readers, specifically
@@ -375,13 +377,18 @@ return $.widget( "ui.calendar", {
375
377
// with the prev and next links would cause loss of focus issues because the links being
376
378
// interacted with will disappear while focused.
377
379
refresh : function ( ) {
380
+ this . labels = Globalize . translate ( "datepicker" ) ;
378
381
379
382
// Determine which day gridcell to focus after refresh
380
383
// TODO: Prevent disabled cells from being focused
381
384
if ( this . options . numberOfMonths === 1 ) {
382
385
this . grid = $ ( this . _buildGrid ( ) ) ;
383
386
this . element . find ( ".ui-calendar-title" ) . html ( this . _buildTitle ( ) ) ;
384
387
this . element . find ( ".ui-calendar-calendar" ) . replaceWith ( this . grid ) ;
388
+ $ ( ".ui-calendar-prev" , this . element ) . attr ( "title" , this . labels . prevText )
389
+ . children ( ) . html ( this . labels . prevText ) ;
390
+ $ ( ".ui-calendar-next" , this . element ) . attr ( "title" , this . labels . nextText )
391
+ . children ( ) . html ( this . labels . nextText ) ;
385
392
} else {
386
393
this . _refreshMultiplePicker ( ) ;
387
394
}
@@ -402,6 +409,10 @@ return $.widget( "ui.calendar", {
402
409
this . element . find ( ".ui-state-focus" ) . not ( ":first" ) . removeClass ( "ui-state-focus" ) ;
403
410
} ,
404
411
412
+ _getTranslation : function ( key ) {
413
+ return $ ( "<a>" ) . text ( this . labels [ key ] ) . html ( ) ;
414
+ } ,
415
+
405
416
_setHiddenPicker : function ( ) {
406
417
this . element . attr ( {
407
418
"aria-hidden" : "true" ,
0 commit comments