Close popup when blurred and make sure that shift-tab when popup is open

skips the trigger.
This commit is contained in:
jzaefferer 2011-04-18 17:07:08 +02:00
parent 4547da1ba5
commit 5076f233db

View File

@ -35,7 +35,7 @@ $.widget( "ui.popup", {
this.element this.element
.addClass("ui-popup") .addClass("ui-popup")
this._close(); this._close();
this._bind(this.options.trigger, { this._bind(this.options.trigger, {
click: function( event ) { click: function( event ) {
event.preventDefault(); event.preventDefault();
@ -46,6 +46,10 @@ $.widget( "ui.popup", {
} }
}); });
this._bind(this.element, {
blur: "_close"
});
this._bind({ this._bind({
keyup: function( event ) { keyup: function( event ) {
if (event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" )) { if (event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" )) {
@ -94,6 +98,10 @@ $.widget( "ui.popup", {
.attr( "aria-expanded", true ) .attr( "aria-expanded", true )
.position( position ) .position( position )
.focus(); .focus();
// take trigger out of tab order to allow shift-tab to skip trigger
this.options.trigger.attr("tabindex", -1);
this.open = true; this.open = true;
this._trigger( "open", event ); this._trigger( "open", event );
}, },
@ -103,6 +111,9 @@ $.widget( "ui.popup", {
.hide() .hide()
.attr( "aria-hidden", true ) .attr( "aria-hidden", true )
.attr( "aria-expanded", false ); .attr( "aria-expanded", false );
this.options.trigger.attr("tabindex", 0);
this.open = false; this.open = false;
this._trigger( "close", event ); this._trigger( "close", event );
} }