thzero
11-11-2007, 03:21 PM
My extended menu allows for 2 things:
a) to allow individual menus not to display icons.
b) to allow individual menus to have different themes.
To utilize it, just include the js and css files into your page and then use Ext.ux.MenuEx instead of Ext.menu.Menu. You will also, unfortunately, need to make the change the onMouseDown function of the Ext.menu.MenuMgr to the following otherwise clicking on menu items will not function correctly.
function onMouseDown(e){
if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".x-menu-layer")){
hideAll();
}
}
Want to use a different set of menuEx? You modify the x-menuEx* classes, or you could copy the x-menuEx class and give it a prefix different than x-menuEx, i.e. 'x-menuBlue', then set the 'clsPrefix' option of the MenuEx to be 'x-menuBlue' and then menu (and submenus) will use those classes.
Want to not display the 'icon'? Just set the 'showIcon' option to false and no icon will be displayed.
Oops, forgot a feature. You can render the menu to a pre-existing element, i.e.
<div id="sidebarMenu"></div>
<script type="text/javascript">
Ext.onReady(function()
{
var sidebarMenuPanel = new Ext.Panel({
id: 'sidebarMenuPanel',
title: 'Sidebar,
layout:'fit',
contentEl: 'sidebarMenuContent',
renderTo: 'sidebarMenuPanel'
});
var sidebarMenu = new Ext.ux.MenuEx(
{
id: 'sidebarMenu',
clsPrefix: 'x-menuEx',
items: [
{
text: 'Home',
handler: onSidebarMenuItemClick,
location: '/'
},
{
text: 'Get Started Here',
handler: onSidebarMenuItemClick,
location: '/index/start'
},
{
text: 'General Rules and Procedures',
handler: onSidebarMenuItemClick,
location: '/index/rules'
},
{
text: 'Member List',
handler: onSidebarMenuItemClick,
location: '/index/memberlist'
},
{
text: 'Forums',
handler: onSidebarMenuItemClick,
location: '/forum/index'
}]
});
sidebarMenu.renderTo('sidebarMenu');
function onSidebarMenuItemClick(btn)
{
window.location = this.location;
}
});
</script>
a) to allow individual menus not to display icons.
b) to allow individual menus to have different themes.
To utilize it, just include the js and css files into your page and then use Ext.ux.MenuEx instead of Ext.menu.Menu. You will also, unfortunately, need to make the change the onMouseDown function of the Ext.menu.MenuMgr to the following otherwise clicking on menu items will not function correctly.
function onMouseDown(e){
if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".x-menu-layer")){
hideAll();
}
}
Want to use a different set of menuEx? You modify the x-menuEx* classes, or you could copy the x-menuEx class and give it a prefix different than x-menuEx, i.e. 'x-menuBlue', then set the 'clsPrefix' option of the MenuEx to be 'x-menuBlue' and then menu (and submenus) will use those classes.
Want to not display the 'icon'? Just set the 'showIcon' option to false and no icon will be displayed.
Oops, forgot a feature. You can render the menu to a pre-existing element, i.e.
<div id="sidebarMenu"></div>
<script type="text/javascript">
Ext.onReady(function()
{
var sidebarMenuPanel = new Ext.Panel({
id: 'sidebarMenuPanel',
title: 'Sidebar,
layout:'fit',
contentEl: 'sidebarMenuContent',
renderTo: 'sidebarMenuPanel'
});
var sidebarMenu = new Ext.ux.MenuEx(
{
id: 'sidebarMenu',
clsPrefix: 'x-menuEx',
items: [
{
text: 'Home',
handler: onSidebarMenuItemClick,
location: '/'
},
{
text: 'Get Started Here',
handler: onSidebarMenuItemClick,
location: '/index/start'
},
{
text: 'General Rules and Procedures',
handler: onSidebarMenuItemClick,
location: '/index/rules'
},
{
text: 'Member List',
handler: onSidebarMenuItemClick,
location: '/index/memberlist'
},
{
text: 'Forums',
handler: onSidebarMenuItemClick,
location: '/forum/index'
}]
});
sidebarMenu.renderTo('sidebarMenu');
function onSidebarMenuItemClick(btn)
{
window.location = this.location;
}
});
</script>