mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Datepicker: Only generate yearshtml once. Fixes #7176 - Datepicker shows only single year in year dropdown if numberOfMonths > 1.
This commit is contained in:
parent
255a8dbba5
commit
98c53d8432
70
ui/jquery.ui.datepicker.js
vendored
70
ui/jquery.ui.datepicker.js
vendored
@ -1579,40 +1579,42 @@ $.extend(Datepicker.prototype, {
|
|||||||
if (!showMonthAfterYear)
|
if (!showMonthAfterYear)
|
||||||
html += monthHtml + (secondary || !(changeMonth && changeYear) ? ' ' : '');
|
html += monthHtml + (secondary || !(changeMonth && changeYear) ? ' ' : '');
|
||||||
// year selection
|
// year selection
|
||||||
inst.yearshtml = '';
|
if ( !inst.yearshtml ) {
|
||||||
if (secondary || !changeYear)
|
inst.yearshtml = '';
|
||||||
html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
|
if (secondary || !changeYear)
|
||||||
else {
|
html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
|
||||||
// determine range of years to display
|
else {
|
||||||
var years = this._get(inst, 'yearRange').split(':');
|
// determine range of years to display
|
||||||
var thisYear = new Date().getFullYear();
|
var years = this._get(inst, 'yearRange').split(':');
|
||||||
var determineYear = function(value) {
|
var thisYear = new Date().getFullYear();
|
||||||
var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
|
var determineYear = function(value) {
|
||||||
(value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
|
var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
|
||||||
parseInt(value, 10)));
|
(value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
|
||||||
return (isNaN(year) ? thisYear : year);
|
parseInt(value, 10)));
|
||||||
};
|
return (isNaN(year) ? thisYear : year);
|
||||||
var year = determineYear(years[0]);
|
};
|
||||||
var endYear = Math.max(year, determineYear(years[1] || ''));
|
var year = determineYear(years[0]);
|
||||||
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
|
var endYear = Math.max(year, determineYear(years[1] || ''));
|
||||||
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
|
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
|
||||||
inst.yearshtml += '<select class="ui-datepicker-year" ' +
|
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
|
||||||
'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
|
inst.yearshtml += '<select class="ui-datepicker-year" ' +
|
||||||
'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
|
||||||
'>';
|
'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
||||||
for (; year <= endYear; year++) {
|
'>';
|
||||||
inst.yearshtml += '<option value="' + year + '"' +
|
for (; year <= endYear; year++) {
|
||||||
(year == drawYear ? ' selected="selected"' : '') +
|
inst.yearshtml += '<option value="' + year + '"' +
|
||||||
'>' + year + '</option>';
|
(year == drawYear ? ' selected="selected"' : '') +
|
||||||
}
|
'>' + year + '</option>';
|
||||||
inst.yearshtml += '</select>';
|
}
|
||||||
//when showing there is no need for later update
|
inst.yearshtml += '</select>';
|
||||||
if( ! $.browser.mozilla ){
|
//when showing there is no need for later update
|
||||||
html += inst.yearshtml;
|
if( ! $.browser.mozilla ){
|
||||||
inst.yearshtml = null;
|
html += inst.yearshtml;
|
||||||
} else {
|
inst.yearshtml = null;
|
||||||
// will be replaced later with inst.yearshtml
|
} else {
|
||||||
html += '<select class="ui-datepicker-year"><option value="' + drawYear + '" selected="selected">' + drawYear + '</option></select>';
|
// will be replaced later with inst.yearshtml
|
||||||
|
html += '<select class="ui-datepicker-year"><option value="' + drawYear + '" selected="selected">' + drawYear + '</option></select>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
html += this._get(inst, 'yearSuffix');
|
html += this._get(inst, 'yearSuffix');
|
||||||
|
Loading…
Reference in New Issue
Block a user