aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-12-12 19:31:39 +0100
committerFelix Nagel <info@felixnagel.com>2012-12-12 19:31:39 +0100
commitb15ae2a64f3a438384f15fa7fdc9c0ea25497528 (patch)
treef038c9131d3df2f9b2f2b9132b4b47612565cbf8 /ui
parent812a90fc8221a1dd2fa79543917e765f1929c71e (diff)
downloadjquery-ui-b15ae2a64f3a438384f15fa7fdc9c0ea25497528.tar.gz
jquery-ui-b15ae2a64f3a438384f15fa7fdc9c0ea25497528.zip
Selectmenu: merge and explain if statements in Menu focus event, remove unneeded Menu focus method call in open
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.selectmenu.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js
index ec7a35998..b926acf0a 100644
--- a/ui/jquery.ui.selectmenu.js
+++ b/ui/jquery.ui.selectmenu.js
@@ -134,13 +134,11 @@ $.widget( "ui.selectmenu", {
},
focus: function( event, ui ) {
var item = ui.item.data( "ui-selectmenu-item" );
-
- if ( that.focus !== undefined ) {
- if ( item.index !== that.focus ) {
- that._trigger( "focus", event, { item: item } );
- if ( !that.isOpen ) {
- that._select( item, event );
- }
+ // prevent inital focus from firing and checks if its a newly focused item
+ if ( that.focus !== undefined && item.index !== that.focus ) {
+ that._trigger( "focus", event, { item: item } );
+ if ( !that.isOpen ) {
+ that._select( item, event );
}
}
that.focus = item.index;
@@ -178,6 +176,7 @@ $.widget( "ui.selectmenu", {
// select current item
item = this._getSelectedItem();
+ // make sure menu is selected item aware
this.menu.menu( "focus", null, item );
this._setSelected( item.data( "ui-selectmenu-item" ) );
@@ -202,7 +201,6 @@ $.widget( "ui.selectmenu", {
this.isOpen = true;
this._toggleAttr();
- this.menu.menu( "focus", event, this._getSelectedItem() );
// do not change position if non default position options are set (needed for custom positioned popup menus)
if ( this.items && !this.options.dropdown && this.options.position.my == "left top" && this.options.position.at == "left bottom" ) {