sync
[web.Reddit] / 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  * @cfg {Boolean} preventDefault (true | false) default false
18
19  * 
20  * @constructor
21  * Create a new Input
22  * @param {Object} config The config object
23  */
24
25 Roo.bootstrap.Link = function(config){
26     Roo.bootstrap.Link.superclass.constructor.call(this, config);
27     
28     this.addEvents({
29         // img events
30         /**
31          * @event click
32          * The img click event for the img.
33          * @param {Roo.EventObject} e
34          */
35         "click" : true
36     });
37 };
38
39 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component,  {
40     
41     href: false,
42     target: false,
43     preventDefault: false,
44
45     getAutoCreate : function(){
46         
47         var cfg = {
48             tag: 'a',
49             html : this.html || 'html-missing'
50         }
51         
52         
53         if(this.alt){
54             cfg.alt = this.alt;
55         }
56         cfg.href = this.href || '#';
57         if(this.target){
58             cfg.target = this.target;
59         }
60         
61         return cfg;
62     },
63     
64     initEvents: function() {
65         
66         if(!this.href){
67             this.el.on('click', this.onClick, this);
68         }
69     },
70     
71     onClick : function(e)
72     {
73         if(this.preventDefault){
74             e.preventDefault();
75         }
76         //Roo.log('img onclick');
77         this.fireEvent('click', this, e);
78     }
79    
80 });
81
82