132 lines
No EOL
4.6 KiB
HTML
132 lines
No EOL
4.6 KiB
HTML
<html><head><title>BaseItem.js</title><link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/></head><body><h1>BaseItem.js</h1><pre class="highlighted"><code><i>/**
|
|
* @class Ext.menu.BaseItem
|
|
* @extends Ext.Component
|
|
* The base class <b>for</b> all items that render into menus. BaseItem provides <b>default</b> rendering, activated state
|
|
* management and base configuration options shared by all menu components.
|
|
* @constructor
|
|
* Creates a <b>new</b> BaseItem
|
|
* @param {Object} config Configuration options
|
|
*/</i>
|
|
Ext.menu.BaseItem = <b>function</b>(config){
|
|
Ext.menu.BaseItem.superclass.constructor.call(<b>this</b>, config);
|
|
|
|
<b>this</b>.addEvents({
|
|
<i>/**
|
|
* @event click
|
|
* Fires when <b>this</b> item is clicked
|
|
* @param {Ext.menu.BaseItem} <b>this</b>
|
|
* @param {Ext.EventObject} e
|
|
*/</i>
|
|
click: true,
|
|
<i>/**
|
|
* @event activate
|
|
* Fires when <b>this</b> item is activated
|
|
* @param {Ext.menu.BaseItem} <b>this</b>
|
|
*/</i>
|
|
activate : true,
|
|
<i>/**
|
|
* @event deactivate
|
|
* Fires when <b>this</b> item is deactivated
|
|
* @param {Ext.menu.BaseItem} <b>this</b>
|
|
*/</i>
|
|
deactivate : true
|
|
});
|
|
|
|
<b>if</b>(this.handler){
|
|
<b>this</b>.on("click", <b>this</b>.handler, <b>this</b>.scope, true);
|
|
}
|
|
};
|
|
|
|
Ext.extend(Ext.menu.BaseItem, Ext.Component, {
|
|
<i>/**
|
|
* @cfg {Function} handler
|
|
* A <b>function</b> that will handle the click event of <b>this</b> menu item (defaults to undefined)
|
|
*/</i>
|
|
<i>// holder</i>
|
|
<i>/***
|
|
* @cfg {Boolean} canActivate True <b>if</b> this item can be visually activated (defaults to false)
|
|
*/</i>
|
|
canActivate : false,
|
|
<i>/**
|
|
* @cfg {String} activeClass The CSS class to use when the item becomes activated (defaults to "x-menu-item-active")
|
|
*/</i>
|
|
activeClass : "x-menu-item-active",
|
|
<i>/**
|
|
* @cfg {Boolean} hideOnClick True to hide the containing menu after <b>this</b> item is clicked (defaults to true)
|
|
*/</i>
|
|
hideOnClick : true,
|
|
<i>/**
|
|
* @cfg {Number} hideDelay Length of time <b>in</b> milliseconds to wait before hiding after a click (defaults to 100)
|
|
*/</i>
|
|
hideDelay : 100,
|
|
|
|
<i>// private</i>
|
|
ctype: "Ext.menu.BaseItem",
|
|
|
|
<i>// private</i>
|
|
actionMode : "container",
|
|
|
|
<i>// private</i>
|
|
render : <b>function</b>(container, parentMenu){
|
|
<b>this</b>.parentMenu = parentMenu;
|
|
Ext.menu.BaseItem.superclass.render.call(<b>this</b>, container);
|
|
<b>this</b>.container.menuItemId = <b>this</b>.id;
|
|
},
|
|
|
|
<i>// private</i>
|
|
onRender : <b>function</b>(container, position){
|
|
<b>this</b>.el = Ext.get(<b>this</b>.el);
|
|
container.dom.appendChild(<b>this</b>.el.dom);
|
|
},
|
|
|
|
<i>// private</i>
|
|
onClick : <b>function</b>(e){
|
|
<b>if</b>(!<b>this</b>.disabled && <b>this</b>.fireEvent("click", <b>this</b>, e) !== false
|
|
&& <b>this</b>.parentMenu.fireEvent("itemclick", <b>this</b>, e) !== false){
|
|
<b>this</b>.handleClick(e);
|
|
}<b>else</b>{
|
|
e.stopEvent();
|
|
}
|
|
},
|
|
|
|
<i>// private</i>
|
|
activate : <b>function</b>(){
|
|
<b>if</b>(this.disabled){
|
|
<b>return</b> false;
|
|
}
|
|
<b>var</b> li = <b>this</b>.container;
|
|
li.addClass(<b>this</b>.activeClass);
|
|
<b>this</b>.region = li.getRegion().adjust(2, 2, -2, -2);
|
|
<b>this</b>.fireEvent("activate", <b>this</b>);
|
|
<b>return</b> true;
|
|
},
|
|
|
|
<i>// private</i>
|
|
deactivate : <b>function</b>(){
|
|
<b>this</b>.container.removeClass(<b>this</b>.activeClass);
|
|
<b>this</b>.fireEvent("deactivate", <b>this</b>);
|
|
},
|
|
|
|
<i>// private</i>
|
|
shouldDeactivate : <b>function</b>(e){
|
|
<b>return</b> !<b>this</b>.region || !<b>this</b>.region.contains(e.getPoint());
|
|
},
|
|
|
|
<i>// private</i>
|
|
handleClick : <b>function</b>(e){
|
|
<b>if</b>(this.hideOnClick){
|
|
<b>this</b>.parentMenu.hide.defer(<b>this</b>.hideDelay, <b>this</b>.parentMenu, [true]);
|
|
}
|
|
},
|
|
|
|
<i>// private</i>
|
|
expandMenu : <b>function</b>(autoActivate){
|
|
<i>// <b>do</b> nothing</i>
|
|
},
|
|
|
|
<i>// private</i>
|
|
hideMenu : <b>function</b>(){
|
|
<i>// <b>do</b> nothing</i>
|
|
}
|
|
});</code></pre><hr><div style="font-size:10px;text-align:center;color:gray;">Ext - Copyright © 2006-2007 Ext JS, LLC<br />All rights reserved.</div>
|
|
</body></html> |