4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
14 * @class Roo.menu.BaseItem
15 * @extends Roo.Component
16 * The base class for all items that render into menus. BaseItem provides default rendering, activated state
17 * management and base configuration options shared by all menu components.
19 * Creates a new BaseItem
20 * @param {Object} config Configuration options
22 Roo.menu.BaseItem = function(config){
23 Roo.menu.BaseItem.superclass.constructor.call(this, config);
28 * Fires when this item is clicked
29 * @param {Roo.menu.BaseItem} this
30 * @param {Roo.EventObject} e
35 * Fires when this item is activated
36 * @param {Roo.menu.BaseItem} this
41 * Fires when this item is deactivated
42 * @param {Roo.menu.BaseItem} this
48 this.on("click", this.handler, this.scope, true);
52 Roo.extend(Roo.menu.BaseItem, Roo.Component, {
54 * @cfg {Function} handler
55 * A function that will handle the click event of this menu item (defaults to undefined)
58 * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to false)
63 * @cfg {Boolean} hidden True to prevent creation of this menu item (defaults to false)
68 * @cfg {String} activeClass The CSS class to use when the item becomes activated (defaults to "x-menu-item-active")
70 activeClass : "x-menu-item-active",
72 * @cfg {Boolean} hideOnClick True to hide the containing menu after this item is clicked (defaults to true)
76 * @cfg {Number} hideDelay Length of time in milliseconds to wait before hiding after a click (defaults to 100)
81 ctype: "Roo.menu.BaseItem",
84 actionMode : "container",
87 render : function(container, parentMenu){
88 this.parentMenu = parentMenu;
89 Roo.menu.BaseItem.superclass.render.call(this, container);
90 this.container.menuItemId = this.id;
94 onRender : function(container, position){
95 this.el = Roo.get(this.el);
96 container.dom.appendChild(this.el.dom);
100 onClick : function(e){
101 if(!this.disabled && this.fireEvent("click", this, e) !== false
102 && this.parentMenu.fireEvent("itemclick", this, e) !== false){
110 activate : function(){
114 var li = this.container;
115 li.addClass(this.activeClass);
116 this.region = li.getRegion().adjust(2, 2, -2, -2);
117 this.fireEvent("activate", this);
122 deactivate : function(){
123 this.container.removeClass(this.activeClass);
124 this.fireEvent("deactivate", this);
128 shouldDeactivate : function(e){
129 return !this.region || !this.region.contains(e.getPoint());
133 handleClick : function(e){
134 if(this.hideOnClick){
135 this.parentMenu.hide.defer(this.hideDelay, this.parentMenu, [true]);
140 expandMenu : function(autoActivate){
145 hideMenu : function(){