Fix onClose bug for ranges in IE

Fix wrapper span bug in IE
Fix remove attribute bug in IE
Refactor more class names to constants
This commit is contained in:
Keith Wood 2008-06-13 13:20:55 +00:00
parent abdda174f2
commit b8b2a5acb8

View File

@ -34,6 +34,8 @@ function Datepicker() {
this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
this._promptClass = 'ui-datepicker-prompt'; // The name of the dialog prompt marker class this._promptClass = 'ui-datepicker-prompt'; // The name of the dialog prompt marker class
this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
this.regional = []; // Available regional settings, indexed by language code this.regional = []; // Available regional settings, indexed by language code
this.regional[''] = { // Default regional settings this.regional[''] = { // Default regional settings
clearText: 'Clear', // Display text for clear link clearText: 'Clear', // Display text for clear link
@ -179,8 +181,8 @@ $.extend(Datepicker.prototype, {
_destroyDatepicker: function(target) { _destroyDatepicker: function(target) {
var nodeName = target.nodeName.toLowerCase(); var nodeName = target.nodeName.toLowerCase();
var calId = target._calId; var calId = target._calId;
target._calId = null;
var $target = $(target); var $target = $(target);
$target.removeAttr('_calId');
if (nodeName == 'input') { if (nodeName == 'input') {
$target.siblings('.' + this._appendClass).replaceWith('').end() $target.siblings('.' + this._appendClass).replaceWith('').end()
.siblings('.' + this._triggerClass).replaceWith('').end() .siblings('.' + this._triggerClass).replaceWith('').end()
@ -329,7 +331,7 @@ $.extend(Datepicker.prototype, {
if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
input.focus(this._showDatepicker); input.focus(this._showDatepicker);
if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
input.wrap('<span class="' + this._wrapClass + '">'); input.wrap('<span class="' + this._wrapClass + '"></span>');
var buttonText = inst._get('buttonText'); var buttonText = inst._get('buttonText');
var buttonImage = inst._get('buttonImage'); var buttonImage = inst._get('buttonImage');
var trigger = $(inst._get('buttonImageOnly') ? var trigger = $(inst._get('buttonImageOnly') ?
@ -627,31 +629,35 @@ $.extend(Datepicker.prototype, {
/* Action for selecting a day. */ /* Action for selecting a day. */
_selectDay: function(id, month, year, td) { _selectDay: function(id, month, year, td) {
if ($(td).is('.ui-datepicker-unselectable')) if ($(td).hasClass(this._unselectableClass))
return; return;
var inst = this._getInst(id); var inst = this._getInst(id);
var rangeSelect = inst._get('rangeSelect'); var rangeSelect = inst._get('rangeSelect');
if (rangeSelect) { if (rangeSelect) {
if (!this._stayOpen) {
$('.ui-datepicker td').removeClass('ui-datepicker-current-day');
$(td).addClass('ui-datepicker-current-day');
}
this._stayOpen = !this._stayOpen; this._stayOpen = !this._stayOpen;
if (this._stayOpen) {
$('.ui-datepicker td').removeClass(this._currentClass);
$(td).addClass(this._currentClass);
}
} }
inst._selectedDay = inst._currentDay = $('a', td).html(); inst._selectedDay = inst._currentDay = $('a', td).html();
inst._selectedMonth = inst._currentMonth = month; inst._selectedMonth = inst._currentMonth = month;
inst._selectedYear = inst._currentYear = year; inst._selectedYear = inst._currentYear = year;
this._selectDate(id, inst._formatDate(
inst._currentDay, inst._currentMonth, inst._currentYear));
if (this._stayOpen) { if (this._stayOpen) {
inst._endDay = inst._endMonth = inst._endYear = null; inst._endDay = inst._endMonth = inst._endYear = null;
inst._rangeStart = new Date(inst._currentYear, inst._currentMonth, inst._currentDay);
this._updateDatepicker(inst);
} }
else if (rangeSelect) { else if (rangeSelect) {
inst._endDay = inst._currentDay; inst._endDay = inst._currentDay;
inst._endMonth = inst._currentMonth; inst._endMonth = inst._currentMonth;
inst._endYear = inst._currentYear; inst._endYear = inst._currentYear;
}
this._selectDate(id, inst._formatDate(
inst._currentDay, inst._currentMonth, inst._currentYear));
if (this._stayOpen) {
inst._rangeStart = new Date(inst._currentYear, inst._currentMonth, inst._currentDay);
this._updateDatepicker(inst);
}
else if (rangeSelect) {
inst._selectedDay = inst._currentDay = inst._rangeStart.getDate(); inst._selectedDay = inst._currentDay = inst._rangeStart.getDate();
inst._selectedMonth = inst._currentMonth = inst._rangeStart.getMonth(); inst._selectedMonth = inst._currentMonth = inst._rangeStart.getMonth();
inst._selectedYear = inst._currentYear = inst._rangeStart.getFullYear(); inst._selectedYear = inst._currentYear = inst._rangeStart.getFullYear();
@ -1101,7 +1107,7 @@ $.extend(DatepickerInstance.prototype, {
var startDate = (!this._currentYear || (this._input && this._input.val() == '') ? null : var startDate = (!this._currentYear || (this._input && this._input.val() == '') ? null :
new Date(this._currentYear, this._currentMonth, this._currentDay)); new Date(this._currentYear, this._currentMonth, this._currentDay));
if (this._get('rangeSelect')) { if (this._get('rangeSelect')) {
return [startDate, (!this._endYear ? null : return [this._rangeStart || startDate, (!this._endYear ? null :
new Date(this._endYear, this._endMonth, this._endDay))]; new Date(this._endYear, this._endMonth, this._endDay))];
} else } else
return startDate; return startDate;
@ -1216,10 +1222,10 @@ $.extend(DatepickerInstance.prototype, {
(otherMonth ? ' ui-datepicker-otherMonth' : '') + // highlight days from other months (otherMonth ? ' ui-datepicker-otherMonth' : '') + // highlight days from other months
(printDate.getTime() == selectedDate.getTime() && drawMonth == this._selectedMonth ? (printDate.getTime() == selectedDate.getTime() && drawMonth == this._selectedMonth ?
' ui-datepicker-days-cell-over' : '') + // highlight selected day ' ui-datepicker-days-cell-over' : '') + // highlight selected day
(unselectable ? ' ui-datepicker-unselectable' : '') + // highlight unselectable days (unselectable ? ' ' + $.datepicker._unselectableClass : '') + // highlight unselectable days
(otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
(printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range
' ui-datepicker-current-day' : '') + // highlight selected day ' ' + $.datepicker._currentClass : '') + // highlight selected day
(printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different) (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
(unselectable ? '' : ' onmouseover="jQuery(this).addClass(\'ui-datepicker-days-cell-over\');' + (unselectable ? '' : ' onmouseover="jQuery(this).addClass(\'ui-datepicker-days-cell-over\');' +