diff --git a/themes/base/calendar.css b/themes/base/calendar.css index def9fe4ff..961209bdc 100644 --- a/themes/base/calendar.css +++ b/themes/base/calendar.css @@ -18,6 +18,10 @@ position: relative; padding: .2em 0; } +.ui-calendar .ui-calendar-header-buttons { + position: relative; + z-index: 1; +} .ui-calendar .ui-calendar-prev, .ui-calendar .ui-calendar-next { cursor: pointer; diff --git a/ui/widgets/calendar.js b/ui/widgets/calendar.js index e4ed97bb9..9184b3b0d 100644 --- a/ui/widgets/calendar.js +++ b/ui/widgets/calendar.js @@ -89,14 +89,12 @@ return $.widget( "ui.calendar", { "click .ui-calendar-prev": function( event ) { event.preventDefault(); this.date.adjust( "M", -this.options.numberOfMonths ); - this.viewDate.setTime( this.date.date().getTime() ); - this.refresh(); + this._updateView(); }, "click .ui-calendar-next": function( event ) { event.preventDefault(); this.date.adjust( "M", this.options.numberOfMonths ); - this.viewDate.setTime( this.date.date().getTime() ); - this.refresh(); + this._updateView(); }, "mousedown .ui-calendar-calendar button": function( event ) { event.preventDefault(); @@ -104,16 +102,17 @@ return $.widget( "ui.calendar", { this._setOption( "value", new Date( $( event.currentTarget ).data( "timestamp" ) ) ); this.refresh(); this._trigger( "select", event ); - this.grid.focus(); + this.activeDescendant.closest( this.grid ).focus(); }, - "mouseenter .ui-calendar-header button": "_hover", - "mouseleave .ui-calendar-header button": "_hover", + "mouseenter .ui-calendar-header-buttons button": "_hover", + "mouseleave .ui-calendar-header-buttons button": "_hover", "mouseenter .ui-calendar-calendar button": "_hover", "mouseleave .ui-calendar-calendar button": "_hover", "keydown .ui-calendar-calendar": "_handleKeydown" } ); this._createCalendar(); + this._setActiveDescendant(); }, _hover: function( event ) { @@ -150,24 +149,27 @@ return $.widget( "ui.calendar", { this.date.adjust( "D", 7 ); break; default: - event.preventDefault(); return; } if ( this._needsRefresh() ) { - if ( this.options.numberOfMonths > 1 && this.date.year() === this.viewDate.year() ) { - this.viewDate.adjust( "M", this.options.numberOfMonths * - ( this.date.month() > this.viewDate.month() ? 1 : -1 ) - ); - this.refresh(); - } else { - this.viewDate.setTime( this.date.date().getTime() ); - this.refresh(); - } - this.grid.focus(); + this._updateView(); + this.activeDescendant.closest( this.grid ).focus(); + } else { + this._setActiveDescendant(); + } + }, + + _updateView: function() { + if ( this.options.numberOfMonths > 1 && this.date.year() === this.viewDate.year() ) { + this.viewDate.adjust( "M", this.options.numberOfMonths * + ( this.date.month() > this.viewDate.month() ? 1 : -1 ) + ); + } else { + this.viewDate.setTime( this.date.date().getTime() ); } - this._setActiveDescendant(); + this.refresh(); }, _needsRefresh: function() { @@ -222,12 +224,12 @@ return $.widget( "ui.calendar", { _createCalendar: function() { var classes = "ui-calendar ui-widget ui-widget-content ui-helper-clearfix ui-corner-all", - pickerHtml = ""; + pickerHtml = this._buildHeaderButtons(); if ( this.options.numberOfMonths === 1 ) { - pickerHtml = this._buildHeader() + this._buildGrid(); + pickerHtml += this._buildHeader() + this._buildGrid(); } else { - pickerHtml = this._buildMultiplePicker(); + pickerHtml += this._buildMultiplePicker(); classes += " ui-calendar-multi"; } @@ -266,15 +268,10 @@ return $.widget( "ui.calendar", { headerClass += " ui-corner-right"; } - html += "