bed0e4a18979435c541fcb52f0924b4a8376b425
[roojs1] / Roo / bootstrap / Element.js
1 /*
2  * - LGPL
3  *
4  * element
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.Element
10  * @extends Roo.bootstrap.Component
11  * Bootstrap Element class
12  * @cfg {String} html contents of the element
13  * @cfg {String} tag tag of the element
14  * @cfg {String} cls class of the element
15  * @cfg {Boolean} preventDefault (true|false) default false
16  * @cfg {Boolean} clickable (true|false) default false
17  * 
18  * @constructor
19  * Create a new Element
20  * @param {Object} config The config object
21  */
22
23 Roo.bootstrap.Element = function(config){
24     Roo.bootstrap.Element.superclass.constructor.call(this, config);
25     
26     this.addEvents({
27         // raw events
28         /**
29          * @event click
30          * When a element is chick
31          * @param {Roo.bootstrap.Element} this
32          * @param {Roo.EventObject} e
33          */
34         "click" : true
35     });
36 };
37
38 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component,  {
39     
40     tag: 'div',
41     cls: '',
42     html: '',
43     preventDefault: false, 
44     clickable: false,
45     
46     getAutoCreate : function(){
47         
48         var cfg = {
49             tag: this.tag,
50             // cls: this.cls, double assign in parent class Component.js :: onRender
51             html: this.html
52         };
53         
54         return cfg;
55     },
56     
57     initEvents: function() 
58     {
59         Roo.bootstrap.Element.superclass.initEvents.call(this);
60         
61         if(this.clickable){
62             this.el.on('click', this.onClick, this);
63         }
64         
65     },
66     
67     onClick : function(e)
68     {
69         if(this.preventDefault){
70             e.preventDefault();
71         }
72         
73         this.fireEvent('click', this, e);
74     },
75     
76     getValue : function()
77     {
78         return this.el.dom.innerHTML;
79     },
80     
81     setValue : function(value)
82     {
83         this.el.dom.innerHTML = value;
84     }
85    
86 });
87
88  
89
90