]> source.dussan.org Git - jquery-ui.git/commitdiff
Calendar: Fix weekday name jumping when using numberOfMonths option
authorFelix Nagel <info@felixnagel.com>
Tue, 25 Aug 2015 15:47:13 +0000 (17:47 +0200)
committerFelix Nagel <info@felixnagel.com>
Tue, 25 Aug 2015 15:47:13 +0000 (17:47 +0200)
Fixes weekday name jumping when clicking the last day of the last
grid. Includes some basic tests for multiple month demo and this
specific issue.

tests/unit/calendar/options.js
ui/widgets/calendar.js

index 5af5e479e5733518c0678adb1a3b8b2ae7ba8935..93f1995801558a9c0178298daf8cd3bfab46d2c6 100644 (file)
@@ -232,7 +232,35 @@ test( "min / max", function() {
        element
                .calendar( "option", { min: minDate, max: maxDate } )
                .calendar( "value", "1/4/09" );
-       testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value > max" );});
+       testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value > max" );
+});
+
+test( "numberOfMonths", function() {
+       expect( 5 );
+       var date = new Date( 2015, 8 - 1, 1 ),
+               input = $( "#calendar" ).calendar({
+                       numberOfMonths: 3,
+                       value: date
+               }),
+               container = input.calendar( "widget" );
+
+       equal( container.find( ".ui-calendar-group" ).length, 3, "3 calendar grids" );
+       equal(
+               container.find( "tbody:first td[id]:first" ).attr( "id" ),
+               "calendar-2015-7-1",
+               "Correct id set for first day of first grid"
+       );
+       equal(
+               container.find( "tbody:last td[id]:last" ).attr( "id" ),
+               "calendar-2015-9-31",
+               "Correct id set for last day of third grid"
+       );
+
+       // Test for jumping in weekday rendering after click on last day of last grid
+       equal( container.find( "thead:last th:last" ).text(), "Sa", "Before click: Last day is saturday" );
+       container.find( "tbody:last td[id]:last button" ).trigger( "mousedown" );
+       equal( container.find( "thead:last th:last" ).text(), "Sa", "After click: Last day is saturday" );
+});
 
 /*
 // TODO: Move this to $.date, Globalize or calendar widget
index 947d79d8d7118fdd6b132c2ef3b5c03f8d804a0a..a9a18994733d160e3d0535537eb6da0654947fa1 100644 (file)
@@ -329,7 +329,7 @@ return $.widget( "ui.calendar", {
                var cells = "",
                        i = 0,
                        weekDayLength = this.viewDate.weekdays().length,
-                       weekdays = this.date.weekdays();
+                       weekdays = this.viewDate.weekdays();
 
                if ( this.options.showWeek ) {
                        cells += "<th class='ui-calendar-week-col'>" + this._getTranslation( "weekHeader" ) + "</th>";