// support: IE <9, jQuery <1.8
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
$( "<span>January 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 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 2009</span>" ).text(), "After prev clicks");
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" );
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" );
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" );
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)
input[isRTL ? "before" : "after"](inst.append);
}
- input.unbind("focus", this._showDatepicker);
+ input.off("focus", this._showDatepicker);
if (inst.trigger) {
inst.trigger.remove();
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");
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]) {
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 = {};
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();
}
}
if ( $.datepicker._shouldFocusInput( inst ) ) {
- inst.input.focus();
+ inst.input.trigger( "focus" );
}
$.datepicker._curInst = inst;
"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)
/* 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. */
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;
}
return false;
}
};
- $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
+ $(this).on(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
});
},
*/
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");
$(this).removeClass("ui-datepicker-next-hover");
}
})
- .delegate( selector, "mouseover", datepicker_handleMouseover );
+ .on( "mouseover", selector, datepicker_handleMouseover );
}
function datepicker_handleMouseover() {
/* Initialise the date picker. */
if (!$.datepicker.initialized) {
- $(document).mousedown($.datepicker._checkExternalClick);
+ $(document).on( "mousedown", $.datepicker._checkExternalClick );
$.datepicker.initialized = true;
}