Menu: Prevent clicking on disabled menu items and remove unnecessary extra padding from disabled items.

This commit is contained in:
kborchers 2012-02-03 16:12:37 -06:00
parent 4259978d39
commit 48ad0994a0
3 changed files with 17 additions and 13 deletions

View File

@ -76,12 +76,12 @@
<ul id="menu2">
<li><a href="#">Aberdeen</a></li>
<li><a href="#">Ada</a></li>
<li><a href="#">Adamsville</a></li>
<li class="ui-state-disabled"><a href="#">Adamsville</a></li>
<li><a href="#">Addyston</a></li>
<li>
<a href="#">Delphi</a>
<ul>
<li><a href="#">Ada</a></li>
<li class="ui-state-disabled"><a href="#">Ada</a></li>
<li><a href="#">Saarland</a></li>
<li><a href="#">Salzburg</a></li>
</ul>
@ -113,7 +113,7 @@
<ul id="menu3">
<li><a href="#"><span class="ui-icon ui-icon-print"></span>Aberdeen</a></li>
<li><a href="#"><span class="ui-icon ui-icon-scissors"></span>Ada</a></li>
<li class="ui-state-disabled"><a href="#"><span class="ui-icon ui-icon-scissors"></span>Ada</a></li>
<li><a href="#">Adamsville</a></li>
<li><a href="#"><span class="ui-icon ui-icon-wrench"></span>Addyston</a></li>
<li>
@ -193,7 +193,7 @@
<div id="menu5">
<blockquote><a href="#">Aberdeen</a></blockquote>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Adamsville</a></blockquote>
<blockquote class="ui-state-disabled"><a href="#">Adamsville</a></blockquote>
<blockquote><a href="#">Addyston</a></blockquote>
<blockquote>
<a href="#">Delphi</a>
@ -243,7 +243,7 @@
<span class="address-content">Bloomsburg, PA 12345</span>
</a>
</div>
<div class="address-item">
<div class="address-item ui-state-disabled">
<a href="#">
<span class="address-header">James Doe</span>
<span class="address-content">78 West Main St Apt 3A</span>

View File

@ -14,7 +14,7 @@
.ui-menu .ui-menu-item a.ui-state-focus,
.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }
.ui-menu .ui-state-disabled { font-weight: normal; padding: .0em .4em; margin: .4em 0 .2em; line-height: 1.5; }
.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; }
/* icon support */
.ui-menu-icons { position: relative; }

View File

@ -56,6 +56,9 @@ $.widget( "ui.menu", {
},
"click .ui-menu-item:has(a)": function( event ) {
event.stopImmediatePropagation();
//Don't select disabled menu items
if ( !$( event.target ).closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
console.log(event.target);
this.select( event );
// Redirect focus to the menu with a delay for firefox
this._delay( function() {
@ -63,6 +66,7 @@ $.widget( "ui.menu", {
this.element.focus();
}
}, 20);
}
},
"mouseover .ui-menu-item": function( event ) {
event.stopImmediatePropagation();