diff options
Diffstat (limited to 'ui/jquery.ui.datepicker.js')
-rw-r--r-- | ui/jquery.ui.datepicker.js | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 5892e2ddc..b433cb79b 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -16,7 +16,6 @@ $.extend($.ui, { datepicker: { version: "@VERSION" } }); var PROP_NAME = "datepicker", - dpuuid = new Date().getTime(), instActive; function getZindex( elem ) { @@ -775,9 +774,10 @@ $.extend(Datepicker.prototype, { inst.dpDiv[showAnim || "show"](showAnim ? duration : null); } - if (inst.input.is(":visible") && !inst.input.is(":disabled")) { + if ( $.datepicker._shouldFocusInput( inst ) ) { inst.input.focus(); } + $.datepicker._curInst = inst; } }, @@ -804,10 +804,7 @@ $.extend(Datepicker.prototype, { inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") + "Class"]("ui-datepicker-rtl"); - // #6694 - don't focus the input if it's already focused - // this breaks the change event in IE - if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input && - inst.input.is(":visible") && !inst.input.is(":disabled") && inst.input[0] !== document.activeElement) { + if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) { inst.input.focus(); } @@ -824,16 +821,11 @@ $.extend(Datepicker.prototype, { } }, - /* Retrieve the size of left and top borders for an element. - * @param elem (jQuery object) the element of interest - * @return (number[2]) the left and top borders - */ - _getBorders: function(elem) { - var convert = function(value) { - return {thin: 1, medium: 2, thick: 3}[value] || value; - }; - return [parseFloat(convert(elem.css("border-left-width"))), - parseFloat(convert(elem.css("border-top-width")))]; + // #6694 - don't focus the input if it's already focused + // this breaks the change event in IE + // Support: IE and jQuery <1.9 + _shouldFocusInput: function( inst ) { + return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" ); }, /* Check positioning to remain on screen. */ @@ -1580,27 +1572,27 @@ $.extend(Datepicker.prototype, { inst.dpDiv.find("[data-handler]").map(function () { var handler = { prev: function () { - window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, -stepMonths, "M"); + $.datepicker._adjustDate(id, -stepMonths, "M"); }, next: function () { - window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, +stepMonths, "M"); + $.datepicker._adjustDate(id, +stepMonths, "M"); }, hide: function () { - window["DP_jQuery_" + dpuuid].datepicker._hideDatepicker(); + $.datepicker._hideDatepicker(); }, today: function () { - window["DP_jQuery_" + dpuuid].datepicker._gotoToday(id); + $.datepicker._gotoToday(id); }, selectDay: function () { - window["DP_jQuery_" + dpuuid].datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this); + $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this); return false; }, selectMonth: function () { - window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "M"); + $.datepicker._selectMonthYear(id, this, "M"); return false; }, selectYear: function () { - window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "Y"); + $.datepicker._selectMonthYear(id, this, "Y"); return false; } }; @@ -2065,8 +2057,4 @@ $.datepicker.initialized = false; $.datepicker.uuid = new Date().getTime(); $.datepicker.version = "@VERSION"; -// Workaround for #4055 -// Add another global to avoid noConflict issues with inline event handlers -window["DP_jQuery_" + dpuuid] = $; - })(jQuery); |