]> source.dussan.org Git - jquery-ui.git/commitdiff
Datepicker: Added additional check to checkExternalClick to work when clicking in...
authorkborchers <k_borchers@yahoo.com>
Mon, 12 Sep 2011 18:30:41 +0000 (13:30 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 16 Sep 2011 14:47:46 +0000 (10:47 -0400)
(cherry picked from commit af76ad1c82625521b94bfc8bf967d9ca4f44da37)

ui/jquery.ui.datepicker.js

index a0b81e86a5dac8689ea85c176981f79ebac0df13..e84535debfa9bf4d0aeaedca73e83a6223f32d1c 100644 (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();
        },