Selectmenu: switch from a to button element

This commit is contained in:
Felix Nagel 2013-03-07 19:15:37 +01:00
parent dffe8f6610
commit 8787cb0456
2 changed files with 10 additions and 12 deletions

View File

@ -35,7 +35,7 @@
.ui-selectmenu-open {
display: block;
}
.ui-selectmenu-button a.ui-button {
.ui-selectmenu-button .ui-button {
display: inline-block;
overflow: hidden;
position: relative;

View File

@ -68,9 +68,8 @@ $.widget( "ui.selectmenu", {
this.element.hide();
// create button
this.button = $( "<a>", {
this.button = $( "<button>", {
"class": "ui-button ui-widget ui-state-default ui-corner-all",
href: "#" + this.ids.id,
tabindex: ( tabindex ? tabindex : this.options.disabled ? -1 : 0 ),
id: this.ids.button,
width: this.element.outerWidth(),
@ -294,8 +293,12 @@ $.widget( "ui.selectmenu", {
this.button.addClass( "ui-state-focus" );
this._off( this.button, "focus" );
},
click: function( event ) {
this._toggle( event );
click: function( event ) {
if ( this.isOpen ) {
this.menu.menu( "select", event );
} else {
this._toggle( event );
}
event.preventDefault();
},
keydown: function( event ) {
@ -327,13 +330,6 @@ $.widget( "ui.selectmenu", {
this._move( "next", event );
}
break;
case $.ui.keyCode.SPACE:
if ( this.isOpen ) {
this.menu.menu( "select", event );
} else {
this._toggle( event );
}
break;
case $.ui.keyCode.LEFT:
this._move( "previous", event );
break;
@ -348,6 +344,8 @@ $.widget( "ui.selectmenu", {
case $.ui.keyCode.PAGE_DOWN:
this._move( "last", event );
break;
case $.ui.keyCode.SPACE:
break;
default:
this.menu.trigger( event );
prevDef = false;