Menu: Rename icon option to icons.submenu

This commit is contained in:
Jörn Zaefferer 2012-07-12 17:23:33 +02:00
parent 1510f7e28a
commit 7759fb4dba
5 changed files with 27 additions and 10 deletions

View File

@ -13,7 +13,10 @@
<script> <script>
$(function() { $(function() {
$( "#menu" ).menu({ $( "#menu" ).menu({
position: { of: "ul:has(a.ui-state-focus):last" } position: { of: "ul:has(a.ui-state-focus):last" },
icons: {
submenu: "ui-icon-carat-1-e"
}
}); });
}); });
</script> </script>

View File

@ -44,11 +44,7 @@
</head> </head>
<body> <body>
<h1 id="qunit-header">jQuery UI Menu Test Suite</h1> <div id="qunit">jQuery UI Menu Test Suite</div>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"> <div id="qunit-fixture">
<ul class="foo" id="menu1"> <ul class="foo" id="menu1">

View File

@ -1,7 +1,9 @@
TestHelpers.commonWidgetTests( "menu", { TestHelpers.commonWidgetTests( "menu", {
defaults: { defaults: {
disabled: false, disabled: false,
icon: "ui-icon-carat-1-e", icons: {
submenu: "ui-icon-carat-1-e"
},
menus: "ul", menus: "ul",
position: { position: {
my: "left top", my: "left top",

View File

@ -40,7 +40,21 @@ test( "{ disabled: false }", function() {
equal( logOutput(), "click,1,afterclick", "Click order not valid." ); equal( logOutput(), "click,1,afterclick", "Click order not valid." );
}); });
// TODO: test icon option test( "{ icons: default }", function() {
expect( 1 );
var element = $( "#menu2" ).menu();
equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-carat-1-e" );
});
test( "{ icons: { submenu: 'custom' } }", function() {
expect( 1 );
var element = $( "#menu2" ).menu({
icons: {
submenu: "custom-class"
}
});
equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon custom-class" );
});
// TODO: test menus option // TODO: test menus option

View File

@ -22,7 +22,9 @@ $.widget( "ui.menu", {
defaultElement: "<ul>", defaultElement: "<ul>",
delay: 300, delay: 300,
options: { options: {
icon: "ui-icon-carat-1-e", icons: {
submenu: "ui-icon-carat-1-e"
},
menus: "ul", menus: "ul",
position: { position: {
my: "left top", my: "left top",
@ -276,7 +278,7 @@ $.widget( "ui.menu", {
refresh: function() { refresh: function() {
// Initialize nested menus // Initialize nested menus
var menus, var menus,
icon = this.options.icon, icon = this.options.icons.submenu,
submenus = this.element.find( this.options.menus + ":not(.ui-menu)" ) submenus = this.element.find( this.options.menus + ":not(.ui-menu)" )
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.hide() .hide()