-<html>\r
-<head>\r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.layout.MenuLayout"></div>/**\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
- 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.itemId || c.id;\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
- }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 ' + (this.extraCls || '')\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
-<div id="cls-Ext.menu.Menu"></div>/**\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
- <div id="cfg-Ext.menu.Menu-defaults"></div>/**\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
- <div id="cfg-Ext.menu.Menu-items"></div>/**\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
- <div id="cfg-Ext.menu.Menu-minWidth"></div>/**\r
- * @cfg {Number} minWidth The minimum width of the menu in pixels (defaults to 120)\r
- */\r
- minWidth : 120,\r
- <div id="cfg-Ext.menu.Menu-shadow"></div>/**\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
- <div id="cfg-Ext.menu.Menu-subMenuAlign"></div>/**\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
- <div id="cfg-Ext.menu.Menu-defaultAlign"></div>/**\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
- <div id="cfg-Ext.menu.Menu-allowOtherMenus"></div>/**\r
- * @cfg {Boolean} allowOtherMenus True to allow multiple menus to be displayed at the same time (defaults to false)\r
- */\r
- allowOtherMenus : false,\r
- <div id="cfg-Ext.menu.Menu-ignoreParentClicks"></div>/**\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
- <div id="cfg-Ext.menu.Menu-enableScrolling"></div>/**\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
- <div id="cfg-Ext.menu.Menu-maxHeight"></div>/**\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
- <div id="cfg-Ext.menu.Menu-scrollIncrement"></div>/**\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
- <div id="cfg-Ext.menu.Menu-showSeparator"></div>/**\r
- * @cfg {Boolean} showSeparator True to show the icon separator. (defaults to true).\r
- */\r
- showSeparator : true,\r
- <div id="cfg-Ext.menu.Menu-defaultOffsets"></div>/**\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
- <div id="cfg-Ext.menu.Menu-floating"></div>/**\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
- <div id="cfg-Ext.menu.Menu-layout"></div>/**\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
- <div id="event-Ext.menu.Menu-click"></div>/**\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
- <div id="event-Ext.menu.Menu-mouseover"></div>/**\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
- <div id="event-Ext.menu.Menu-mouseout"></div>/**\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
- <div id="event-Ext.menu.Menu-itemclick"></div>/**\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{\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
- <div id="method-Ext.menu.Menu-show"></div>/**\r
- * If <code>{@link #floating}=true</code>, shows this menu relative to\r
- * another element, 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
- if(this.fireEvent('beforeshow', this) !== false){\r
- this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign, this.defaultOffsets), parentMenu, false);\r
- }\r
- }else{\r
- Ext.menu.Menu.superclass.show.call(this);\r
- }\r
- },\r
-\r
- <div id="method-Ext.menu.Menu-showAt"></div>/**\r
- * Displays this menu at a specific xy position\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, /* private: */_e){\r
- this.parentMenu = parentMenu;\r
- if(!this.el){\r
- this.render();\r
- }\r
- this.el.setXY(xy);\r
- if(this.enableScrolling){\r
- this.constrainScroll(xy[1]);\r
- }\r
- this.el.show();\r
- Ext.menu.Menu.superclass.onShow.call(this);\r
- if(Ext.isIE){\r
- this.layout.doAutoSize();\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
- 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: ' '\r
- }),\r
- bottom: this.el.createChild({\r
- tag: 'div',\r
- cls: 'x-menu-scroller x-menu-scroller-bottom',\r
- html: ' '\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
- <div id="method-Ext.menu.Menu-hide"></div>/**\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
- if(this.deepHide === true && this.parentMenu){\r
- this.parentMenu.hide(true);\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
- <div id="method-Ext.menu.Menu-addSeparator"></div>/**\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
- <div id="method-Ext.menu.Menu-addElement"></div>/**\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
- <div id="method-Ext.menu.Menu-addItem"></div>/**\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
- <div id="method-Ext.menu.Menu-addMenuItem"></div>/**\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
- <div id="method-Ext.menu.Menu-addText"></div>/**\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
- }\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
-}());</pre> \r
-</body>\r
-</html>
\ No newline at end of file
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../prettify/prettify.js"></script>
+ <style type="text/css">
+ .highlight { display: block; background-color: #ddd; }
+ </style>
+ <script type="text/javascript">
+ function highlight() {
+ document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+ }
+ </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+ <pre class="prettyprint lang-js"><span id='Ext-layout-container-boxOverflow-Menu'>/**
+</span> * @class Ext.layout.container.boxOverflow.Menu
+ * @extends Ext.layout.container.boxOverflow.None
+ * @private
+ */
+Ext.define('Ext.layout.container.boxOverflow.Menu', {
+
+ /* Begin Definitions */
+
+ extend: 'Ext.layout.container.boxOverflow.None',
+ requires: ['Ext.toolbar.Separator', 'Ext.button.Button'],
+ alternateClassName: 'Ext.layout.boxOverflow.Menu',
+
+ /* End Definitions */
+
+<span id='Ext-layout-container-boxOverflow-Menu-cfg-afterCtCls'> /**
+</span> * @cfg {String} afterCtCls
+ * CSS class added to the afterCt element. This is the element that holds any special items such as scrollers,
+ * which must always be present at the rightmost edge of the Container
+ */
+
+<span id='Ext-layout-container-boxOverflow-Menu-property-noItemsMenuText'> /**
+</span> * @property noItemsMenuText
+ * @type String
+ * HTML fragment to render into the toolbar overflow menu if there are no items to display
+ */
+ noItemsMenuText : '<div class="' + Ext.baseCSSPrefix + 'toolbar-no-items">(None)</div>',
+
+ constructor: function(layout) {
+ var me = this;
+
+ me.callParent(arguments);
+
+ // Before layout, we need to re-show all items which we may have hidden due to a previous overflow.
+ layout.beforeLayout = Ext.Function.createInterceptor(layout.beforeLayout, this.clearOverflow, this);
+
+ me.afterCtCls = me.afterCtCls || Ext.baseCSSPrefix + 'box-menu-' + layout.parallelAfter;
+<span id='Ext-layout-container-boxOverflow-Menu-property-menuItems'> /**
+</span> * @property menuItems
+ * @type Array
+ * Array of all items that are currently hidden and should go into the dropdown menu
+ */
+ me.menuItems = [];
+ },
+
+ onRemove: function(comp){
+ Ext.Array.remove(this.menuItems, comp);
+ },
+
+ handleOverflow: function(calculations, targetSize) {
+ var me = this,
+ layout = me.layout,
+ methodName = 'get' + layout.parallelPrefixCap,
+ newSize = {},
+ posArgs = [null, null];
+
+ me.callParent(arguments);
+ this.createMenu(calculations, targetSize);
+ newSize[layout.perpendicularPrefix] = targetSize[layout.perpendicularPrefix];
+ newSize[layout.parallelPrefix] = targetSize[layout.parallelPrefix] - me.afterCt[methodName]();
+
+ // Center the menuTrigger button.
+ // TODO: Should we emulate align: 'middle' like this, or should we 'stretchmax' the menuTrigger?
+ posArgs[layout.perpendicularSizeIndex] = (calculations.meta.maxSize - me.menuTrigger['get' + layout.perpendicularPrefixCap]()) / 2;
+ me.menuTrigger.setPosition.apply(me.menuTrigger, posArgs);
+
+ return { targetSize: newSize };
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-clearOverflow'> /**
+</span> * @private
+ * Called by the layout, when it determines that there is no overflow.
+ * Also called as an interceptor to the layout's onLayout method to reshow
+ * previously hidden overflowing items.
+ */
+ clearOverflow: function(calculations, targetSize) {
+ var me = this,
+ newWidth = targetSize ? targetSize.width + (me.afterCt ? me.afterCt.getWidth() : 0) : 0,
+ items = me.menuItems,
+ i = 0,
+ length = items.length,
+ item;
+
+ me.hideTrigger();
+ for (; i < length; i++) {
+ items[i].show();
+ }
+ items.length = 0;
+
+ return targetSize ? {
+ targetSize: {
+ height: targetSize.height,
+ width : newWidth
+ }
+ } : null;
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-showTrigger'> /**
+</span> * @private
+ */
+ showTrigger: function() {
+ this.menuTrigger.show();
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-hideTrigger'> /**
+</span> * @private
+ */
+ hideTrigger: function() {
+ if (this.menuTrigger !== undefined) {
+ this.menuTrigger.hide();
+ }
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-beforeMenuShow'> /**
+</span> * @private
+ * Called before the overflow menu is shown. This constructs the menu's items, caching them for as long as it can.
+ */
+ beforeMenuShow: function(menu) {
+ var me = this,
+ items = me.menuItems,
+ i = 0,
+ len = items.length,
+ item,
+ prev;
+
+ var needsSep = function(group, prev){
+ return group.isXType('buttongroup') && !(prev instanceof Ext.toolbar.Separator);
+ };
+
+ me.clearMenu();
+ menu.removeAll();
+
+ for (; i < len; i++) {
+ item = items[i];
+
+ // Do not show a separator as a first item
+ if (!i && (item instanceof Ext.toolbar.Separator)) {
+ continue;
+ }
+ if (prev && (needsSep(item, prev) || needsSep(prev, item))) {
+ menu.add('-');
+ }
+
+ me.addComponentToMenu(menu, item);
+ prev = item;
+ }
+
+ // put something so the menu isn't empty if no compatible items found
+ if (menu.items.length < 1) {
+ menu.add(me.noItemsMenuText);
+ }
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-createMenuConfig'> /**
+</span> * @private
+ * Returns a menu config for a given component. This config is used to create a menu item
+ * to be added to the expander menu
+ * @param {Ext.Component} component The component to create the config for
+ * @param {Boolean} hideOnClick Passed through to the menu item
+ */
+ createMenuConfig : function(component, hideOnClick) {
+ var config = Ext.apply({}, component.initialConfig),
+ group = component.toggleGroup;
+
+ Ext.copyTo(config, component, [
+ 'iconCls', 'icon', 'itemId', 'disabled', 'handler', 'scope', 'menu'
+ ]);
+
+ Ext.apply(config, {
+ text : component.overflowText || component.text,
+ hideOnClick: hideOnClick,
+ destroyMenu: false
+ });
+
+ if (group || component.enableToggle) {
+ Ext.apply(config, {
+ group : group,
+ checked: component.pressed,
+ listeners: {
+ checkchange: function(item, checked){
+ component.toggle(checked);
+ }
+ }
+ });
+ }
+
+ delete config.ownerCt;
+ delete config.xtype;
+ delete config.id;
+ return config;
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-addComponentToMenu'> /**
+</span> * @private
+ * Adds the given Toolbar item to the given menu. Buttons inside a buttongroup are added individually.
+ * @param {Ext.menu.Menu} menu The menu to add to
+ * @param {Ext.Component} component The component to add
+ */
+ addComponentToMenu : function(menu, component) {
+ var me = this;
+ if (component instanceof Ext.toolbar.Separator) {
+ menu.add('-');
+ } else if (component.isComponent) {
+ if (component.isXType('splitbutton')) {
+ menu.add(me.createMenuConfig(component, true));
+
+ } else if (component.isXType('button')) {
+ menu.add(me.createMenuConfig(component, !component.menu));
+
+ } else if (component.isXType('buttongroup')) {
+ component.items.each(function(item){
+ me.addComponentToMenu(menu, item);
+ });
+ } else {
+ menu.add(Ext.create(Ext.getClassName(component), me.createMenuConfig(component)));
+ }
+ }
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-clearMenu'> /**
+</span> * @private
+ * Deletes the sub-menu of each item in the expander menu. Submenus are created for items such as
+ * splitbuttons and buttongroups, where the Toolbar item cannot be represented by a single menu item
+ */
+ clearMenu : function() {
+ var menu = this.moreMenu;
+ if (menu && menu.items) {
+ menu.items.each(function(item) {
+ if (item.menu) {
+ delete item.menu;
+ }
+ });
+ }
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-createMenu'> /**
+</span> * @private
+ * Creates the overflow trigger and menu used when enableOverflow is set to true and the items
+ * in the layout are too wide to fit in the space available
+ */
+ createMenu: function(calculations, targetSize) {
+ var me = this,
+ layout = me.layout,
+ startProp = layout.parallelBefore,
+ sizeProp = layout.parallelPrefix,
+ available = targetSize[sizeProp],
+ boxes = calculations.boxes,
+ i = 0,
+ len = boxes.length,
+ box;
+
+ if (!me.menuTrigger) {
+ me.createInnerElements();
+
+<span id='Ext-layout-container-boxOverflow-Menu-property-menu'> /**
+</span> * @private
+ * @property menu
+ * @type Ext.menu.Menu
+ * The expand menu - holds items for every item that cannot be shown
+ * because the container is currently not large enough.
+ */
+ me.menu = Ext.create('Ext.menu.Menu', {
+ hideMode: 'offsets',
+ listeners: {
+ scope: me,
+ beforeshow: me.beforeMenuShow
+ }
+ });
+
+<span id='Ext-layout-container-boxOverflow-Menu-property-menuTrigger'> /**
+</span> * @private
+ * @property menuTrigger
+ * @type Ext.button.Button
+ * The expand button which triggers the overflow menu to be shown
+ */
+ me.menuTrigger = Ext.create('Ext.button.Button', {
+ ownerCt : me.layout.owner, // To enable the Menu to ascertain a valid zIndexManager owner in the same tree
+ iconCls : Ext.baseCSSPrefix + layout.owner.getXType() + '-more-icon',
+ ui : layout.owner instanceof Ext.toolbar.Toolbar ? 'default-toolbar' : 'default',
+ menu : me.menu,
+ getSplitCls: function() { return '';},
+ renderTo: me.afterCt
+ });
+ }
+ me.showTrigger();
+ available -= me.afterCt.getWidth();
+
+ // Hide all items which are off the end, and store them to allow them to be restored
+ // before each layout operation.
+ me.menuItems.length = 0;
+ for (; i < len; i++) {
+ box = boxes[i];
+ if (box[startProp] + box[sizeProp] > available) {
+ me.menuItems.push(box.component);
+ box.component.hide();
+ }
+ }
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-createInnerElements'> /**
+</span> * @private
+ * Creates the beforeCt, innerCt and afterCt elements if they have not already been created
+ * @param {Ext.container.Container} container The Container attached to this Layout instance
+ * @param {Ext.core.Element} target The target Element
+ */
+ createInnerElements: function() {
+ var me = this,
+ target = me.layout.getRenderTarget();
+
+ if (!this.afterCt) {
+ target.addCls(Ext.baseCSSPrefix + me.layout.direction + '-box-overflow-body');
+ this.afterCt = target.insertSibling({cls: Ext.layout.container.Box.prototype.innerCls + ' ' + this.afterCtCls}, 'before');
+ }
+ },
+
+<span id='Ext-layout-container-boxOverflow-Menu-method-destroy'> /**
+</span> * @private
+ */
+ destroy: function() {
+ Ext.destroy(this.menu, this.menuTrigger);
+ }
+});</pre>
+</body>
+</html>