]> source.dussan.org Git - jquery-ui.git/commitdiff
Calendar: Introduce refresh callback event 1786/head
authorFelix Nagel <info@felixnagel.com>
Sun, 11 Dec 2016 22:30:25 +0000 (23:30 +0100)
committerFelix Nagel <info@felixnagel.com>
Sat, 21 Jan 2017 12:49:36 +0000 (13:49 +0100)
tests/unit/calendar/common.js
tests/unit/calendar/events.js
tests/unit/datepicker/common.js
tests/unit/datepicker/events.js
ui/widgets/calendar.js
ui/widgets/datepicker.js

index ea637a9b8d07af13b2c08fcb2f2fe90c3781af48..1f3a0fe215b3bf180c6e325c2b280e96acd60d5f 100644 (file)
@@ -37,6 +37,7 @@ common.testWidget( "calendar", {
                // callbacks
                change: null,
                create: null,
+               refresh: null,
                select: null
        }
 } );
index 6dc2e5eefe4e2875fe819efaa32d6ad41a125f26..7148ff343a968afa12590815323bc12252ce3d09 100644 (file)
@@ -98,4 +98,26 @@ QUnit.test( "select", function( assert ) {
        step1();
 } );
 
+QUnit.test( "refresh", function( assert ) {
+       assert.expect( 2 );
+
+       var shouldFire;
+
+       this.element.calendar( {
+               refresh: function() {
+                       assert.ok( shouldFire, "refresh event fired" );
+               }
+       } );
+
+       shouldFire = true;
+       this.element.find( "button.ui-calendar-next" ).simulate( "click" );
+
+       shouldFire = false;
+       this.element.find( "table button:eq(1)" ).simulate( "click" );
+
+       testHelper.focusGrid( this.element ).simulate( "keydown", { keyCode: $.ui.keyCode.END } );
+       shouldFire = true;
+       testHelper.focusGrid( this.element ).simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+} );
+
 } );
index 527ddcbf341fd2b8a588142696b17356c7439a0b..6b0b0487dcaf5e03f6ed3401a5d5ec310d12c151 100644 (file)
@@ -46,6 +46,7 @@ common.testWidget( "datepicker", {
                close: null,
                create: null,
                open: null,
+               refresh: null,
                select: null
        }
 } );
index 76615084caaada84a1bb8f9b76df95cf0ad6aab9..5a923d252fe23997d8be42496d8b9b41c8c2158a 100644 (file)
@@ -180,4 +180,22 @@ QUnit.test( "select", function( assert ) {
        step1();
 } );
 
+QUnit.test( "refresh", function( assert ) {
+       assert.expect( 1 );
+
+       var shouldFire;
+
+       this.element.calendar( {
+               refresh: function() {
+                       assert.ok( shouldFire, "refresh event fired" );
+               }
+       } );
+
+       shouldFire = true;
+       this.element.find( "button.ui-calendar-next" ).simulate( "click" );
+
+       shouldFire = false;
+       this.element.find( "table button:eq(1)" ).simulate( "click" );
+} );
+
 } );
index 0c961a3d710058814f7e96f2a124e40a94325e85..31a650d0ec2be77a02388dbea2baa1796ec73f56 100644 (file)
@@ -73,6 +73,7 @@ return $.widget( "ui.calendar", {
 
                // callbacks
                change: null,
+               refresh: null,
                select: null
        },
 
@@ -595,6 +596,8 @@ return $.widget( "ui.calendar", {
                this._setActiveDescendant();
                this._refreshHeaderButtons();
                this._createButtons();
+
+               this._trigger( "refresh" );
        },
 
        _refreshHeaderButtons: function() {
index 1325434d3d01a71cde368634c7e72142d0bae0b2..48926ff72b4d20a58293d41048ad3cb80f47de58 100644 (file)
@@ -55,11 +55,12 @@ var widget = $.widget( "ui.datepicker", {
                change: null,
                close: null,
                open: null,
+               refresh: null,
                select: null
        },
 
        calendarOptions: [ "buttons", "classes", "disabled", "dateFormat", "eachDay",
-               "icons", "labels", "locale", "max", "min", "numberOfMonths", "showWeek" ],
+               "icons", "labels", "locale", "max", "min", "numberOfMonths", "showWeek", "refresh" ],
 
        _create: function() {
                this.suppressExpandOnFocus = false;