aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.selectmenu.js
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2011-10-09 00:47:09 +0200
committerFelix Nagel <info@felixnagel.com>2011-10-09 00:47:09 +0200
commitf4454ce30e00cdbd501c323abccc11dcc3d44e9f (patch)
treee465aa4a219eee2f18441e7d7790b61cf1a10c58 /ui/jquery.ui.selectmenu.js
parentac54556fb3b7ab08744cc7ea663a276d5c91cdd4 (diff)
downloadjquery-ui-f4454ce30e00cdbd501c323abccc11dcc3d44e9f.tar.gz
jquery-ui-f4454ce30e00cdbd501c323abccc11dcc3d44e9f.zip
Selectmenu: fixed click scrollbar issue (follow up), improved document event handling
Diffstat (limited to 'ui/jquery.ui.selectmenu.js')
-rw-r--r--ui/jquery.ui.selectmenu.js66
1 files changed, 29 insertions, 37 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js
index c02b8988a..c0d6fbe40 100644
--- a/ui/jquery.ui.selectmenu.js
+++ b/ui/jquery.ui.selectmenu.js
@@ -52,39 +52,27 @@ $.widget( "ui.selectmenu", {
options.value = that.element[0].value;
}
+ // catch click event of the label
+ that._bind({
+ 'click': function( event ) {
+ that.newelement.focus();
+ event.preventDefault();
+ }
+ });
+
that._addNewelement();
+ that._bind( that.newelement, that._newelementEvents );
+
that._addList();
-
- // built menu
that.refresh();
- that._bind( that.newelement, that._newelementEvents );
-
- // document click closes menu
- that._bind( document, {
- 'mousedown': function( event ) {
- if ( that.opened && !that.hover) {
- window.setTimeout( function() {
- that.close( event );
- }, 200 );
- }
- }
- });
},
_addNewelement: function() {
var that = this,
options = this.options,
tabindex = this.element.attr( 'tabindex' );
-
- // catch click event of the label
- that._bind({
- 'click': function( event ) {
- that.newelement.focus();
- event.preventDefault();
- }
- });
-
+
// hide original select tag
that.element.hide();
@@ -134,18 +122,6 @@ $.widget( "ui.selectmenu", {
var text = that.newelement.find( "span.ui-button-text");
var setWidth = text.width() + parseFloat( text.css( "padding-left" ) ) + parseFloat( text.css( "margin-left" ) );
}
-
- that._bind( that.list, {
- 'click': function( event ) {
- event.preventDefault();
- },
- mouseenter: function() {
- that.hover = true;
- },
- mouseleave: function() {
- that.hover = false;
- }
- });
// wrap list
that.listWrap = $( '<div />' )
@@ -177,6 +153,23 @@ $.widget( "ui.selectmenu", {
that.focus = item.index;
}
});
+
+ that._bind( that.list, {
+ 'click': function( event ) {
+ event.preventDefault();
+ }
+ });
+
+ // document click closes menu
+ that._bind( document, {
+ 'mousedown': function( event ) {
+ if ( that.opened && !$( event.target ).is( that.list ) ) {
+ window.setTimeout( function() {
+ that.close( event );
+ }, 200 );
+ }
+ }
+ });
},
refresh: function() {
@@ -255,7 +248,6 @@ $.widget( "ui.selectmenu", {
close: function( event, focus ) {
var that = this,
options = this.options;
-
if ( that.opened ) {
if ( options.dropdown ) {
that.newelement
@@ -332,7 +324,7 @@ $.widget( "ui.selectmenu", {
keydown: function( event ) {
switch (event.keyCode) {
case $.ui.keyCode.TAB:
- if ( this.opened ) this.close();
+ if ( this.opened ) this.close( event );
break;
case $.ui.keyCode.ENTER:
if ( this.opened ) {