r3483 committed - Datepicker - Fixed #4885 - Tab key should not have default behaviour p...

r3483 committed - Datepicker - Fixed #4885 - Tab key should not have default behaviour p...

Revision: 3483
Author: kbwood.au@gmail.com
Date: Sun Nov 29 16:03:36 2009
Log: Datepicker - Fixed #4885 - Tab key should not have default behaviour
prevented by datepicker
http://code.google.com/p/jquery-ui/source/detail?r=3483
Modified:
/trunk/ui/jquery.ui.datepicker.js
=======================================
--- /trunk/ui/jquery.ui.datepicker.js    Sun Nov 29 14:56:30 2009
+++ /trunk/ui/jquery.ui.datepicker.js    Sun Nov 29 16:03:36 2009
@@ -421,7 +421,7 @@
        }
        if (inst) {
            if (this._curInst == inst) {
-                this._hideDatepicker(null);
+                this._hideDatepicker();
            }
            var date = this._getDateDatepicker(target);
            extendRemove(inst.settings, settings);
@@ -475,17 +475,18 @@
        inst._keyEvent = true;
        if ($.datepicker._datepickerShowing)
            switch (event.keyCode) {
-                case 9: $.datepicker._hideDatepicker(null, '');
+                case 9: $.datepicker._hideDatepicker();
+                        handled = false;
                        break; // hide on tab out
                case 13: var sel = $('td.' + $.datepicker._dayOverClass +
                            ', td.' + $.datepicker._currentClass, inst.dpDiv);
                        if (sel[0])
                            $.datepicker._selectDay(event.target, inst.selectedMonth,
inst.selectedYear, sel[0]);
                        else
-                            $.datepicker._hideDatepicker(null,
$.datepicker._get(inst, 'duration'));
+                            $.datepicker._hideDatepicker();
                        return false; // don't submit the form
                        break; // select the value on enter
-                case 27: $.datepicker._hideDatepicker(null,
$.datepicker._get(inst, 'duration'));
+                case 27: $.datepicker._hideDatepicker();
                        break; // hide on escape
                case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
                            -$.datepicker._get(inst, 'stepBigMonths') :
@@ -575,9 +576,11 @@
        if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput
== input) // already here
            return;
        var inst = $.datepicker._getInst(input);
+        if ($.datepicker._curInst && $.datepicker._curInst != inst) {
+            $.datepicker._curInst.dpDiv.stop(true, true);
+        }
        var beforeShow = $.datepicker._get(inst, 'beforeShow');
        extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input,
[input, inst]) : {}));
-        $.datepicker._hideDatepicker(null, '');
        $.datepicker._lastInput = input;
        $.datepicker._setDateFromField(inst);
        if ($.datepicker._inDialog) // hide cursor
@@ -713,17 +716,17 @@
    },
    /* Hide the date picker from view.
-     @param input element - the input field attached to the date picker
-     @param duration string - the duration over which to close the date
picker */
-    _hideDatepicker: function(input, duration) {
+     @param input element - the input field attached to the date picker */
+    _hideDatepicker: function(input) {
        var inst = this._curInst;
        if (!inst || (input && inst != $.data(input, PROP_NAME)))
            return;
        if (this._datepickerShowing) {
-            duration = duration || this._get(inst, 'duration');
            var showAnim = this._get(inst, 'showAnim');
+            var duration = this._get(inst, 'duration');
            var postProcess = function() {
                $.datepicker._tidyDialog(inst);
+                this._curInst = null;
            };
            if ($.effects && $.effects[showAnim])
                inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'),
duration, postProcess);
@@ -747,7 +750,6 @@
            }
            this._inDialog = false;
        }
-        this._curInst = null;
    },
    /* Tidy up after a dialog display. */
@@ -764,7 +766,7 @@
                !$target.hasClass($.datepicker.markerClassName) &&
                !$target.hasClass($.datepicker._triggerClass) &&
                $.datepicker._datepickerShowing && !($.datepicker._inDialog &&
$.blockUI))
-            $.datepicker._hideDatepicker(null, '');
+            $.datepicker._hideDatepicker();
    },
    /* Adjust one of the date sub-fields. */
@@ -857,7 +859,7 @@
        if (inst.inline)
            this._updateDatepicker(inst);
        else {
-            this._hideDatepicker(null, this._get(inst, 'duration'));
+            this._hideDatepicker();
            this._lastInput = inst.input[0];
            if (typeof(inst.input[0]) != 'object')
                inst.input[0].focus(); // restore focus
--