Roo/bootstrap/Link.js
[roojs1] / Roo / bootstrap / Link.js
1 /*
2  * - LGPL
3  *
4  * image
5  * 
6  */
7
8
9 /**
10  * @class Roo.bootstrap.Link
11  * @extends Roo.bootstrap.Component
12  * Bootstrap Link Class
13  * @cfg {String} alt image alternative text
14  * @cfg {String} href a tag href
15  * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
16  * @cfg {String} html the content of the link.
17
18  * 
19  * @constructor
20  * Create a new Input
21  * @param {Object} config The config object
22  */
23
24 Roo.bootstrap.Link = function(config){
25     Roo.bootstrap.Link.superclass.constructor.call(this, config);
26     
27     this.addEvents({
28         // img events
29         /**
30          * @event click
31          * The img click event for the img.
32          * @param {Roo.EventObject} e
33          */
34         "click" : true
35     });
36 };
37
38 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component,  {
39     
40     href: false,
41     target: false,
42
43     getAutoCreate : function(){
44         
45         var cfg = {
46             tag: 'a',
47             html : this.html || 'html-missing'
48         }
49         
50         
51         if(this.alt){
52             cfg.alt = this.alt;
53         }
54         cfg.href = this.href || '#';
55         if(this.target){
56             cfg.target = this.target;
57         }
58         
59         return cfg;
60     },
61     
62     initEvents: function() {
63         
64         if(!this.href){
65             this.el.on('click', this.onClick, this);
66         }
67     },
68     
69     onClick : function(e)
70     {
71         Roo.log('img onclick');
72         this.fireEvent('click', this, e);
73     }
74    
75 });
76
77