From a348aff8dc58b3e5e2030a6fec73ffdb6f52c0fd Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Fri, 5 Mar 2021 15:01:01 +0800 Subject: [PATCH] roojs-bootstrap.js roojs-bootstrap-debug.js Roo/bootstrap/CardUploader.js --- Roo/bootstrap/CardUploader.js | 1 + roojs-bootstrap-debug.js | 25 +++++++++++++++++++++---- roojs-bootstrap.js | 5 +++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Roo/bootstrap/CardUploader.js b/Roo/bootstrap/CardUploader.js index bd51c50c23..6cc9e2e76b 100644 --- a/Roo/bootstrap/CardUploader.js +++ b/Roo/bootstrap/CardUploader.js @@ -329,6 +329,7 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input, { reader.readAsDataURL(fc[i].src); } + next(); } diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 12493ad454..4183233c1c 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -12528,6 +12528,7 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input, { { tag: 'input', type : 'hidden', + nane : this.name, value : this.value, cls : 'd-none form-control' }, @@ -12778,12 +12779,28 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input, { updateInput : function() { + var i =0; var data = []; - this.fileCollection.each(function(e) { - data.push(e.data); - }); + var dom = this.inputEl().dom; + var fc = this.fileCollection; + var next = function() { + if (i >= fc.length) { + dom.value = JSON.stringify(data); + return; + } + var reader = new FileReader(); + reader.onloadend = function(evt) { + // file is loaded + var ee = Roo.apply({}, fc[i]); + ee.src = evt.target.result; + data.push(ee); + + }; + reader.readAsDataURL(fc[i].src); + + } + - this.inputEl().dom.value = JSON.stringify(data); } diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 06c388d2f8..2efdd7117a 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -520,7 +520,7 @@ this.fireEvent("afterremove",this)}},createList:function(){this.list=Roo.get(doc }},onHide:function(){var ae=this.getActionEl();ae.dom.style.display='none';},onTriggerClick:Roo.emptyFn}); // Roo/bootstrap/CardUploader.js Roo.bootstrap.CardUploader=function(A){Roo.bootstrap.CardUploader.superclass.constructor.call(this,A);this.fileCollection=new Roo.util.MixedCollection(false,function(r){return r.data.id});};Roo.extend(Roo.bootstrap.CardUploader,Roo.bootstrap.Input,{errorTimeout:3000,images:false,fileCollection:false,allowBlank:true,getAutoCreate:function(){var A={cls:'form-group',cn:[{tag:'label',html:this.fieldLabel} -,{tag:'input',type:'hidden',value:this.value,cls:'d-none form-control'},{tag:'input',multiple:'multiple',type:'file',cls:'d-none roo-card-upload-selector'},{cls:'roo-card-uploader-button-container w-100 mb-2'},{cls:'card-columns roo-card-uploader-container'} +,{tag:'input',type:'hidden',nane:this.name,value:this.value,cls:'d-none form-control'},{tag:'input',multiple:'multiple',type:'file',cls:'d-none roo-card-upload-selector'},{cls:'roo-card-uploader-button-container w-100 mb-2'},{cls:'card-columns roo-card-uploader-container'} ]};return A;},getChildContainer:function(){return this.containerEl;},getButtonContainer:function(){return this.el.select(".roo-card-uploader-button-container").first();},initEvents:function(){Roo.bootstrap.Input.prototype.initEvents.call(this);var t=this; this.addxtype({xns:Roo.bootstrap,xtype:'Button',container_method:'getButtonContainer',html:this.html,cls:'w-100 ',listeners:{'click':function(A,e){t.onClick(e);}}});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);if(this.images){var t=this;this.images.forEach(function(A){t.addCard(A)});this.images=false;}this.containerEl=this.el.select('.roo-card-uploader-container',true).first(); @@ -530,7 +530,8 @@ this.selectorEl=this.el.select('.roo-card-upload-selector',true).first();this.se }},{xns:Roo.bootstrap,xtype:'Button',size:'sm',weight:'danger',cls:'col-1',fa:'times',listeners:{click:function(){t.removeCard(A.id)}}}]}]}];var cn=this.addxtype({xns:Roo.bootstrap,xtype:'Card',closeable:true,header:!A.mimetype.match(/image/)&&!A.preview?"Document":false,header_image:A.mimetype.match(/image/)?A.src:A.preview,header_image_fit_square:true,data:A,html:false,items:B,initEvents:function(){Roo.bootstrap.Card.prototype.initEvents.call(this); this.imgEl=this.el.select('.card-img-top').first();if(this.imgEl){this.imgEl.on('click',function(){t.previewCard(A.id);},this);this.imgEl.set({'pointer':'cursor'});}}});this.fileCollection.add(cn);this.updateInput();},removeCard:function(id){var A=this.fileCollection.get(id); A.data.is_deleted=1;A.data.src='';this.fileCollection.remove(A);A.el.dom.parentNode.removeChild(A.el.dom);},reset:function(){this.fileCollection.each(function(A){A.el.dom.parentNode.removeChild(A.el.dom);});this.fileCollection.clear();this.updateInput();} -,updateInput:function(){var A=[];this.fileCollection.each(function(e){A.push(e.data);});this.inputEl().dom.value=JSON.stringify(A);}});Roo.bootstrap.CardUploader.ID=-1; +,updateInput:function(){var i=0;var A=[];var B=this.inputEl().dom;var fc=this.fileCollection;var C=function(){if(i>=fc.length){B.value=JSON.stringify(A);return;}var D=new FileReader();D.onloadend=function(E){var ee=Roo.apply({},fc[i]);ee.src=E.target.result; +A.push(ee);};D.readAsDataURL(fc[i].src);}}});Roo.bootstrap.CardUploader.ID=-1; // Roo/data/SortTypes.js Roo.data.SortTypes={none:function(s){return s;},stripTagsRE:/<\/?[^>]+>/gi,asText:function(s){return String(s).replace(this.stripTagsRE,"");},asUCText:function(s){return String(s).toUpperCase().replace(this.stripTagsRE,"");},asUCString:function(s){return String(s).toUpperCase(); },asDate:function(s){if(!s){return 0;}if(s instanceof Date){return s.getTime();}return Date.parse(String(s));},asFloat:function(s){var A=parseFloat(String(s).replace(/,/g,""));if(isNaN(A)){A=0;}return A;},asInt:function(s){var A=parseInt(String(s).replace(/,/g,"")); -- 2.39.2