Skip to content

Commit d7939fa

Browse files
committed
Calendar: Add icons option support
1 parent 6fdf14f commit d7939fa

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

tests/unit/calendar/common.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ common.testWidget( "calendar", {
1717
disabled: false,
1818
dateFormat: { date: "short" },
1919
eachDay: $.noop,
20+
icons: {
21+
prevButton: "ui-icon-circle-triangle-w",
22+
nextButton: "ui-icon-circle-triangle-e"
23+
},
2024
labels: {
2125
"datePickerRole": "date picker",
2226
"nextText": "Next",

ui/widgets/calendar.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ return $.widget( "ui.calendar", {
5454
},
5555
dateFormat: { date: "short" },
5656
eachDay: $.noop,
57+
icons: {
58+
prevButton: "ui-icon-circle-triangle-w",
59+
nextButton: "ui-icon-circle-triangle-e"
60+
},
5761
labels: {
5862
"datePickerRole": "date picker",
5963
"nextText": "Next",
@@ -309,20 +313,21 @@ return $.widget( "ui.calendar", {
309313
_buildHeaderButtons: function() {
310314
var buttons = $( "<div>" );
311315

312-
this.prevButton = $( "<button>", {
313-
html: "<span class='ui-icon ui-icon-circle-triangle-w'></span>"
314-
} );
315-
this.nextButton = $( "<button>", {
316-
html: "<span class='ui-icon ui-icon-circle-triangle-e'></span>"
317-
} );
318-
319-
this._addClass( buttons, "ui-calendar-header-buttons" )
320-
._addClass( this.prevButton, "ui-calendar-prev" )
321-
._addClass( this.nextButton, "ui-calendar-next" );
316+
this._addClass( buttons, "ui-calendar-header-buttons" );
322317

323318
return buttons
324-
.append( this.prevButton )
325-
.append( this.nextButton );
319+
.append( this.prevButton = this._buildIconButton( "prev" ) )
320+
.append( this.nextButton = this._buildIconButton( "next" ) );
321+
},
322+
323+
_buildIconButton: function( key ) {
324+
var button = $( "<button>" ),
325+
icon = $( "<span>" );
326+
327+
this._addClass( button, "ui-calendar-" + key )
328+
._addClass( icon, null, "ui-icon " + this.options.icons[ key + "Button" ] );
329+
330+
return button.append( icon );
326331
},
327332

328333
_buildHeader: function() {

0 commit comments

Comments
 (0)