Roo/bootstrap/DocumentManager.js
[roojs1] / Roo / bootstrap / DocumentManager.js
index e4134ee..2032bd1 100644 (file)
@@ -238,7 +238,7 @@ Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component,  {
         this.progress = new Roo.bootstrap.Progress({
             cls : 'roo-document-manager-progress',
             active : true,
-            striped : true,
+            striped : true
         });
         
         this.progress.render(this.progressDialog.getChildContainer());
@@ -303,7 +303,8 @@ Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component,  {
         Roo.each(this.files, function(file){
             
             if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
-                files.push(file);
+                var f = this.renderPreview(file);
+                files.push(f);
                 return;
             }
             
@@ -432,9 +433,9 @@ Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component,  {
             return;
         }
         
-        var file = this.renderThumbImage(response.data);
+        var file = this.renderPreview(response.data);
         
-        this.files.push(response.data);
+        this.files.push(file);
         
         this.arrange();
         
@@ -543,8 +544,12 @@ Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component,  {
         this.arrange();
     },
     
-    renderThumbImage : function(file)
+    renderPreview : function(file)
     {
+        if(typeof(file.target) != 'undefined' && file.target){
+            return file;
+        }
+        
         var previewEl = this.managerEl.createChild({
             tag : 'div',
             cls : 'roo-document-manager-preview',
@@ -558,7 +563,7 @@ Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component,  {
                 {
                     tag : 'button',
                     cls : 'close',
-                    html : 'x'
+                    html : '<i class="fa fa-times-circle"></i>'
                 }
             ]
         });
@@ -570,10 +575,33 @@ Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component,  {
         file.target = previewEl;
 
         var image = previewEl.select('img', true).first();
-
+        
+        var _this = this;
+        
+        image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
+        
         image.on('click', this.onClick, this, file);
         
         return file;
-    }
+        
+    },
     
+    onPreviewLoad : function(file, image)
+    {
+        if(typeof(file.target) == 'undefined' || !file.target){
+            return;
+        }
+        
+        var width = image.dom.naturalWidth || image.dom.width;
+        var height = image.dom.naturalHeight || image.dom.height;
+        
+        if(width > height){
+            file.target.addClass('wide');
+            return;
+        }
+        
+        file.target.addClass('tall');
+        return;
+        
+    }
 });