Skip to content

Commit

Permalink
Calendar: Add icons option support
Browse files Browse the repository at this point in the history
  • Loading branch information
fnagel committed Sep 29, 2016
1 parent 6fdf14f commit d7939fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
4 changes: 4 additions & 0 deletions tests/unit/calendar/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ common.testWidget( "calendar", {
disabled: false,
dateFormat: { date: "short" },
eachDay: $.noop,
icons: {
prevButton: "ui-icon-circle-triangle-w",
nextButton: "ui-icon-circle-triangle-e"
},
labels: {
"datePickerRole": "date picker",
"nextText": "Next",
Expand Down
29 changes: 17 additions & 12 deletions ui/widgets/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ return $.widget( "ui.calendar", {
},
dateFormat: { date: "short" },
eachDay: $.noop,
icons: {
prevButton: "ui-icon-circle-triangle-w",
nextButton: "ui-icon-circle-triangle-e"
},
labels: {
"datePickerRole": "date picker",
"nextText": "Next",
Expand Down Expand Up @@ -309,20 +313,21 @@ return $.widget( "ui.calendar", {
_buildHeaderButtons: function() {
var buttons = $( "<div>" );

this.prevButton = $( "<button>", {
html: "<span class='ui-icon ui-icon-circle-triangle-w'></span>"
} );
this.nextButton = $( "<button>", {
html: "<span class='ui-icon ui-icon-circle-triangle-e'></span>"
} );

this._addClass( buttons, "ui-calendar-header-buttons" )
._addClass( this.prevButton, "ui-calendar-prev" )
._addClass( this.nextButton, "ui-calendar-next" );
this._addClass( buttons, "ui-calendar-header-buttons" );

return buttons
.append( this.prevButton )
.append( this.nextButton );
.append( this.prevButton = this._buildIconButton( "prev" ) )
.append( this.nextButton = this._buildIconButton( "next" ) );
},

_buildIconButton: function( key ) {
var button = $( "<button>" ),
icon = $( "<span>" );

this._addClass( button, "ui-calendar-" + key )
._addClass( icon, null, "ui-icon " + this.options.icons[ key + "Button" ] );

return button.append( icon );
},

_buildHeader: function() {
Expand Down

0 comments on commit d7939fa

Please sign in to comment.