10 * @class Roo.bootstrap.Img
11 * @extends Roo.bootstrap.Component
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 * @cfg {String} href a tag href
18 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
19 * @cfg {String} xsUrl xs image source
20 * @cfg {String} smUrl sm image source
21 * @cfg {String} mdUrl md image source
22 * @cfg {String} lgUrl lg image source
26 * @param {Object} config The config object
29 Roo.bootstrap.Img = function(config){
30 Roo.bootstrap.Img.superclass.constructor.call(this, config);
36 * The img click event for the img.
37 * @param {Roo.EventObject} e
43 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
55 getAutoCreate : function()
57 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
58 return this.createSingleImg();
63 cls: 'roo-image-responsive-group',
68 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
70 if(!_this[size + 'Url']){
76 cls: (_this.imgResponsive) ? 'img-responsive' : '',
77 html: _this.html || cfg.html,
78 src: _this[size + 'Url']
81 img.cls += ' roo-image-responsive-' + size;
83 var s = ['xs', 'sm', 'md', 'lg'];
85 s.splice(s.indexOf(size), 1);
87 Roo.each(s, function(ss){
89 img.cls += ' hidden-' + ss;
92 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
93 cfg.cls += ' img-' + _this.border;
110 a.target = _this.target;
114 cfg.cn.push((_this.href) ? a : img);
121 createSingleImg : function()
125 cls: (this.imgResponsive) ? 'img-responsive' : '',
129 cfg.html = this.html || cfg.html;
131 cfg.src = this.src || cfg.src;
133 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
134 cfg.cls += ' img-' + this.border;
151 a.target = this.target;
156 return (this.href) ? a : cfg;
159 initEvents: function()
162 this.el.on('click', this.onClick, this);
167 onClick : function(e)
169 Roo.log('img onclick');
170 this.fireEvent('click', this, e);