121 lines
No EOL
4.7 KiB
HTML
121 lines
No EOL
4.7 KiB
HTML
<html><head><title>Item.js</title><link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/></head><body><h1>Item.js</h1><pre class="highlighted"><code><i>/**
|
|
* @class Ext.menu.Item
|
|
* @extends Ext.menu.BaseItem
|
|
* A base class <b>for</b> all menu items that require menu-related functionality (like sub-menus) and are not static
|
|
* display items. Item extends the base functionality of {@link Ext.menu.BaseItem} by adding menu-specific
|
|
* activation and click handling.
|
|
* @constructor
|
|
* Creates a <b>new</b> Item
|
|
* @param {Object} config Configuration options
|
|
*/</i>
|
|
Ext.menu.Item = <b>function</b>(config){
|
|
Ext.menu.Item.superclass.constructor.call(<b>this</b>, config);
|
|
<b>if</b>(this.menu){
|
|
<b>this</b>.menu = Ext.menu.MenuMgr.get(<b>this</b>.menu);
|
|
}
|
|
};
|
|
Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {
|
|
<i>/**
|
|
* @cfg {String} icon
|
|
* The path to an icon to display <b>in</b> this menu item (defaults to Ext.BLANK_IMAGE_URL)
|
|
*/</i>
|
|
<i>// holder</i>
|
|
<i>/***
|
|
* @cfg {String} itemCls The <b>default</b> CSS class to use <b>for</b> menu items (defaults to "x-menu-item")
|
|
*/</i>
|
|
itemCls : "x-menu-item",
|
|
<i>/**
|
|
* @cfg {Boolean} canActivate True <b>if</b> this item can be visually activated (defaults to true)
|
|
*/</i>
|
|
canActivate : true,
|
|
|
|
<i>// private</i>
|
|
ctype: "Ext.menu.Item",
|
|
|
|
<i>// private</i>
|
|
onRender : <b>function</b>(container, position){
|
|
<b>var</b> el = document.createElement("a");
|
|
el.hideFocus = true;
|
|
el.unselectable = "on";
|
|
el.href = <b>this</b>.href || "#";
|
|
<b>if</b>(this.hrefTarget){
|
|
el.target = <b>this</b>.hrefTarget;
|
|
}
|
|
el.className = <b>this</b>.itemCls + (<b>this</b>.menu ? " x-menu-item-arrow" : "") + (<b>this</b>.cls ? " " + <b>this</b>.cls : "");
|
|
el.innerHTML = String.format(
|
|
'<img src="{0}" class="x-menu-item-icon">{1}',
|
|
<b>this</b>.icon || Ext.BLANK_IMAGE_URL, <b>this</b>.text);
|
|
<b>this</b>.el = el;
|
|
Ext.menu.Item.superclass.onRender.call(<b>this</b>, container, position);
|
|
},
|
|
|
|
<i>/**
|
|
* Sets the text to display <b>in</b> this menu item
|
|
* @param {String} text The text to display
|
|
*/</i>
|
|
setText : <b>function</b>(text){
|
|
<b>this</b>.text = text;
|
|
<b>if</b>(this.rendered){
|
|
<b>this</b>.el.update(String.format(
|
|
'<img src="{0}" class="x-menu-item-icon">{1}',
|
|
<b>this</b>.icon || Ext.BLANK_IMAGE_URL, <b>this</b>.text));
|
|
<b>this</b>.parentMenu.autoWidth();
|
|
}
|
|
},
|
|
|
|
<i>// private</i>
|
|
handleClick : <b>function</b>(e){
|
|
<b>if</b>(!<b>this</b>.href){ <i>// <b>if</b> no link defined, stop the event automatically</i>
|
|
e.stopEvent();
|
|
}
|
|
Ext.menu.Item.superclass.handleClick.apply(<b>this</b>, arguments);
|
|
},
|
|
|
|
<i>// private</i>
|
|
activate : <b>function</b>(autoExpand){
|
|
<b>if</b>(Ext.menu.Item.superclass.activate.apply(<b>this</b>, arguments)){
|
|
<b>this</b>.focus();
|
|
<b>if</b>(autoExpand){
|
|
<b>this</b>.expandMenu();
|
|
}
|
|
}
|
|
<b>return</b> true;
|
|
},
|
|
|
|
<i>// private</i>
|
|
shouldDeactivate : <b>function</b>(e){
|
|
<b>if</b>(Ext.menu.Item.superclass.shouldDeactivate.call(<b>this</b>, e)){
|
|
<b>if</b>(this.menu && <b>this</b>.menu.isVisible()){
|
|
<b>return</b> !<b>this</b>.menu.getEl().getRegion().contains(e.getPoint());
|
|
}
|
|
<b>return</b> true;
|
|
}
|
|
<b>return</b> false;
|
|
},
|
|
|
|
<i>// private</i>
|
|
deactivate : <b>function</b>(){
|
|
Ext.menu.Item.superclass.deactivate.apply(<b>this</b>, arguments);
|
|
<b>this</b>.hideMenu();
|
|
},
|
|
|
|
<i>// private</i>
|
|
expandMenu : <b>function</b>(autoActivate){
|
|
<b>if</b>(!<b>this</b>.disabled && <b>this</b>.menu){
|
|
<b>if</b>(!<b>this</b>.menu.isVisible()){
|
|
<b>this</b>.menu.show(<b>this</b>.container, <b>this</b>.parentMenu.subMenuAlign || "tl-tr?", <b>this</b>.parentMenu);
|
|
}
|
|
<b>if</b>(autoActivate){
|
|
<b>this</b>.menu.tryActivate(0, 1);
|
|
}
|
|
}
|
|
},
|
|
|
|
<i>// private</i>
|
|
hideMenu : <b>function</b>(){
|
|
<b>if</b>(this.menu && <b>this</b>.menu.isVisible()){
|
|
<b>this</b>.menu.hide();
|
|
}
|
|
}
|
|
});</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> |