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
17 * The base class for all items that render into menus. BaseItem provides default rendering, activated state
18 * management and base configuration options shared by all menu components.
20 * Creates a new BaseItem
21 * @param {Object} config Configuration options
23 Roo.menu.BaseItem = function(config){
24 Roo.menu.BaseItem.superclass.constructor.call(this, config);
29 * Fires when this item is clicked
30 * @param {Roo.menu.BaseItem} this
31 * @param {Roo.EventObject} e
36 * Fires when this item is activated
37 * @param {Roo.menu.BaseItem} this
42 * Fires when this item is deactivated
43 * @param {Roo.menu.BaseItem} this
49 this.on("click", this.handler, this.scope, true);
53 Roo.extend(Roo.menu.BaseItem, Roo.Component, {
55 * @cfg {Function} handler
56 * A function that will handle the click event of this menu item (defaults to undefined)
59 * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to false)
64 * @cfg {Boolean} hidden True to prevent creation of this menu item (defaults to false)
69 * @cfg {String} activeClass The CSS class to use when the item becomes activated (defaults to "x-menu-item-active")
71 activeClass : "x-menu-item-active",
73 * @cfg {Boolean} hideOnClick True to hide the containing menu after this item is clicked (defaults to true)
77 * @cfg {Number} hideDelay Length of time in milliseconds to wait before hiding after a click (defaults to 100)
82 ctype: "Roo.menu.BaseItem",
85 actionMode : "container",
88 render : function(container, parentMenu){
89 this.parentMenu = parentMenu;
90 Roo.menu.BaseItem.superclass.render.call(this, container);
91 this.container.menuItemId = this.id;
95 onRender : function(container, position){
96 this.el = Roo.get(this.el);
97 container.dom.appendChild(this.el.dom);
101 onClick : function(e){
102 if(!this.disabled && this.fireEvent("click", this, e) !== false
103 && this.parentMenu.fireEvent("itemclick", this, e) !== false){
111 activate : function(){
115 var li = this.container;
116 li.addClass(this.activeClass);
117 this.region = li.getRegion().adjust(2, 2, -2, -2);
118 this.fireEvent("activate", this);
123 deactivate : function(){
124 this.container.removeClass(this.activeClass);
125 this.fireEvent("deactivate", this);
129 shouldDeactivate : function(e){
130 return !this.region || !this.region.contains(e.getPoint());
134 handleClick : function(e){
135 if(this.hideOnClick){
136 this.parentMenu.hide.defer(this.hideDelay, this.parentMenu, [true]);
141 expandMenu : function(autoActivate){
146 hideMenu : function(){