Upgrade to ExtJS 3.0.3 - Released 10/11/2009
[extjs.git] / src / widgets / menu / TextItem.js
1 /*!
2  * Ext JS Library 3.0.3
3  * Copyright(c) 2006-2009 Ext JS, LLC
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /**
8  * @class Ext.menu.TextItem
9  * @extends Ext.menu.BaseItem
10  * Adds a static text string to a menu, usually used as either a heading or group separator.
11  * @constructor
12  * Creates a new TextItem
13  * @param {Object/String} config If config is a string, it is used as the text to display, otherwise it
14  * is applied as a config object (and should contain a <tt>text</tt> property).
15  * @xtype menutextitem
16  */
17 Ext.menu.TextItem = function(cfg){
18     if(typeof cfg == 'string'){
19         cfg = {text: cfg}
20     }
21     Ext.menu.TextItem.superclass.constructor.call(this, cfg);
22 };
23
24 Ext.extend(Ext.menu.TextItem, Ext.menu.BaseItem, {
25     /**
26      * @cfg {String} text The text to display for this item (defaults to '')
27      */
28     /**
29      * @cfg {Boolean} hideOnClick True to hide the containing menu after this item is clicked (defaults to false)
30      */
31     hideOnClick : false,
32     /**
33      * @cfg {String} itemCls The default CSS class to use for text items (defaults to "x-menu-text")
34      */
35     itemCls : "x-menu-text",
36
37     // private
38     onRender : function(){
39         var s = document.createElement("span");
40         s.className = this.itemCls;
41         s.innerHTML = this.text;
42         this.el = s;
43         Ext.menu.TextItem.superclass.onRender.apply(this, arguments);
44     }
45 });
46 Ext.reg('menutextitem', Ext.menu.TextItem);