major doc changes
[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  * @children Roo.bootstrap.Component
12  * Bootstrap Element class (basically a DIV used to make random stuff )
13  * 
14  * @cfg {String} html contents of the element
15  * @cfg {String} tag tag of the element
16  * @cfg {String} cls class of the element
17  * @cfg {Boolean} preventDefault (true|false) default false
18  * @cfg {Boolean} clickable (true|false) default false
19  * @cfg {String} role default blank - set to button to force cursor pointer
20  
21  * 
22  * @constructor
23  * Create a new Element
24  * @param {Object} config The config object
25  */
26
27 Roo.bootstrap.Element = function(config){
28     Roo.bootstrap.Element.superclass.constructor.call(this, config);
29     
30     this.addEvents({
31         // raw events
32         /**
33          * @event click
34          * When a element is chick
35          * @param {Roo.bootstrap.Element} this
36          * @param {Roo.EventObject} e
37          */
38         "click" : true 
39         
40       
41     });
42 };
43
44 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component,  {
45     
46     tag: 'div',
47     cls: '',
48     html: '',
49     preventDefault: false, 
50     clickable: false,
51     tapedTwice : false,
52     role : false,
53     
54     getAutoCreate : function(){
55         
56         var cfg = {
57             tag: this.tag,
58             // cls: this.cls, double assign in parent class Component.js :: onRender
59             html: this.html
60         };
61         if (this.role !== false) {
62             cfg.role = this.role;
63         }
64         
65         return cfg;
66     },
67     
68     initEvents: function() 
69     {
70         Roo.bootstrap.Element.superclass.initEvents.call(this);
71         
72         if(this.clickable){
73             this.el.on('click', this.onClick, this);
74         }
75         
76         
77     },
78     
79     onClick : function(e)
80     {
81         if(this.preventDefault){
82             e.preventDefault();
83         }
84         
85         this.fireEvent('click', this, e); // why was this double click before?
86     },
87     
88     
89     
90
91     
92     
93     getValue : function()
94     {
95         return this.el.dom.innerHTML;
96     },
97     
98     setValue : function(value)
99     {
100         this.el.dom.innerHTML = value;
101     }
102    
103 });
104
105  
106
107