Roo/bootstrap/Element.js
[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  * 
17  * @constructor
18  * Create a new Element
19  * @param {Object} config The config object
20  */
21
22 Roo.bootstrap.Element = function(config){
23     Roo.bootstrap.Element.superclass.constructor.call(this, config);
24     
25     this.addEvents({
26         // raw events
27         /**
28          * @event click
29          * When a element is chick
30          * @param {Roo.bootstrap.Element} this
31          * @param {Roo.EventObject} e
32          */
33         "click" : true
34     });
35 };
36
37 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component,  {
38     
39     tag: 'div',
40     cls: '',
41     html: '',
42     preventDefault: false, 
43     
44     getAutoCreate : function(){
45         
46         var cfg = {
47             tag: this.tag,
48             cls: this.cls,
49             html: this.html
50         }
51         
52         return cfg;
53     },
54     
55     initEvents: function() 
56     {
57         Roo.bootstrap.Element.superclass.initEvents.call(this);
58         
59         this.el.on('click', this.onClick, this);
60         
61     },
62     
63     onClick : function(e)
64     {
65         if(this.preventDefault){
66             e.preventDefault();
67         }
68         
69         this.fireEvent('click', this, e);
70     },
71     
72     getValue : function()
73     {
74         return this.el.dom.innerHTML;
75     },
76     
77     setValue : function(value)
78     {
79         this.el.dom.innerHTML = value;
80     }
81    
82 });
83
84  
85
86