]> source.dussan.org Git - jquery-ui.git/commitdiff
Datepicker: Remove core event/alias and deprecated module dependencies
authorAlexander Schmitz <arschmitz@gmail.com>
Thu, 14 May 2015 01:54:56 +0000 (21:54 -0400)
committerAlexander Schmitz <arschmitz@gmail.com>
Wed, 20 May 2015 18:27:55 +0000 (14:27 -0400)
demos/datepicker/animation.html
demos/datepicker/date-formats.html
demos/datepicker/localization.html
tests/unit/datepicker/core.js
tests/unit/datepicker/events.js
tests/unit/datepicker/options.js
ui/datepicker.js

index 990fd6262e3e71df54518b79993de43c44d19ed2..36860cb421aa1ca5644bb494cf66dcdb122ded0d 100644 (file)
@@ -19,7 +19,7 @@
        <script>
        $(function() {
                $( "#datepicker" ).datepicker();
-               $( "#anim" ).change(function() {
+               $( "#anim" ).on( "change", function() {
                        $( "#datepicker" ).datepicker( "option", "showAnim", $( this ).val() );
                });
        });
index 39be9aa1522991a6991b2458cf3be2cb874596c4..5664beb5b6fdc38b5c62e058aa121aad3dead8b7 100644 (file)
@@ -12,7 +12,7 @@
        <script>
        $(function() {
                $( "#datepicker" ).datepicker();
-               $( "#format" ).change(function() {
+               $( "#format" ).on( "change", function() {
                        $( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val() );
                });
        });
index 2761dd31baf6e11eb07a2538cc47525254f705a1..72933f011149282213aa971c915b3d63a23d2ae1 100644 (file)
@@ -16,7 +16,7 @@
        <script>
        $(function() {
                $( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] );
-               $( "#locale" ).change(function() {
+               $( "#locale" ).on( "change", function() {
                        $( "#datepicker" ).datepicker( "option",
                                $.datepicker.regional[ $( this ).val() ] );
                });
index f6e0dd58f6a84c99a12a12dd5489931558f90bd7..446f6757e7fb895ae2d741200ec5b32e728eb478 100644 (file)
@@ -8,7 +8,7 @@ define( [
 
 module( "datepicker: core", {
        setup: function() {
-               $( "body" ).focus();
+               $( "body" ).trigger( "focus" );
        }
 });
 
index ea69c1aaab582ee89718be0cb5802e28dec4e86f..634fb6b791af4112c1f7e247ebce651434c693f0 100644 (file)
@@ -137,14 +137,14 @@ test("beforeShowDay-getDate", function() {
                // support: IE <9, jQuery <1.8
                // In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
                $( "<span>January&#xa0;2010</span>" ).text(), "Initial month");
-       $("a.ui-datepicker-next", dp).click();
-       $("a.ui-datepicker-next", dp).click();
+       $("a.ui-datepicker-next", dp).trigger( "click" );
+       $("a.ui-datepicker-next", dp).trigger( "click" );
        // contains non-breaking space
        equal($("div.ui-datepicker-title").text(),
                $( "<span>March&#xa0;2010</span>" ).text(), "After next clicks");
        inp.datepicker("hide").datepicker("show");
-       $("a.ui-datepicker-prev", dp).click();
-       $("a.ui-datepicker-prev", dp).click();
+       $("a.ui-datepicker-prev", dp).trigger( "click" );
+       $("a.ui-datepicker-prev", dp).trigger( "click" );
        // contains non-breaking space
        equal($("div.ui-datepicker-title").text(),
                $( "<span>November&#xa0;2009</span>" ).text(), "After prev clicks");
index c8a30678b6bb6442bfc25fd66ed45658214d9514..573b29b32d29b974109b8824e8e0a91b7837700f 100644 (file)
@@ -154,9 +154,9 @@ test("change", function() {
 
                        testHelper.onFocus( inp, function() {
                                ok( !dp.is( ":visible" ), "Button - not rendered on focus" );
-                               button.click();
+                               button.trigger( "click" );
                                ok( dp.is( ":visible" ), "Button - rendered on button click" );
-                               button.click();
+                               button.trigger( "click" );
                                ok( !dp.is( ":visible" ), "Button - hidden on second button click" );
                                inp.datepicker( "hide" ).datepicker( "destroy" );
 
@@ -183,9 +183,9 @@ test("change", function() {
 
                        testHelper.onFocus( inp, function() {
                                ok( !dp.is( ":visible" ), "Image button - not rendered on focus" );
-                               image.click();
+                               image.trigger( "click" );
                                ok( dp.is( ":visible" ), "Image button - rendered on image click" );
-                               image.click();
+                               image.trigger( "click" );
                                ok( !dp.is( ":visible" ), "Image button - hidden on second image click" );
                                inp.datepicker( "hide" ).datepicker( "destroy" );
 
@@ -214,9 +214,9 @@ test("change", function() {
                                        ok( dp.is( ":visible" ), "Both - rendered on focus" );
                                        body.simulate( "mousedown", {} );
                                        ok( !dp.is( ":visible" ), "Both - hidden on external click" );
-                                       button.click();
+                                       button.trigger( "click" );
                                        ok( dp.is( ":visible" ), "Both - rendered on button click" );
-                                       button.click();
+                                       button.trigger( "click" );
                                        ok( !dp.is( ":visible" ), "Both - hidden on second button click" );
                                        inp.datepicker( "hide" ).datepicker( "destroy" );
 
index 5be0c6f0f9b33f6649b7e1b4e7e8c63ac2d6f59e..cf63cbb208642b96e2eca0dae204d991b1cfa502 100644 (file)
@@ -214,8 +214,8 @@ $.extend(Datepicker.prototype, {
                        return;
                }
                this._attachments(input, inst);
-               input.addClass(this.markerClassName).keydown(this._doKeyDown).
-                       keypress(this._doKeyPress).keyup(this._doKeyUp);
+               input.addClass(this.markerClassName).on( "keydown", this._doKeyDown).
+                       on( "keypress", this._doKeyPress).on( "keyup", this._doKeyUp);
                this._autoSize(inst);
                $.data(target, "datepicker", inst);
                //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
@@ -238,7 +238,7 @@ $.extend(Datepicker.prototype, {
                        input[isRTL ? "before" : "after"](inst.append);
                }
 
-               input.unbind("focus", this._showDatepicker);
+               input.off("focus", this._showDatepicker);
 
                if (inst.trigger) {
                        inst.trigger.remove();
@@ -246,7 +246,7 @@ $.extend(Datepicker.prototype, {
 
                showOn = this._get(inst, "showOn");
                if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
-                       input.focus(this._showDatepicker);
+                       input.on( "focus", this._showDatepicker );
                }
                if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
                        buttonText = this._get(inst, "buttonText");
@@ -258,7 +258,7 @@ $.extend(Datepicker.prototype, {
                                        html(!buttonImage ? buttonText : $("<img/>").attr(
                                        { src:buttonImage, alt:buttonText, title:buttonText })));
                        input[isRTL ? "before" : "after"](inst.trigger);
-                       inst.trigger.click(function() {
+                       inst.trigger.on( "click", function() {
                                if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
                                        $.datepicker._hideDatepicker();
                                } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
@@ -339,7 +339,7 @@ $.extend(Datepicker.prototype, {
                        id = "dp" + this.uuid;
                        this._dialogInput = $("<input type='text' id='" + id +
                                "' style='position: absolute; top: -100px; width: 0px;'/>");
-                       this._dialogInput.keydown(this._doKeyDown);
+                       this._dialogInput.on( "keydown", this._doKeyDown );
                        $("body").append(this._dialogInput);
                        inst = this._dialogInst = this._newInst(this._dialogInput, false);
                        inst.settings = {};
@@ -390,10 +390,10 @@ $.extend(Datepicker.prototype, {
                        inst.append.remove();
                        inst.trigger.remove();
                        $target.removeClass(this.markerClassName).
-                               unbind("focus", this._showDatepicker).
-                               unbind("keydown", this._doKeyDown).
-                               unbind("keypress", this._doKeyPress).
-                               unbind("keyup", this._doKeyUp);
+                               off("focus", this._showDatepicker).
+                               off("keydown", this._doKeyDown).
+                               off("keypress", this._doKeyPress).
+                               off("keyup", this._doKeyUp);
                } else if (nodeName === "div" || nodeName === "span") {
                        $target.removeClass(this.markerClassName).empty();
                }
@@ -798,7 +798,7 @@ $.extend(Datepicker.prototype, {
                        }
 
                        if ( $.datepicker._shouldFocusInput( inst ) ) {
-                               inst.input.focus();
+                               inst.input.trigger( "focus" );
                        }
 
                        $.datepicker._curInst = inst;
@@ -832,7 +832,7 @@ $.extend(Datepicker.prototype, {
                        "Class"]("ui-datepicker-rtl");
 
                if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
-                       inst.input.focus();
+                       inst.input.trigger( "focus" );
                }
 
                // deffered render of the years select (to avoid flashes on Firefox)
@@ -941,7 +941,7 @@ $.extend(Datepicker.prototype, {
 
        /* Tidy up after a dialog display. */
        _tidyDialog: function(inst) {
-               inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
+               inst.dpDiv.removeClass(this._dialogClass).off(".ui-datepicker-calendar");
        },
 
        /* Close date picker if clicked elsewhere. */
@@ -1058,7 +1058,7 @@ $.extend(Datepicker.prototype, {
                        this._hideDatepicker();
                        this._lastInput = inst.input[0];
                        if (typeof(inst.input[0]) !== "object") {
-                               inst.input.focus(); // restore focus
+                               inst.input.trigger( "focus" ); // restore focus
                        }
                        this._lastInput = null;
                }
@@ -1624,7 +1624,7 @@ $.extend(Datepicker.prototype, {
                                        return false;
                                }
                        };
-                       $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
+                       $(this).on(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
                });
        },
 
@@ -2007,7 +2007,7 @@ $.extend(Datepicker.prototype, {
  */
 function datepicker_bindHover(dpDiv) {
        var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
-       return dpDiv.delegate(selector, "mouseout", function() {
+       return dpDiv.on( "mouseout", selector, function() {
                        $(this).removeClass("ui-state-hover");
                        if (this.className.indexOf("ui-datepicker-prev") !== -1) {
                                $(this).removeClass("ui-datepicker-prev-hover");
@@ -2016,7 +2016,7 @@ function datepicker_bindHover(dpDiv) {
                                $(this).removeClass("ui-datepicker-next-hover");
                        }
                })
-               .delegate( selector, "mouseover", datepicker_handleMouseover );
+               .on( "mouseover", selector, datepicker_handleMouseover );
 }
 
 function datepicker_handleMouseover() {
@@ -2056,7 +2056,7 @@ $.fn.datepicker = function(options){
 
        /* Initialise the date picker. */
        if (!$.datepicker.initialized) {
-               $(document).mousedown($.datepicker._checkExternalClick);
+               $(document).on( "mousedown", $.datepicker._checkExternalClick );
                $.datepicker.initialized = true;
        }