3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.menu.BaseItem"></div>/**
10 * @class Ext.menu.BaseItem
11 * @extends Ext.Component
12 * The base class for all items that render into menus. BaseItem provides default rendering, activated state
13 * management and base configuration options shared by all menu components.
15 * Creates a new BaseItem
16 * @param {Object} config Configuration options
19 Ext.menu.BaseItem = Ext.extend(Ext.Component, {
20 <div id="prop-Ext.menu.BaseItem-parentMenu"></div>/**
21 * @property parentMenu
23 * The parent Menu of this Item.
25 <div id="cfg-Ext.menu.BaseItem-handler"></div>/**
26 * @cfg {Function} handler
27 * A function that will handle the click event of this menu item (optional).
28 * The handler is passed the following parameters:<div class="mdetail-params"><ul>
29 * <li><code>b</code> : Item<div class="sub-desc">This menu Item.</div></li>
30 * <li><code>e</code> : EventObject<div class="sub-desc">The click event.</div></li>
33 <div id="cfg-Ext.menu.BaseItem-scope"></div>/**
35 * The scope (<tt><b>this</b></tt> reference) in which the handler function will be called.
37 <div id="cfg-Ext.menu.BaseItem-canActivate"></div>/**
38 * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to false)
41 <div id="cfg-Ext.menu.BaseItem-activeClass"></div>/**
42 * @cfg {String} activeClass The CSS class to use when the item becomes activated (defaults to "x-menu-item-active")
44 activeClass : "x-menu-item-active",
45 <div id="cfg-Ext.menu.BaseItem-hideOnClick"></div>/**
46 * @cfg {Boolean} hideOnClick True to hide the containing menu after this item is clicked (defaults to true)
49 <div id="cfg-Ext.menu.BaseItem-clickHideDelay"></div>/**
50 * @cfg {Number} clickHideDelay Length of time in milliseconds to wait before hiding after a click (defaults to 100)
55 ctype : "Ext.menu.BaseItem",
58 actionMode : "container",
60 initComponent : function(){
61 Ext.menu.BaseItem.superclass.initComponent.call(this);
63 <div id="event-Ext.menu.BaseItem-click"></div>/**
65 * Fires when this item is clicked
66 * @param {Ext.menu.BaseItem} this
67 * @param {Ext.EventObject} e
70 <div id="event-Ext.menu.BaseItem-activate"></div>/**
72 * Fires when this item is activated
73 * @param {Ext.menu.BaseItem} this
76 <div id="event-Ext.menu.BaseItem-deactivate"></div>/**
78 * Fires when this item is deactivated
79 * @param {Ext.menu.BaseItem} this
84 this.on("click", this.handler, this.scope);
89 onRender : function(container, position){
90 Ext.menu.BaseItem.superclass.onRender.apply(this, arguments);
91 if(this.ownerCt && this.ownerCt instanceof Ext.menu.Menu){
92 this.parentMenu = this.ownerCt;
94 this.container.addClass('x-menu-list-item');
98 mouseenter: this.activate,
99 mouseleave: this.deactivate
104 <div id="method-Ext.menu.BaseItem-setHandler"></div>/**
105 * Sets the function that will handle click events for this item (equivalent to passing in the {@link #handler}
106 * config property). If an existing handler is already registered, it will be unregistered for you.
107 * @param {Function} handler The function that should be called on click
108 * @param {Object} scope The scope (<code>this</code> reference) in which the handler function is executed. Defaults to this menu item.
110 setHandler : function(handler, scope){
112 this.un("click", this.handler, this.scope);
114 this.on("click", this.handler = handler, this.scope = scope);
118 onClick : function(e){
119 if(!this.disabled && this.fireEvent("click", this, e) !== false
120 && (this.parentMenu && this.parentMenu.fireEvent("itemclick", this, e) !== false)){
128 activate : function(){
132 var li = this.container;
133 li.addClass(this.activeClass);
134 this.region = li.getRegion().adjust(2, 2, -2, -2);
135 this.fireEvent("activate", this);
140 deactivate : function(){
141 this.container.removeClass(this.activeClass);
142 this.fireEvent("deactivate", this);
146 shouldDeactivate : function(e){
147 return !this.region || !this.region.contains(e.getPoint());
151 handleClick : function(e){
152 var pm = this.parentMenu;
153 if(this.hideOnClick){
155 pm.hide.defer(this.clickHideDelay, pm, [true]);
157 pm.deactivateActive();
162 // private. Do nothing
163 expandMenu : Ext.emptyFn,
165 // private. Do nothing
166 hideMenu : Ext.emptyFn
168 Ext.reg('menubaseitem', Ext.menu.BaseItem);</pre>
\r