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