+++ /dev/null
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\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
- */\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
- /**\r
- * @cfg {Mixed} menu 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
- /**\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
- /**\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
- /**\r
- * @cfg {String} text The text to display in this item (defaults to '').\r
- */\r
- /**\r
- * @cfg {String} href The href attribute to use for the underlying anchor link (defaults to '#').\r
- */\r
- /**\r
- * @cfg {String} hrefTarget The target attribute to use for the underlying anchor link (defaults to '').\r
- */\r
- /**\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
- /**\r
- * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to true)\r
- */\r
- canActivate : true,\r
- /**\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
- var el = document.createElement("a");\r
- el.hideFocus = true;\r
- el.unselectable = "on";\r
- el.href = this.href || "#";\r
- if(this.hrefTarget){\r
- el.target = this.hrefTarget;\r
- }\r
- el.className = this.itemCls + (this.menu ? " x-menu-item-arrow" : "") + (this.cls ? " " + this.cls : "");\r
- el.innerHTML = String.format(\r
- '<img src="{0}" class="x-menu-item-icon {2}" />{1}',\r
- this.icon || Ext.BLANK_IMAGE_URL, this.itemText||this.text, this.iconCls || '');\r
- this.el = el;\r
- Ext.menu.Item.superclass.onRender.call(this, container, position);\r
- },\r
-\r
- /**\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.el.update(String.format(\r
- '<img src="{0}" class="x-menu-item-icon {2}">{1}',\r
- this.icon || Ext.BLANK_IMAGE_URL, this.text, this.iconCls || ''));\r
- this.parentMenu.autoWidth();\r
- }\r
- },\r
-\r
- /**\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.el.child('img.x-menu-item-icon').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
-});
\ No newline at end of file