aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.menu.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2011-07-29 14:00:00 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2011-07-29 14:00:00 +0200
commit982b752c3507f8e8512ca02f365a2d854d65a5cc (patch)
treed5ca7624fa6d3bd99120538fd7ab235ce41fad99 /ui/jquery.ui.menu.js
parent61caba7803d1c3885a8e2a6cd3c1e8b723e8beee (diff)
parent0ff3396e8853d1858db56e4ad7552f87c09e5504 (diff)
downloadjquery-ui-982b752c3507f8e8512ca02f365a2d854d65a5cc.tar.gz
jquery-ui-982b752c3507f8e8512ca02f365a2d854d65a5cc.zip
Merge branch 'widget-delegation'
Diffstat (limited to 'ui/jquery.ui.menu.js')
-rw-r--r--ui/jquery.ui.menu.js67
1 files changed, 26 insertions, 41 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index c55ae75c9..27e76d909 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -38,52 +38,37 @@ $.widget( "ui.menu", {
id: this.menuId,
role: "menu"
})
+ // need to catch all clicks on disabled menu
+ // not possible through _bind
.bind( "click.menu", function( event ) {
- var item = $( event.target ).closest( ".ui-menu-item:has(a)" );
if ( self.options.disabled ) {
- return false;
- }
- if ( !item.length ) {
- return;
+ event.preventDefault();
}
+ });
+ this._bind({
+ "click .ui-menu-item:has(a)": function( event ) {
+ event.stopImmediatePropagation();
+ var target = $( event.currentTarget );
// it's possible to click an item without hovering it (#7085)
- if ( !self.active || ( self.active[ 0 ] !== item[ 0 ] ) ) {
- self.focus( event, item );
- }
- self.select( event );
- })
- .bind( "mouseover.menu", function( event ) {
- if ( self.options.disabled ) {
- return;
- }
- var target = $( event.target ).closest( ".ui-menu-item" );
- if ( target.length ) {
- //Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
- target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
- self.focus( event, target );
- }
- })
- .bind( "mouseout.menu", function( event ) {
- if ( self.options.disabled ) {
- return;
- }
- var target = $( event.target ).closest( ".ui-menu-item" );
- if ( target.length ) {
- self.blur( event );
+ if ( !this.active || ( this.active[ 0 ] !== target[ 0 ] ) ) {
+ this.focus( event, target );
}
- })
- .bind( "focus.menu", function( event ) {
- if ( self.options.disabled ) {
- return;
- }
- self.focus( event, $( event.target ).children( ".ui-menu-item:first" ) );
- })
- .bind( "blur.menu", function( event ) {
- if ( self.options.disabled ) {
- return;
- }
- self.collapseAll( event );
- });
+ this.select( event );
+ },
+ "mouseover .ui-menu-item": function( event ) {
+ event.stopImmediatePropagation();
+ var target = $( event.currentTarget );
+ // Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
+ target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
+ this.focus( event, target );
+ },
+ "mouseout .ui-menu-item": "blur",
+ "focus": function( event ) {
+ this.focus( event, $( event.target ).children( ".ui-menu-item:first" ) );
+ },
+ "blur": "collapseAll"
+ });
+
this.refresh();
this.element.attr( "tabIndex", 0 ).bind( "keydown.menu", function( event ) {