aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2016-12-11 23:10:26 +0100
committerFelix Nagel <info@felixnagel.com>2017-01-21 13:49:35 +0100
commitde20614bd7332b740c6ec095e0e5c48c2f97c8bf (patch)
tree289044f7f0b09df38268b14d31620cadbdad9dc3
parentb49d12d088268d5ae5aaaa4dc43f092798c72e98 (diff)
downloadjquery-ui-de20614bd7332b740c6ec095e0e5c48c2f97c8bf.tar.gz
jquery-ui-de20614bd7332b740c6ec095e0e5c48c2f97c8bf.zip
Calendar: Make select and change event pass the current value
-rw-r--r--tests/unit/calendar/events.js10
-rw-r--r--ui/widgets/calendar.js4
2 files changed, 8 insertions, 6 deletions
diff --git a/tests/unit/calendar/events.js b/tests/unit/calendar/events.js
index 59508cb8a..6dc2e5eef 100644
--- a/tests/unit/calendar/events.js
+++ b/tests/unit/calendar/events.js
@@ -12,12 +12,12 @@ QUnit.module( "calendar: events", {
} );
QUnit.test( "change", function( assert ) {
- assert.expect( 6 );
+ assert.expect( 8 );
var shouldFire, eventType;
this.element.calendar( {
- change: function( event ) {
+ change: function( event, ui ) {
assert.ok( shouldFire, "change event fired" );
assert.equal(
event.type,
@@ -29,6 +29,7 @@ QUnit.test( "change", function( assert ) {
eventType,
"change originalEvent on calendar button " + eventType
);
+ assert.equal( $.type( ui.value ), "date", "value is a date object" );
}
} );
@@ -48,14 +49,14 @@ QUnit.test( "change", function( assert ) {
} );
QUnit.test( "select", function( assert ) {
- assert.expect( 6 );
+ assert.expect( 8 );
var ready = assert.async(),
that = this,
message, eventType;
this.element.calendar( {
- select: function( event ) {
+ select: function( event, ui ) {
assert.ok( true, "select event fired " + message );
assert.equal(
event.type,
@@ -67,6 +68,7 @@ QUnit.test( "select", function( assert ) {
eventType,
"select originalEvent " + message
);
+ assert.equal( $.type( ui.value ), "date", "value is a date object" );
}
} );
diff --git a/ui/widgets/calendar.js b/ui/widgets/calendar.js
index 538230bb6..0c961a3d7 100644
--- a/ui/widgets/calendar.js
+++ b/ui/widgets/calendar.js
@@ -134,13 +134,13 @@ return $.widget( "ui.calendar", {
this._updateDayElement( "ui-state-active" );
// Allow datepicker to handle focus
- if ( this._trigger( "select", event ) !== false ) {
+ if ( this._trigger( "select", event, { value: this.options.value } ) !== false ) {
this.activeDescendant.closest( this.grid ).focus();
event.preventDefault();
}
if ( oldValue !== this.options.value.getTime() ) {
- this._trigger( "change", event );
+ this._trigger( "change", event, { value: this.options.value } );
}
},