aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.datepicker.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-06-16 10:35:04 -0700
committerScott González <scott.gonzalez@gmail.com>2011-06-16 10:35:04 -0700
commitfb210ae1ec16cefb1e4d4dfaf7d55499cac53ab8 (patch)
tree8b66bd9fa76ed154f01142dee08b67ba0223e176 /ui/jquery.ui.datepicker.js
parent4bdbab9a671c1eaeaea0a2c179b74cde2f84d75e (diff)
parentabf833049d4e56b591595b65c5150baa0ff2223f (diff)
downloadjquery-ui-fb210ae1ec16cefb1e4d4dfaf7d55499cac53ab8.tar.gz
jquery-ui-fb210ae1ec16cefb1e4d4dfaf7d55499cac53ab8.zip
Merge pull request #353 from kborchers/bug_7043
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
Diffstat (limited to 'ui/jquery.ui.datepicker.js')
-rw-r--r--ui/jquery.ui.datepicker.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index ae3a9ac32..ee0a86338 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -115,6 +115,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 () {
@@ -691,6 +694,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));
@@ -1480,6 +1484,7 @@ $.extend(Datepicker.prototype, {
var html = '';
for (var row = 0; row < numMonths[0]; row++) {
var group = '';
+ this.maxRows = 4;
for (var col = 0; col < numMonths[1]; col++) {
var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
var cornerClass = ' ui-corner-all';
@@ -1514,7 +1519,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>';