aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.datepicker.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-07-25 11:53:14 -0400
committerScott González <scott.gonzalez@gmail.com>2011-07-25 11:53:14 -0400
commit19a9de7e668cdb3b76c3b733d0147f1853cb38a5 (patch)
treea259b421dd77cbec27e55db9b4d1104bf5214a2a /ui/jquery.ui.datepicker.js
parentdaadc343be2f139e82719e2e5ff466aa19ec166f (diff)
parent51ee3be39829e339c8e4bccb532347944e600ca5 (diff)
downloadjquery-ui-19a9de7e668cdb3b76c3b733d0147f1853cb38a5.tar.gz
jquery-ui-19a9de7e668cdb3b76c3b733d0147f1853cb38a5.zip
Merge branch 'master' into core-1.6.1
Conflicts: demos/menubar/default.html tests/unit/autocomplete/autocomplete.html tests/visual/effects/effects.all.html ui/jquery.ui.menu.js ui/jquery.ui.popup.js
Diffstat (limited to 'ui/jquery.ui.datepicker.js')
-rw-r--r--ui/jquery.ui.datepicker.js47
1 files changed, 41 insertions, 6 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index aa42c972e..9f7f0b6e1 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -105,7 +105,8 @@ function Datepicker() {
altFormat: '', // The date format to use for the alternate field
constrainInput: true, // The input is constrained by the current date format
showButtonPanel: false, // True to show button panel, false to not show it
- autoSize: false // True to size the input for the date format, false to leave as is
+ autoSize: false, // True to size the input for the date format, false to leave as is
+ disabled: false // The initial disabled state
};
$.extend(this._defaults, this.regional['']);
this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
@@ -114,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 () {
@@ -194,6 +198,10 @@ $.extend(Datepicker.prototype, {
});
this._autoSize(inst);
$.data(target, PROP_NAME, inst);
+ //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
+ if( inst.settings.disabled ) {
+ this._disableDatepicker( target );
+ }
},
/* Make attachments based on settings. */
@@ -273,7 +281,13 @@ $.extend(Datepicker.prototype, {
this._setDate(inst, this._getDefaultDate(inst), true);
this._updateDatepicker(inst);
this._updateAlternate(inst);
- inst.dpDiv.show();
+ //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
+ if( inst.settings.disabled ) {
+ this._disableDatepicker( target );
+ }
+ // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
+ // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
+ inst.dpDiv.css( "display", "block" );
},
/* Pop-up the date picker in a "dialog" box.
@@ -517,6 +531,13 @@ $.extend(Datepicker.prototype, {
$.datepicker._currentClass + ')', inst.dpDiv);
if (sel[0])
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
+ var onSelect = $.datepicker._get(inst, 'onSelect');
+ if (onSelect) {
+ var dateStr = $.datepicker._formatDate(inst);
+
+ // trigger custom callback
+ onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
+ }
else
$.datepicker._hideDatepicker();
return false; // don't submit the form
@@ -682,6 +703,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));
@@ -919,8 +941,7 @@ $.extend(Datepicker.prototype, {
else {
this._hideDatepicker();
this._lastInput = inst.input[0];
- if (typeof(inst.input[0]) != 'object')
- inst.input.focus(); // restore focus
+ inst.input.focus(); // restore focus
this._lastInput = null;
}
},
@@ -1083,7 +1104,10 @@ $.extend(Datepicker.prototype, {
}
}
if (iValue < value.length){
- throw "Extra/unparsed characters found in date: " + value.substring(iValue);
+ var extra = value.substr(iValue);
+ if (!/^\s+/.test(extra)) {
+ throw "Extra/unparsed characters found in date: " + extra;
+ }
}
if (year == -1)
year = new Date().getFullYear();
@@ -1380,6 +1404,14 @@ $.extend(Datepicker.prototype, {
if (inst.input) {
inst.input.val(clear ? '' : this._formatDate(inst));
}
+
+ var onSelect = this._get(inst, 'onSelect');
+ if (onSelect) {
+ var dateStr = this._formatDate(inst);
+
+ // trigger custom callback
+ onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
+ }
},
/* Retrieve the date(s) directly. */
@@ -1471,6 +1503,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';
@@ -1505,7 +1538,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>';