Skip to content

Commit 183422b

Browse files
committed
Datepicker: Remove core event/alias and deprecated module dependencies
1 parent 12df1b7 commit 183422b

File tree

7 files changed

+32
-32
lines changed

7 files changed

+32
-32
lines changed

demos/datepicker/animation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<script>
2020
$(function() {
2121
$( "#datepicker" ).datepicker();
22-
$( "#anim" ).change(function() {
22+
$( "#anim" ).on( "change", function() {
2323
$( "#datepicker" ).datepicker( "option", "showAnim", $( this ).val() );
2424
});
2525
});

demos/datepicker/date-formats.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<script>
1313
$(function() {
1414
$( "#datepicker" ).datepicker();
15-
$( "#format" ).change(function() {
15+
$( "#format" ).on( "change", function() {
1616
$( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val() );
1717
});
1818
});

demos/datepicker/localization.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<script>
1717
$(function() {
1818
$( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] );
19-
$( "#locale" ).change(function() {
19+
$( "#locale" ).on( "change", function() {
2020
$( "#datepicker" ).datepicker( "option",
2121
$.datepicker.regional[ $( this ).val() ] );
2222
});

tests/unit/datepicker/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define( [
88

99
module( "datepicker: core", {
1010
setup: function() {
11-
$( "body" ).focus();
11+
$( "body" ).trigger( "focus" );
1212
}
1313
});
1414

tests/unit/datepicker/events.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ test("beforeShowDay-getDate", function() {
137137
// support: IE <9, jQuery <1.8
138138
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
139139
$( "<span>January&#xa0;2010</span>" ).text(), "Initial month");
140-
$("a.ui-datepicker-next", dp).click();
141-
$("a.ui-datepicker-next", dp).click();
140+
$("a.ui-datepicker-next", dp).trigger( "click" );
141+
$("a.ui-datepicker-next", dp).trigger( "click" );
142142
// contains non-breaking space
143143
equal($("div.ui-datepicker-title").text(),
144144
$( "<span>March&#xa0;2010</span>" ).text(), "After next clicks");
145145
inp.datepicker("hide").datepicker("show");
146-
$("a.ui-datepicker-prev", dp).click();
147-
$("a.ui-datepicker-prev", dp).click();
146+
$("a.ui-datepicker-prev", dp).trigger( "click" );
147+
$("a.ui-datepicker-prev", dp).trigger( "click" );
148148
// contains non-breaking space
149149
equal($("div.ui-datepicker-title").text(),
150150
$( "<span>November&#xa0;2009</span>" ).text(), "After prev clicks");

tests/unit/datepicker/options.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ test("change", function() {
154154

155155
testHelper.onFocus( inp, function() {
156156
ok( !dp.is( ":visible" ), "Button - not rendered on focus" );
157-
button.click();
157+
button.trigger( "click" );
158158
ok( dp.is( ":visible" ), "Button - rendered on button click" );
159-
button.click();
159+
button.trigger( "click" );
160160
ok( !dp.is( ":visible" ), "Button - hidden on second button click" );
161161
inp.datepicker( "hide" ).datepicker( "destroy" );
162162

@@ -183,9 +183,9 @@ test("change", function() {
183183

184184
testHelper.onFocus( inp, function() {
185185
ok( !dp.is( ":visible" ), "Image button - not rendered on focus" );
186-
image.click();
186+
image.trigger( "click" );
187187
ok( dp.is( ":visible" ), "Image button - rendered on image click" );
188-
image.click();
188+
image.trigger( "click" );
189189
ok( !dp.is( ":visible" ), "Image button - hidden on second image click" );
190190
inp.datepicker( "hide" ).datepicker( "destroy" );
191191

@@ -214,9 +214,9 @@ test("change", function() {
214214
ok( dp.is( ":visible" ), "Both - rendered on focus" );
215215
body.simulate( "mousedown", {} );
216216
ok( !dp.is( ":visible" ), "Both - hidden on external click" );
217-
button.click();
217+
button.trigger( "click" );
218218
ok( dp.is( ":visible" ), "Both - rendered on button click" );
219-
button.click();
219+
button.trigger( "click" );
220220
ok( !dp.is( ":visible" ), "Both - hidden on second button click" );
221221
inp.datepicker( "hide" ).datepicker( "destroy" );
222222

ui/datepicker.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ $.extend(Datepicker.prototype, {
214214
return;
215215
}
216216
this._attachments(input, inst);
217-
input.addClass(this.markerClassName).keydown(this._doKeyDown).
218-
keypress(this._doKeyPress).keyup(this._doKeyUp);
217+
input.addClass(this.markerClassName).on( "keydown", this._doKeyDown).
218+
on( "keypress", this._doKeyPress).on( "keyup", this._doKeyUp);
219219
this._autoSize(inst);
220220
$.data(target, "datepicker", inst);
221221
//If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
@@ -238,15 +238,15 @@ $.extend(Datepicker.prototype, {
238238
input[isRTL ? "before" : "after"](inst.append);
239239
}
240240

241-
input.unbind("focus", this._showDatepicker);
241+
input.off("focus", this._showDatepicker);
242242

243243
if (inst.trigger) {
244244
inst.trigger.remove();
245245
}
246246

247247
showOn = this._get(inst, "showOn");
248248
if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
249-
input.focus(this._showDatepicker);
249+
input.on( "focus", this._showDatepicker );
250250
}
251251
if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
252252
buttonText = this._get(inst, "buttonText");
@@ -258,7 +258,7 @@ $.extend(Datepicker.prototype, {
258258
html(!buttonImage ? buttonText : $("<img/>").attr(
259259
{ src:buttonImage, alt:buttonText, title:buttonText })));
260260
input[isRTL ? "before" : "after"](inst.trigger);
261-
inst.trigger.click(function() {
261+
inst.trigger.on( "click", function() {
262262
if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
263263
$.datepicker._hideDatepicker();
264264
} else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
@@ -339,7 +339,7 @@ $.extend(Datepicker.prototype, {
339339
id = "dp" + this.uuid;
340340
this._dialogInput = $("<input type='text' id='" + id +
341341
"' style='position: absolute; top: -100px; width: 0px;'/>");
342-
this._dialogInput.keydown(this._doKeyDown);
342+
this._dialogInput.on( "keydown", this._doKeyDown );
343343
$("body").append(this._dialogInput);
344344
inst = this._dialogInst = this._newInst(this._dialogInput, false);
345345
inst.settings = {};
@@ -390,10 +390,10 @@ $.extend(Datepicker.prototype, {
390390
inst.append.remove();
391391
inst.trigger.remove();
392392
$target.removeClass(this.markerClassName).
393-
unbind("focus", this._showDatepicker).
394-
unbind("keydown", this._doKeyDown).
395-
unbind("keypress", this._doKeyPress).
396-
unbind("keyup", this._doKeyUp);
393+
off("focus", this._showDatepicker).
394+
off("keydown", this._doKeyDown).
395+
off("keypress", this._doKeyPress).
396+
off("keyup", this._doKeyUp);
397397
} else if (nodeName === "div" || nodeName === "span") {
398398
$target.removeClass(this.markerClassName).empty();
399399
}
@@ -798,7 +798,7 @@ $.extend(Datepicker.prototype, {
798798
}
799799

800800
if ( $.datepicker._shouldFocusInput( inst ) ) {
801-
inst.input.focus();
801+
inst.input.trigger( "focus" );
802802
}
803803

804804
$.datepicker._curInst = inst;
@@ -832,7 +832,7 @@ $.extend(Datepicker.prototype, {
832832
"Class"]("ui-datepicker-rtl");
833833

834834
if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
835-
inst.input.focus();
835+
inst.input.trigger( "focus" );
836836
}
837837

838838
// deffered render of the years select (to avoid flashes on Firefox)
@@ -941,7 +941,7 @@ $.extend(Datepicker.prototype, {
941941

942942
/* Tidy up after a dialog display. */
943943
_tidyDialog: function(inst) {
944-
inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
944+
inst.dpDiv.removeClass(this._dialogClass).off(".ui-datepicker-calendar");
945945
},
946946

947947
/* Close date picker if clicked elsewhere. */
@@ -1058,7 +1058,7 @@ $.extend(Datepicker.prototype, {
10581058
this._hideDatepicker();
10591059
this._lastInput = inst.input[0];
10601060
if (typeof(inst.input[0]) !== "object") {
1061-
inst.input.focus(); // restore focus
1061+
inst.input.trigger( "focus" ); // restore focus
10621062
}
10631063
this._lastInput = null;
10641064
}
@@ -1624,7 +1624,7 @@ $.extend(Datepicker.prototype, {
16241624
return false;
16251625
}
16261626
};
1627-
$(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
1627+
$(this).on(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
16281628
});
16291629
},
16301630

@@ -2007,7 +2007,7 @@ $.extend(Datepicker.prototype, {
20072007
*/
20082008
function datepicker_bindHover(dpDiv) {
20092009
var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
2010-
return dpDiv.delegate(selector, "mouseout", function() {
2010+
return dpDiv.on( "mouseout", selector, function() {
20112011
$(this).removeClass("ui-state-hover");
20122012
if (this.className.indexOf("ui-datepicker-prev") !== -1) {
20132013
$(this).removeClass("ui-datepicker-prev-hover");
@@ -2016,7 +2016,7 @@ function datepicker_bindHover(dpDiv) {
20162016
$(this).removeClass("ui-datepicker-next-hover");
20172017
}
20182018
})
2019-
.delegate( selector, "mouseover", datepicker_handleMouseover );
2019+
.on( "mouseover", selector, datepicker_handleMouseover );
20202020
}
20212021

20222022
function datepicker_handleMouseover() {
@@ -2056,7 +2056,7 @@ $.fn.datepicker = function(options){
20562056

20572057
/* Initialise the date picker. */
20582058
if (!$.datepicker.initialized) {
2059-
$(document).mousedown($.datepicker._checkExternalClick);
2059+
$(document).on( "mousedown", $.datepicker._checkExternalClick );
20602060
$.datepicker.initialized = true;
20612061
}
20622062

0 commit comments

Comments
 (0)