From 767d1730403ff2d184717b43042d3ba98b71596c Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Sun, 11 Dec 2016 23:30:25 +0100 Subject: [PATCH] Calendar: Introduce refresh callback event --- tests/unit/calendar/common.js | 1 + tests/unit/calendar/events.js | 22 ++++++++++++++++++++++ tests/unit/datepicker/common.js | 1 + tests/unit/datepicker/events.js | 18 ++++++++++++++++++ ui/widgets/calendar.js | 3 +++ ui/widgets/datepicker.js | 3 ++- 6 files changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/unit/calendar/common.js b/tests/unit/calendar/common.js index ea637a9b8..1f3a0fe21 100644 --- a/tests/unit/calendar/common.js +++ b/tests/unit/calendar/common.js @@ -37,6 +37,7 @@ common.testWidget( "calendar", { // callbacks change: null, create: null, + refresh: null, select: null } } ); diff --git a/tests/unit/calendar/events.js b/tests/unit/calendar/events.js index 6dc2e5eef..7148ff343 100644 --- a/tests/unit/calendar/events.js +++ b/tests/unit/calendar/events.js @@ -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 } ); +} ); + } ); diff --git a/tests/unit/datepicker/common.js b/tests/unit/datepicker/common.js index 527ddcbf3..6b0b0487d 100644 --- a/tests/unit/datepicker/common.js +++ b/tests/unit/datepicker/common.js @@ -46,6 +46,7 @@ common.testWidget( "datepicker", { close: null, create: null, open: null, + refresh: null, select: null } } ); diff --git a/tests/unit/datepicker/events.js b/tests/unit/datepicker/events.js index 76615084c..5a923d252 100644 --- a/tests/unit/datepicker/events.js +++ b/tests/unit/datepicker/events.js @@ -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" ); +} ); + } ); diff --git a/ui/widgets/calendar.js b/ui/widgets/calendar.js index 0c961a3d7..31a650d0e 100644 --- a/ui/widgets/calendar.js +++ b/ui/widgets/calendar.js @@ -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() { diff --git a/ui/widgets/datepicker.js b/ui/widgets/datepicker.js index 1325434d3..48926ff72 100644 --- a/ui/widgets/datepicker.js +++ b/ui/widgets/datepicker.js @@ -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; -- 2.39.5