aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkborchers <k_borchers@yahoo.com>2011-05-27 15:10:53 -0500
committerScott González <scott.gonzalez@gmail.com>2011-06-16 13:35:48 -0400
commit57b9e9d399fd5e04d60428ed98f585e49373dc85 (patch)
treec9fc9ac5a062037ff2129beef28db2af056fd8cf
parent4d8529cf8406a3feecbe30d57c2ceb366ec71eb4 (diff)
downloadjquery-ui-57b9e9d399fd5e04d60428ed98f585e49373dc85.tar.gz
jquery-ui-57b9e9d399fd5e04d60428ed98f585e49373dc85.zip
Datepicker: Calculate the max number of rows necessary when displaying months. Fixes #7043 - Datepicker: Using multiple months always renders 6 rows of dates even if only 5 are needed
(cherry picked from commit 1d984e76b79bfeda15eff392e06d8ed0eab72333)
-rw-r--r--ui/jquery.ui.datepicker.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index 35c1fc11e..66d2e3553 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -114,6 +114,9 @@ function Datepicker() {
$.extend(Datepicker.prototype, {
/* Class name added to elements to indicate already configured with a date picker. */
markerClassName: 'hasDatepicker',
+
+ //Keep track of the maximum number of rows displayed (see #7043)
+ maxRows: 4,
/* Debug logging (if enabled). */
log: function () {
@@ -680,6 +683,7 @@ $.extend(Datepicker.prototype, {
/* Generate the date picker content. */
_updateDatepicker: function(inst) {
var self = this;
+ self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
var borders = $.datepicker._getBorders(inst.dpDiv);
instActive = inst; // for delegate hover events
inst.dpDiv.empty().append(this._generateHTML(inst));
@@ -1501,7 +1505,9 @@ $.extend(Datepicker.prototype, {
if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
- var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate
+ var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
+ var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
+ this.maxRows = numRows;
var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
calender += '<tr>';