docs/default.css
[roojs1] / roojs-bootstrap-debug.js
index 86d7e41..40493b7 100644 (file)
@@ -24037,6 +24037,8 @@ Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component,  {
  * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
  * @cfg {Boolean} isDocument (true|false) default false
  * @cfg {String} url action url
+ * @cfg {String} paramName default 'imageUpload'
+ * @cfg {String} method default POST
  * 
  * @constructor
  * Create a new UploadCropbox
@@ -24167,6 +24169,8 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component,  {
     buttons : false,
     canvasLoaded : false,
     isDocument : false,
+    method : 'POST',
+    paramName : 'imageUpload',
     
     getAutoCreate : function()
     {
@@ -24174,16 +24178,16 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component,  {
             tag : 'div',
             cls : 'roo-upload-cropbox',
             cn : [
+                {
+                    tag : 'input',
+                    cls : 'roo-upload-cropbox-selector',
+                    type : 'file'
+                },
                 {
                     tag : 'div',
                     cls : 'roo-upload-cropbox-body',
                     style : 'cursor:pointer',
                     cn : [
-                        {
-                            tag : 'input',
-                            cls : 'roo-upload-cropbox-selector',
-                            type : 'file'
-                        },
                         {
                             tag : 'div',
                             cls : 'roo-upload-cropbox-preview'
@@ -24313,6 +24317,8 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component,  {
         this.cropData = false;
         this.notifyEl.dom.innerHTML = this.emptyText;
         
+        this.selectorEl.dom.value = '';
+        
     },
     
     resize : function()
@@ -24374,8 +24380,6 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component,  {
             this.prepare(file);
         }
         
-        this.selectorEl.dom.value = '';
-        
     },
     
     trash : function(e)
@@ -24406,15 +24410,15 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component,  {
     
     onLoadCanvas : function()
     {   
+        this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
+        this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
+        
         this.bodyEl.un('click', this.beforeSelectFile, this);
         
         this.notifyEl.hide();
         this.thumbEl.show();
         this.footerEl.show();
         
-        this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
-        this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
-        
         this.baseRotateLevel();
         
         if(this.isDocument){
@@ -24995,7 +24999,9 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component,  {
         
         this.cropData = canvas.toDataURL(this.cropType);
         
-        this.fireEvent('crop', this, this.cropData);
+        if(this.fireEvent('crop', this, this.cropData) !== false){
+            this.process(this.file, this.cropData);
+        }
         
         return;
         
@@ -25232,10 +25238,6 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component,  {
     {
         this.xhr = new XMLHttpRequest();
         
-        if(typeof(this.file.id) != 'undefined' && this.file.id * 1 > 0){
-            return;
-        }
-        
         file.xhr = this.xhr;
 
         this.xhr.open(this.method, this.url, true);
@@ -25273,7 +25275,17 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component,  {
             formData.append('crop', crop);
         }
         
-        formData.append(this.paramName, file, file.name);
+        if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
+            formData.append(this.paramName, file, file.name);
+        }
+        
+        if(typeof(file.filename) != 'undefined'){
+            formData.append('filename', file.filename);
+        }
+        
+        if(typeof(file.mimetype) != 'undefined'){
+            formData.append('mimetype', file.mimetype);
+        }
         
         if(this.fireEvent('arrange', this, formData) != false){
             this.xhr.send(formData);
@@ -25310,56 +25322,6 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component,  {
         
     },
     
-    uploadFromSource : function(file, crop)
-    {
-        this.xhr = new XMLHttpRequest();
-        
-        this.xhr.open(this.method, this.url, true);
-        
-        var headers = {
-            "Accept": "application/json",
-            "Cache-Control": "no-cache",
-            "X-Requested-With": "XMLHttpRequest"
-        };
-        
-        for (var headerName in headers) {
-            var headerValue = headers[headerName];
-            if (headerValue) {
-                this.xhr.setRequestHeader(headerName, headerValue);
-            }
-        }
-        
-        var _this = this;
-        
-        this.xhr.onload = function()
-        {
-            _this.xhrOnLoad(_this.xhr);
-        }
-        
-        this.xhr.onerror = function()
-        {
-            _this.xhrOnError(_this.xhr);
-        }
-        
-        var formData = new FormData();
-
-        formData.append('returnHTML', 'NO');
-        
-        formData.append('crop', crop);
-        
-        if(typeof(file.filename) != 'undefined'){
-            formData.append('filename', file.filename);
-        }
-        
-        if(typeof(file.mimetype) != 'undefined'){
-            formData.append('mimetype', file.mimetype);
-        }
-        
-        if(this.fireEvent('arrange', this, formData) != false){
-            this.xhr.send(formData);
-        };
-    },
-    
     prepare : function(file)
     {   
         this.file = false;
@@ -25870,7 +25832,14 @@ Roo.bootstrap.DocumentManager = function(config){
          * Fire before select file
          * @param {Roo.bootstrap.DocumentManager} this
          */
-        "beforeselectfile" : true
+        "beforeselectfile" : true,
+        /**
+         * @event process
+         * Fire before process file
+         * @param {Roo.bootstrap.DocumentManager} this
+         * @param {Object} file
+         */
+        "process" : true
         
     });
 };
@@ -26274,14 +26243,17 @@ Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component,  {
     
     process : function(file)
     {
-        if(this.editable && file.type.indexOf('image') != -1){
-            this.fireEvent('edit', this, file);
+        if(this.fireEvent('process', this, file) !== false){
+            if(this.editable && file.type.indexOf('image') != -1){
+                this.fireEvent('edit', this, file);
+                return;
+            }
+
+            this.uploadStart(file, false);
+
             return;
         }
         
-        this.uploadStart(file, false);
-        
-        return;
     },
     
     uploadStart : function(file, crop)