Roo/bootstrap/CardUploader.js
[roojs1] / Roo / bootstrap / CardUploader.js
index f55b5d8..f1d275a 100644 (file)
@@ -23,7 +23,7 @@ Roo.bootstrap.CardUploader = function(config){
     Roo.bootstrap.CardUploader.superclass.constructor.call(this, config);
     
     
-    this.imageCollection  = new Roo.util.MixedCollection(function(r) { return r.id });
+    this.imageCollection  = new Roo.util.MixedCollection(function(r) { return r.data.id });
     
     
 };
@@ -145,7 +145,8 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Button,  {
             is_uploaded : false,
             src : url,
             title : file.name,
-            mimetype : file.mimetype,
+            mimetype : file.type,
+            preview : false,
         })
         
     },
@@ -155,7 +156,7 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Button,  {
         // hidden input element?
         // if the file is not an image...
         //then we need to use something other that and header_image
-        
+        var t = this;
         //   remove.....
         var footer = [
             {
@@ -178,7 +179,7 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Button,  {
                                 fa : 'download',
                                 listeners : {
                                     click : function() {
-                                        // download
+                                        this.downloadCard(data.id)
                                     }
                                 }
                             },
@@ -190,7 +191,12 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Button,  {
                                 size : 'sm',
                                 weight: 'danger',
                                 cls : 'col-1',
-                                fa : 'times'
+                                fa : 'times',
+                                listeners : {
+                                    click : function() {
+                                        this.removeCard(data.id)
+                                    }
+                                }
                             }
                         ]
                     }
@@ -206,8 +212,8 @@ Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Button,  {
                 xns : Roo.bootstrap,
                 xtype : 'Card',
                 closeable : true,
-                header : !data.mimetype.match('/image/') ? "Document": false,
-                header_image : data.mimetype.match('/image/') ? data.src  : false,
+                header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
+                header_image : data.mimetype.match(/image/) ? data.src  : data.preview,
                 data : data,
                 html : false,
                 listeners : {