mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Datepicker - Fixed #4704 - Datepicker global variable isn't unique
This commit is contained in:
parent
d33c2de502
commit
707539f3cf
25
ui/jquery.ui.datepicker.js
vendored
25
ui/jquery.ui.datepicker.js
vendored
@ -16,6 +16,7 @@
|
|||||||
$.extend($.ui, { datepicker: { version: "@VERSION" } });
|
$.extend($.ui, { datepicker: { version: "@VERSION" } });
|
||||||
|
|
||||||
var PROP_NAME = 'datepicker';
|
var PROP_NAME = 'datepicker';
|
||||||
|
var dpuuid = new Date().getTime();
|
||||||
|
|
||||||
/* Date picker manager.
|
/* Date picker manager.
|
||||||
Use the singleton instance of this class, $.datepicker, to interact with the date picker.
|
Use the singleton instance of this class, $.datepicker, to interact with the date picker.
|
||||||
@ -1357,7 +1358,8 @@ $.extend(Datepicker.prototype, {
|
|||||||
this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
|
this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
|
||||||
this._getFormatConfig(inst)));
|
this._getFormatConfig(inst)));
|
||||||
var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
|
var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
|
||||||
'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
|
'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
||||||
|
'.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
|
||||||
' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
|
' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
|
||||||
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
|
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
|
||||||
var nextText = this._get(inst, 'nextText');
|
var nextText = this._get(inst, 'nextText');
|
||||||
@ -1365,16 +1367,19 @@ $.extend(Datepicker.prototype, {
|
|||||||
this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
|
this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
|
||||||
this._getFormatConfig(inst)));
|
this._getFormatConfig(inst)));
|
||||||
var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
|
var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
|
||||||
'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
|
'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
||||||
|
'.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
|
||||||
' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
|
' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
|
||||||
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
|
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
|
||||||
var currentText = this._get(inst, 'currentText');
|
var currentText = this._get(inst, 'currentText');
|
||||||
var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
|
var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
|
||||||
currentText = (!navigationAsDateFormat ? currentText :
|
currentText = (!navigationAsDateFormat ? currentText :
|
||||||
this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
|
this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
|
||||||
var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
|
var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
||||||
|
'.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
|
||||||
var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
|
var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
|
||||||
(this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery.datepicker._gotoToday(\'#' + inst.id + '\');"' +
|
(this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
||||||
|
'.datepicker._gotoToday(\'#' + inst.id + '\');"' +
|
||||||
'>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
|
'>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
|
||||||
var firstDay = parseInt(this._get(inst, 'firstDay'),10);
|
var firstDay = parseInt(this._get(inst, 'firstDay'),10);
|
||||||
firstDay = (isNaN(firstDay) ? 0 : firstDay);
|
firstDay = (isNaN(firstDay) ? 0 : firstDay);
|
||||||
@ -1447,7 +1452,7 @@ $.extend(Datepicker.prototype, {
|
|||||||
(printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
|
(printDate.getTime() == currentDate.getTime() ? ' ' + this._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 ? '' : ' onclick="DP_jQuery.datepicker._selectDay(\'#' +
|
(unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' +
|
||||||
inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions
|
inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions
|
||||||
(otherMonth && !showOtherMonths ? ' ' : // display for other months
|
(otherMonth && !showOtherMonths ? ' ' : // display for other months
|
||||||
(unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
|
(unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
|
||||||
@ -1492,8 +1497,8 @@ $.extend(Datepicker.prototype, {
|
|||||||
var inMinYear = (minDate && minDate.getFullYear() == drawYear);
|
var inMinYear = (minDate && minDate.getFullYear() == drawYear);
|
||||||
var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
|
var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
|
||||||
monthHtml += '<select class="ui-datepicker-month" ' +
|
monthHtml += '<select class="ui-datepicker-month" ' +
|
||||||
'onchange="DP_jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
|
'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
|
||||||
'onclick="DP_jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
||||||
'>';
|
'>';
|
||||||
for (var month = 0; month < 12; month++) {
|
for (var month = 0; month < 12; month++) {
|
||||||
if ((!inMinYear || month >= minDate.getMonth()) &&
|
if ((!inMinYear || month >= minDate.getMonth()) &&
|
||||||
@ -1524,8 +1529,8 @@ $.extend(Datepicker.prototype, {
|
|||||||
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
|
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
|
||||||
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
|
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
|
||||||
html += '<select class="ui-datepicker-year" ' +
|
html += '<select class="ui-datepicker-year" ' +
|
||||||
'onchange="DP_jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
|
'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
|
||||||
'onclick="DP_jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
||||||
'>';
|
'>';
|
||||||
for (; year <= endYear; year++) {
|
for (; year <= endYear; year++) {
|
||||||
html += '<option value="' + year + '"' +
|
html += '<option value="' + year + '"' +
|
||||||
@ -1685,6 +1690,6 @@ $.datepicker.version = "@VERSION";
|
|||||||
|
|
||||||
// Workaround for #4055
|
// Workaround for #4055
|
||||||
// Add another global to avoid noConflict issues with inline event handlers
|
// Add another global to avoid noConflict issues with inline event handlers
|
||||||
window.DP_jQuery = $;
|
window['DP_jQuery_' + dpuuid] = $;
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
Loading…
Reference in New Issue
Block a user