remove debugging code
[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  * @cfg {String} anchor name for the anchor link
18  * @cfg {String} fa - favicon
19
20  * @cfg {Boolean} preventDefault (true | false) default false
21
22  * 
23  * @constructor
24  * Create a new Input
25  * @param {Object} config The config object
26  */
27
28 Roo.bootstrap.Link = function(config){
29     Roo.bootstrap.Link.superclass.constructor.call(this, config);
30     
31     this.addEvents({
32         // img events
33         /**
34          * @event click
35          * The img click event for the img.
36          * @param {Roo.EventObject} e
37          */
38         "click" : true
39     });
40 };
41
42 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component,  {
43     
44     href: false,
45     target: false,
46     preventDefault: false,
47     anchor : false,
48     alt : false,
49     fa: false,
50
51
52     getAutoCreate : function()
53     {
54         var html = this.html || '';
55         
56         if (this.fa !== false) {
57             html = '<i class="fa fa-' + this.fa + '"></i>';
58         }
59         var cfg = {
60             tag: 'a'
61         };
62         // anchor's do not require html/href...
63         if (this.anchor === false) {
64             cfg.html = html;
65             cfg.href = this.href || '#';
66         } else {
67             cfg.name = this.anchor;
68             if (this.html !== false || this.fa !== false) {
69                 cfg.html = html;
70             }
71             if (this.href !== false) {
72                 cfg.href = this.href;
73             }
74         }
75         
76         if(this.alt !== false){
77             cfg.alt = this.alt;
78         }
79         
80         
81         if(this.target !== false) {
82             cfg.target = this.target;
83         }
84         
85         return cfg;
86     },
87     
88     initEvents: function() {
89         
90         if(!this.href || this.preventDefault){
91             this.el.on('click', this.onClick, this);
92         }
93     },
94     
95     onClick : function(e)
96     {
97         if(this.preventDefault){
98             e.preventDefault();
99         }
100         //Roo.log('img onclick');
101         this.fireEvent('click', this, e);
102     }
103    
104 });
105
106