-<div id="cls-Ext.menu.Item"></div>/**\r
- * @class Ext.menu.Item\r
- * @extends Ext.menu.BaseItem\r
- * A base class for all menu items that require menu-related functionality (like sub-menus) and are not static\r
- * display items. Item extends the base functionality of {@link Ext.menu.BaseItem} by adding menu-specific\r
- * activation and click handling.\r
- * @constructor\r
- * Creates a new Item\r
- * @param {Object} config Configuration options\r
- * @xtype menuitem\r
- */\r
-Ext.menu.Item = function(config){\r
- Ext.menu.Item.superclass.constructor.call(this, config);\r
- if(this.menu){\r
- this.menu = Ext.menu.MenuMgr.get(this.menu);\r
- }\r
-};\r
-Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {\r
- <div id="prop-Ext.menu.Item-menu"></div>/**\r
- * @property menu\r
- * @type Ext.menu.Menu\r
- * The submenu associated with this Item if one was configured.\r
- */\r
- <div id="cfg-Ext.menu.Item-menu"></div>/**\r
- * @cfg {Mixed} menu (optional) Either an instance of {@link Ext.menu.Menu} or the config object for an\r
- * {@link Ext.menu.Menu} which acts as the submenu when this item is activated.\r
- */\r
- <div id="cfg-Ext.menu.Item-icon"></div>/**\r
- * @cfg {String} icon The path to an icon to display in this item (defaults to Ext.BLANK_IMAGE_URL). If\r
- * icon is specified {@link #iconCls} should not be.\r
- */\r
- <div id="cfg-Ext.menu.Item-iconCls"></div>/**\r
- * @cfg {String} iconCls A CSS class that specifies a background image that will be used as the icon for\r
- * this item (defaults to ''). If iconCls is specified {@link #icon} should not be.\r
- */\r
- <div id="cfg-Ext.menu.Item-text"></div>/**\r
- * @cfg {String} text The text to display in this item (defaults to '').\r
- */\r
- <div id="cfg-Ext.menu.Item-href"></div>/**\r
- * @cfg {String} href The href attribute to use for the underlying anchor link (defaults to '#').\r
- */\r
- <div id="cfg-Ext.menu.Item-hrefTarget"></div>/**\r
- * @cfg {String} hrefTarget The target attribute to use for the underlying anchor link (defaults to '').\r
- */\r
- <div id="cfg-Ext.menu.Item-itemCls"></div>/**\r
- * @cfg {String} itemCls The default CSS class to use for menu items (defaults to 'x-menu-item')\r
- */\r
- itemCls : 'x-menu-item',\r
- <div id="cfg-Ext.menu.Item-canActivate"></div>/**\r
- * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to true)\r
- */\r
- canActivate : true,\r
- <div id="cfg-Ext.menu.Item-showDelay"></div>/**\r
- * @cfg {Number} showDelay Length of time in milliseconds to wait before showing this item (defaults to 200)\r
- */\r
- showDelay: 200,\r
- // doc'd in BaseItem\r
- hideDelay: 200,\r
-\r
- // private\r
- ctype: 'Ext.menu.Item',\r
-\r
- // private\r
- onRender : function(container, position){\r
- if (!this.itemTpl) {\r
- this.itemTpl = Ext.menu.Item.prototype.itemTpl = new Ext.XTemplate(\r
- '<a id="{id}" class="{cls}" hidefocus="true" unselectable="on" href="{href}"',\r
- '<tpl if="hrefTarget">',\r
- ' target="{hrefTarget}"',\r
- '</tpl>',\r
- '>',\r
- '<img src="{icon}" class="x-menu-item-icon {iconCls}"/>',\r
- '<span class="x-menu-item-text">{text}</span>',\r
- '</a>'\r
- );\r
- }\r
- var a = this.getTemplateArgs();\r
- this.el = position ? this.itemTpl.insertBefore(position, a, true) : this.itemTpl.append(container, a, true);\r
- this.iconEl = this.el.child('img.x-menu-item-icon');\r
- this.textEl = this.el.child('.x-menu-item-text');\r
- Ext.menu.Item.superclass.onRender.call(this, container, position);\r
- },\r
-\r
- getTemplateArgs: function() {\r
- return {\r
- id: this.id,\r
- cls: this.itemCls + (this.menu ? ' x-menu-item-arrow' : '') + (this.cls ? ' ' + this.cls : ''),\r
- href: this.href || '#',\r
- hrefTarget: this.hrefTarget,\r
- icon: this.icon || Ext.BLANK_IMAGE_URL,\r
- iconCls: this.iconCls || '',\r
- text: this.itemText||this.text||' '\r
- };\r
- },\r
-\r
- <div id="method-Ext.menu.Item-setText"></div>/**\r
- * Sets the text to display in this menu item\r
- * @param {String} text The text to display\r
- */\r
- setText : function(text){\r
- this.text = text||' ';\r
- if(this.rendered){\r
- this.textEl.update(this.text);\r
- this.parentMenu.layout.doAutoSize();\r
- }\r
- },\r
-\r
- <div id="method-Ext.menu.Item-setIconClass"></div>/**\r
- * Sets the CSS class to apply to the item's icon element\r
- * @param {String} cls The CSS class to apply\r
- */\r
- setIconClass : function(cls){\r
- var oldCls = this.iconCls;\r
- this.iconCls = cls;\r
- if(this.rendered){\r
- this.iconEl.replaceClass(oldCls, this.iconCls);\r
- }\r
- },\r
- \r
- //private\r
- beforeDestroy: function(){\r
- if (this.menu){\r
- this.menu.destroy();\r
- }\r
- Ext.menu.Item.superclass.beforeDestroy.call(this);\r
- },\r
-\r
- // private\r
- handleClick : function(e){\r
- if(!this.href){ // if no link defined, stop the event automatically\r
- e.stopEvent();\r
- }\r
- Ext.menu.Item.superclass.handleClick.apply(this, arguments);\r
- },\r
-\r
- // private\r
- activate : function(autoExpand){\r
- if(Ext.menu.Item.superclass.activate.apply(this, arguments)){\r
- this.focus();\r
- if(autoExpand){\r
- this.expandMenu();\r
- }\r
- }\r
- return true;\r
- },\r
-\r
- // private\r
- shouldDeactivate : function(e){\r
- if(Ext.menu.Item.superclass.shouldDeactivate.call(this, e)){\r
- if(this.menu && this.menu.isVisible()){\r
- return !this.menu.getEl().getRegion().contains(e.getPoint());\r
- }\r
- return true;\r
- }\r
- return false;\r
- },\r
-\r
- // private\r
- deactivate : function(){\r
- Ext.menu.Item.superclass.deactivate.apply(this, arguments);\r
- this.hideMenu();\r
- },\r
-\r
- // private\r
- expandMenu : function(autoActivate){\r
- if(!this.disabled && this.menu){\r
- clearTimeout(this.hideTimer);\r
- delete this.hideTimer;\r
- if(!this.menu.isVisible() && !this.showTimer){\r
- this.showTimer = this.deferExpand.defer(this.showDelay, this, [autoActivate]);\r
- }else if (this.menu.isVisible() && autoActivate){\r
- this.menu.tryActivate(0, 1);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- deferExpand : function(autoActivate){\r
- delete this.showTimer;\r
- this.menu.show(this.container, this.parentMenu.subMenuAlign || 'tl-tr?', this.parentMenu);\r
- if(autoActivate){\r
- this.menu.tryActivate(0, 1);\r
- }\r
- },\r
-\r
- // private\r
- hideMenu : function(){\r
- clearTimeout(this.showTimer);\r
- delete this.showTimer;\r
- if(!this.hideTimer && this.menu && this.menu.isVisible()){\r
- this.hideTimer = this.deferHide.defer(this.hideDelay, this);\r
- }\r
- },\r
-\r
- // private\r
- deferHide : function(){\r
- delete this.hideTimer;\r
- if(this.menu.over){\r
- this.parentMenu.setActiveItem(this, false);\r
- }else{\r
- this.menu.hide();\r
- }\r
- }\r
-});\r
-Ext.reg('menuitem', Ext.menu.Item);</pre>
+<div id="cls-Ext.menu.Item"></div>/**
+ * @class Ext.menu.Item
+ * @extends Ext.menu.BaseItem
+ * A base class for 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 new Item
+ * @param {Object} config Configuration options
+ * @xtype menuitem
+ */
+Ext.menu.Item = Ext.extend(Ext.menu.BaseItem, {
+ <div id="prop-Ext.menu.Item-menu"></div>/**
+ * @property menu
+ * @type Ext.menu.Menu
+ * The submenu associated with this Item if one was configured.
+ */
+ <div id="cfg-Ext.menu.Item-menu"></div>/**
+ * @cfg {Mixed} menu (optional) Either an instance of {@link Ext.menu.Menu} or the config object for an
+ * {@link Ext.menu.Menu} which acts as the submenu when this item is activated.
+ */
+ <div id="cfg-Ext.menu.Item-icon"></div>/**
+ * @cfg {String} icon The path to an icon to display in this item (defaults to Ext.BLANK_IMAGE_URL). If
+ * icon is specified {@link #iconCls} should not be.
+ */
+ <div id="cfg-Ext.menu.Item-iconCls"></div>/**
+ * @cfg {String} iconCls A CSS class that specifies a background image that will be used as the icon for
+ * this item (defaults to ''). If iconCls is specified {@link #icon} should not be.
+ */
+ <div id="cfg-Ext.menu.Item-text"></div>/**
+ * @cfg {String} text The text to display in this item (defaults to '').
+ */
+ <div id="cfg-Ext.menu.Item-href"></div>/**
+ * @cfg {String} href The href attribute to use for the underlying anchor link (defaults to '#').
+ */
+ <div id="cfg-Ext.menu.Item-hrefTarget"></div>/**
+ * @cfg {String} hrefTarget The target attribute to use for the underlying anchor link (defaults to '').
+ */
+ <div id="cfg-Ext.menu.Item-itemCls"></div>/**
+ * @cfg {String} itemCls The default CSS class to use for menu items (defaults to 'x-menu-item')
+ */
+ itemCls : 'x-menu-item',
+ <div id="cfg-Ext.menu.Item-canActivate"></div>/**
+ * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to true)
+ */
+ canActivate : true,
+ <div id="cfg-Ext.menu.Item-showDelay"></div>/**
+ * @cfg {Number} showDelay Length of time in milliseconds to wait before showing this item (defaults to 200)
+ */
+ showDelay: 200,
+
+ <div id="cfg-Ext.menu.Item-altText"></div>/**
+ * @cfg {String} altText The altText to use for the icon, if it exists. Defaults to <tt>''</tt>.
+ */
+ altText: '',
+
+ // doc'd in BaseItem
+ hideDelay: 200,
+
+ // private
+ ctype: 'Ext.menu.Item',
+
+ initComponent : function(){
+ Ext.menu.Item.superclass.initComponent.call(this);
+ if(this.menu){
+ this.menu = Ext.menu.MenuMgr.get(this.menu);
+ this.menu.ownerCt = this;
+ }
+ },
+
+ // private
+ onRender : function(container, position){
+ if (!this.itemTpl) {
+ this.itemTpl = Ext.menu.Item.prototype.itemTpl = new Ext.XTemplate(
+ '<a id="{id}" class="{cls}" hidefocus="true" unselectable="on" href="{href}"',
+ '<tpl if="hrefTarget">',
+ ' target="{hrefTarget}"',
+ '</tpl>',
+ '>',
+ '<img alt="{altText}" src="{icon}" class="x-menu-item-icon {iconCls}"/>',
+ '<span class="x-menu-item-text">{text}</span>',
+ '</a>'
+ );
+ }
+ var a = this.getTemplateArgs();
+ this.el = position ? this.itemTpl.insertBefore(position, a, true) : this.itemTpl.append(container, a, true);
+ this.iconEl = this.el.child('img.x-menu-item-icon');
+ this.textEl = this.el.child('.x-menu-item-text');
+ if(!this.href) { // if no link defined, prevent the default anchor event
+ this.mon(this.el, 'click', Ext.emptyFn, null, { preventDefault: true });
+ }
+ Ext.menu.Item.superclass.onRender.call(this, container, position);
+ },
+
+ getTemplateArgs: function() {
+ return {
+ id: this.id,
+ cls: this.itemCls + (this.menu ? ' x-menu-item-arrow' : '') + (this.cls ? ' ' + this.cls : ''),
+ href: this.href || '#',
+ hrefTarget: this.hrefTarget,
+ icon: this.icon || Ext.BLANK_IMAGE_URL,
+ iconCls: this.iconCls || '',
+ text: this.itemText||this.text||' ',
+ altText: this.altText || ''
+ };
+ },
+
+ <div id="method-Ext.menu.Item-setText"></div>/**
+ * Sets the text to display in this menu item
+ * @param {String} text The text to display
+ */
+ setText : function(text){
+ this.text = text||' ';
+ if(this.rendered){
+ this.textEl.update(this.text);
+ this.parentMenu.layout.doAutoSize();
+ }
+ },
+
+ <div id="method-Ext.menu.Item-setIconClass"></div>/**
+ * Sets the CSS class to apply to the item's icon element
+ * @param {String} cls The CSS class to apply
+ */
+ setIconClass : function(cls){
+ var oldCls = this.iconCls;
+ this.iconCls = cls;
+ if(this.rendered){
+ this.iconEl.replaceClass(oldCls, this.iconCls);
+ }
+ },
+
+ //private
+ beforeDestroy: function(){
+ if (this.menu){
+ delete this.menu.ownerCt;
+ this.menu.destroy();
+ }
+ Ext.menu.Item.superclass.beforeDestroy.call(this);
+ },
+
+ // private
+ handleClick : function(e){
+ if(!this.href){ // if no link defined, stop the event automatically
+ e.stopEvent();
+ }
+ Ext.menu.Item.superclass.handleClick.apply(this, arguments);
+ },
+
+ // private
+ activate : function(autoExpand){
+ if(Ext.menu.Item.superclass.activate.apply(this, arguments)){
+ this.focus();
+ if(autoExpand){
+ this.expandMenu();
+ }
+ }
+ return true;
+ },
+
+ // private
+ shouldDeactivate : function(e){
+ if(Ext.menu.Item.superclass.shouldDeactivate.call(this, e)){
+ if(this.menu && this.menu.isVisible()){
+ return !this.menu.getEl().getRegion().contains(e.getPoint());
+ }
+ return true;
+ }
+ return false;
+ },
+
+ // private
+ deactivate : function(){
+ Ext.menu.Item.superclass.deactivate.apply(this, arguments);
+ this.hideMenu();
+ },
+
+ // private
+ expandMenu : function(autoActivate){
+ if(!this.disabled && this.menu){
+ clearTimeout(this.hideTimer);
+ delete this.hideTimer;
+ if(!this.menu.isVisible() && !this.showTimer){
+ this.showTimer = this.deferExpand.defer(this.showDelay, this, [autoActivate]);
+ }else if (this.menu.isVisible() && autoActivate){
+ this.menu.tryActivate(0, 1);
+ }
+ }
+ },
+
+ // private
+ deferExpand : function(autoActivate){
+ delete this.showTimer;
+ this.menu.show(this.container, this.parentMenu.subMenuAlign || 'tl-tr?', this.parentMenu);
+ if(autoActivate){
+ this.menu.tryActivate(0, 1);
+ }
+ },
+
+ // private
+ hideMenu : function(){
+ clearTimeout(this.showTimer);
+ delete this.showTimer;
+ if(!this.hideTimer && this.menu && this.menu.isVisible()){
+ this.hideTimer = this.deferHide.defer(this.hideDelay, this);
+ }
+ },
+
+ // private
+ deferHide : function(){
+ delete this.hideTimer;
+ if(this.menu.over){
+ this.parentMenu.setActiveItem(this, false);
+ }else{
+ this.menu.hide();
+ }
+ }
+});
+Ext.reg('menuitem', Ext.menu.Item);</pre>