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)
62 * @cfg {String} activeClass The CSS class to use when the item becomes activated (defaults to "x-menu-item-active")
64 activeClass : "x-menu-item-active",
66 * @cfg {Boolean} hideOnClick True to hide the containing menu after this item is clicked (defaults to true)
70 * @cfg {Number} hideDelay Length of time in milliseconds to wait before hiding after a click (defaults to 100)
75 ctype: "Roo.menu.BaseItem",
78 actionMode : "container",
81 render : function(container, parentMenu){
82 this.parentMenu = parentMenu;
83 Roo.menu.BaseItem.superclass.render.call(this, container);
84 this.container.menuItemId = this.id;
88 onRender : function(container, position){
89 this.el = Roo.get(this.el);
90 container.dom.appendChild(this.el.dom);
94 onClick : function(e){
95 if(!this.disabled && this.fireEvent("click", this, e) !== false
96 && this.parentMenu.fireEvent("itemclick", this, e) !== false){
104 activate : function(){
108 var li = this.container;
109 li.addClass(this.activeClass);
110 this.region = li.getRegion().adjust(2, 2, -2, -2);
111 this.fireEvent("activate", this);
116 deactivate : function(){
117 this.container.removeClass(this.activeClass);
118 this.fireEvent("deactivate", this);
122 shouldDeactivate : function(e){
123 return !this.region || !this.region.contains(e.getPoint());
127 handleClick : function(e){
128 if(this.hideOnClick){
129 this.parentMenu.hide.defer(this.hideDelay, this.parentMenu, [true]);
134 expandMenu : function(autoActivate){
139 hideMenu : function(){