roojs-core.js
[roojs1] / roojs-ui-debug.js
index f0e808f..923703b 100644 (file)
@@ -35922,7 +35922,6 @@ Roo.LayoutStateManager.prototype = {
  */
 Roo.ContentPanel = function(el, config, content){
     
-    console.log("ContentPanel Constructor");
     /*
     if(el.autoCreate || el.xtype){ // xtype is available if this is called from factory
         config = el;
@@ -36308,11 +36307,9 @@ layout.addxtype({
     addxtype : function(cfg) {
         if(cfg.xtype.match(/^UploadCropbox$/)) {
 
-            cfg.el = this.el.appendChild(document.createElement("div"));
-
             this.cropbox = new Roo.factory(cfg);
 
-            this.cropbox.render();
+            this.cropbox.render(this.el);
 
             return this.cropbox;
         }
@@ -43596,7 +43593,6 @@ Roo.XTemplate.from = function(el){
  */
 
  Roo.dialog.UploadCropbox = function(config){
-    console.log("Dialog UploadCropbox Constructor");
     Roo.dialog.UploadCropbox.superclass.constructor.call(this, config);
     
     this.addEvents({
@@ -43692,7 +43688,14 @@ Roo.XTemplate.from = function(el){
          * @param {Roo.dialog.UploadCropbox} this
          * @param {Object} formData
          */
-        "arrange" : true
+        "arrange" : true,
+        /**
+         * @event loadcanvas
+         * Fire after load the canvas
+         * @param {Roo.dialog.UploadCropbox}
+         * @param {Object} imgEl
+         */
+        "loadcanvas" : true
     });
     
     this.buttons = this.buttons || Roo.dialog.UploadCropbox.footer.STANDARD;
@@ -43779,8 +43782,33 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     onRender : function(ct, position)
     {
-        console.log("On Render");
         Roo.dialog.UploadCropbox.superclass.onRender.call(this, ct, position);
+
+        if(this.el){
+            if (this.el.attr('xtype')) {
+                this.el.attr('xtypex', this.el.attr('xtype'));
+                this.el.dom.removeAttribute('xtype');
+                
+                this.initEvents();
+            }
+        }
+        else {
+            var cfg = Roo.apply({},  this.getAutoCreate());
+        
+            cfg.id = this.id || Roo.id();
+            
+            if (this.cls) {
+                cfg.cls = (typeof(cfg.cls) == 'undefined' ? this.cls : cfg.cls) + ' ' + this.cls;
+            }
+            
+            if (this.style) { // fixme needs to support more complex style data.
+                cfg.style = (typeof(cfg.style) == 'undefined' ? this.style : cfg.style) + '; ' + this.style;
+            }
+            
+            this.el = ct.createChild(cfg, position);
+            
+            this.initEvents();
+        }
         
         if (this.buttons.length) {
             
@@ -43875,7 +43903,7 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
         this.cropData = false;
         this.notifyEl.dom.innerHTML = this.emptyText;
         
-        this.selectorEl.dom.value = '';
+        // this.selectorEl.dom.value = '';
         
     },
     
@@ -43926,6 +43954,7 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     onFileSelected : function(e)
     {
+        console.log("ON FILE SELECTED");
         e.preventDefault();
         
         if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
@@ -43952,6 +43981,8 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     loadCanvas : function(src)
     {   
+        console.log("LOAD CANVAS");
+        console.log(src);
         if(this.fireEvent('beforeloadcanvas', this, src) != false){
             
             this.reset();
@@ -43968,31 +43999,36 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     onLoadCanvas : function()
     {   
+        console.log("ON LOAD CANVAS");
         this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
         this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
+
+        if(this.fireEvent('loadcanvas', this, this.imageEl) != false){
         
-        this.bodyEl.un('click', this.beforeSelectFile, this);
-        
-        this.notifyEl.hide();
-        this.thumbEl.show();
-        this.footerEl.show();
-        
-        this.baseRotateLevel();
+            this.bodyEl.un('click', this.beforeSelectFile, this);
+            
+            this.notifyEl.hide();
+            this.thumbEl.show();
+            this.footerEl.show();
+            
+            this.baseRotateLevel();
+            
+            if(this.isDocument){
+                this.setThumbBoxSize();
+            }
+            
+            this.setThumbBoxPosition();
+            
+            this.baseScaleLevel();
+            
+            this.draw();
+            
+            this.resize();
+            
+            this.canvasLoaded = true;
         
-        if(this.isDocument){
-            this.setThumbBoxSize();
         }
         
-        this.setThumbBoxPosition();
-        
-        this.baseScaleLevel();
-        
-        this.draw();
-        
-        this.resize();
-        
-        this.canvasLoaded = true;
-        
         if(this.loadMask){
             this.maskEl.unmask();
         }
@@ -44079,9 +44115,7 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
         e.stopEvent();
         
         this.startScale = this.scale;
-        
         this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
-        
         if(!this.zoomable()){
             this.scale = this.startScale;
             return;
@@ -44102,6 +44136,9 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
         
         var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
         var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
+
+        var maxWidth = this.imageEl.OriginWidth;
+        var maxHeight = this.imageEl.OriginHeight;
         
         if(
                 this.isDocument &&
@@ -44131,10 +44168,10 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
                 !this.isDocument &&
                 (this.rotate == 0 || this.rotate == 180) && 
                 (
-                    width < this.minWidth || 
-                    width > this.imageEl.OriginWidth || 
-                    height < this.minHeight || 
-                    height > this.imageEl.OriginHeight
+                    width < this.minWidth ||
+                    height < this.minHeight ||
+                    width > maxWidth ||
+                    height > maxHeight
                 )
         ){
             return false;
@@ -44275,28 +44312,29 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     draw : function()
     {
+        console.log("DRAW");
         this.previewEl.dom.innerHTML = '';
         
-        var canvasEl = document.createElement("canvas");
+        // var canvasEl = document.createElement("canvas");
         
-        var contextEl = canvasEl.getContext("2d");
+        // var contextEl = canvasEl.getContext("2d");
         
-        canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
-        canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
-        var center = this.imageEl.OriginWidth / 2;
+        // canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
+        // canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
+        // var center = this.imageEl.OriginWidth / 2;
         
-        if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
-            canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
-            canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
-            center = this.imageEl.OriginHeight / 2;
-        }
+        // if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
+        //     canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
+        //     canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
+        //     center = this.imageEl.OriginHeight / 2;
+        // }
         
-        contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
+        // contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
         
-        contextEl.translate(center, center);
-        contextEl.rotate(this.rotate * Math.PI / 180);
+        // contextEl.translate(center, center);
+        // contextEl.rotate(this.rotate * Math.PI / 180);
 
-        contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
+        // contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
         
         this.canvasEl = document.createElement("canvas");
         
@@ -44605,6 +44643,7 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     setThumbBoxPosition : function()
     {
+        console.log("SET THUMBBOX POSITION");
         var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
         var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
         
@@ -44615,6 +44654,7 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     baseRotateLevel : function()
     {
+        console.log("BASE ROTATE LEVEL");
         this.baseRotate = 1;
         
         if(
@@ -44631,6 +44671,7 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     baseScaleLevel : function()
     {
+        console.log("BASE SCALE LEVEL");
         var width, height;
         
         if(this.isDocument){
@@ -44707,7 +44748,7 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     getScaleLevel : function()
     {
-        return this.baseScale * Math.pow(1.1, this.scale);
+        return this.baseScale * Math.pow(1.02, this.scale);
     },
     
     onTouchStart : function(e)
@@ -44898,6 +44939,8 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
     
     prepare : function(file)
     {   
+        console.log("PREPARE");
+        console.log(file);
         if(this.loadMask){
             this.maskEl.mask(this.loadingText);
         }