From c8b42ce27a822df6e6b7eb1fa7ec49c2d459518a Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 20 Jul 2021 12:25:51 +0800 Subject: [PATCH] sync --- docs/json/roodata.json | 6 ++++++ docs/src/Roo_bootstrap_Img.js.html | 22 +++++++++++++++++++--- docs/symbols/Roo.bootstrap.Img.json | 7 +++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/docs/json/roodata.json b/docs/json/roodata.json index 8d553cfb66..0ddc914f77 100644 --- a/docs/json/roodata.json +++ b/docs/json/roodata.json @@ -33269,6 +33269,12 @@ "desc" : "image alternative text", "memberOf" : "" }, + { + "name" : "backgroundContain", + "type" : "Boolean", + "desc" : "(use style background and contain image in content)", + "memberOf" : "" + }, { "name" : "border", "type" : "String", diff --git a/docs/src/Roo_bootstrap_Img.js.html b/docs/src/Roo_bootstrap_Img.js.html index dbe6292a27..c757a8406d 100644 --- a/docs/src/Roo_bootstrap_Img.js.html +++ b/docs/src/Roo_bootstrap_Img.js.html @@ -20,6 +20,7 @@ * @cfg {String} smUrl sm image source * @cfg {String} mdUrl md image source * @cfg {String} lgUrl lg image source + * @cfg {Boolean} backgroundContain (use style background and contain image in content) * * @constructor * Create a new Input @@ -57,6 +58,7 @@ smUrl: '', mdUrl: '', lgUrl: '', + backgroundContain : false, getAutoCreate : function() { @@ -129,12 +131,20 @@ tag: 'img', cls: (this.imgResponsive) ? 'img-responsive' : '', html : null, - src : 'about:blank' // just incase src get's set to undefined?!? + src : Roo.BLANK_IMAGE_URL // just incase src get's set to undefined?!? }; + if (this.backgroundContain) { + cfg.cls += ' background-contain'; + } + cfg.html = this.html || cfg.html; - cfg.src = this.src || cfg.src; + if (this.backgroundContain) { + cfg.style="background-image: url(" + this.src + ')'; + } else { + cfg.src = this.src || cfg.src; + } if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) { cfg.cls += ' img-' + this.border; @@ -167,7 +177,13 @@ if(!this.href){ this.el.on('click', this.onClick, this); } - this.el.select('img', true).on('load', this.onImageLoad, this); + if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){ + this.el.on('load', this.onImageLoad, this); + } else { + // not sure if this works.. not tested + this.el.select('img', true).on('load', this.onImageLoad, this); + } + }, onClick : function(e) diff --git a/docs/symbols/Roo.bootstrap.Img.json b/docs/symbols/Roo.bootstrap.Img.json index d29c7b426e..d69561ea91 100644 --- a/docs/symbols/Roo.bootstrap.Img.json +++ b/docs/symbols/Roo.bootstrap.Img.json @@ -66,6 +66,13 @@ "memberOf" : "Roo.bootstrap.Img", "values" : [] }, + { + "name" : "backgroundContain", + "type" : "Boolean", + "desc" : "(use style background and contain image in content)", + "memberOf" : "Roo.bootstrap.Img", + "values" : [] + }, { "name" : "listeners", "type" : "Object", -- 2.39.2