X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..c8256059947f3aa8f5b0a9a2acf55e2142bb4742:/pkgs/pkg-menu-debug.js?ds=inline
diff --git a/pkgs/pkg-menu-debug.js b/pkgs/pkg-menu-debug.js
index 1af9eaed..71028f54 100644
--- a/pkgs/pkg-menu-debug.js
+++ b/pkgs/pkg-menu-debug.js
@@ -1,101 +1,9 @@
/*!
- * Ext JS Library 3.1.0
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/
-/**
- * @class Ext.layout.MenuLayout
- * @extends Ext.layout.ContainerLayout
- *
Layout manager used by {@link Ext.menu.Menu}. Generally this class should not need to be used directly.
- */
- 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(
- '',
- '',
- '',
- '',
- ''
- );
- }
-
- if(c && !c.rendered){
- if(Ext.isNumber(position)){
- position = target.dom.childNodes[position];
- }
- var a = this.getItemArgs(c);
-
-// The Component's positionEl is the it is rendered into
- c.render(c.positionEl = position ?
- this.itemTpl.insertBefore(position, a, true) :
- this.itemTpl.append(target, a, true));
-
-// Link the containing 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 which is part of our target
- 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;
-
/**
* @class Ext.menu.Menu
* @extends Ext.Container
@@ -192,6 +100,13 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
*/
floating : true,
+
+ /**
+ * @cfg {Number} zIndex
+ * zIndex to use when the menu is floating.
+ */
+ zIndex: 15000,
+
// private
hidden : true,
@@ -256,10 +171,10 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
}
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
});
}
},
@@ -290,7 +205,7 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
dh: dh,
constrain: false,
parentEl: ct,
- zindex:15000
+ zindex: this.zIndex
});
}else{
this.el = ct.createChild(dh);
@@ -474,7 +389,7 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
// 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.
@@ -497,12 +412,31 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
},
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);
@@ -513,6 +447,7 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
this.el.select('.x-menu-scroller').setDisplayed('none');
}
this.ul.dom.scrollTop = 0;
+ return returnY;
},
createScrollers : function(){
@@ -573,9 +508,11 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
* @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
@@ -653,7 +590,9 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
* @return {Ext.menu.Item} The menu item that was added
*/
addElement : function(el){
- return this.add(new Ext.menu.BaseItem(el));
+ return this.add(new Ext.menu.BaseItem({
+ el: el
+ }));
},
/**
@@ -685,6 +624,7 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
//private
onDestroy : function(){
+ Ext.EventManager.removeResizeListener(this.hide, this);
var pm = this.parentMenu;
if(pm && pm.activeChild == this){
delete pm.activeChild;
@@ -692,7 +632,6 @@ Ext.menu.Menu = Ext.extend(Ext.Container, {
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();
}
@@ -829,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);
}
}
@@ -881,7 +820,7 @@ Ext.menu.MenuMgr = function(){
* @return {Boolean} success True if any active menus were hidden.
*/
hideAll : function(){
- return hideAll();
+ return hideAll();
},
// private
@@ -1015,7 +954,7 @@ Ext.menu.BaseItem = Ext.extend(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,
@@ -1024,33 +963,33 @@ Ext.menu.BaseItem = Ext.extend(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);
- }
+ /**
+ * @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
@@ -1207,216 +1146,216 @@ Ext.menu.Separator = Ext.extend(Ext.menu.BaseItem, {
Ext.menu.Separator.superclass.onRender.apply(this, arguments);
}
});
-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,
- // 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(
- '',
- ' target="{hrefTarget}"',
- '',
- '>',
- '',
- '',
- ''
- );
- }
- 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||' '
- };
- },
-
- /**
- * Sets the text to display in this menu item
- * @param {String} text The text to display
- */
- setText : function(text){
- this.text = text||' ';
- 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('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,
+ // 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(
+ '',
+ ' target="{hrefTarget}"',
+ '',
+ '>',
+ '',
+ '',
+ ''
+ );
+ }
+ 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||' '
+ };
+ },
+
+ /**
+ * Sets the text to display in this menu item
+ * @param {String} text The text to display
+ */
+ setText : function(text){
+ this.text = text||' ';
+ 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
@@ -1506,12 +1445,13 @@ Ext.menu.CheckItem = Ext.extend(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)){
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);
}
}
@@ -1525,224 +1465,224 @@ Ext.menu.CheckItem = Ext.extend(Ext.menu.Item, {
Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
}
});
-Ext.reg('menucheckitem', Ext.menu.CheckItem);/**
- * @class Ext.menu.DateMenu
- * @extends Ext.menu.Menu
- * A menu containing an {@link Ext.DatePicker} Component.
- * Notes:
- * - Although not listed here, the constructor for this class
- * accepts all of the configuration options of {@link Ext.DatePicker}.
- * - If subclassing DateMenu, any configuration options for the DatePicker must be
- * applied to the initialConfig property of the DateMenu.
- * Applying {@link Ext.DatePicker DatePicker} configuration settings to
- * this will not affect the DatePicker's configuration.
- *
- * @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:
- * picker
: DatePickerThe Ext.DatePicker.
- * date
: DateThe selected date.
- *
- */
- /**
- * @cfg {Object} scope
- * The scope (this reference) in which the {@link #handler}
- * 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 null.
- */
- 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
- * A menu containing a {@link Ext.ColorPalette} Component.
- * Notes:
- * - Although not listed here, the constructor for this class
- * accepts all of the configuration options of {@link Ext.ColorPalette}.
- * - If subclassing ColorMenu, any configuration options for the ColorPalette must be
- * applied to the initialConfig property of the ColorMenu.
- * Applying {@link Ext.ColorPalette ColorPalette} configuration settings to
- * this will not affect the ColorPalette's configuration.
- *
*
- * @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:
- */
- /**
- * @cfg {Object} scope
- * The scope (this reference) in which the {@link #handler}
- * 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 null.
- */
- 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);
+Ext.reg('menucheckitem', Ext.menu.CheckItem);/**
+ * @class Ext.menu.DateMenu
+ * @extends Ext.menu.Menu
+ * A menu containing an {@link Ext.DatePicker} Component.
+ * Notes:
+ * - Although not listed here, the constructor for this class
+ * accepts all of the configuration options of {@link Ext.DatePicker}.
+ * - If subclassing DateMenu, any configuration options for the DatePicker must be
+ * applied to the initialConfig property of the DateMenu.
+ * Applying {@link Ext.DatePicker DatePicker} configuration settings to
+ * this will not affect the DatePicker's configuration.
+ *
+ * @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:
+ * picker
: DatePickerThe Ext.DatePicker.
+ * date
: DateThe selected date.
+ *
+ */
+ /**
+ * @cfg {Object} scope
+ * The scope (this reference) in which the {@link #handler}
+ * 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 null.
+ */
+ 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
+ * A menu containing a {@link Ext.ColorPalette} Component.
+ * Notes:
+ * - Although not listed here, the constructor for this class
+ * accepts all of the configuration options of {@link Ext.ColorPalette}.
+ * - If subclassing ColorMenu, any configuration options for the ColorPalette must be
+ * applied to the initialConfig property of the ColorMenu.
+ * Applying {@link Ext.ColorPalette ColorPalette} configuration settings to
+ * this will not affect the ColorPalette's configuration.
+ *
*
+ * @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:
+ */
+ /**
+ * @cfg {Object} scope
+ * The scope (this reference) in which the {@link #handler}
+ * 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 null.
+ */
+ 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);