-<html>\r
-<head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \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>/**
- * @class Ext.layout.MenuLayout
- * @extends Ext.layout.ContainerLayout
- * <p>Layout manager used by {@link Ext.menu.Menu}. Generally this class should not need to be used directly.</p>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body onload="prettyPrint();">
+ <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.3.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
*/
- Ext.layout.MenuLayout = Ext.extend(Ext.layout.ContainerLayout, {
- monitorResize : true,
-
- setContainer : function(ct){
- this.monitorResize = !ct.floating;
- // This event is only fired by the menu in IE, used so we don't couple
- // the menu with the layout.
- ct.on('autosize', this.doAutoSize, this);
- Ext.layout.MenuLayout.superclass.setContainer.call(this, ct);
- },
-
- renderItem : function(c, position, target){
- if (!this.itemTpl) {
- this.itemTpl = Ext.layout.MenuLayout.prototype.itemTpl = new Ext.XTemplate(
- '<li id="{itemId}" class="{itemCls}">',
- '<tpl if="needsIcon">',
- '<img src="{icon}" class="{iconCls}"/>',
- '</tpl>',
- '</li>'
- );
- }
-
- if(c && !c.rendered){
- if(Ext.isNumber(position)){
- position = target.dom.childNodes[position];
- }
- var a = this.getItemArgs(c);
-
-// The Component's positionEl is the <li> it is rendered into
- c.render(c.positionEl = position ?
- this.itemTpl.insertBefore(position, a, true) :
- this.itemTpl.append(target, a, true));
-
-// Link the containing <li> to the item.
- c.positionEl.menuItemId = c.getItemId();
-
-// If rendering a regular Component, and it needs an icon,
-// move the Component rightwards.
- if (!a.isMenuItem && a.needsIcon) {
- c.positionEl.addClass('x-menu-list-item-indent');
- }
- this.configureItem(c, position);
- }else if(c && !this.isValidParent(c, target)){
- if(Ext.isNumber(position)){
- position = target.dom.childNodes[position];
- }
- target.dom.insertBefore(c.getActionEl().dom, position || null);
- }
- },
-
- getItemArgs : function(c) {
- var isMenuItem = c instanceof Ext.menu.Item;
- return {
- isMenuItem: isMenuItem,
- needsIcon: !isMenuItem && (c.icon || c.iconCls),
- icon: c.icon || Ext.BLANK_IMAGE_URL,
- iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),
- itemId: 'x-menu-el-' + c.id,
- itemCls: 'x-menu-list-item '
- };
- },
-
-// Valid if the Component is in a <li> which is part of our target <ul>
- isValidParent : function(c, target) {
- return c.el.up('li.x-menu-list-item', 5).dom.parentNode === (target.dom || target);
- },
-
- onLayout : function(ct, target){
- this.renderAll(ct, target);
- this.doAutoSize();
- },
-
- doAutoSize : function(){
- var ct = this.container, w = ct.width;
- if(ct.floating){
- if(w){
- ct.setWidth(w);
- }else if(Ext.isIE){
- ct.setWidth(Ext.isStrict && (Ext.isIE7 || Ext.isIE8) ? 'auto' : ct.minWidth);
- var el = ct.getEl(), t = el.dom.offsetWidth; // force recalc
- ct.setWidth(ct.getLayoutTarget().getWidth() + el.getFrameWidth('lr'));
- }
- }
- }
-});
-Ext.Container.LAYOUTS['menu'] = Ext.layout.MenuLayout;
-
<div id="cls-Ext.menu.Menu"></div>/**
* @class Ext.menu.Menu
* @extends Ext.Container
*/
floating : true,
+
+ <div id="cfg-Ext.menu.Menu-zIndex"></div>/**
+ * @cfg {Number} zIndex
+ * zIndex to use when the menu is floating.
+ */
+ zIndex: 15000,
+
// private
hidden : true,
}
Ext.menu.Menu.superclass.initComponent.call(this);
if(this.autoLayout){
+ var fn = this.doLayout.createDelegate(this, []);
this.on({
- add: this.doLayout,
- remove: this.doLayout,
- scope: this
+ add: fn,
+ remove: fn
});
}
},
dh: dh,
constrain: false,
parentEl: ct,
- zindex:15000
+ zindex: this.zIndex
});
}else{
this.el = ct.createChild(dh);
var items = this.items;
for(var i = start, len = items.length; i >= 0 && i < len; i+= step){
var item = items.get(i);
- if(!item.disabled && (item.canActivate || item.isFormField)){
+ if(item.isVisible() && !item.disabled && (item.canActivate || item.isFormField)){
this.setActiveItem(item, false);
return item;
}
// set the position so we can figure out the constrain value.
this.el.setXY(xy);
//constrain the value, keep the y coordinate the same
- this.constrainScroll(xy[1]);
+ xy[1] = this.constrainScroll(xy[1]);
xy = [this.el.adjustForConstraints(xy)[0], xy[1]];
}else{
//constrain to the viewport.
},
constrainScroll : function(y){
- var max, full = this.ul.setHeight('auto').getHeight();
+ var max, full = this.ul.setHeight('auto').getHeight(),
+ returnY = y, normalY, parentEl, scrollTop, viewHeight;
if(this.floating){
- max = this.maxHeight ? this.maxHeight : Ext.fly(this.el.dom.parentNode).getViewSize(false).height - y;
+ 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.el.select('.x-menu-scroller').setDisplayed('none');
}
this.ul.dom.scrollTop = 0;
+ return returnY;
},
createScrollers : function(){
* @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
*/
hide : function(deep){
- this.deepHide = deep;
- Ext.menu.Menu.superclass.hide.call(this);
- delete this.deepHide;
+ if (!this.isDestroyed) {
+ this.deepHide = deep;
+ Ext.menu.Menu.superclass.hide.call(this);
+ delete this.deepHide;
+ }
},
// private
return c;
},
- applyDefaults : function(c){
- if(!Ext.isString(c)){
+ applyDefaults : function(c) {
+ if (!Ext.isString(c)) {
c = Ext.menu.Menu.superclass.applyDefaults.call(this, c);
var d = this.internalDefaults;
if(d){
},
// private
- getMenuItem : function(config){
- if(!config.isXType){
- if(!config.xtype && Ext.isBoolean(config.checked)){
- return new Ext.menu.CheckItem(config)
+ 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);
}
* Adds a separator bar to the menu
* @return {Ext.menu.Item} The menu item that was added
*/
- addSeparator : function(){
+ addSeparator : function() {
return this.add(new Ext.menu.Separator());
},
* @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));
+ addElement : function(el) {
+ return this.add(new Ext.menu.BaseItem({
+ el: el
+ }));
},
<div id="method-Ext.menu.Menu-addItem"></div>/**
* @param {Ext.menu.Item} item The menu item to add
* @return {Ext.menu.Item} The menu item that was added
*/
- addItem : function(item){
+ addItem : function(item) {
return this.add(item);
},
* @param {Object} config A MenuItem config object
* @return {Ext.menu.Item} The menu item that was added
*/
- addMenuItem : function(config){
+ addMenuItem : function(config) {
return this.add(this.getMenuItem(config));
},
//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);
- Ext.EventManager.removeResizeListener(this.hide, this);
if(this.keyNav) {
this.keyNav.disable();
}
}
};
}());
-</pre> \r
-</body>\r
+</pre>
+</body>
</html>
\ No newline at end of file