sync
[roojs1] / Roo / bootstrap / ButtonUploader.js
index e392eea..7149c64 100644 (file)
@@ -12,7 +12,7 @@
  * @cfg {Number} errorTimeout default 3000
  * @cfg {Array}  images  an array of ?? Img objects ??? when loading existing files..
  * @cfg {Array}  html The button text.
-
+ * @cfg {Boolean}  multiple (default true) Should the upload allow multiple files to be uploaded.
  *
  * @constructor
  * Create a new CardUploader
@@ -38,8 +38,8 @@ Roo.bootstrap.ButtonUploader = function(config){
          /**
          * @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
         
@@ -56,22 +56,25 @@ Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button,  {
     fileCollection : false,
     allowBlank : true,
     
+    multiple : true,
+    
     getAutoCreate : function()
     {
-        
+        var im = {
+            tag: 'input',
+            type : 'file',
+            cls : 'd-none  roo-card-upload-selector' 
+          
+        };
+        if (this.multiple) {
+            im.multiple = 'multiple';
+        }
         
         return  {
             cls :'div' ,
             cn : [
                 Roo.bootstrap.Button.prototype.getAutoCreate.call(this),
-                {
-                    tag: 'input',
-                    multiple : 'multiple',
-                    type : 'file',
-                    cls : 'd-none  roo-card-upload-selector' 
-                  
-                }
-                 
+                im
 
             ]
         };
@@ -124,12 +127,11 @@ Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button,  {
         if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
             return;
         }
+        var files = Array.prototype.slice.call(this.selectorEl.dom.files);
+        this.selectorEl.dom.reset();
+        
+        this.fireEvent('uploaded', this,  files );
         
-        Roo.each(this.selectorEl.dom.files, function(file){
-            var url = this.urlAPI.createObjectURL(file); // not sure...
-            this.fireEvent('uploaded', this, [file, url]);
-        }, this);
-         
     },