--- /dev/null
+<html>\r
+<head>\r
+ <title>The source code</title>\r
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body onload="prettyPrint();">\r
+ <pre class="prettyprint lang-js"><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> \r
+</body>\r
+</html>
\ No newline at end of file