5ab2d1834e1bdd052abbc2ab990682fdf14b3fba
[roojs1] / Roo / menu / TextItem.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11
12 /**
13  * @class Roo.menu.TextItem
14  * @extends Roo.menu.BaseItem
15  * Adds a static text string to a menu, usually used as either a heading or group separator.
16  * Note: old style constructor with text is still supported.
17  * 
18  * @constructor
19  * Creates a new TextItem
20  * @param {Object} cfg Configuration
21  */
22 Roo.menu.TextItem = function(cfg){
23     if (typeof(cfg) == 'string') {
24         this.text = cfg;
25     } else {
26         Roo.apply(this,cfg);
27     }
28     
29     Roo.menu.TextItem.superclass.constructor.call(this);
30 };
31
32 Roo.extend(Roo.menu.TextItem, Roo.menu.BaseItem, {
33     /**
34      * @cfg {Boolean} text Text to show on item.
35      */
36     text : '',
37     
38     /**
39      * @cfg {Boolean} hideOnClick True to hide the containing menu after this item is clicked (defaults to false)
40      */
41     hideOnClick : false,
42     /**
43      * @cfg {String} itemCls The default CSS class to use for text items (defaults to "x-menu-text")
44      */
45     itemCls : "x-menu-text",
46
47     // private
48     onRender : function(){
49         var s = document.createElement("span");
50         s.className = this.itemCls;
51         s.innerHTML = this.text;
52         this.el = s;
53         Roo.menu.TextItem.superclass.onRender.apply(this, arguments);
54     }
55 });