Skip to content

Commit d6de67a

Browse files
committed
Calendar: Introduce getter / setter for grid id
1 parent 9bb209c commit d6de67a

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

ui/widgets/calendar.js

+16-8
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

@@ -287,7 +287,7 @@ return $.widget( "ui.calendar", {
287287

288288
this._addClass( header, "ui-calendar-header-first ui-calendar-header-last" );
289289
this.element
290-
.attr( "aria-labelledby", this.gridId + "-title" )
290+
.attr( "aria-labelledby", this._getGridId() + "-title" )
291291
.append( header )
292292
.append( this._buildGrid() );
293293
},
@@ -305,8 +305,8 @@ return $.widget( "ui.calendar", {
305305
// TODO: Shouldn't we pass date as a parameter to build* fns
306306
// instead of setting this.viewDate?
307307
this._setViewDate( months[ i ] );
308-
this.gridId = this.id + "-" + i;
309-
labelledBy.push( this.gridId + "-title" );
308+
this._setGridId( this.id + "-" + i );
309+
labelledBy.push( this._getGridId() + "-title" );
310310

311311
element = $( "<div>" );
312312
this._addClass( element, "ui-calendar-group" );
@@ -353,7 +353,7 @@ return $.widget( "ui.calendar", {
353353

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

359359
this._addClass( header, "ui-calendar-header", "ui-widget-header ui-helper-clearfix" )
@@ -367,7 +367,7 @@ return $.widget( "ui.calendar", {
367367
},
368368

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

@@ -394,7 +394,7 @@ return $.widget( "ui.calendar", {
394394
role: "grid",
395395
tabindex: 0,
396396
"aria-readonly": true,
397-
"aria-labelledby": this.gridId + "-month-label",
397+
"aria-labelledby": this._getGridId() + "-month-label",
398398
"aria-activedescendant": this._getDayId( this._getDate() )
399399
} );
400400

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

@@ -666,6 +666,14 @@ return $.widget( "ui.calendar", {
666666
} );
667667
},
668668

669+
_getGridId: function() {
670+
return this.gridId;
671+
},
672+
673+
_setGridId: function( id ) {
674+
this.gridId = id;
675+
},
676+
669677
_getDate: function() {
670678
return this.date;
671679
},

0 commit comments

Comments
 (0)