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