From 2bcfa70e639b502425033178eaa648d30e810f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Witkowski?= Date: Mon, 16 Sep 2013 12:13:53 +0200 Subject: [PATCH] Fix first day in calendar error / number of rows in calendar. When first day of month is sunday and option -use Monday as first day is set in calendar widget the month start form Monday. Problem when some month need more that 5 rows to show all days. --- javascript/calendar_widget.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/javascript/calendar_widget.js b/javascript/calendar_widget.js index 85febf6..601c26d 100755 --- a/javascript/calendar_widget.js +++ b/javascript/calendar_widget.js @@ -25,6 +25,7 @@ this.firstDay = new Date(this.year, this.month, 1); this.startingDay = this.firstDay.getDay(); if($.CalendarWidget.settings.startOnMonday) { + if(this.startingDay === 0) this.startingDay=6; else this.startingDay--; } this.monthLength = this.settings.calDaysInMonth[this.month]; @@ -162,7 +163,7 @@ var cell = 1; var empties = 0; - var row_count = Math.ceil(this.monthLength/7); + var row_count = Math.ceil((this.monthLength+this.startingDay)/7); for (var i = 0; i < row_count; i++) { for (var j = 0; j <= 6; j++) { date = "";