diff options
author | Felix Nagel <info@felixnagel.com> | 2012-01-27 23:06:53 +0100 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2012-01-27 23:06:53 +0100 |
commit | 4bbfc2fd969e8445645f38f3dbf2962086e6f772 (patch) | |
tree | 92a22848fd922fff1a162bd55ac914ba74eea26d | |
parent | 62ba812af993106c00669849053d0dad965623b0 (diff) | |
download | jquery-ui-4bbfc2fd969e8445645f38f3dbf2962086e6f772.tar.gz jquery-ui-4bbfc2fd969e8445645f38f3dbf2962086e6f772.zip |
Selectmenu: cleanup and small improvements
-rw-r--r-- | ui/jquery.ui.selectmenu.js | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 1b24724d8..07f4f3abb 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -130,7 +130,7 @@ $.widget( "ui.selectmenu", { if ( that.isOpen ) { event.preventDefault(); - that.close( event, true); + that.close( event ); } }, focus: function( event, ui ) { @@ -178,8 +178,9 @@ $.widget( "ui.selectmenu", { this.menuItems.find( 'a' ).attr( 'role', 'option' ); // select current item - this.menu.menu( "focus", null, this._getSelectedItem() ); - this._setSelected(); + var item = this._getSelectedItem(); + this.menu.menu( "focus", null, item ); + this._setSelected( item.data( "item.selectmenu" ) ); // set and transfer disabled state this._getCreateOptions(); @@ -234,19 +235,15 @@ $.widget( "ui.selectmenu", { } }, - close: function( event, focus ) { + close: function( event ) { if ( this.isOpen ) { this._toggleButtonStyle(); this.menuWrap.removeClass( 'ui-selectmenu-open' ); this.menu.attr( "aria-hidden", true ); this.button.attr( "aria-expanded", false ); + this.isOpen = false; - - if ( focus ) { - this.button.focus(); - } - this._trigger( "close", event ); } }, @@ -374,10 +371,9 @@ $.widget( "ui.selectmenu", { _select: function( item, event ) { var oldIndex = this.element[0].selectedIndex; - // change native select element this.element[0].selectedIndex = item.index; - this._setSelected(); + this._setSelected( item ); this._trigger( "select", event, { item: item } ); if ( item.index != oldIndex ) { @@ -385,11 +381,10 @@ $.widget( "ui.selectmenu", { } }, - _setSelected: function() { - var item = this._getSelectedItem(), - link = item.find("a"); + _setSelected: function( item ) { + var link = item.element.find("a"); // update button text - this.button.button( "option", "label", item.text() ); + this.button.button( "option", "label", item.label ); // change ARIA attr this.button.add( this.menu ).attr( "aria-activedescendant" , link.attr( "id" ) ); this.menuItems.find("a").attr( "aria-selected", false ); |