]> source.dussan.org Git - jquery-ui.git/commitdiff
Calendar: Make select and change event pass the current value
authorFelix Nagel <info@felixnagel.com>
Sun, 11 Dec 2016 22:10:26 +0000 (23:10 +0100)
committerFelix Nagel <info@felixnagel.com>
Sat, 21 Jan 2017 12:49:35 +0000 (13:49 +0100)
tests/unit/calendar/events.js
ui/widgets/calendar.js

index 59508cb8a00ea2c9239603e587a9eb83ce4debc3..6dc2e5eefe4e2875fe819efaa32d6ad41a125f26 100644 (file)
@@ -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" );
                }
        } );
 
index 538230bb6817a0a4ddce10c62800646cdc7d72bf..0c961a3d710058814f7e96f2a124e40a94325e85 100644 (file)
@@ -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 }  );
                }
        },