]> source.dussan.org Git - jquery-ui.git/commitdiff
Calendar: Add icons option support
authorFelix Nagel <info@felixnagel.com>
Sat, 16 Apr 2016 15:20:58 +0000 (17:20 +0200)
committerFelix Nagel <info@felixnagel.com>
Thu, 29 Sep 2016 13:10:46 +0000 (15:10 +0200)
tests/unit/calendar/common.js
ui/widgets/calendar.js

index 586c505f8d87e213e9dbcfb75e77f165fbaed3a0..b6807ec84ef516b467f65d9af82ac7147255d7a5 100644 (file)
@@ -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",
index f84c4d1cf87d66698c021708895e9241f8f22535..4c9a03545682d6aa6647a32186588775eb63b5ec 100644 (file)
@@ -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",
@@ -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() {