From 1016d7d5e1428817482299b73d08b8ea8065869a Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 20 Jul 2021 11:40:05 +0800 Subject: [PATCH] sync --- Roo/bootstrap/Img.js | 16 ++++++++++++++-- roojs-bootstrap-debug.js | 16 ++++++++++++++-- roojs-bootstrap.js | 7 ++++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/Roo/bootstrap/Img.js b/Roo/bootstrap/Img.js index 9e32c01bef..0226544263 100644 --- a/Roo/bootstrap/Img.js +++ b/Roo/bootstrap/Img.js @@ -36,7 +36,13 @@ Roo.bootstrap.Img = function(config){ * The img click event for the img. * @param {Roo.EventObject} e */ - "click" : true + "click" : true, + /** + * @event load + * The when any image loads + * @param {Roo.EventObject} e + */ + "load" : true }); }; @@ -161,7 +167,7 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { if(!this.href){ this.el.on('click', this.onClick, this); } - + this.el.select('img', true).on('load', this.onImageLoad, this); }, onClick : function(e) @@ -169,6 +175,12 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { Roo.log('img onclick'); this.fireEvent('click', this, e); }, + onImageLoad: function(e) + { + Roo.log('img load'); + this.fireEvent('load', this, e); + }, + /** * Sets the url of the image - used to update it * @param {String} url the url of the image diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 26788cc96c..6c59b8e231 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -3059,7 +3059,13 @@ Roo.bootstrap.Img = function(config){ * The img click event for the img. * @param {Roo.EventObject} e */ - "click" : true + "click" : true, + /** + * @event load + * The when any image loads + * @param {Roo.EventObject} e + */ + "load" : true }); }; @@ -3184,7 +3190,7 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { if(!this.href){ this.el.on('click', this.onClick, this); } - + this.el.select('img', true).on('load', this.onImageLoad, this); }, onClick : function(e) @@ -3192,6 +3198,12 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { Roo.log('img onclick'); this.fireEvent('click', this, e); }, + onImageLoad: function(e) + { + Roo.log('img load'); + this.fireEvent('load', this, e); + }, + /** * Sets the url of the image - used to update it * @param {String} url the url of the image diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index cb3881c90c..eae769cc87 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -128,12 +128,13 @@ this.selectorEl=this.el.select('.roo-card-upload-selector',true).first();this.se if(typeof(this.selectorEl.dom.files)=='undefined'||!this.selectorEl.dom.files.length){return;}var A=Array.prototype.slice.call(this.selectorEl.dom.files);this.selectorEl.dom.value='';this.fireEvent('uploaded',this,A);},reset:function(){this.selectorEl}}); // Roo/bootstrap/Img.js -Roo.bootstrap.Img=function(A){Roo.bootstrap.Img.superclass.constructor.call(this,A);this.addEvents({"click":true});};Roo.extend(Roo.bootstrap.Img,Roo.bootstrap.Component,{imgResponsive:true,border:'',src:'about:blank',href:false,target:false,xsUrl:'',smUrl:'',mdUrl:'',lgUrl:'',getAutoCreate:function(){if(this.src||(!this.xsUrl&&!this.smUrl&&!this.mdUrl&&!this.lgUrl)){return this.createSingleImg(); +Roo.bootstrap.Img=function(A){Roo.bootstrap.Img.superclass.constructor.call(this,A);this.addEvents({"click":true,"load":true});};Roo.extend(Roo.bootstrap.Img,Roo.bootstrap.Component,{imgResponsive:true,border:'',src:'about:blank',href:false,target:false,xsUrl:'',smUrl:'',mdUrl:'',lgUrl:'',getAutoCreate:function(){if(this.src||(!this.xsUrl&&!this.smUrl&&!this.mdUrl&&!this.lgUrl)){return this.createSingleImg(); }var A={tag:'div',cls:'roo-image-responsive-group',cn:[]};var B=this;Roo.each(['xs','sm','md','lg'],function(C){if(!B[C+'Url']){return;}var D={tag:'img',cls:(B.imgResponsive)?'img-responsive':'',html:B.html||A.html,src:B[C+'Url']};D.cls+=' roo-image-responsive-'+C; var s=['xs','sm','md','lg'];s.splice(s.indexOf(C),1);Roo.each(s,function(ss){D.cls+=' hidden-'+ss;});if(['rounded','circle','thumbnail'].indexOf(B.border)>-1){A.cls+=' img-'+B.border;}if(B.alt){A.alt=B.alt;}if(B.href){var a={tag:'a',href:B.href,cn:[D]};if(this.target){a.target=B.target; }}A.cn.push((B.href)?a:D);});return A;},createSingleImg:function(){var A={tag:'img',cls:(this.imgResponsive)?'img-responsive':'',html:null,src:'about:blank'};A.html=this.html||A.html;A.src=this.src||A.src;if(['rounded','circle','thumbnail'].indexOf(this.border)>-1){A.cls+=' img-'+this.border; -}if(this.alt){A.alt=this.alt;}if(this.href){var a={tag:'a',href:this.href,cn:[A]};if(this.target){a.target=this.target;}}return (this.href)?a:A;},initEvents:function(){if(!this.href){this.el.on('click',this.onClick,this);}},onClick:function(e){Roo.log('img onclick'); -this.fireEvent('click',this,e);},setSrc:function(A){this.src=A;if(this.src||(!this.xsUrl&&!this.smUrl&&!this.mdUrl&&!this.lgUrl)){this.el.dom.src=A;return;}this.el.select('img',true).first().dom.src=A;}}); +}if(this.alt){A.alt=this.alt;}if(this.href){var a={tag:'a',href:this.href,cn:[A]};if(this.target){a.target=this.target;}}return (this.href)?a:A;},initEvents:function(){if(!this.href){this.el.on('click',this.onClick,this);}this.el.select('img',true).on('load',this.onImageLoad,this); +},onClick:function(e){Roo.log('img onclick');this.fireEvent('click',this,e);},onImageLoad:function(e){Roo.log('img load');this.fireEvent('load',this,e);},setSrc:function(A){this.src=A;if(this.src||(!this.xsUrl&&!this.smUrl&&!this.mdUrl&&!this.lgUrl)){this.el.dom.src=A; +return;}this.el.select('img',true).first().dom.src=A;}}); // Roo/bootstrap/Link.js Roo.bootstrap.Link=function(A){Roo.bootstrap.Link.superclass.constructor.call(this,A);this.addEvents({"click":true});};Roo.extend(Roo.bootstrap.Link,Roo.bootstrap.Component,{href:false,target:false,preventDefault:false,anchor:false,alt:false,fa:false,getAutoCreate:function(){var A=this.html||''; if(this.fa!==false){A='';}var B={tag:'a'};if(this.anchor===false){B.html=A;B.href=this.href||'#';}else{B.name=this.anchor;if(this.html!==false||this.fa!==false){B.html=A;}if(this.href!==false){B.href=this.href;}}if(this.alt!==false){B.alt=this.alt; -- 2.39.2