fine tune buttonuploader api
authorAlan Knowles <alan@roojs.com>
Wed, 2 Jun 2021 07:40:54 +0000 (15:40 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 2 Jun 2021 07:40:54 +0000 (15:40 +0800)
Roo/bootstrap/ButtonUploader.js
roojs-bootstrap-debug.js
roojs-bootstrap.js

index e392eea..a76c31b 100644 (file)
@@ -38,8 +38,8 @@ Roo.bootstrap.ButtonUploader = function(config){
          /**
          * @event fired when files have been selected, 
          * When a the download link is clicked
          /**
          * @event fired when files have been selected, 
          * When a the download link is clicked
-         * @param {Roo.bootstrap.Card} this
-         * @param {Object} The image information data  contains 
+         * @param {Roo.bootstrap.UploaderButton} this
+         * @param {Array} Array of files that have been uploaded
          */
         'uploaded' : true
         
          */
         'uploaded' : true
         
@@ -124,12 +124,8 @@ Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button,  {
         if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
             return;
         }
         if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
             return;
         }
+        this.fireEvent('uploaded', this,  this.selectorEl.dom.files );
         
         
-        Roo.each(this.selectorEl.dom.files, function(file){
-            var url = this.urlAPI.createObjectURL(file); // not sure...
-            this.fireEvent('uploaded', this, [file, url]);
-        }, this);
-         
     },
     
        
     },
     
        
index 86cf32b..8880d70 100644 (file)
@@ -2888,8 +2888,8 @@ Roo.bootstrap.ButtonUploader = function(config){
          /**
          * @event fired when files have been selected, 
          * When a the download link is clicked
          /**
          * @event fired when files have been selected, 
          * When a the download link is clicked
-         * @param {Roo.bootstrap.Card} this
-         * @param {Object} The image information data  contains 
+         * @param {Roo.bootstrap.UploaderButton} this
+         * @param {Array} Array of files that have been uploaded
          */
         'uploaded' : true
         
          */
         'uploaded' : true
         
@@ -2974,12 +2974,8 @@ Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button,  {
         if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
             return;
         }
         if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
             return;
         }
+        this.fireEvent('uploaded', this,  this.selectorEl.dom.files );
         
         
-        Roo.each(this.selectorEl.dom.files, function(file){
-            var url = this.urlAPI.createObjectURL(file); // not sure...
-            this.fireEvent('uploaded', this, [file, url]);
-        }, this);
-         
     },
     
        
     },
     
        
index 0e3ecf0..d94ea30 100644 (file)
@@ -124,7 +124,7 @@ Roo.bootstrap.CardImageTop=function(A){Roo.bootstrap.CardImageTop.superclass.con
 Roo.bootstrap.ButtonUploader=function(A){Roo.bootstrap.ButtonUploader.superclass.constructor.call(this,A);this.addEvents({'beforeselect':true,'uploaded':true});};Roo.extend(Roo.bootstrap.ButtonUploader,Roo.bootstrap.Button,{errorTimeout:3000,images:false,fileCollection:false,allowBlank:true,getAutoCreate:function(){return {cls:'div',cn:[Roo.bootstrap.Button.prototype.getAutoCreate.call(this),{tag:'input',multiple:'multiple',type:'file',cls:'d-none  roo-card-upload-selector'}
 ]};},initEvents:function(){Roo.bootstrap.Button.prototype.initEvents.call(this);this.urlAPI=(window.createObjectURL&&window)||(window.URL&&URL.revokeObjectURL&&URL)||(window.webkitURL&&webkitURL);this.selectorEl=this.el.select('.roo-card-upload-selector',true).first();
 this.selectorEl.on('change',this.onFileSelected,this);},onClick:function(e){e.preventDefault();if(this.fireEvent('beforeselect',this)===false){return;}this.selectorEl.dom.click();},onFileSelected:function(e){e.preventDefault();if(typeof(this.selectorEl.dom.files)=='undefined'||!this.selectorEl.dom.files.length){return;
 Roo.bootstrap.ButtonUploader=function(A){Roo.bootstrap.ButtonUploader.superclass.constructor.call(this,A);this.addEvents({'beforeselect':true,'uploaded':true});};Roo.extend(Roo.bootstrap.ButtonUploader,Roo.bootstrap.Button,{errorTimeout:3000,images:false,fileCollection:false,allowBlank:true,getAutoCreate:function(){return {cls:'div',cn:[Roo.bootstrap.Button.prototype.getAutoCreate.call(this),{tag:'input',multiple:'multiple',type:'file',cls:'d-none  roo-card-upload-selector'}
 ]};},initEvents:function(){Roo.bootstrap.Button.prototype.initEvents.call(this);this.urlAPI=(window.createObjectURL&&window)||(window.URL&&URL.revokeObjectURL&&URL)||(window.webkitURL&&webkitURL);this.selectorEl=this.el.select('.roo-card-upload-selector',true).first();
 this.selectorEl.on('change',this.onFileSelected,this);},onClick:function(e){e.preventDefault();if(this.fireEvent('beforeselect',this)===false){return;}this.selectorEl.dom.click();},onFileSelected:function(e){e.preventDefault();if(typeof(this.selectorEl.dom.files)=='undefined'||!this.selectorEl.dom.files.length){return;
-}Roo.each(this.selectorEl.dom.files,function(A){var B=this.urlAPI.createObjectURL(A);this.fireEvent('uploaded',this,[A,B]);},this);},reset:function(){this.selectorEl}});
+}this.fireEvent('uploaded',this,this.selectorEl.dom.files);},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();
 }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;
 // 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();
 }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;