Roo/dialog/UploadCropbox.js
[roojs1] / Roo / dialog / UploadCropbox.js
index 6181b88..8279efb 100644 (file)
          * @param {Object} file
          */
         "inspect" : true,
-        /**
-         * @event beforeupload
-         * Fire before xhr upload the file
-         * @param {Roo.dialog.UploadCropbox} this
-         * @param {Object} data
-         */
-         "beforeupload" : true,
         /**
          * @event upload
          * Fire when xhr upload the file
@@ -565,8 +558,11 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
         e.stopEvent();
         
         this.startScale = this.scale;
-        this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
+        this.scale = (e.getWheelDelta() > 0) ? (this.scale + 1) : (this.scale - 1);
         
+        console.log('startScale: ' + this.startScale);
+        console.log('scale: ' + this.scale);
+        console.log('getWheelDelta: ' + e.getWheelDelta());
         if(!this.zoomable()){
             this.scale = this.startScale;
             return;
@@ -1060,11 +1056,11 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
             }
         }
         
-        height = 300;
+        height = 500;
         width = Math.ceil(this.minWidth * height / this.minHeight);
         
         if(this.minWidth > this.minHeight){
-            width = 300;
+            width = 500;
             height = Math.ceil(this.minHeight * width / this.minWidth);
         }
         
@@ -1313,11 +1309,8 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
         
         var formData = new FormData();
 
-        formData.append("onid", "43024");
-        formData.append("ontable", "pressrelease_boilerplate");
-
         formData.append('returnHTML', 'NO');
-        
+
         if(crop){
             formData.append('crop', crop);
             var blobBin = atob(crop.split(',')[1]);
@@ -1325,7 +1318,7 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
             for(var i = 0; i < blobBin.length; i++) {
                 array.push(blobBin.charCodeAt(i));
             }
-            var croppedFile =new Blob([new Uint8Array(array)], {type: 'image/png'});
+            var croppedFile =new Blob([new Uint8Array(array)], {type: this.cropType});
             formData.append(this.paramName, croppedFile, file.name);
         }
         
@@ -1399,7 +1392,9 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
         }
         
         this.file = file;
-        this.cropType = file.type;
+        if(typeof(file.type) != 'undefined' && file.type.length != 0) {
+            this.cropType = file.type;
+        }
         
         var _this = this;