mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Menu: Refactor to get rid of var that. Cleanup some odd formattings and unneeded temp vars
This commit is contained in:
parent
ae0c4e44ff
commit
e1ec6f8ebb
@ -16,7 +16,7 @@
|
|||||||
right: 10,
|
right: 10,
|
||||||
top: 10
|
top: 10
|
||||||
}).appendTo(document.body).themeswitcher();
|
}).appendTo(document.body).themeswitcher();
|
||||||
|
|
||||||
function create() {
|
function create() {
|
||||||
menus.menu({
|
menus.menu({
|
||||||
select: function(event, ui) {
|
select: function(event, ui) {
|
||||||
@ -24,8 +24,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var menus = $("#menu1, #menu2, #menu3, #menu4");
|
var menus = $("#menu1, #menu2, #menu3, .menu4");
|
||||||
create();
|
create();
|
||||||
|
|
||||||
$("#toggle-destroy").toggle(function() {
|
$("#toggle-destroy").toggle(function() {
|
||||||
@ -41,11 +41,11 @@
|
|||||||
<style>
|
<style>
|
||||||
body { font-size:62.5%; }
|
body { font-size:62.5%; }
|
||||||
.ui-menu { width: 200px; margin-bottom: 2em; }
|
.ui-menu { width: 200px; margin-bottom: 2em; }
|
||||||
#menu4 { height: 200px; overflow: auto; }
|
.menu4 { height: 200px; overflow: auto; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<ul id="menu1">
|
<ul id="menu1">
|
||||||
<li><a href="#">Aberdeen</a></li>
|
<li><a href="#">Aberdeen</a></li>
|
||||||
<li><a href="#">Ada</a></li>
|
<li><a href="#">Ada</a></li>
|
||||||
@ -132,7 +132,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul id="menu4">
|
<ul class="menu4">
|
||||||
<li><a href="#">Aberdeen</a></li>
|
<li><a href="#">Aberdeen</a></li>
|
||||||
<li><a href="#">Ada</a></li>
|
<li><a href="#">Ada</a></li>
|
||||||
<li><a href="#">Adamsville</a></li>
|
<li><a href="#">Adamsville</a></li>
|
||||||
|
40
ui/jquery.ui.menu.js
vendored
40
ui/jquery.ui.menu.js
vendored
@ -220,35 +220,33 @@ $.widget( "ui.menu", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
var that = this,
|
// initialize nested menus
|
||||||
|
var submenus = this.element.find( "ul:not(.ui-menu)" )
|
||||||
// initialize nested menus
|
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
|
||||||
submenus = this.element.find( "ul:not(.ui-menu)" )
|
.attr( "role", "menu" )
|
||||||
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
|
.hide()
|
||||||
.attr( "role", "menu" )
|
.attr( "aria-hidden", "true" )
|
||||||
.hide()
|
.attr( "aria-expanded", "false" );
|
||||||
.attr( "aria-hidden", "true" )
|
|
||||||
.attr( "aria-expanded", "false" ),
|
|
||||||
|
|
||||||
// don't refresh list items that are already adapted
|
// don't refresh list items that are already adapted
|
||||||
items = submenus.add( this.element ).children( "li:not(.ui-menu-item):has(a)" )
|
var menuId = this.menuId;
|
||||||
.addClass( "ui-menu-item" )
|
submenus.add( this.element ).children( "li:not(.ui-menu-item):has(a)" )
|
||||||
.attr( "role", "presentation" );
|
.addClass( "ui-menu-item" )
|
||||||
|
.attr( "role", "presentation" )
|
||||||
items.children( "a" )
|
.children( "a" )
|
||||||
.addClass( "ui-corner-all" )
|
.addClass( "ui-corner-all" )
|
||||||
.attr( "tabIndex", -1 )
|
.attr( "tabIndex", -1 )
|
||||||
.attr( "role", "menuitem" )
|
.attr( "role", "menuitem" )
|
||||||
.attr( "id", function( i ) {
|
.attr( "id", function( i ) {
|
||||||
return that.element.attr( "id" ) + "-" + i;
|
return menuId + "-" + i;
|
||||||
});
|
});
|
||||||
|
|
||||||
submenus.each( function() {
|
submenus.each( function() {
|
||||||
var menu = $( this ),
|
var menu = $( this ),
|
||||||
item = menu.prev( "a" );
|
item = menu.prev( "a" );
|
||||||
|
|
||||||
item.attr( "aria-haspopup", "true" )
|
item.attr( "aria-haspopup", "true" )
|
||||||
.prepend( '<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>' );
|
.prepend( '<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>' );
|
||||||
menu.attr( "aria-labelledby", item.attr( "id" ) );
|
menu.attr( "aria-labelledby", item.attr( "id" ) );
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user