Skip to content

Commit 2ac81ad

Browse files
committed
Calendar: Introduce getter / setter for grid id
1 parent e3c4253 commit 2ac81ad

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

ui/widgets/calendar.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ return $.widget( "ui.calendar", {
8989

9090
_create: function() {
9191
this.id = this.element.uniqueId().attr( "id" );
92-
this.gridId = this.id;
92+
this._setGridId( this.id );
9393
this.labels = this.options.labels;
9494
this.buttonClickContext = this.element[ 0 ];
9595

@@ -285,7 +285,7 @@ return $.widget( "ui.calendar", {
285285

286286
this._addClass( header, "ui-calendar-header-first ui-calendar-header-last" );
287287
this.element
288-
.attr( "aria-labelledby", this.gridId + "-title" )
288+
.attr( "aria-labelledby", this._getGridId() + "-title" )
289289
.append( header )
290290
.append( this._buildGrid() );
291291
},
@@ -303,8 +303,8 @@ return $.widget( "ui.calendar", {
303303
// TODO: Shouldn't we pass date as a parameter to build* fns
304304
// instead of setting this.viewDate?
305305
this._setViewDate( months[ i ] );
306-
this.gridId = this.id + "-" + i;
307-
labelledBy.push( this.gridId + "-title" );
306+
this._setGridId( this.id + "-" + i );
307+
labelledBy.push( this._getGridId() + "-title" );
308308

309309
element = $( "<div>" );
310310
this._addClass( element, "ui-calendar-group" );
@@ -351,7 +351,7 @@ return $.widget( "ui.calendar", {
351351

352352
_buildHeader: function() {
353353
var header = $( "<div>" ),
354-
title = $( "<div>", { role: "header", id: this.gridId + "-title" } ),
354+
title = $( "<div>", { role: "header", id: this._getGridId() + "-title" } ),
355355
notice = $( "<span>" ).text( ", " + this._getTranslation( "datePickerRole" ) );
356356

357357
this._addClass( header, "ui-calendar-header", "ui-widget-header ui-helper-clearfix" )
@@ -365,7 +365,7 @@ return $.widget( "ui.calendar", {
365365
},
366366

367367
_buildTitle: function() {
368-
var title = $( "<div>", { role: "alert", id: this.gridId + "-month-label" } ),
368+
var title = $( "<div>", { role: "alert", id: this._getGridId() + "-month-label" } ),
369369
month = this._buildTitleMonth(),
370370
year = this._buildTitleYear();
371371

@@ -392,7 +392,7 @@ return $.widget( "ui.calendar", {
392392
role: "grid",
393393
tabindex: 0,
394394
"aria-readonly": true,
395-
"aria-labelledby": this.gridId + "-month-label",
395+
"aria-labelledby": this._getGridId() + "-month-label",
396396
"aria-activedescendant": this._getDayId( this._getDate() )
397397
} );
398398

@@ -464,7 +464,7 @@ return $.widget( "ui.calendar", {
464464
"role='gridcell'",
465465
"aria-selected='" + ( this._isCurrent( day ) ? true : false ) + "'",
466466
"aria-label='" + dayName + ", " + this._format( dateObject ) + "'",
467-
"aria-describedby='" + this.gridId + "-month-label'"
467+
"aria-describedby='" + this._getGridId() + "-month-label'"
468468
],
469469
selectable = ( day.selectable && this._isValid( dateObject ) );
470470

@@ -664,6 +664,14 @@ return $.widget( "ui.calendar", {
664664
} );
665665
},
666666

667+
_getGridId: function() {
668+
return this.gridId;
669+
},
670+
671+
_setGridId: function( id ) {
672+
this.gridId = id;
673+
},
674+
667675
_getDate: function() {
668676
return this.date;
669677
},

0 commit comments

Comments
 (0)