aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.selectmenu.js
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-11-29 20:23:30 +0100
committerFelix Nagel <info@felixnagel.com>2012-11-29 20:23:30 +0100
commitf622428c43b38da040b9220646b5384b9917b7bc (patch)
treede579d6a937667555cd585f6dde3401c9a906eed /ui/jquery.ui.selectmenu.js
parentac7b8f925a4db353c25c147947b3ca83ecb25d70 (diff)
downloadjquery-ui-f622428c43b38da040b9220646b5384b9917b7bc.tar.gz
jquery-ui-f622428c43b38da040b9220646b5384b9917b7bc.zip
Selectmenu: improve disabled check in open method
Diffstat (limited to 'ui/jquery.ui.selectmenu.js')
-rw-r--r--ui/jquery.ui.selectmenu.js64
1 files changed, 33 insertions, 31 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js
index 87323c9d5..95c463a08 100644
--- a/ui/jquery.ui.selectmenu.js
+++ b/ui/jquery.ui.selectmenu.js
@@ -27,7 +27,7 @@ $.widget( "ui.selectmenu", {
at: "left bottom",
collision: "none"
},
-
+
// callbacks
change: null,
close: null,
@@ -101,8 +101,8 @@ $.widget( "ui.selectmenu", {
"class": "ui-selectmenu-button"
})
.append( this.button )
- .insertAfter( this.element );
-
+ .insertAfter( this.element );
+
this._on( this.button, this._buttonEvents );
this._hoverable( this.button );
this._focusable( this.button );
@@ -194,38 +194,40 @@ $.widget( "ui.selectmenu", {
},
open: function( event ) {
- if ( !this.options.disabled ) {
- var _position = {
- of: this.button
- };
-
- // make sure menu is refreshed on first init (needed at least for IE9)
- if ( this.isOpen === undefined ) {
- this.button.trigger( "focus" );
- }
+ if ( this.options.disabled ) {
+ return;
+ }
- this.isOpen = true;
- this._toggleAttr();
- this.menu.menu( "focus", event, this._getSelectedItem() );
-
- if ( this.items && !this.options.dropdown && this.options.position.my == "left top" && this.options.position.at == "left bottom" ) {
- var currentItem = this._getSelectedItem();
- // center current item
- if ( this.menu.outerHeight() < this.menu.prop( "scrollHeight" ) ) {
- this.menuWrap.css( "left" , -10000 );
- this.menu.scrollTop( this.menu.scrollTop() + currentItem.position().top - this.menu.outerHeight() / 2 + currentItem.outerHeight() / 2 );
- this.menuWrap.css( "left" , "auto" );
- }
- _position.my = "left top" + ( this.menu.offset().top - currentItem.offset().top + ( this.button.outerHeight() - currentItem.outerHeight() ) / 2 );
- _position.at = "left top";
- }
+ var _position = {
+ of: this.button
+ };
- this.menuWrap
- .zIndex( this.element.zIndex() + 1 )
- .position( $.extend( {}, this.options.position, _position ) );
+ // make sure menu is refreshed on first init (needed at least for IE9)
+ if ( this.isOpen === undefined ) {
+ this.button.trigger( "focus" );
+ }
- this._trigger( "open", event );
+ this.isOpen = true;
+ this._toggleAttr();
+ this.menu.menu( "focus", event, this._getSelectedItem() );
+
+ if ( this.items && !this.options.dropdown && this.options.position.my == "left top" && this.options.position.at == "left bottom" ) {
+ var currentItem = this._getSelectedItem();
+ // center current item
+ if ( this.menu.outerHeight() < this.menu.prop( "scrollHeight" ) ) {
+ this.menuWrap.css( "left" , -10000 );
+ this.menu.scrollTop( this.menu.scrollTop() + currentItem.position().top - this.menu.outerHeight() / 2 + currentItem.outerHeight() / 2 );
+ this.menuWrap.css( "left" , "auto" );
+ }
+ _position.my = "left top" + ( this.menu.offset().top - currentItem.offset().top + ( this.button.outerHeight() - currentItem.outerHeight() ) / 2 );
+ _position.at = "left top";
}
+
+ this.menuWrap
+ .zIndex( this.element.zIndex() + 1 )
+ .position( $.extend( {}, this.options.position, _position ) );
+
+ this._trigger( "open", event );
},
close: function( event ) {