Upgrade to ExtJS 3.3.1 - Released 11/30/2010
[extjs.git] / pkgs / pkg-menu-debug.js
index b8c9b7b..b8401cb 100644 (file)
 /*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
  */
-/**\r
- * @class Ext.layout.MenuLayout\r
- * @extends Ext.layout.ContainerLayout\r
- * <p>Layout manager used by {@link Ext.menu.Menu}. Generally this class should not need to be used directly.</p>\r
- */\r
- Ext.layout.MenuLayout = Ext.extend(Ext.layout.ContainerLayout, {\r
-    monitorResize : true,\r
-\r
-    setContainer : function(ct){\r
-        this.monitorResize = !ct.floating;\r
-        // This event is only fired by the menu in IE, used so we don't couple\r
-        // the menu with the layout.\r
-        ct.on('autosize', this.doAutoSize, this);\r
-        Ext.layout.MenuLayout.superclass.setContainer.call(this, ct);\r
-    },\r
-\r
-    renderItem : function(c, position, target){\r
-        if (!this.itemTpl) {\r
-            this.itemTpl = Ext.layout.MenuLayout.prototype.itemTpl = new Ext.XTemplate(\r
-                '<li id="{itemId}" class="{itemCls}">',\r
-                    '<tpl if="needsIcon">',\r
-                        '<img src="{icon}" class="{iconCls}"/>',\r
-                    '</tpl>',\r
-                '</li>'\r
-            );\r
-        }\r
-\r
-        if(c && !c.rendered){\r
-            if(Ext.isNumber(position)){\r
-                position = target.dom.childNodes[position];\r
-            }\r
-            var a = this.getItemArgs(c);\r
-\r
-//          The Component's positionEl is the <li> it is rendered into\r
-            c.render(c.positionEl = position ?\r
-                this.itemTpl.insertBefore(position, a, true) :\r
-                this.itemTpl.append(target, a, true));\r
-\r
-//          Link the containing <li> to the item.\r
-            c.positionEl.menuItemId = c.getItemId();\r
-\r
-//          If rendering a regular Component, and it needs an icon,\r
-//          move the Component rightwards.\r
-            if (!a.isMenuItem && a.needsIcon) {\r
-                c.positionEl.addClass('x-menu-list-item-indent');\r
-            }\r
-            this.configureItem(c, position);\r
-        }else if(c && !this.isValidParent(c, target)){\r
-            if(Ext.isNumber(position)){\r
-                position = target.dom.childNodes[position];\r
-            }\r
-            target.dom.insertBefore(c.getActionEl().dom, position || null);\r
-        }\r
-    },\r
-\r
-    getItemArgs : function(c) {\r
-        var isMenuItem = c instanceof Ext.menu.Item;\r
-        return {\r
-            isMenuItem: isMenuItem,\r
-            needsIcon: !isMenuItem && (c.icon || c.iconCls),\r
-            icon: c.icon || Ext.BLANK_IMAGE_URL,\r
-            iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),\r
-            itemId: 'x-menu-el-' + c.id,\r
-            itemCls: 'x-menu-list-item '\r
-        };\r
-    },\r
-\r
-//  Valid if the Component is in a <li> which is part of our target <ul>\r
-    isValidParent : function(c, target) {\r
-        return c.el.up('li.x-menu-list-item', 5).dom.parentNode === (target.dom || target);\r
-    },\r
-\r
-    onLayout : function(ct, target){\r
-        this.renderAll(ct, target);\r
-        this.doAutoSize();\r
-    },\r
-\r
-    doAutoSize : function(){\r
-        var ct = this.container, w = ct.width;\r
-        if(ct.floating){\r
-            if(w){\r
-                ct.setWidth(w);\r
-            }else if(Ext.isIE){\r
-                ct.setWidth(Ext.isStrict && (Ext.isIE7 || Ext.isIE8) ? 'auto' : ct.minWidth);\r
-                var el = ct.getEl(), t = el.dom.offsetWidth; // force recalc\r
-                ct.setWidth(ct.getLayoutTarget().getWidth() + el.getFrameWidth('lr'));\r
-            }\r
-        }\r
-    }\r
-});\r
-Ext.Container.LAYOUTS['menu'] = Ext.layout.MenuLayout;\r
-\r
-/**\r
- * @class Ext.menu.Menu\r
- * @extends Ext.Container\r
- * <p>A menu object.  This is the container to which you may add menu items.  Menu can also serve as a base class\r
- * when you want a specialized menu based off of another component (like {@link Ext.menu.DateMenu} for example).</p>\r
- * <p>Menus may contain either {@link Ext.menu.Item menu items}, or general {@link Ext.Component Component}s.</p>\r
- * <p>To make a contained general {@link Ext.Component Component} line up with other {@link Ext.menu.Item menu items}\r
- * specify <tt>iconCls: 'no-icon'</tt>.  This reserves a space for an icon, and indents the Component in line\r
- * with the other menu items.  See {@link Ext.form.ComboBox}.{@link Ext.form.ComboBox#getListParent getListParent}\r
- * for an example.</p>\r
- * <p>By default, Menus are absolutely positioned, floating Components. By configuring a Menu with\r
- * <b><tt>{@link #floating}:false</tt></b>, a Menu may be used as child of a Container.</p>\r
- *\r
- * @xtype menu\r
- */\r
-Ext.menu.Menu = Ext.extend(Ext.Container, {\r
-    /**\r
-     * @cfg {Object} defaults\r
-     * A config object that will be applied to all items added to this container either via the {@link #items}\r
-     * config or via the {@link #add} method.  The defaults config can contain any number of\r
-     * name/value property pairs to be added to each item, and should be valid for the types of items\r
-     * being added to the menu.\r
-     */\r
-    /**\r
-     * @cfg {Mixed} items\r
-     * An array of items to be added to this menu. Menus may contain either {@link Ext.menu.Item menu items},\r
-     * or general {@link Ext.Component Component}s.\r
-     */\r
-    /**\r
-     * @cfg {Number} minWidth The minimum width of the menu in pixels (defaults to 120)\r
-     */\r
-    minWidth : 120,\r
-    /**\r
-     * @cfg {Boolean/String} shadow True or 'sides' for the default effect, 'frame' for 4-way shadow, and 'drop'\r
-     * for bottom-right shadow (defaults to 'sides')\r
-     */\r
-    shadow : 'sides',\r
-    /**\r
-     * @cfg {String} subMenuAlign The {@link Ext.Element#alignTo} anchor position value to use for submenus of\r
-     * this menu (defaults to 'tl-tr?')\r
-     */\r
-    subMenuAlign : 'tl-tr?',\r
-    /**\r
-     * @cfg {String} defaultAlign The default {@link Ext.Element#alignTo} anchor position value for this menu\r
-     * relative to its element of origin (defaults to 'tl-bl?')\r
-     */\r
-    defaultAlign : 'tl-bl?',\r
-    /**\r
-     * @cfg {Boolean} allowOtherMenus True to allow multiple menus to be displayed at the same time (defaults to false)\r
-     */\r
-    allowOtherMenus : false,\r
-    /**\r
-     * @cfg {Boolean} ignoreParentClicks True to ignore clicks on any item in this menu that is a parent item (displays\r
-     * a submenu) so that the submenu is not dismissed when clicking the parent item (defaults to false).\r
-     */\r
-    ignoreParentClicks : false,\r
-    /**\r
-     * @cfg {Boolean} enableScrolling True to allow the menu container to have scroller controls if the menu is too long (defaults to true).\r
-     */\r
-    enableScrolling : true,\r
-    /**\r
-     * @cfg {Number} maxHeight The maximum height of the menu. Only applies when enableScrolling is set to True (defaults to null).\r
-     */\r
-    maxHeight : null,\r
-    /**\r
-     * @cfg {Number} scrollIncrement The amount to scroll the menu. Only applies when enableScrolling is set to True (defaults to 24).\r
-     */\r
-    scrollIncrement : 24,\r
-    /**\r
-     * @cfg {Boolean} showSeparator True to show the icon separator. (defaults to true).\r
-     */\r
-    showSeparator : true,\r
-    /**\r
-     * @cfg {Array} defaultOffsets An array specifying the [x, y] offset in pixels by which to\r
-     * change the default Menu popup position after aligning according to the {@link #defaultAlign}\r
-     * configuration. Defaults to <tt>[0, 0]</tt>.\r
-     */\r
-    defaultOffsets : [0, 0],\r
-    \r
-    /**\r
-     * @cfg {Boolean} plain\r
-     * True to remove the incised line down the left side of the menu. Defaults to <tt>false</tt>.\r
-     */\r
-    plain : false,\r
-\r
-    /**\r
-     * @cfg {Boolean} floating\r
-     * <p>By default, a Menu configured as <b><code>floating:true</code></b>\r
-     * will be rendered as an {@link Ext.Layer} (an absolutely positioned,\r
-     * floating Component with zindex=15000).\r
-     * If configured as <b><code>floating:false</code></b>, the Menu may be\r
-     * used as child item of another Container instead of a free-floating\r
-     * {@link Ext.Layer Layer}.\r
-     */\r
-    floating : true,\r
-\r
-    // private\r
-    hidden : true,\r
-\r
-    /**\r
-     * @cfg {String/Object} layout\r
-     * This class assigns a default layout (<code>layout:'<b>menu</b>'</code>).\r
-     * Developers <i>may</i> override this configuration option if another layout is required.\r
-     * See {@link Ext.Container#layout} for additional information.\r
-     */\r
-    layout : 'menu',\r
-    hideMode : 'offsets',    // Important for laying out Components\r
-    scrollerHeight : 8,\r
-    autoLayout : true,       // Provided for backwards compat\r
-    defaultType : 'menuitem',\r
-\r
-    initComponent : function(){\r
-        if(Ext.isArray(this.initialConfig)){\r
-            Ext.apply(this, {items:this.initialConfig});\r
-        }\r
-        this.addEvents(\r
-            /**\r
-             * @event click\r
-             * Fires when this menu is clicked (or when the enter key is pressed while it is active)\r
-             * @param {Ext.menu.Menu} this\r
-            * @param {Ext.menu.Item} menuItem The menu item that was clicked\r
-             * @param {Ext.EventObject} e\r
-             */\r
-            'click',\r
-            /**\r
-             * @event mouseover\r
-             * Fires when the mouse is hovering over this menu\r
-             * @param {Ext.menu.Menu} this\r
-             * @param {Ext.EventObject} e\r
-             * @param {Ext.menu.Item} menuItem The menu item that was clicked\r
-             */\r
-            'mouseover',\r
-            /**\r
-             * @event mouseout\r
-             * Fires when the mouse exits this menu\r
-             * @param {Ext.menu.Menu} this\r
-             * @param {Ext.EventObject} e\r
-             * @param {Ext.menu.Item} menuItem The menu item that was clicked\r
-             */\r
-            'mouseout',\r
-            /**\r
-             * @event itemclick\r
-             * Fires when a menu item contained in this menu is clicked\r
-             * @param {Ext.menu.BaseItem} baseItem The BaseItem that was clicked\r
-             * @param {Ext.EventObject} e\r
-             */\r
-            'itemclick'\r
-        );\r
-        Ext.menu.MenuMgr.register(this);\r
-        if(this.floating){\r
-            Ext.EventManager.onWindowResize(this.hide, this);\r
-        }else{\r
-            if(this.initialConfig.hidden !== false){\r
-                this.hidden = false;\r
-            }\r
-            this.internalDefaults = {hideOnClick: false};\r
-        }\r
-        Ext.menu.Menu.superclass.initComponent.call(this);\r
-        if(this.autoLayout){\r
-            this.on({\r
-                add: this.doLayout,\r
-                remove: this.doLayout,\r
-                scope: this\r
-            });\r
-        }\r
-    },\r
-\r
-    //private\r
-    getLayoutTarget : function() {\r
-        return this.ul;\r
-    },\r
-\r
-    // private\r
-    onRender : function(ct, position){\r
-        if(!ct){\r
-            ct = Ext.getBody();\r
-        }\r
-\r
-        var dh = {\r
-            id: this.getId(),\r
-            cls: 'x-menu ' + ((this.floating) ? 'x-menu-floating x-layer ' : '') + (this.cls || '') + (this.plain ? ' x-menu-plain' : '') + (this.showSeparator ? '' : ' x-menu-nosep'),\r
-            style: this.style,\r
-            cn: [\r
-                {tag: 'a', cls: 'x-menu-focus', href: '#', onclick: 'return false;', tabIndex: '-1'},\r
-                {tag: 'ul', cls: 'x-menu-list'}\r
-            ]\r
-        };\r
-        if(this.floating){\r
-            this.el = new Ext.Layer({\r
-                shadow: this.shadow,\r
-                dh: dh,\r
-                constrain: false,\r
-                parentEl: ct,\r
-                zindex:15000\r
-            });\r
-        }else{\r
-            this.el = ct.createChild(dh);\r
-        }\r
-        Ext.menu.Menu.superclass.onRender.call(this, ct, position);\r
-\r
-        if(!this.keyNav){\r
-            this.keyNav = new Ext.menu.MenuNav(this);\r
-        }\r
-        // generic focus element\r
-        this.focusEl = this.el.child('a.x-menu-focus');\r
-        this.ul = this.el.child('ul.x-menu-list');\r
-        this.mon(this.ul, {\r
-            scope: this,\r
-            click: this.onClick,\r
-            mouseover: this.onMouseOver,\r
-            mouseout: this.onMouseOut\r
-        });\r
-        if(this.enableScrolling){\r
-            this.mon(this.el, {\r
-                scope: this,\r
-                delegate: '.x-menu-scroller',\r
-                click: this.onScroll,\r
-                mouseover: this.deactivateActive\r
-            });\r
-        }\r
-    },\r
-\r
-    // private\r
-    findTargetItem : function(e){\r
-        var t = e.getTarget('.x-menu-list-item', this.ul, true);\r
-        if(t && t.menuItemId){\r
-            return this.items.get(t.menuItemId);\r
-        }\r
-    },\r
-\r
-    // private\r
-    onClick : function(e){\r
-        var t = this.findTargetItem(e);\r
-        if(t){\r
-            if(t.isFormField){\r
-                this.setActiveItem(t);\r
-            }else if(t instanceof Ext.menu.BaseItem){\r
-                if(t.menu && this.ignoreParentClicks){\r
-                    t.expandMenu();\r
-                    e.preventDefault();\r
-                }else if(t.onClick){\r
-                    t.onClick(e);\r
-                    this.fireEvent('click', this, t, e);\r
-                }\r
-            }\r
-        }\r
-    },\r
-\r
-    // private\r
-    setActiveItem : function(item, autoExpand){\r
-        if(item != this.activeItem){\r
-            this.deactivateActive();\r
-            if((this.activeItem = item).isFormField){\r
-                item.focus();\r
-            }else{\r
-                item.activate(autoExpand);\r
-            }\r
-        }else if(autoExpand){\r
-            item.expandMenu();\r
-        }\r
-    },\r
-\r
-    deactivateActive : function(){\r
-        var a = this.activeItem;\r
-        if(a){\r
-            if(a.isFormField){\r
-                //Fields cannot deactivate, but Combos must collapse\r
-                if(a.collapse){\r
-                    a.collapse();\r
-                }\r
-            }else{\r
-                a.deactivate();\r
-            }\r
-            delete this.activeItem;\r
-        }\r
-    },\r
-\r
-    // private\r
-    tryActivate : function(start, step){\r
-        var items = this.items;\r
-        for(var i = start, len = items.length; i >= 0 && i < len; i+= step){\r
-            var item = items.get(i);\r
-            if(!item.disabled && (item.canActivate || item.isFormField)){\r
-                this.setActiveItem(item, false);\r
-                return item;\r
-            }\r
-        }\r
-        return false;\r
-    },\r
-\r
-    // private\r
-    onMouseOver : function(e){\r
-        var t = this.findTargetItem(e);\r
-        if(t){\r
-            if(t.canActivate && !t.disabled){\r
-                this.setActiveItem(t, true);\r
-            }\r
-        }\r
-        this.over = true;\r
-        this.fireEvent('mouseover', this, e, t);\r
-    },\r
-\r
-    // private\r
-    onMouseOut : function(e){\r
-        var t = this.findTargetItem(e);\r
-        if(t){\r
-            if(t == this.activeItem && t.shouldDeactivate && t.shouldDeactivate(e)){\r
-                this.activeItem.deactivate();\r
-                delete this.activeItem;\r
-            }\r
-        }\r
-        this.over = false;\r
-        this.fireEvent('mouseout', this, e, t);\r
-    },\r
-\r
-    // private\r
-    onScroll : function(e, t){\r
-        if(e){\r
-            e.stopEvent();\r
-        }\r
-        var ul = this.ul.dom, top = Ext.fly(t).is('.x-menu-scroller-top');\r
-        ul.scrollTop += this.scrollIncrement * (top ? -1 : 1);\r
-        if(top ? ul.scrollTop <= 0 : ul.scrollTop + this.activeMax >= ul.scrollHeight){\r
-           this.onScrollerOut(null, t);\r
-        }\r
-    },\r
-\r
-    // private\r
-    onScrollerIn : function(e, t){\r
-        var ul = this.ul.dom, top = Ext.fly(t).is('.x-menu-scroller-top');\r
-        if(top ? ul.scrollTop > 0 : ul.scrollTop + this.activeMax < ul.scrollHeight){\r
-            Ext.fly(t).addClass(['x-menu-item-active', 'x-menu-scroller-active']);\r
-        }\r
-    },\r
-\r
-    // private\r
-    onScrollerOut : function(e, t){\r
-        Ext.fly(t).removeClass(['x-menu-item-active', 'x-menu-scroller-active']);\r
-    },\r
-\r
-    /**\r
-     * If <code>{@link #floating}=true</code>, shows this menu relative to\r
-     * another element using {@link #showat}, otherwise uses {@link Ext.Component#show}.\r
-     * @param {Mixed} element The element to align to\r
-     * @param {String} position (optional) The {@link Ext.Element#alignTo} anchor position to use in aligning to\r
-     * the element (defaults to this.defaultAlign)\r
-     * @param {Ext.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)\r
-     */\r
-    show : function(el, pos, parentMenu){\r
-        if(this.floating){\r
-            this.parentMenu = parentMenu;\r
-            if(!this.el){\r
-                this.render();\r
-                this.doLayout(false, true);\r
-            }\r
-            this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign, this.defaultOffsets), parentMenu);\r
-        }else{\r
-            Ext.menu.Menu.superclass.show.call(this);\r
-        }\r
-    },\r
-\r
-    /**\r
-     * Displays this menu at a specific xy position and fires the 'show' event if a\r
-     * handler for the 'beforeshow' event does not return false cancelling the operation.\r
-     * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)\r
-     * @param {Ext.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)\r
-     */\r
-    showAt : function(xy, parentMenu){\r
-        if(this.fireEvent('beforeshow', this) !== false){\r
-            this.parentMenu = parentMenu;\r
-            if(!this.el){\r
-                this.render();\r
-            }\r
-            if(this.enableScrolling){\r
-                // set the position so we can figure out the constrain value.\r
-                this.el.setXY(xy);\r
-                //constrain the value, keep the y coordinate the same\r
-                this.constrainScroll(xy[1]);\r
-                xy = [this.el.adjustForConstraints(xy)[0], xy[1]];\r
-            }else{\r
-                //constrain to the viewport.\r
-                xy = this.el.adjustForConstraints(xy);\r
-            }\r
-            this.el.setXY(xy);\r
-            this.el.show();\r
-            Ext.menu.Menu.superclass.onShow.call(this);\r
-            if(Ext.isIE){\r
-                // internal event, used so we don't couple the layout to the menu\r
-                this.fireEvent('autosize', this);\r
-                if(!Ext.isIE8){\r
-                    this.el.repaint();\r
-                }\r
-            }\r
-            this.hidden = false;\r
-            this.focus();\r
-            this.fireEvent('show', this);\r
-        }\r
-    },\r
-\r
-    constrainScroll : function(y){\r
-        var max, full = this.ul.setHeight('auto').getHeight();\r
-        if(this.floating){\r
-            max = this.maxHeight ? this.maxHeight : Ext.fly(this.el.dom.parentNode).getViewSize().height - y;\r
-        }else{\r
-            max = this.getHeight();\r
-        }\r
-        if(full > max && max > 0){\r
-            this.activeMax = max - this.scrollerHeight * 2 - this.el.getFrameWidth('tb') - Ext.num(this.el.shadowOffset, 0);\r
-            this.ul.setHeight(this.activeMax);\r
-            this.createScrollers();\r
-            this.el.select('.x-menu-scroller').setDisplayed('');\r
-        }else{\r
-            this.ul.setHeight(full);\r
-            this.el.select('.x-menu-scroller').setDisplayed('none');\r
-        }\r
-        this.ul.dom.scrollTop = 0;\r
-    },\r
-\r
-    createScrollers : function(){\r
-        if(!this.scroller){\r
-            this.scroller = {\r
-                pos: 0,\r
-                top: this.el.insertFirst({\r
-                    tag: 'div',\r
-                    cls: 'x-menu-scroller x-menu-scroller-top',\r
-                    html: '&#160;'\r
-                }),\r
-                bottom: this.el.createChild({\r
-                    tag: 'div',\r
-                    cls: 'x-menu-scroller x-menu-scroller-bottom',\r
-                    html: '&#160;'\r
-                })\r
-            };\r
-            this.scroller.top.hover(this.onScrollerIn, this.onScrollerOut, this);\r
-            this.scroller.topRepeater = new Ext.util.ClickRepeater(this.scroller.top, {\r
-                listeners: {\r
-                    click: this.onScroll.createDelegate(this, [null, this.scroller.top], false)\r
-                }\r
-            });\r
-            this.scroller.bottom.hover(this.onScrollerIn, this.onScrollerOut, this);\r
-            this.scroller.bottomRepeater = new Ext.util.ClickRepeater(this.scroller.bottom, {\r
-                listeners: {\r
-                    click: this.onScroll.createDelegate(this, [null, this.scroller.bottom], false)\r
-                }\r
-            });\r
-        }\r
-    },\r
-\r
-    onLayout : function(){\r
-        if(this.isVisible()){\r
-            if(this.enableScrolling){\r
-                this.constrainScroll(this.el.getTop());\r
-            }\r
-            if(this.floating){\r
-                this.el.sync();\r
-            }\r
-        }\r
-    },\r
-\r
-    focus : function(){\r
-        if(!this.hidden){\r
-            this.doFocus.defer(50, this);\r
-        }\r
-    },\r
-\r
-    doFocus : function(){\r
-        if(!this.hidden){\r
-            this.focusEl.focus();\r
-        }\r
-    },\r
-\r
-    /**\r
-     * Hides this menu and optionally all parent menus\r
-     * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)\r
-     */\r
-    hide : function(deep){\r
-        this.deepHide = deep;\r
-        Ext.menu.Menu.superclass.hide.call(this);\r
-        delete this.deepHide;\r
-    },\r
-\r
-    // private\r
-    onHide : function(){\r
-        Ext.menu.Menu.superclass.onHide.call(this);\r
-        this.deactivateActive();\r
-        if(this.el && this.floating){\r
-            this.el.hide();\r
-        }\r
-        var pm = this.parentMenu;\r
-        if(this.deepHide === true && pm){\r
-            if(pm.floating){\r
-                pm.hide(true);\r
-            }else{\r
-                pm.deactivateActive();\r
-            }\r
-        }\r
-    },\r
-\r
-    // private\r
-    lookupComponent : function(c){\r
-         if(Ext.isString(c)){\r
-            c = (c == 'separator' || c == '-') ? new Ext.menu.Separator() : new Ext.menu.TextItem(c);\r
-             this.applyDefaults(c);\r
-         }else{\r
-            if(Ext.isObject(c)){\r
-                c = this.getMenuItem(c);\r
-            }else if(c.tagName || c.el){ // element. Wrap it.\r
-                c = new Ext.BoxComponent({\r
-                    el: c\r
-                });\r
-            }\r
-         }\r
-         return c;\r
-    },\r
-\r
-    applyDefaults : function(c){\r
-        if(!Ext.isString(c)){\r
-            c = Ext.menu.Menu.superclass.applyDefaults.call(this, c);\r
-            var d = this.internalDefaults;\r
-            if(d){\r
-                if(c.events){\r
-                    Ext.applyIf(c.initialConfig, d);\r
-                    Ext.apply(c, d);\r
-                }else{\r
-                    Ext.applyIf(c, d);\r
-                }\r
-            }\r
-        }\r
-        return c;\r
-    },\r
-\r
-    // private\r
-    getMenuItem : function(config){\r
-       if(!config.isXType){\r
-            if(!config.xtype && Ext.isBoolean(config.checked)){\r
-                return new Ext.menu.CheckItem(config)\r
-            }\r
-            return Ext.create(config, this.defaultType);\r
-        }\r
-        return config;\r
-    },\r
-\r
-    /**\r
-     * Adds a separator bar to the menu\r
-     * @return {Ext.menu.Item} The menu item that was added\r
-     */\r
-    addSeparator : function(){\r
-        return this.add(new Ext.menu.Separator());\r
-    },\r
-\r
-    /**\r
-     * Adds an {@link Ext.Element} object to the menu\r
-     * @param {Mixed} el The element or DOM node to add, or its id\r
-     * @return {Ext.menu.Item} The menu item that was added\r
-     */\r
-    addElement : function(el){\r
-        return this.add(new Ext.menu.BaseItem(el));\r
-    },\r
-\r
-    /**\r
-     * Adds an existing object based on {@link Ext.menu.BaseItem} to the menu\r
-     * @param {Ext.menu.Item} item The menu item to add\r
-     * @return {Ext.menu.Item} The menu item that was added\r
-     */\r
-    addItem : function(item){\r
-        return this.add(item);\r
-    },\r
-\r
-    /**\r
-     * Creates a new {@link Ext.menu.Item} based an the supplied config object and adds it to the menu\r
-     * @param {Object} config A MenuItem config object\r
-     * @return {Ext.menu.Item} The menu item that was added\r
-     */\r
-    addMenuItem : function(config){\r
-        return this.add(this.getMenuItem(config));\r
-    },\r
-\r
-    /**\r
-     * Creates a new {@link Ext.menu.TextItem} with the supplied text and adds it to the menu\r
-     * @param {String} text The text to display in the menu item\r
-     * @return {Ext.menu.Item} The menu item that was added\r
-     */\r
-    addText : function(text){\r
-        return this.add(new Ext.menu.TextItem(text));\r
-    },\r
-\r
-    //private\r
-    onDestroy : function(){\r
-        Ext.menu.Menu.superclass.onDestroy.call(this);\r
-        Ext.menu.MenuMgr.unregister(this);\r
-        Ext.EventManager.removeResizeListener(this.hide, this);\r
-        if(this.keyNav) {\r
-            this.keyNav.disable();\r
-        }\r
-        var s = this.scroller;\r
-        if(s){\r
-            Ext.destroy(s.topRepeater, s.bottomRepeater, s.top, s.bottom);\r
-        }\r
-        Ext.destroy(\r
-            this.el,\r
-            this.focusEl,\r
-            this.ul\r
-        );\r
-    }\r
-});\r
-\r
-Ext.reg('menu', Ext.menu.Menu);\r
-\r
-// MenuNav is a private utility class used internally by the Menu\r
-Ext.menu.MenuNav = Ext.extend(Ext.KeyNav, function(){\r
-    function up(e, m){\r
-        if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){\r
-            m.tryActivate(m.items.length-1, -1);\r
-        }\r
-    }\r
-    function down(e, m){\r
-        if(!m.tryActivate(m.items.indexOf(m.activeItem)+1, 1)){\r
-            m.tryActivate(0, 1);\r
-        }\r
-    }\r
-    return {\r
-        constructor : function(menu){\r
-            Ext.menu.MenuNav.superclass.constructor.call(this, menu.el);\r
-            this.scope = this.menu = menu;\r
-        },\r
-\r
-        doRelay : function(e, h){\r
-            var k = e.getKey();\r
-//          Keystrokes within a form Field (e.g.: down in a Combo) do not navigate. Allow only TAB\r
-            if (this.menu.activeItem && this.menu.activeItem.isFormField && k != e.TAB) {\r
-                return false;\r
-            }\r
-            if(!this.menu.activeItem && e.isNavKeyPress() && k != e.SPACE && k != e.RETURN){\r
-                this.menu.tryActivate(0, 1);\r
-                return false;\r
-            }\r
-            return h.call(this.scope || this, e, this.menu);\r
-        },\r
-\r
-        tab: function(e, m) {\r
-            e.stopEvent();\r
-            if (e.shiftKey) {\r
-                up(e, m);\r
-            } else {\r
-                down(e, m);\r
-            }\r
-        },\r
-\r
-        up : up,\r
-\r
-        down : down,\r
-\r
-        right : function(e, m){\r
-            if(m.activeItem){\r
-                m.activeItem.expandMenu(true);\r
-            }\r
-        },\r
-\r
-        left : function(e, m){\r
-            m.hide();\r
-            if(m.parentMenu && m.parentMenu.activeItem){\r
-                m.parentMenu.activeItem.activate();\r
-            }\r
-        },\r
-\r
-        enter : function(e, m){\r
-            if(m.activeItem){\r
-                e.stopPropagation();\r
-                m.activeItem.onClick(e);\r
-                m.fireEvent('click', this, m.activeItem);\r
-                return true;\r
-            }\r
-        }\r
-    };\r
-}());\r
+/**
+ * @class Ext.menu.Menu
+ * @extends Ext.Container
+ * <p>A menu object.  This is the container to which you may add menu items.  Menu can also serve as a base class
+ * when you want a specialized menu based off of another component (like {@link Ext.menu.DateMenu} for example).</p>
+ * <p>Menus may contain either {@link Ext.menu.Item menu items}, or general {@link Ext.Component Component}s.</p>
+ * <p>To make a contained general {@link Ext.Component Component} line up with other {@link Ext.menu.Item menu items}
+ * specify <tt>iconCls: 'no-icon'</tt>.  This reserves a space for an icon, and indents the Component in line
+ * with the other menu items.  See {@link Ext.form.ComboBox}.{@link Ext.form.ComboBox#getListParent getListParent}
+ * for an example.</p>
+ * <p>By default, Menus are absolutely positioned, floating Components. By configuring a Menu with
+ * <b><tt>{@link #floating}:false</tt></b>, a Menu may be used as child of a Container.</p>
+ *
+ * @xtype menu
+ */
+Ext.menu.Menu = Ext.extend(Ext.Container, {
+    /**
+     * @cfg {Object} defaults
+     * A config object that will be applied to all items added to this container either via the {@link #items}
+     * config or via the {@link #add} method.  The defaults config can contain any number of
+     * name/value property pairs to be added to each item, and should be valid for the types of items
+     * being added to the menu.
+     */
+    /**
+     * @cfg {Mixed} items
+     * An array of items to be added to this menu. Menus may contain either {@link Ext.menu.Item menu items},
+     * or general {@link Ext.Component Component}s.
+     */
+    /**
+     * @cfg {Number} minWidth The minimum width of the menu in pixels (defaults to 120)
+     */
+    minWidth : 120,
+    /**
+     * @cfg {Boolean/String} shadow True or 'sides' for the default effect, 'frame' for 4-way shadow, and 'drop'
+     * for bottom-right shadow (defaults to 'sides')
+     */
+    shadow : 'sides',
+    /**
+     * @cfg {String} subMenuAlign The {@link Ext.Element#alignTo} anchor position value to use for submenus of
+     * this menu (defaults to 'tl-tr?')
+     */
+    subMenuAlign : 'tl-tr?',
+    /**
+     * @cfg {String} defaultAlign The default {@link Ext.Element#alignTo} anchor position value for this menu
+     * relative to its element of origin (defaults to 'tl-bl?')
+     */
+    defaultAlign : 'tl-bl?',
+    /**
+     * @cfg {Boolean} allowOtherMenus True to allow multiple menus to be displayed at the same time (defaults to false)
+     */
+    allowOtherMenus : false,
+    /**
+     * @cfg {Boolean} ignoreParentClicks True to ignore clicks on any item in this menu that is a parent item (displays
+     * a submenu) so that the submenu is not dismissed when clicking the parent item (defaults to false).
+     */
+    ignoreParentClicks : false,
+    /**
+     * @cfg {Boolean} enableScrolling True to allow the menu container to have scroller controls if the menu is too long (defaults to true).
+     */
+    enableScrolling : true,
+    /**
+     * @cfg {Number} maxHeight The maximum height of the menu. Only applies when enableScrolling is set to True (defaults to null).
+     */
+    maxHeight : null,
+    /**
+     * @cfg {Number} scrollIncrement The amount to scroll the menu. Only applies when enableScrolling is set to True (defaults to 24).
+     */
+    scrollIncrement : 24,
+    /**
+     * @cfg {Boolean} showSeparator True to show the icon separator. (defaults to true).
+     */
+    showSeparator : true,
+    /**
+     * @cfg {Array} defaultOffsets An array specifying the [x, y] offset in pixels by which to
+     * change the default Menu popup position after aligning according to the {@link #defaultAlign}
+     * configuration. Defaults to <tt>[0, 0]</tt>.
+     */
+    defaultOffsets : [0, 0],
+
+    /**
+     * @cfg {Boolean} plain
+     * True to remove the incised line down the left side of the menu. Defaults to <tt>false</tt>.
+     */
+    plain : false,
+
+    /**
+     * @cfg {Boolean} floating
+     * <p>By default, a Menu configured as <b><code>floating:true</code></b>
+     * will be rendered as an {@link Ext.Layer} (an absolutely positioned,
+     * floating Component with zindex=15000).
+     * If configured as <b><code>floating:false</code></b>, the Menu may be
+     * used as child item of another Container instead of a free-floating
+     * {@link Ext.Layer Layer}.
+     */
+    floating : true,
+
+
+    /**
+     * @cfg {Number} zIndex
+     * zIndex to use when the menu is floating.
+     */
+    zIndex: 15000,
+
+    // private
+    hidden : true,
+
+    /**
+     * @cfg {String/Object} layout
+     * This class assigns a default layout (<code>layout:'<b>menu</b>'</code>).
+     * Developers <i>may</i> override this configuration option if another layout is required.
+     * See {@link Ext.Container#layout} for additional information.
+     */
+    layout : 'menu',
+    hideMode : 'offsets',    // Important for laying out Components
+    scrollerHeight : 8,
+    autoLayout : true,       // Provided for backwards compat
+    defaultType : 'menuitem',
+    bufferResize : false,
+
+    initComponent : function(){
+        if(Ext.isArray(this.initialConfig)){
+            Ext.apply(this, {items:this.initialConfig});
+        }
+        this.addEvents(
+            /**
+             * @event click
+             * Fires when this menu is clicked (or when the enter key is pressed while it is active)
+             * @param {Ext.menu.Menu} this
+            * @param {Ext.menu.Item} menuItem The menu item that was clicked
+             * @param {Ext.EventObject} e
+             */
+            'click',
+            /**
+             * @event mouseover
+             * Fires when the mouse is hovering over this menu
+             * @param {Ext.menu.Menu} this
+             * @param {Ext.EventObject} e
+             * @param {Ext.menu.Item} menuItem The menu item that was clicked
+             */
+            'mouseover',
+            /**
+             * @event mouseout
+             * Fires when the mouse exits this menu
+             * @param {Ext.menu.Menu} this
+             * @param {Ext.EventObject} e
+             * @param {Ext.menu.Item} menuItem The menu item that was clicked
+             */
+            'mouseout',
+            /**
+             * @event itemclick
+             * Fires when a menu item contained in this menu is clicked
+             * @param {Ext.menu.BaseItem} baseItem The BaseItem that was clicked
+             * @param {Ext.EventObject} e
+             */
+            'itemclick'
+        );
+        Ext.menu.MenuMgr.register(this);
+        if(this.floating){
+            Ext.EventManager.onWindowResize(this.hide, this);
+        }else{
+            if(this.initialConfig.hidden !== false){
+                this.hidden = false;
+            }
+            this.internalDefaults = {hideOnClick: false};
+        }
+        Ext.menu.Menu.superclass.initComponent.call(this);
+        if(this.autoLayout){
+            var fn = this.doLayout.createDelegate(this, []);
+            this.on({
+                add: fn,
+                remove: fn
+            });
+        }
+    },
+
+    //private
+    getLayoutTarget : function() {
+        return this.ul;
+    },
+
+    // private
+    onRender : function(ct, position){
+        if(!ct){
+            ct = Ext.getBody();
+        }
+
+        var dh = {
+            id: this.getId(),
+            cls: 'x-menu ' + ((this.floating) ? 'x-menu-floating x-layer ' : '') + (this.cls || '') + (this.plain ? ' x-menu-plain' : '') + (this.showSeparator ? '' : ' x-menu-nosep'),
+            style: this.style,
+            cn: [
+                {tag: 'a', cls: 'x-menu-focus', href: '#', onclick: 'return false;', tabIndex: '-1'},
+                {tag: 'ul', cls: 'x-menu-list'}
+            ]
+        };
+        if(this.floating){
+            this.el = new Ext.Layer({
+                shadow: this.shadow,
+                dh: dh,
+                constrain: false,
+                parentEl: ct,
+                zindex: this.zIndex
+            });
+        }else{
+            this.el = ct.createChild(dh);
+        }
+        Ext.menu.Menu.superclass.onRender.call(this, ct, position);
+
+        if(!this.keyNav){
+            this.keyNav = new Ext.menu.MenuNav(this);
+        }
+        // generic focus element
+        this.focusEl = this.el.child('a.x-menu-focus');
+        this.ul = this.el.child('ul.x-menu-list');
+        this.mon(this.ul, {
+            scope: this,
+            click: this.onClick,
+            mouseover: this.onMouseOver,
+            mouseout: this.onMouseOut
+        });
+        if(this.enableScrolling){
+            this.mon(this.el, {
+                scope: this,
+                delegate: '.x-menu-scroller',
+                click: this.onScroll,
+                mouseover: this.deactivateActive
+            });
+        }
+    },
+
+    // private
+    findTargetItem : function(e){
+        var t = e.getTarget('.x-menu-list-item', this.ul, true);
+        if(t && t.menuItemId){
+            return this.items.get(t.menuItemId);
+        }
+    },
+
+    // private
+    onClick : function(e){
+        var t = this.findTargetItem(e);
+        if(t){
+            if(t.isFormField){
+                this.setActiveItem(t);
+            }else if(t instanceof Ext.menu.BaseItem){
+                if(t.menu && this.ignoreParentClicks){
+                    t.expandMenu();
+                    e.preventDefault();
+                }else if(t.onClick){
+                    t.onClick(e);
+                    this.fireEvent('click', this, t, e);
+                }
+            }
+        }
+    },
+
+    // private
+    setActiveItem : function(item, autoExpand){
+        if(item != this.activeItem){
+            this.deactivateActive();
+            if((this.activeItem = item).isFormField){
+                item.focus();
+            }else{
+                item.activate(autoExpand);
+            }
+        }else if(autoExpand){
+            item.expandMenu();
+        }
+    },
+
+    deactivateActive : function(){
+        var a = this.activeItem;
+        if(a){
+            if(a.isFormField){
+                //Fields cannot deactivate, but Combos must collapse
+                if(a.collapse){
+                    a.collapse();
+                }
+            }else{
+                a.deactivate();
+            }
+            delete this.activeItem;
+        }
+    },
+
+    // private
+    tryActivate : function(start, step){
+        var items = this.items;
+        for(var i = start, len = items.length; i >= 0 && i < len; i+= step){
+            var item = items.get(i);
+            if(item.isVisible() && !item.disabled && (item.canActivate || item.isFormField)){
+                this.setActiveItem(item, false);
+                return item;
+            }
+        }
+        return false;
+    },
+
+    // private
+    onMouseOver : function(e){
+        var t = this.findTargetItem(e);
+        if(t){
+            if(t.canActivate && !t.disabled){
+                this.setActiveItem(t, true);
+            }
+        }
+        this.over = true;
+        this.fireEvent('mouseover', this, e, t);
+    },
+
+    // private
+    onMouseOut : function(e){
+        var t = this.findTargetItem(e);
+        if(t){
+            if(t == this.activeItem && t.shouldDeactivate && t.shouldDeactivate(e)){
+                this.activeItem.deactivate();
+                delete this.activeItem;
+            }
+        }
+        this.over = false;
+        this.fireEvent('mouseout', this, e, t);
+    },
+
+    // private
+    onScroll : function(e, t){
+        if(e){
+            e.stopEvent();
+        }
+        var ul = this.ul.dom, top = Ext.fly(t).is('.x-menu-scroller-top');
+        ul.scrollTop += this.scrollIncrement * (top ? -1 : 1);
+        if(top ? ul.scrollTop <= 0 : ul.scrollTop + this.activeMax >= ul.scrollHeight){
+           this.onScrollerOut(null, t);
+        }
+    },
+
+    // private
+    onScrollerIn : function(e, t){
+        var ul = this.ul.dom, top = Ext.fly(t).is('.x-menu-scroller-top');
+        if(top ? ul.scrollTop > 0 : ul.scrollTop + this.activeMax < ul.scrollHeight){
+            Ext.fly(t).addClass(['x-menu-item-active', 'x-menu-scroller-active']);
+        }
+    },
+
+    // private
+    onScrollerOut : function(e, t){
+        Ext.fly(t).removeClass(['x-menu-item-active', 'x-menu-scroller-active']);
+    },
+
+    /**
+     * If <code>{@link #floating}=true</code>, shows this menu relative to
+     * another element using {@link #showat}, otherwise uses {@link Ext.Component#show}.
+     * @param {Mixed} element The element to align to
+     * @param {String} position (optional) The {@link Ext.Element#alignTo} anchor position to use in aligning to
+     * the element (defaults to this.defaultAlign)
+     * @param {Ext.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
+     */
+    show : function(el, pos, parentMenu){
+        if(this.floating){
+            this.parentMenu = parentMenu;
+            if(!this.el){
+                this.render();
+                this.doLayout(false, true);
+            }
+            this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign, this.defaultOffsets), parentMenu);
+        }else{
+            Ext.menu.Menu.superclass.show.call(this);
+        }
+    },
+
+    /**
+     * Displays this menu at a specific xy position and fires the 'show' event if a
+     * handler for the 'beforeshow' event does not return false cancelling the operation.
+     * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
+     * @param {Ext.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
+     */
+    showAt : function(xy, parentMenu){
+        if(this.fireEvent('beforeshow', this) !== false){
+            this.parentMenu = parentMenu;
+            if(!this.el){
+                this.render();
+            }
+            if(this.enableScrolling){
+                // set the position so we can figure out the constrain value.
+                this.el.setXY(xy);
+                //constrain the value, keep the y coordinate the same
+                xy[1] = this.constrainScroll(xy[1]);
+                xy = [this.el.adjustForConstraints(xy)[0], xy[1]];
+            }else{
+                //constrain to the viewport.
+                xy = this.el.adjustForConstraints(xy);
+            }
+            this.el.setXY(xy);
+            this.el.show();
+            Ext.menu.Menu.superclass.onShow.call(this);
+            if(Ext.isIE){
+                // internal event, used so we don't couple the layout to the menu
+                this.fireEvent('autosize', this);
+                if(!Ext.isIE8){
+                    this.el.repaint();
+                }
+            }
+            this.hidden = false;
+            this.focus();
+            this.fireEvent('show', this);
+        }
+    },
+
+    constrainScroll : function(y){
+        var max, full = this.ul.setHeight('auto').getHeight(),
+            returnY = y, normalY, parentEl, scrollTop, viewHeight;
+        if(this.floating){
+            parentEl = Ext.fly(this.el.dom.parentNode);
+            scrollTop = parentEl.getScroll().top;
+            viewHeight = parentEl.getViewSize().height;
+            //Normalize y by the scroll position for the parent element.  Need to move it into the coordinate space
+            //of the view.
+            normalY = y - scrollTop;
+            max = this.maxHeight ? this.maxHeight : viewHeight - normalY;
+            if(full > viewHeight) {
+                max = viewHeight;
+                //Set returnY equal to (0,0) in view space by reducing y by the value of normalY
+                returnY = y - normalY;
+            } else if(max < full) {
+                returnY = y - (full - max);
+                max = full;
+            }
+        }else{
+            max = this.getHeight();
+        }
+        // Always respect maxHeight 
+        if (this.maxHeight){
+            max = Math.min(this.maxHeight, max);
+        }
+        if(full > max && max > 0){
+            this.activeMax = max - this.scrollerHeight * 2 - this.el.getFrameWidth('tb') - Ext.num(this.el.shadowOffset, 0);
+            this.ul.setHeight(this.activeMax);
+            this.createScrollers();
+            this.el.select('.x-menu-scroller').setDisplayed('');
+        }else{
+            this.ul.setHeight(full);
+            this.el.select('.x-menu-scroller').setDisplayed('none');
+        }
+        this.ul.dom.scrollTop = 0;
+        return returnY;
+    },
+
+    createScrollers : function(){
+        if(!this.scroller){
+            this.scroller = {
+                pos: 0,
+                top: this.el.insertFirst({
+                    tag: 'div',
+                    cls: 'x-menu-scroller x-menu-scroller-top',
+                    html: '&#160;'
+                }),
+                bottom: this.el.createChild({
+                    tag: 'div',
+                    cls: 'x-menu-scroller x-menu-scroller-bottom',
+                    html: '&#160;'
+                })
+            };
+            this.scroller.top.hover(this.onScrollerIn, this.onScrollerOut, this);
+            this.scroller.topRepeater = new Ext.util.ClickRepeater(this.scroller.top, {
+                listeners: {
+                    click: this.onScroll.createDelegate(this, [null, this.scroller.top], false)
+                }
+            });
+            this.scroller.bottom.hover(this.onScrollerIn, this.onScrollerOut, this);
+            this.scroller.bottomRepeater = new Ext.util.ClickRepeater(this.scroller.bottom, {
+                listeners: {
+                    click: this.onScroll.createDelegate(this, [null, this.scroller.bottom], false)
+                }
+            });
+        }
+    },
+
+    onLayout : function(){
+        if(this.isVisible()){
+            if(this.enableScrolling){
+                this.constrainScroll(this.el.getTop());
+            }
+            if(this.floating){
+                this.el.sync();
+            }
+        }
+    },
+
+    focus : function(){
+        if(!this.hidden){
+            this.doFocus.defer(50, this);
+        }
+    },
+
+    doFocus : function(){
+        if(!this.hidden){
+            this.focusEl.focus();
+        }
+    },
+
+    /**
+     * Hides this menu and optionally all parent menus
+     * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
+     */
+    hide : function(deep){
+        if (!this.isDestroyed) {
+            this.deepHide = deep;
+            Ext.menu.Menu.superclass.hide.call(this);
+            delete this.deepHide;
+        }
+    },
+
+    // private
+    onHide : function(){
+        Ext.menu.Menu.superclass.onHide.call(this);
+        this.deactivateActive();
+        if(this.el && this.floating){
+            this.el.hide();
+        }
+        var pm = this.parentMenu;
+        if(this.deepHide === true && pm){
+            if(pm.floating){
+                pm.hide(true);
+            }else{
+                pm.deactivateActive();
+            }
+        }
+    },
+
+    // private
+    lookupComponent : function(c){
+         if(Ext.isString(c)){
+            c = (c == 'separator' || c == '-') ? new Ext.menu.Separator() : new Ext.menu.TextItem(c);
+             this.applyDefaults(c);
+         }else{
+            if(Ext.isObject(c)){
+                c = this.getMenuItem(c);
+            }else if(c.tagName || c.el){ // element. Wrap it.
+                c = new Ext.BoxComponent({
+                    el: c
+                });
+            }
+         }
+         return c;
+    },
+
+    applyDefaults : function(c) {
+        if (!Ext.isString(c)) {
+            c = Ext.menu.Menu.superclass.applyDefaults.call(this, c);
+            var d = this.internalDefaults;
+            if(d){
+                if(c.events){
+                    Ext.applyIf(c.initialConfig, d);
+                    Ext.apply(c, d);
+                }else{
+                    Ext.applyIf(c, d);
+                }
+            }
+        }
+        return c;
+    },
+
+    // private
+    getMenuItem : function(config) {
+        if (!config.isXType) {
+            if (!config.xtype && Ext.isBoolean(config.checked)) {
+                return new Ext.menu.CheckItem(config);
+            }
+            return Ext.create(config, this.defaultType);
+        }
+        return config;
+    },
+
+    /**
+     * Adds a separator bar to the menu
+     * @return {Ext.menu.Item} The menu item that was added
+     */
+    addSeparator : function() {
+        return this.add(new Ext.menu.Separator());
+    },
+
+    /**
+     * Adds an {@link Ext.Element} object to the menu
+     * @param {Mixed} el The element or DOM node to add, or its id
+     * @return {Ext.menu.Item} The menu item that was added
+     */
+    addElement : function(el) {
+        return this.add(new Ext.menu.BaseItem({
+            el: el
+        }));
+    },
+
+    /**
+     * Adds an existing object based on {@link Ext.menu.BaseItem} to the menu
+     * @param {Ext.menu.Item} item The menu item to add
+     * @return {Ext.menu.Item} The menu item that was added
+     */
+    addItem : function(item) {
+        return this.add(item);
+    },
+
+    /**
+     * Creates a new {@link Ext.menu.Item} based an the supplied config object and adds it to the menu
+     * @param {Object} config A MenuItem config object
+     * @return {Ext.menu.Item} The menu item that was added
+     */
+    addMenuItem : function(config) {
+        return this.add(this.getMenuItem(config));
+    },
+
+    /**
+     * Creates a new {@link Ext.menu.TextItem} with the supplied text and adds it to the menu
+     * @param {String} text The text to display in the menu item
+     * @return {Ext.menu.Item} The menu item that was added
+     */
+    addText : function(text){
+        return this.add(new Ext.menu.TextItem(text));
+    },
+
+    //private
+    onDestroy : function(){
+        Ext.EventManager.removeResizeListener(this.hide, this);
+        var pm = this.parentMenu;
+        if(pm && pm.activeChild == this){
+            delete pm.activeChild;
+        }
+        delete this.parentMenu;
+        Ext.menu.Menu.superclass.onDestroy.call(this);
+        Ext.menu.MenuMgr.unregister(this);
+        if(this.keyNav) {
+            this.keyNav.disable();
+        }
+        var s = this.scroller;
+        if(s){
+            Ext.destroy(s.topRepeater, s.bottomRepeater, s.top, s.bottom);
+        }
+        Ext.destroy(
+            this.el,
+            this.focusEl,
+            this.ul
+        );
+    }
+});
+
+Ext.reg('menu', Ext.menu.Menu);
+
+// MenuNav is a private utility class used internally by the Menu
+Ext.menu.MenuNav = Ext.extend(Ext.KeyNav, function(){
+    function up(e, m){
+        if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){
+            m.tryActivate(m.items.length-1, -1);
+        }
+    }
+    function down(e, m){
+        if(!m.tryActivate(m.items.indexOf(m.activeItem)+1, 1)){
+            m.tryActivate(0, 1);
+        }
+    }
+    return {
+        constructor : function(menu){
+            Ext.menu.MenuNav.superclass.constructor.call(this, menu.el);
+            this.scope = this.menu = menu;
+        },
+
+        doRelay : function(e, h){
+            var k = e.getKey();
+//          Keystrokes within a form Field (e.g.: down in a Combo) do not navigate. Allow only TAB
+            if (this.menu.activeItem && this.menu.activeItem.isFormField && k != e.TAB) {
+                return false;
+            }
+            if(!this.menu.activeItem && e.isNavKeyPress() && k != e.SPACE && k != e.RETURN){
+                this.menu.tryActivate(0, 1);
+                return false;
+            }
+            return h.call(this.scope || this, e, this.menu);
+        },
+
+        tab: function(e, m) {
+            e.stopEvent();
+            if (e.shiftKey) {
+                up(e, m);
+            } else {
+                down(e, m);
+            }
+        },
+
+        up : up,
+
+        down : down,
+
+        right : function(e, m){
+            if(m.activeItem){
+                m.activeItem.expandMenu(true);
+            }
+        },
+
+        left : function(e, m){
+            m.hide();
+            if(m.parentMenu && m.parentMenu.activeItem){
+                m.parentMenu.activeItem.activate();
+            }
+        },
+
+        enter : function(e, m){
+            if(m.activeItem){
+                e.stopPropagation();
+                m.activeItem.onClick(e);
+                m.fireEvent('click', this, m.activeItem);
+                return true;
+            }
+        }
+    };
+}());
 /**
  * @class Ext.menu.MenuMgr
  * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
@@ -797,7 +742,9 @@ Ext.menu.MenuMgr = function(){
            c.each(function(m){
                m.hide();
            });
+           return true;
        }
+       return false;
    }
 
    // private
@@ -821,7 +768,7 @@ Ext.menu.MenuMgr = function(){
        if(m.parentMenu){
           m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
           m.parentMenu.activeChild = m;
-       }else if(last && last.isVisible()){
+       }else if(last && !last.isDestroyed && last.isVisible()){
           m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
        }
    }
@@ -854,25 +801,14 @@ Ext.menu.MenuMgr = function(){
        }
    }
 
-   // private
-   function onBeforeCheck(mi, state){
-       if(state){
-           var g = groups[mi.group];
-           for(var i = 0, l = g.length; i < l; i++){
-               if(g[i] != mi){
-                   g[i].setChecked(false);
-               }
-           }
-       }
-   }
-
    return {
 
        /**
         * Hides all menus that are currently visible
+        * @return {Boolean} success True if any active menus were hidden.
         */
        hideAll : function(){
-            hideAll();  
+            return hideAll();
        },
 
        // private
@@ -881,18 +817,12 @@ Ext.menu.MenuMgr = function(){
                init();
            }
            menus[menu.id] = menu;
-           menu.on("beforehide", onBeforeHide);
-           menu.on("hide", onHide);
-           menu.on("beforeshow", onBeforeShow);
-           menu.on("show", onShow);
-           var g = menu.group;
-           if(g && menu.events["checkchange"]){
-               if(!groups[g]){
-                   groups[g] = [];
-               }
-               groups[g].push(menu);
-               menu.on("checkchange", onCheck);
-           }
+           menu.on({
+               beforehide: onBeforeHide,
+               hide: onHide,
+               beforeshow: onBeforeShow,
+               show: onShow
+           });
        },
 
         /**
@@ -923,11 +853,6 @@ Ext.menu.MenuMgr = function(){
            menu.un("hide", onHide);
            menu.un("beforeshow", onBeforeShow);
            menu.un("show", onShow);
-           var g = menu.group;
-           if(g && menu.events["checkchange"]){
-               groups[g].remove(menu);
-               menu.un("checkchange", onCheck);
-           }
        },
 
        // private
@@ -938,7 +863,6 @@ Ext.menu.MenuMgr = function(){
                    groups[g] = [];
                }
                groups[g].push(menuItem);
-               menuItem.on("beforecheckchange", onBeforeCheck);
            }
        },
 
@@ -947,7 +871,23 @@ Ext.menu.MenuMgr = function(){
            var g = menuItem.group;
            if(g){
                groups[g].remove(menuItem);
-               menuItem.un("beforecheckchange", onBeforeCheck);
+           }
+       },
+       
+       // private
+       onCheckChange: function(item, state){
+           if(item.group && state){
+               var group = groups[item.group],
+                   i = 0,
+                   len = group.length,
+                   current;
+                   
+               for(; i < len; i++){
+                   current = group[i];
+                   if(current != item){
+                       current.setChecked(false);
+                   }
+               }
            }
        },
 
@@ -986,37 +926,7 @@ Ext.menu.MenuMgr = function(){
  * @param {Object} config Configuration options
  * @xtype menubaseitem
  */
-Ext.menu.BaseItem = function(config){
-    Ext.menu.BaseItem.superclass.constructor.call(this, config);
-
-    this.addEvents(
-        /**
-         * @event click
-         * Fires when this item is clicked
-         * @param {Ext.menu.BaseItem} this
-         * @param {Ext.EventObject} e
-         */
-        'click',
-        /**
-         * @event activate
-         * Fires when this item is activated
-         * @param {Ext.menu.BaseItem} this
-         */
-        'activate',
-        /**
-         * @event deactivate
-         * Fires when this item is deactivated
-         * @param {Ext.menu.BaseItem} this
-         */
-        'deactivate'
-    );
-
-    if(this.handler){
-        this.on("click", this.handler, this.scope);
-    }
-};
-
-Ext.extend(Ext.menu.BaseItem, Ext.Component, {
+Ext.menu.BaseItem = Ext.extend(Ext.Component, {
     /**
      * @property parentMenu
      * @type Ext.menu.Menu
@@ -1047,7 +957,7 @@ Ext.extend(Ext.menu.BaseItem, Ext.Component, {
      */
     hideOnClick : true,
     /**
-     * @cfg {Number} clickHideDelay Length of time in milliseconds to wait before hiding after a click (defaults to 100)
+     * @cfg {Number} clickHideDelay Length of time in milliseconds to wait before hiding after a click (defaults to 1)
      */
     clickHideDelay : 1,
 
@@ -1057,6 +967,34 @@ Ext.extend(Ext.menu.BaseItem, Ext.Component, {
     // private
     actionMode : "container",
 
+    initComponent : function(){
+        Ext.menu.BaseItem.superclass.initComponent.call(this);
+        this.addEvents(
+            /**
+             * @event click
+             * Fires when this item is clicked
+             * @param {Ext.menu.BaseItem} this
+             * @param {Ext.EventObject} e
+             */
+            'click',
+            /**
+             * @event activate
+             * Fires when this item is activated
+             * @param {Ext.menu.BaseItem} this
+             */
+            'activate',
+            /**
+             * @event deactivate
+             * Fires when this item is deactivated
+             * @param {Ext.menu.BaseItem} this
+             */
+            'deactivate'
+        );
+        if(this.handler){
+            this.on("click", this.handler, this.scope);
+        }
+    },
+
     // private
     onRender : function(container, position){
         Ext.menu.BaseItem.superclass.onRender.apply(this, arguments);
@@ -1064,9 +1002,12 @@ Ext.extend(Ext.menu.BaseItem, Ext.Component, {
             this.parentMenu = this.ownerCt;
         }else{
             this.container.addClass('x-menu-list-item');
-            this.mon(this.el, 'click', this.onClick, this);
-            this.mon(this.el, 'mouseenter', this.activate, this);
-            this.mon(this.el, 'mouseleave', this.deactivate, this);
+            this.mon(this.el, {
+                scope: this,
+                click: this.onClick,
+                mouseenter: this.activate,
+                mouseleave: this.deactivate
+            });
         }
     },
 
@@ -1074,7 +1015,7 @@ Ext.extend(Ext.menu.BaseItem, Ext.Component, {
      * Sets the function that will handle click events for this item (equivalent to passing in the {@link #handler}
      * config property).  If an existing handler is already registered, it will be unregistered for you.
      * @param {Function} handler The function that should be called on click
-     * @param {Object} scope The scope that should be passed to the handler
+     * @param {Object} scope The scope (<code>this</code> reference) in which the handler function is executed. Defaults to this menu item.
      */
     setHandler : function(handler, scope){
         if(this.handler){
@@ -1144,14 +1085,7 @@ Ext.reg('menubaseitem', Ext.menu.BaseItem);/**
  * is applied as a config object (and should contain a <tt>text</tt> property).
  * @xtype menutextitem
  */
-Ext.menu.TextItem = function(cfg){
-    if(typeof cfg == 'string'){
-        cfg = {text: cfg}
-    }
-    Ext.menu.TextItem.superclass.constructor.call(this, cfg);
-};
-
-Ext.extend(Ext.menu.TextItem, Ext.menu.BaseItem, {
+Ext.menu.TextItem = Ext.extend(Ext.menu.BaseItem, {
     /**
      * @cfg {String} text The text to display for this item (defaults to '')
      */
@@ -1163,9 +1097,18 @@ Ext.extend(Ext.menu.TextItem, Ext.menu.BaseItem, {
      * @cfg {String} itemCls The default CSS class to use for text items (defaults to "x-menu-text")
      */
     itemCls : "x-menu-text",
+    
+    constructor : function(config) {
+        if (typeof config == 'string') {
+            config = {
+                text: config
+            };
+        }
+        Ext.menu.TextItem.superclass.constructor.call(this, config);
+    },
 
     // private
-    onRender : function(){
+    onRender : function() {
         var s = document.createElement("span");
         s.className = this.itemCls;
         s.innerHTML = this.text;
@@ -1182,11 +1125,7 @@ Ext.reg('menutextitem', Ext.menu.TextItem);/**
  * @param {Object} config Configuration options
  * @xtype menuseparator
  */
-Ext.menu.Separator = function(config){
-    Ext.menu.Separator.superclass.constructor.call(this, config);
-};
-
-Ext.extend(Ext.menu.Separator, Ext.menu.BaseItem, {
+Ext.menu.Separator = Ext.extend(Ext.menu.BaseItem, {
     /**
      * @cfg {String} itemCls The default CSS class to use for separators (defaults to "x-menu-sep")
      */
@@ -1212,210 +1151,223 @@ Ext.extend(Ext.menu.Separator, Ext.menu.BaseItem, {
         Ext.menu.Separator.superclass.onRender.apply(this, arguments);
     }
 });
-Ext.reg('menuseparator', Ext.menu.Separator);/**\r
- * @class Ext.menu.Item\r
- * @extends Ext.menu.BaseItem\r
- * A base class for all menu items that require menu-related functionality (like sub-menus) and are not static\r
- * display items.  Item extends the base functionality of {@link Ext.menu.BaseItem} by adding menu-specific\r
- * activation and click handling.\r
- * @constructor\r
- * Creates a new Item\r
- * @param {Object} config Configuration options\r
- * @xtype menuitem\r
- */\r
-Ext.menu.Item = function(config){\r
-    Ext.menu.Item.superclass.constructor.call(this, config);\r
-    if(this.menu){\r
-        this.menu = Ext.menu.MenuMgr.get(this.menu);\r
-    }\r
-};\r
-Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {\r
-    /**\r
-     * @property menu\r
-     * @type Ext.menu.Menu\r
-     * The submenu associated with this Item if one was configured.\r
-     */\r
-    /**\r
-     * @cfg {Mixed} menu (optional) Either an instance of {@link Ext.menu.Menu} or the config object for an\r
-     * {@link Ext.menu.Menu} which acts as the submenu when this item is activated.\r
-     */\r
-    /**\r
-     * @cfg {String} icon The path to an icon to display in this item (defaults to Ext.BLANK_IMAGE_URL).  If\r
-     * icon is specified {@link #iconCls} should not be.\r
-     */\r
-    /**\r
-     * @cfg {String} iconCls A CSS class that specifies a background image that will be used as the icon for\r
-     * this item (defaults to '').  If iconCls is specified {@link #icon} should not be.\r
-     */\r
-    /**\r
-     * @cfg {String} text The text to display in this item (defaults to '').\r
-     */\r
-    /**\r
-     * @cfg {String} href The href attribute to use for the underlying anchor link (defaults to '#').\r
-     */\r
-    /**\r
-     * @cfg {String} hrefTarget The target attribute to use for the underlying anchor link (defaults to '').\r
-     */\r
-    /**\r
-     * @cfg {String} itemCls The default CSS class to use for menu items (defaults to 'x-menu-item')\r
-     */\r
-    itemCls : 'x-menu-item',\r
-    /**\r
-     * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to true)\r
-     */\r
-    canActivate : true,\r
-    /**\r
-     * @cfg {Number} showDelay Length of time in milliseconds to wait before showing this item (defaults to 200)\r
-     */\r
-    showDelay: 200,\r
-    // doc'd in BaseItem\r
-    hideDelay: 200,\r
-\r
-    // private\r
-    ctype: 'Ext.menu.Item',\r
-\r
-    // private\r
-    onRender : function(container, position){\r
-        if (!this.itemTpl) {\r
-            this.itemTpl = Ext.menu.Item.prototype.itemTpl = new Ext.XTemplate(\r
-                '<a id="{id}" class="{cls}" hidefocus="true" unselectable="on" href="{href}"',\r
-                    '<tpl if="hrefTarget">',\r
-                        ' target="{hrefTarget}"',\r
-                    '</tpl>',\r
-                 '>',\r
-                     '<img src="{icon}" class="x-menu-item-icon {iconCls}"/>',\r
-                     '<span class="x-menu-item-text">{text}</span>',\r
-                 '</a>'\r
-             );\r
-        }\r
-        var a = this.getTemplateArgs();\r
-        this.el = position ? this.itemTpl.insertBefore(position, a, true) : this.itemTpl.append(container, a, true);\r
-        this.iconEl = this.el.child('img.x-menu-item-icon');\r
-        this.textEl = this.el.child('.x-menu-item-text');\r
-        Ext.menu.Item.superclass.onRender.call(this, container, position);\r
-    },\r
-\r
-    getTemplateArgs: function() {\r
-        return {\r
-            id: this.id,\r
-            cls: this.itemCls + (this.menu ?  ' x-menu-item-arrow' : '') + (this.cls ?  ' ' + this.cls : ''),\r
-            href: this.href || '#',\r
-            hrefTarget: this.hrefTarget,\r
-            icon: this.icon || Ext.BLANK_IMAGE_URL,\r
-            iconCls: this.iconCls || '',\r
-            text: this.itemText||this.text||'&#160;'\r
-        };\r
-    },\r
-\r
-    /**\r
-     * Sets the text to display in this menu item\r
-     * @param {String} text The text to display\r
-     */\r
-    setText : function(text){\r
-        this.text = text||'&#160;';\r
-        if(this.rendered){\r
-            this.textEl.update(this.text);\r
-            this.parentMenu.layout.doAutoSize();\r
-        }\r
-    },\r
-\r
-    /**\r
-     * Sets the CSS class to apply to the item's icon element\r
-     * @param {String} cls The CSS class to apply\r
-     */\r
-    setIconClass : function(cls){\r
-        var oldCls = this.iconCls;\r
-        this.iconCls = cls;\r
-        if(this.rendered){\r
-            this.iconEl.replaceClass(oldCls, this.iconCls);\r
-        }\r
-    },\r
-    \r
-    //private\r
-    beforeDestroy: function(){\r
-        if (this.menu){\r
-            this.menu.destroy();\r
-        }\r
-        Ext.menu.Item.superclass.beforeDestroy.call(this);\r
-    },\r
-\r
-    // private\r
-    handleClick : function(e){\r
-        if(!this.href){ // if no link defined, stop the event automatically\r
-            e.stopEvent();\r
-        }\r
-        Ext.menu.Item.superclass.handleClick.apply(this, arguments);\r
-    },\r
-\r
-    // private\r
-    activate : function(autoExpand){\r
-        if(Ext.menu.Item.superclass.activate.apply(this, arguments)){\r
-            this.focus();\r
-            if(autoExpand){\r
-                this.expandMenu();\r
-            }\r
-        }\r
-        return true;\r
-    },\r
-\r
-    // private\r
-    shouldDeactivate : function(e){\r
-        if(Ext.menu.Item.superclass.shouldDeactivate.call(this, e)){\r
-            if(this.menu && this.menu.isVisible()){\r
-                return !this.menu.getEl().getRegion().contains(e.getPoint());\r
-            }\r
-            return true;\r
-        }\r
-        return false;\r
-    },\r
-\r
-    // private\r
-    deactivate : function(){\r
-        Ext.menu.Item.superclass.deactivate.apply(this, arguments);\r
-        this.hideMenu();\r
-    },\r
-\r
-    // private\r
-    expandMenu : function(autoActivate){\r
-        if(!this.disabled && this.menu){\r
-            clearTimeout(this.hideTimer);\r
-            delete this.hideTimer;\r
-            if(!this.menu.isVisible() && !this.showTimer){\r
-                this.showTimer = this.deferExpand.defer(this.showDelay, this, [autoActivate]);\r
-            }else if (this.menu.isVisible() && autoActivate){\r
-                this.menu.tryActivate(0, 1);\r
-            }\r
-        }\r
-    },\r
-\r
-    // private\r
-    deferExpand : function(autoActivate){\r
-        delete this.showTimer;\r
-        this.menu.show(this.container, this.parentMenu.subMenuAlign || 'tl-tr?', this.parentMenu);\r
-        if(autoActivate){\r
-            this.menu.tryActivate(0, 1);\r
-        }\r
-    },\r
-\r
-    // private\r
-    hideMenu : function(){\r
-        clearTimeout(this.showTimer);\r
-        delete this.showTimer;\r
-        if(!this.hideTimer && this.menu && this.menu.isVisible()){\r
-            this.hideTimer = this.deferHide.defer(this.hideDelay, this);\r
-        }\r
-    },\r
-\r
-    // private\r
-    deferHide : function(){\r
-        delete this.hideTimer;\r
-        if(this.menu.over){\r
-            this.parentMenu.setActiveItem(this, false);\r
-        }else{\r
-            this.menu.hide();\r
-        }\r
-    }\r
-});\r
+Ext.reg('menuseparator', Ext.menu.Separator);/**
+ * @class Ext.menu.Item
+ * @extends Ext.menu.BaseItem
+ * A base class for all menu items that require menu-related functionality (like sub-menus) and are not static
+ * display items.  Item extends the base functionality of {@link Ext.menu.BaseItem} by adding menu-specific
+ * activation and click handling.
+ * @constructor
+ * Creates a new Item
+ * @param {Object} config Configuration options
+ * @xtype menuitem
+ */
+Ext.menu.Item = Ext.extend(Ext.menu.BaseItem, {
+    /**
+     * @property menu
+     * @type Ext.menu.Menu
+     * The submenu associated with this Item if one was configured.
+     */
+    /**
+     * @cfg {Mixed} menu (optional) Either an instance of {@link Ext.menu.Menu} or the config object for an
+     * {@link Ext.menu.Menu} which acts as the submenu when this item is activated.
+     */
+    /**
+     * @cfg {String} icon The path to an icon to display in this item (defaults to Ext.BLANK_IMAGE_URL).  If
+     * icon is specified {@link #iconCls} should not be.
+     */
+    /**
+     * @cfg {String} iconCls A CSS class that specifies a background image that will be used as the icon for
+     * this item (defaults to '').  If iconCls is specified {@link #icon} should not be.
+     */
+    /**
+     * @cfg {String} text The text to display in this item (defaults to '').
+     */
+    /**
+     * @cfg {String} href The href attribute to use for the underlying anchor link (defaults to '#').
+     */
+    /**
+     * @cfg {String} hrefTarget The target attribute to use for the underlying anchor link (defaults to '').
+     */
+    /**
+     * @cfg {String} itemCls The default CSS class to use for menu items (defaults to 'x-menu-item')
+     */
+    itemCls : 'x-menu-item',
+    /**
+     * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to true)
+     */
+    canActivate : true,
+    /**
+     * @cfg {Number} showDelay Length of time in milliseconds to wait before showing this item (defaults to 200)
+     */
+    showDelay: 200,
+    
+    /**
+     * @cfg {String} altText The altText to use for the icon, if it exists. Defaults to <tt>''</tt>.
+     */
+    altText: '',
+    
+    // doc'd in BaseItem
+    hideDelay: 200,
+
+    // private
+    ctype: 'Ext.menu.Item',
+
+    initComponent : function(){
+        Ext.menu.Item.superclass.initComponent.call(this);
+        if(this.menu){
+            this.menu = Ext.menu.MenuMgr.get(this.menu);
+            this.menu.ownerCt = this;
+        }
+    },
+
+    // private
+    onRender : function(container, position){
+        if (!this.itemTpl) {
+            this.itemTpl = Ext.menu.Item.prototype.itemTpl = new Ext.XTemplate(
+                '<a id="{id}" class="{cls}" hidefocus="true" unselectable="on" href="{href}"',
+                    '<tpl if="hrefTarget">',
+                        ' target="{hrefTarget}"',
+                    '</tpl>',
+                 '>',
+                     '<img alt="{altText}" src="{icon}" class="x-menu-item-icon {iconCls}"/>',
+                     '<span class="x-menu-item-text">{text}</span>',
+                 '</a>'
+             );
+        }
+        var a = this.getTemplateArgs();
+        this.el = position ? this.itemTpl.insertBefore(position, a, true) : this.itemTpl.append(container, a, true);
+        this.iconEl = this.el.child('img.x-menu-item-icon');
+        this.textEl = this.el.child('.x-menu-item-text');
+        if(!this.href) { // if no link defined, prevent the default anchor event
+            this.mon(this.el, 'click', Ext.emptyFn, null, { preventDefault: true });
+        }
+        Ext.menu.Item.superclass.onRender.call(this, container, position);
+    },
+
+    getTemplateArgs: function() {
+        return {
+            id: this.id,
+            cls: this.itemCls + (this.menu ?  ' x-menu-item-arrow' : '') + (this.cls ?  ' ' + this.cls : ''),
+            href: this.href || '#',
+            hrefTarget: this.hrefTarget,
+            icon: this.icon || Ext.BLANK_IMAGE_URL,
+            iconCls: this.iconCls || '',
+            text: this.itemText||this.text||'&#160;',
+            altText: this.altText || ''
+        };
+    },
+
+    /**
+     * Sets the text to display in this menu item
+     * @param {String} text The text to display
+     */
+    setText : function(text){
+        this.text = text||'&#160;';
+        if(this.rendered){
+            this.textEl.update(this.text);
+            this.parentMenu.layout.doAutoSize();
+        }
+    },
+
+    /**
+     * Sets the CSS class to apply to the item's icon element
+     * @param {String} cls The CSS class to apply
+     */
+    setIconClass : function(cls){
+        var oldCls = this.iconCls;
+        this.iconCls = cls;
+        if(this.rendered){
+            this.iconEl.replaceClass(oldCls, this.iconCls);
+        }
+    },
+
+    //private
+    beforeDestroy: function(){
+        if (this.menu){
+            delete this.menu.ownerCt;
+            this.menu.destroy();
+        }
+        Ext.menu.Item.superclass.beforeDestroy.call(this);
+    },
+
+    // private
+    handleClick : function(e){
+        if(!this.href){ // if no link defined, stop the event automatically
+            e.stopEvent();
+        }
+        Ext.menu.Item.superclass.handleClick.apply(this, arguments);
+    },
+
+    // private
+    activate : function(autoExpand){
+        if(Ext.menu.Item.superclass.activate.apply(this, arguments)){
+            this.focus();
+            if(autoExpand){
+                this.expandMenu();
+            }
+        }
+        return true;
+    },
+
+    // private
+    shouldDeactivate : function(e){
+        if(Ext.menu.Item.superclass.shouldDeactivate.call(this, e)){
+            if(this.menu && this.menu.isVisible()){
+                return !this.menu.getEl().getRegion().contains(e.getPoint());
+            }
+            return true;
+        }
+        return false;
+    },
+
+    // private
+    deactivate : function(){
+        Ext.menu.Item.superclass.deactivate.apply(this, arguments);
+        this.hideMenu();
+    },
+
+    // private
+    expandMenu : function(autoActivate){
+        if(!this.disabled && this.menu){
+            clearTimeout(this.hideTimer);
+            delete this.hideTimer;
+            if(!this.menu.isVisible() && !this.showTimer){
+                this.showTimer = this.deferExpand.defer(this.showDelay, this, [autoActivate]);
+            }else if (this.menu.isVisible() && autoActivate){
+                this.menu.tryActivate(0, 1);
+            }
+        }
+    },
+
+    // private
+    deferExpand : function(autoActivate){
+        delete this.showTimer;
+        this.menu.show(this.container, this.parentMenu.subMenuAlign || 'tl-tr?', this.parentMenu);
+        if(autoActivate){
+            this.menu.tryActivate(0, 1);
+        }
+    },
+
+    // private
+    hideMenu : function(){
+        clearTimeout(this.showTimer);
+        delete this.showTimer;
+        if(!this.hideTimer && this.menu && this.menu.isVisible()){
+            this.hideTimer = this.deferHide.defer(this.hideDelay, this);
+        }
+    },
+
+    // private
+    deferHide : function(){
+        delete this.hideTimer;
+        if(this.menu.over){
+            this.parentMenu.setActiveItem(this, false);
+        }else{
+            this.menu.hide();
+        }
+    }
+});
 Ext.reg('menuitem', Ext.menu.Item);/**
  * @class Ext.menu.CheckItem
  * @extends Ext.menu.Item
@@ -1425,37 +1377,7 @@ Ext.reg('menuitem', Ext.menu.Item);/**
  * @param {Object} config Configuration options
  * @xtype menucheckitem
  */
-Ext.menu.CheckItem = function(config){
-    Ext.menu.CheckItem.superclass.constructor.call(this, config);
-    this.addEvents(
-        /**
-         * @event beforecheckchange
-         * Fires before the checked value is set, providing an opportunity to cancel if needed
-         * @param {Ext.menu.CheckItem} this
-         * @param {Boolean} checked The new checked value that will be set
-         */
-        "beforecheckchange" ,
-        /**
-         * @event checkchange
-         * Fires after the checked value has been set
-         * @param {Ext.menu.CheckItem} this
-         * @param {Boolean} checked The checked value that was set
-         */
-        "checkchange"
-    );
-    /**
-     * A function that handles the checkchange event.  The function is undefined by default, but if an implementation
-     * is provided, it will be called automatically when the checkchange event fires.
-     * @param {Ext.menu.CheckItem} this
-     * @param {Boolean} checked The checked value that was set
-     * @method checkHandler
-     */
-    if(this.checkHandler){
-        this.on('checkchange', this.checkHandler, this.scope);
-    }
-    Ext.menu.MenuMgr.registerCheckable(this);
-};
-Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {
+Ext.menu.CheckItem = Ext.extend(Ext.menu.Item, {
     /**
      * @cfg {String} group
      * All check items with the same group name will automatically be grouped into a single-select
@@ -1472,13 +1394,44 @@ Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {
 
     /**
      * @cfg {Boolean} checked True to initialize this checkbox as checked (defaults to false).  Note that
-     * if this checkbox is part of a radio group (group = true) only the last item in the group that is
+     * if this checkbox is part of a radio group (group = true) only the first item in the group that is
      * initialized with checked = true will be rendered as checked.
      */
     checked: false,
 
     // private
     ctype: "Ext.menu.CheckItem",
+    
+    initComponent : function(){
+        Ext.menu.CheckItem.superclass.initComponent.call(this);
+           this.addEvents(
+               /**
+                * @event beforecheckchange
+                * Fires before the checked value is set, providing an opportunity to cancel if needed
+                * @param {Ext.menu.CheckItem} this
+                * @param {Boolean} checked The new checked value that will be set
+                */
+               "beforecheckchange" ,
+               /**
+                * @event checkchange
+                * Fires after the checked value has been set
+                * @param {Ext.menu.CheckItem} this
+                * @param {Boolean} checked The checked value that was set
+                */
+               "checkchange"
+           );
+           /**
+            * A function that handles the checkchange event.  The function is undefined by default, but if an implementation
+            * is provided, it will be called automatically when the checkchange event fires.
+            * @param {Ext.menu.CheckItem} this
+            * @param {Boolean} checked The checked value that was set
+            * @method checkHandler
+            */
+           if(this.checkHandler){
+               this.on('checkchange', this.checkHandler, this.scope);
+           }
+           Ext.menu.MenuMgr.registerCheckable(this);
+    },
 
     // private
     onRender : function(c){
@@ -1504,12 +1457,14 @@ Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {
      * @param {Boolean} suppressEvent (optional) True to prevent the checkchange event from firing (defaults to false)
      */
     setChecked : function(state, suppressEvent){
-        if(this.checked != state && this.fireEvent("beforecheckchange", this, state) !== false){
+        var suppress = suppressEvent === true;
+        if(this.checked != state && (suppress || this.fireEvent("beforecheckchange", this, state) !== false)){
+            Ext.menu.MenuMgr.onCheckChange(this, state);
             if(this.container){
                 this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");
             }
             this.checked = state;
-            if(suppressEvent !== true){
+            if(!suppress){
                 this.fireEvent("checkchange", this, state);
             }
         }
@@ -1523,223 +1478,224 @@ Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {
        Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
     }
 });
-Ext.reg('menucheckitem', Ext.menu.CheckItem);/**\r
- * @class Ext.menu.DateMenu\r
- * @extends Ext.menu.Menu\r
- * <p>A menu containing an {@link Ext.DatePicker} Component.</p>\r
- * <p>Notes:</p><div class="mdetail-params"><ul>\r
- * <li>Although not listed here, the <b>constructor</b> for this class\r
- * accepts all of the configuration options of <b>{@link Ext.DatePicker}</b>.</li>\r
- * <li>If subclassing DateMenu, any configuration options for the DatePicker must be\r
- * applied to the <tt><b>initialConfig</b></tt> property of the DateMenu.\r
- * Applying {@link Ext.DatePicker DatePicker} configuration settings to\r
- * <b><tt>this</tt></b> will <b>not</b> affect the DatePicker's configuration.</li>\r
- * </ul></div>\r
- * @xtype datemenu\r
- */\r
- Ext.menu.DateMenu = Ext.extend(Ext.menu.Menu, {\r
-    /** \r
-     * @cfg {Boolean} enableScrolling\r
-     * @hide \r
-     */\r
-    enableScrolling : false,\r
-    /**\r
-     * @cfg {Function} handler\r
-     * Optional. A function that will handle the select event of this menu.\r
-     * The handler is passed the following parameters:<div class="mdetail-params"><ul>\r
-     * <li><code>picker</code> : DatePicker<div class="sub-desc">The Ext.DatePicker.</div></li>\r
-     * <li><code>date</code> : Date<div class="sub-desc">The selected date.</div></li>\r
-     * </ul></div>\r
-     */\r
-    /**\r
-     * @cfg {Object} scope\r
-     * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>\r
-     * function will be called.  Defaults to this DateMenu instance.\r
-     */    \r
-    /** \r
-     * @cfg {Boolean} hideOnClick\r
-     * False to continue showing the menu after a date is selected, defaults to true.\r
-     */\r
-    hideOnClick : true,\r
-    \r
-    /** \r
-     * @cfg {String} pickerId\r
-     * An id to assign to the underlying date picker. Defaults to <tt>null</tt>.\r
-     */\r
-    pickerId : null,\r
-    \r
-    /** \r
-     * @cfg {Number} maxHeight\r
-     * @hide \r
-     */\r
-    /** \r
-     * @cfg {Number} scrollIncrement\r
-     * @hide \r
-     */\r
-    /**\r
-     * The {@link Ext.DatePicker} instance for this DateMenu\r
-     * @property picker\r
-     * @type DatePicker\r
-     */\r
-    cls : 'x-date-menu',\r
-    \r
-    /**\r
-     * @event click\r
-     * @hide\r
-     */\r
-    \r
-    /**\r
-     * @event itemclick\r
-     * @hide\r
-     */\r
-\r
-    initComponent : function(){\r
-        this.on('beforeshow', this.onBeforeShow, this);\r
-        if(this.strict = (Ext.isIE7 && Ext.isStrict)){\r
-            this.on('show', this.onShow, this, {single: true, delay: 20});\r
-        }\r
-        Ext.apply(this, {\r
-            plain: true,\r
-            showSeparator: false,\r
-            items: this.picker = new Ext.DatePicker(Ext.applyIf({\r
-                internalRender: this.strict || !Ext.isIE,\r
-                ctCls: 'x-menu-date-item',\r
-                id: this.pickerId\r
-            }, this.initialConfig))\r
-        });\r
-        this.picker.purgeListeners();\r
-        Ext.menu.DateMenu.superclass.initComponent.call(this);\r
-        /**\r
-         * @event select\r
-         * Fires when a date is selected from the {@link #picker Ext.DatePicker}\r
-         * @param {DatePicker} picker The {@link #picker Ext.DatePicker}\r
-         * @param {Date} date The selected date\r
-         */\r
-        this.relayEvents(this.picker, ['select']);\r
-        this.on('select', this.menuHide, this);\r
-        if(this.handler){\r
-            this.on('select', this.handler, this.scope || this);\r
-        }\r
-    },\r
-\r
-    menuHide : function() {\r
-        if(this.hideOnClick){\r
-            this.hide(true);\r
-        }\r
-    },\r
-\r
-    onBeforeShow : function(){\r
-        if(this.picker){\r
-            this.picker.hideMonthPicker(true);\r
-        }\r
-    },\r
-\r
-    onShow : function(){\r
-        var el = this.picker.getEl();\r
-        el.setWidth(el.getWidth()); //nasty hack for IE7 strict mode\r
-    }\r
- });\r
- Ext.reg('datemenu', Ext.menu.DateMenu);\r
- /**\r
- * @class Ext.menu.ColorMenu\r
- * @extends Ext.menu.Menu\r
- * <p>A menu containing a {@link Ext.ColorPalette} Component.</p>\r
- * <p>Notes:</p><div class="mdetail-params"><ul>\r
- * <li>Although not listed here, the <b>constructor</b> for this class\r
- * accepts all of the configuration options of <b>{@link Ext.ColorPalette}</b>.</li>\r
- * <li>If subclassing ColorMenu, any configuration options for the ColorPalette must be\r
- * applied to the <tt><b>initialConfig</b></tt> property of the ColorMenu.\r
- * Applying {@link Ext.ColorPalette ColorPalette} configuration settings to\r
- * <b><tt>this</tt></b> will <b>not</b> affect the ColorPalette's configuration.</li>\r
- * </ul></div> * \r
- * @xtype colormenu\r
- */\r
- Ext.menu.ColorMenu = Ext.extend(Ext.menu.Menu, {\r
-    /** \r
-     * @cfg {Boolean} enableScrolling\r
-     * @hide \r
-     */\r
-    enableScrolling : false,\r
-    /**\r
-     * @cfg {Function} handler\r
-     * Optional. A function that will handle the select event of this menu.\r
-     * The handler is passed the following parameters:<div class="mdetail-params"><ul>\r
-     * <li><code>palette</code> : ColorPalette<div class="sub-desc">The {@link #palette Ext.ColorPalette}.</div></li>\r
-     * <li><code>color</code> : String<div class="sub-desc">The 6-digit color hex code (without the # symbol).</div></li>\r
-     * </ul></div>\r
-     */\r
-    /**\r
-     * @cfg {Object} scope\r
-     * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>\r
-     * function will be called.  Defaults to this ColorMenu instance.\r
-     */    \r
-    \r
-    /** \r
-     * @cfg {Boolean} hideOnClick\r
-     * False to continue showing the menu after a color is selected, defaults to true.\r
-     */\r
-    hideOnClick : true,\r
-    \r
-    cls : 'x-color-menu',\r
-    \r
-    /** \r
-     * @cfg {String} paletteId\r
-     * An id to assign to the underlying color palette. Defaults to <tt>null</tt>.\r
-     */\r
-    paletteId : null,\r
-    \r
-    /** \r
-     * @cfg {Number} maxHeight\r
-     * @hide \r
-     */\r
-    /** \r
-     * @cfg {Number} scrollIncrement\r
-     * @hide \r
-     */\r
-    /**\r
-     * @property palette\r
-     * @type ColorPalette\r
-     * The {@link Ext.ColorPalette} instance for this ColorMenu\r
-     */\r
-    \r
-    \r
-    /**\r
-     * @event click\r
-     * @hide\r
-     */\r
-    \r
-    /**\r
-     * @event itemclick\r
-     * @hide\r
-     */\r
-    \r
-    initComponent : function(){\r
-        Ext.apply(this, {\r
-            plain: true,\r
-            showSeparator: false,\r
-            items: this.palette = new Ext.ColorPalette(Ext.applyIf({\r
-                id: this.paletteId\r
-            }, this.initialConfig))\r
-        });\r
-        this.palette.purgeListeners();\r
-        Ext.menu.ColorMenu.superclass.initComponent.call(this);\r
-        /**\r
-         * @event select\r
-         * Fires when a color is selected from the {@link #palette Ext.ColorPalette}\r
-         * @param {Ext.ColorPalette} palette The {@link #palette Ext.ColorPalette}\r
-         * @param {String} color The 6-digit color hex code (without the # symbol)\r
-         */\r
-        this.relayEvents(this.palette, ['select']);\r
-        this.on('select', this.menuHide, this);\r
-        if(this.handler){\r
-            this.on('select', this.handler, this.scope || this);\r
-        }\r
-    },\r
-\r
-    menuHide : function(){\r
-        if(this.hideOnClick){\r
-            this.hide(true);\r
-        }\r
-    }\r
-});\r
-Ext.reg('colormenu', Ext.menu.ColorMenu);\r
+Ext.reg('menucheckitem', Ext.menu.CheckItem);/**
+ * @class Ext.menu.DateMenu
+ * @extends Ext.menu.Menu
+ * <p>A menu containing an {@link Ext.DatePicker} Component.</p>
+ * <p>Notes:</p><div class="mdetail-params"><ul>
+ * <li>Although not listed here, the <b>constructor</b> for this class
+ * accepts all of the configuration options of <b>{@link Ext.DatePicker}</b>.</li>
+ * <li>If subclassing DateMenu, any configuration options for the DatePicker must be
+ * applied to the <tt><b>initialConfig</b></tt> property of the DateMenu.
+ * Applying {@link Ext.DatePicker DatePicker} configuration settings to
+ * <b><tt>this</tt></b> will <b>not</b> affect the DatePicker's configuration.</li>
+ * </ul></div>
+ * @xtype datemenu
+ */
+ Ext.menu.DateMenu = Ext.extend(Ext.menu.Menu, {
+    /** 
+     * @cfg {Boolean} enableScrolling
+     * @hide 
+     */
+    enableScrolling : false,
+    /**
+     * @cfg {Function} handler
+     * Optional. A function that will handle the select event of this menu.
+     * The handler is passed the following parameters:<div class="mdetail-params"><ul>
+     * <li><code>picker</code> : DatePicker<div class="sub-desc">The Ext.DatePicker.</div></li>
+     * <li><code>date</code> : Date<div class="sub-desc">The selected date.</div></li>
+     * </ul></div>
+     */
+    /**
+     * @cfg {Object} scope
+     * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>
+     * function will be called.  Defaults to this DateMenu instance.
+     */    
+    /** 
+     * @cfg {Boolean} hideOnClick
+     * False to continue showing the menu after a date is selected, defaults to true.
+     */
+    hideOnClick : true,
+    
+    /** 
+     * @cfg {String} pickerId
+     * An id to assign to the underlying date picker. Defaults to <tt>null</tt>.
+     */
+    pickerId : null,
+    
+    /** 
+     * @cfg {Number} maxHeight
+     * @hide 
+     */
+    /** 
+     * @cfg {Number} scrollIncrement
+     * @hide 
+     */
+    /**
+     * The {@link Ext.DatePicker} instance for this DateMenu
+     * @property picker
+     * @type DatePicker
+     */
+    cls : 'x-date-menu',
+    
+    /**
+     * @event click
+     * @hide
+     */
+    
+    /**
+     * @event itemclick
+     * @hide
+     */
+
+    initComponent : function(){
+        this.on('beforeshow', this.onBeforeShow, this);
+        if(this.strict = (Ext.isIE7 && Ext.isStrict)){
+            this.on('show', this.onShow, this, {single: true, delay: 20});
+        }
+        Ext.apply(this, {
+            plain: true,
+            showSeparator: false,
+            items: this.picker = new Ext.DatePicker(Ext.applyIf({
+                internalRender: this.strict || !Ext.isIE,
+                ctCls: 'x-menu-date-item',
+                id: this.pickerId
+            }, this.initialConfig))
+        });
+        this.picker.purgeListeners();
+        Ext.menu.DateMenu.superclass.initComponent.call(this);
+        /**
+         * @event select
+         * Fires when a date is selected from the {@link #picker Ext.DatePicker}
+         * @param {DatePicker} picker The {@link #picker Ext.DatePicker}
+         * @param {Date} date The selected date
+         */
+        this.relayEvents(this.picker, ['select']);
+        this.on('show', this.picker.focus, this.picker);
+        this.on('select', this.menuHide, this);
+        if(this.handler){
+            this.on('select', this.handler, this.scope || this);
+        }
+    },
+
+    menuHide : function() {
+        if(this.hideOnClick){
+            this.hide(true);
+        }
+    },
+
+    onBeforeShow : function(){
+        if(this.picker){
+            this.picker.hideMonthPicker(true);
+        }
+    },
+
+    onShow : function(){
+        var el = this.picker.getEl();
+        el.setWidth(el.getWidth()); //nasty hack for IE7 strict mode
+    }
+ });
+ Ext.reg('datemenu', Ext.menu.DateMenu);
+ /**
+ * @class Ext.menu.ColorMenu
+ * @extends Ext.menu.Menu
+ * <p>A menu containing a {@link Ext.ColorPalette} Component.</p>
+ * <p>Notes:</p><div class="mdetail-params"><ul>
+ * <li>Although not listed here, the <b>constructor</b> for this class
+ * accepts all of the configuration options of <b>{@link Ext.ColorPalette}</b>.</li>
+ * <li>If subclassing ColorMenu, any configuration options for the ColorPalette must be
+ * applied to the <tt><b>initialConfig</b></tt> property of the ColorMenu.
+ * Applying {@link Ext.ColorPalette ColorPalette} configuration settings to
+ * <b><tt>this</tt></b> will <b>not</b> affect the ColorPalette's configuration.</li>
+ * </ul></div> * 
+ * @xtype colormenu
+ */
+ Ext.menu.ColorMenu = Ext.extend(Ext.menu.Menu, {
+    /** 
+     * @cfg {Boolean} enableScrolling
+     * @hide 
+     */
+    enableScrolling : false,
+    /**
+     * @cfg {Function} handler
+     * Optional. A function that will handle the select event of this menu.
+     * The handler is passed the following parameters:<div class="mdetail-params"><ul>
+     * <li><code>palette</code> : ColorPalette<div class="sub-desc">The {@link #palette Ext.ColorPalette}.</div></li>
+     * <li><code>color</code> : String<div class="sub-desc">The 6-digit color hex code (without the # symbol).</div></li>
+     * </ul></div>
+     */
+    /**
+     * @cfg {Object} scope
+     * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>
+     * function will be called.  Defaults to this ColorMenu instance.
+     */    
+    
+    /** 
+     * @cfg {Boolean} hideOnClick
+     * False to continue showing the menu after a color is selected, defaults to true.
+     */
+    hideOnClick : true,
+    
+    cls : 'x-color-menu',
+    
+    /** 
+     * @cfg {String} paletteId
+     * An id to assign to the underlying color palette. Defaults to <tt>null</tt>.
+     */
+    paletteId : null,
+    
+    /** 
+     * @cfg {Number} maxHeight
+     * @hide 
+     */
+    /** 
+     * @cfg {Number} scrollIncrement
+     * @hide 
+     */
+    /**
+     * @property palette
+     * @type ColorPalette
+     * The {@link Ext.ColorPalette} instance for this ColorMenu
+     */
+    
+    
+    /**
+     * @event click
+     * @hide
+     */
+    
+    /**
+     * @event itemclick
+     * @hide
+     */
+    
+    initComponent : function(){
+        Ext.apply(this, {
+            plain: true,
+            showSeparator: false,
+            items: this.palette = new Ext.ColorPalette(Ext.applyIf({
+                id: this.paletteId
+            }, this.initialConfig))
+        });
+        this.palette.purgeListeners();
+        Ext.menu.ColorMenu.superclass.initComponent.call(this);
+        /**
+         * @event select
+         * Fires when a color is selected from the {@link #palette Ext.ColorPalette}
+         * @param {Ext.ColorPalette} palette The {@link #palette Ext.ColorPalette}
+            * @param {String} color The 6-digit color hex code (without the # symbol)
+         */
+        this.relayEvents(this.palette, ['select']);
+        this.on('select', this.menuHide, this);
+        if(this.handler){
+            this.on('select', this.handler, this.scope || this);
+        }
+    },
+
+    menuHide : function(){
+        if(this.hideOnClick){
+            this.hide(true);
+        }
+    }
+});
+Ext.reg('colormenu', Ext.menu.ColorMenu);