Datepicker: Added additional check to checkExternalClick to work when clicking in another datepicker and removed old fix. Fixes #7686 - infinite loop when onclose event shows a second calendar

(cherry picked from commit af76ad1c82)
This commit is contained in:
kborchers 2011-09-12 13:30:41 -05:00 committed by Scott González
parent af7d433818
commit 872387abd5

View File

@ -636,10 +636,10 @@ $.extend(Datepicker.prototype, {
return;
var inst = $.datepicker._getInst(input);
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
if ( $.datepicker._datepickerShowing ) {
$.datepicker._triggerOnClose($.datepicker._curInst);
}
$.datepicker._curInst.dpDiv.stop(true, true);
if ( inst && $.datepicker._datepickerShowing ) {
$.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
}
}
var beforeShow = $.datepicker._get(inst, 'beforeShow');
var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
@ -788,14 +788,6 @@ $.extend(Datepicker.prototype, {
return [position.left, position.top];
},
/* Trigger custom callback of onClose. */
_triggerOnClose: function(inst) {
var onClose = this._get(inst, 'onClose');
if (onClose)
onClose.apply((inst.input ? inst.input[0] : null),
[(inst.input ? inst.input.val() : ''), inst]);
},
/* Hide the date picker from view.
@param input element - the input field attached to the date picker */
_hideDatepicker: function(input) {
@ -816,8 +808,11 @@ $.extend(Datepicker.prototype, {
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
if (!showAnim)
postProcess();
$.datepicker._triggerOnClose(inst);
this._datepickerShowing = false;
var onClose = this._get(inst, 'onClose');
if (onClose)
onClose.apply((inst.input ? inst.input[0] : null),
[(inst.input ? inst.input.val() : ''), inst]);
this._lastInput = null;
if (this._inDialog) {
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
@ -839,12 +834,16 @@ $.extend(Datepicker.prototype, {
_checkExternalClick: function(event) {
if (!$.datepicker._curInst)
return;
var $target = $(event.target);
if ($target[0].id != $.datepicker._mainDivId &&
var $target = $(event.target),
inst = $.datepicker._getInst($target[0]);
if ( ( ( $target[0].id != $.datepicker._mainDivId &&
$target.parents('#' + $.datepicker._mainDivId).length == 0 &&
!$target.hasClass($.datepicker.markerClassName) &&
!$target.hasClass($.datepicker._triggerClass) &&
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
$.datepicker._hideDatepicker();
},