Calendar: Fix weekday name jumping when using numberOfMonths option

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.
This commit is contained in:
Felix Nagel 2015-08-25 17:47:13 +02:00
parent 31d9184aa3
commit a307992375
2 changed files with 30 additions and 2 deletions

View 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

View 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>";