X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..10a866c12701c0a0afd0ac85dcdcf32a421514ac:/pkgs/resizable.js?ds=sidebyside diff --git a/pkgs/resizable.js b/pkgs/resizable.js index 3404dacf..a25db4a7 100644 --- a/pkgs/resizable.js +++ b/pkgs/resizable.js @@ -1,7 +1,7 @@ /* - * Ext JS Library 3.0.3 + * Ext JS Library 3.1.0 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ -Ext.Resizable=function(d,e){this.el=Ext.get(d);if(e&&e.wrap){e.resizeChild=this.el;this.el=this.el.wrap(typeof e.wrap=="object"?e.wrap:{cls:"xresizable-wrap"});this.el.id=this.el.dom.id=e.resizeChild.id+"-rzwrap";this.el.setStyle("overflow","hidden");this.el.setPositioning(e.resizeChild.getPositioning());e.resizeChild.clearPositioning();if(!e.width||!e.height){var f=e.resizeChild.getSize();this.el.setSize(f.width,f.height)}if(e.pinned&&!e.adjustments){e.adjustments="auto"}}this.proxy=this.el.createProxy({tag:"div",cls:"x-resizable-proxy",id:this.el.id+"-rzproxy"},Ext.getBody());this.proxy.unselectable();this.proxy.enableDisplayMode("block");Ext.apply(this,e);if(this.pinned){this.disableTrackOver=true;this.el.addClass("x-resizable-pinned")}var j=this.el.getStyle("position");if(j!="absolute"&&j!="fixed"){this.el.setStyle("position","relative")}if(!this.handles){this.handles="s,e,se";if(this.multiDirectional){this.handles+=",n,w"}}if(this.handles=="all"){this.handles="n s e w ne nw se sw"}var n=this.handles.split(/\s*?[,;]\s*?| /);var c=Ext.Resizable.positions;for(var h=0,k=n.length;h0){if(a>(e/2)){d=c+(e-a)}else{d=c-a}}return Math.max(b,d)},resizeElement:function(){var a=this.proxy.getBox();if(this.updateBox){this.el.setBox(a,false,this.animate,this.duration,null,this.easing)}else{this.el.setSize(a.width,a.height,this.animate,this.duration,null,this.easing)}this.updateChildSize();if(!this.dynamic){this.proxy.hide()}return a},constrain:function(b,c,a,d){if(b-cd){c=b-d}}return c},onMouseMove:function(v){if(this.enabled&&this.activeHandle){try{if(this.resizeRegion&&!this.resizeRegion.contains(v.getPoint())){return}var s=this.curSize||this.startBox,k=this.startBox.x,j=this.startBox.y,c=k,b=j,l=s.width,t=s.height,d=l,n=t,m=this.minWidth,z=this.minHeight,r=this.maxWidth,C=this.maxHeight,g=this.widthIncrement,a=this.heightIncrement,A=v.getXY(),q=-(this.startPoint[0]-Math.max(this.minX,A[0])),o=-(this.startPoint[1]-Math.max(this.minY,A[1])),i=this.activeHandle.position,D,f;switch(i){case"east":l+=q;l=Math.min(Math.max(m,l),r);break;case"south":t+=o;t=Math.min(Math.max(z,t),C);break;case"southeast":l+=q;t+=o;l=Math.min(Math.max(m,l),r);t=Math.min(Math.max(z,t),C);break;case"north":o=this.constrain(t,o,z,C);j+=o;t-=o;break;case"west":q=this.constrain(l,q,m,r);k+=q;l-=q;break;case"northeast":l+=q;l=Math.min(Math.max(m,l),r);o=this.constrain(t,o,z,C);j+=o;t-=o;break;case"northwest":q=this.constrain(l,q,m,r);o=this.constrain(t,o,z,C);j+=o;t-=o;k+=q;l-=q;break;case"southwest":q=this.constrain(l,q,m,r);t+=o;t=Math.min(Math.max(z,t),C);k+=q;l-=q;break}var p=this.snap(l,g,m);var B=this.snap(t,a,z);if(p!=l||B!=t){switch(i){case"northeast":j-=B-t;break;case"north":j-=B-t;break;case"southwest":k-=p-l;break;case"west":k-=p-l;break;case"northwest":k-=p-l;j-=B-t;break}l=p;t=B}if(this.preserveRatio){switch(i){case"southeast":case"east":t=n*(l/d);t=Math.min(Math.max(z,t),C);l=d*(t/n);break;case"south":l=d*(t/n);l=Math.min(Math.max(m,l),r);t=n*(l/d);break;case"northeast":l=d*(t/n);l=Math.min(Math.max(m,l),r);t=n*(l/d);break;case"north":D=l;l=d*(t/n);l=Math.min(Math.max(m,l),r);t=n*(l/d);k+=(D-l)/2;break;case"southwest":t=n*(l/d);t=Math.min(Math.max(z,t),C);D=l;l=d*(t/n);k+=D-l;break;case"west":f=t;t=n*(l/d);t=Math.min(Math.max(z,t),C);j+=(f-t)/2;D=l;l=d*(t/n);k+=D-l;break;case"northwest":D=l;f=t;t=n*(l/d);t=Math.min(Math.max(z,t),C);l=d*(t/n);j+=f-t;k+=D-l;break}}this.proxy.setBounds(k,j,l,t);if(this.dynamic){this.resizeElement()}}catch(u){}}},handleOver:function(){if(this.enabled){this.el.addClass("x-resizable-over")}},handleOut:function(){if(!this.resizing){this.el.removeClass("x-resizable-over")}},getEl:function(){return this.el},getResizeChild:function(){return this.resizeChild},destroy:function(b){Ext.destroy(this.dd,this.overlay,this.proxy);this.overlay=null;this.proxy=null;var c=Ext.Resizable.positions;for(var a in c){if(typeof c[a]!="function"&&this[c[a]]){this[c[a]].destroy()}}if(b){this.el.update("");Ext.destroy(this.el);this.el=null}this.purgeListeners()},syncHandleHeight:function(){var a=this.el.getHeight(true);if(this.west){this.west.el.setHeight(a)}if(this.east){this.east.el.setHeight(a)}}});Ext.Resizable.positions={n:"north",s:"south",e:"east",w:"west",se:"southeast",sw:"southwest",nw:"northwest",ne:"northeast"};Ext.Resizable.Handle=function(c,e,b,d){if(!this.tpl){var a=Ext.DomHelper.createTemplate({tag:"div",cls:"x-resizable-handle x-resizable-handle-{0}"});a.compile();Ext.Resizable.Handle.prototype.tpl=a}this.position=e;this.rz=c;this.el=this.tpl.append(c.el.dom,[this.position],true);this.el.unselectable();if(d){this.el.setOpacity(0)}this.el.on("mousedown",this.onMouseDown,this);if(!b){this.el.on({scope:this,mouseover:this.onMouseOver,mouseout:this.onMouseOut})}};Ext.Resizable.Handle.prototype={afterResize:function(a){},onMouseDown:function(a){this.rz.onMouseDown(this,a)},onMouseOver:function(a){this.rz.handleOver(this,a)},onMouseOut:function(a){this.rz.handleOut(this,a)},destroy:function(){Ext.destroy(this.el);this.el=null}}; \ No newline at end of file +Ext.Resizable=function(d,e){this.el=Ext.get(d);if(e&&e.wrap){e.resizeChild=this.el;this.el=this.el.wrap(typeof e.wrap=="object"?e.wrap:{cls:"xresizable-wrap"});this.el.id=this.el.dom.id=e.resizeChild.id+"-rzwrap";this.el.setStyle("overflow","hidden");this.el.setPositioning(e.resizeChild.getPositioning());e.resizeChild.clearPositioning();if(!e.width||!e.height){var f=e.resizeChild.getSize();this.el.setSize(f.width,f.height)}if(e.pinned&&!e.adjustments){e.adjustments="auto"}}this.proxy=this.el.createProxy({tag:"div",cls:"x-resizable-proxy",id:this.el.id+"-rzproxy"},Ext.getBody());this.proxy.unselectable();this.proxy.enableDisplayMode("block");Ext.apply(this,e);if(this.pinned){this.disableTrackOver=true;this.el.addClass("x-resizable-pinned")}var j=this.el.getStyle("position");if(j!="absolute"&&j!="fixed"){this.el.setStyle("position","relative")}if(!this.handles){this.handles="s,e,se";if(this.multiDirectional){this.handles+=",n,w"}}if(this.handles=="all"){this.handles="n s e w ne nw se sw"}var n=this.handles.split(/\s*?[,;]\s*?| /);var c=Ext.Resizable.positions;for(var h=0,k=n.length;h0){if(a>(e/2)){d=c+(e-a)}else{d=c-a}}return Math.max(b,d)},resizeElement:function(){var a=this.proxy.getBox();if(this.updateBox){this.el.setBox(a,false,this.animate,this.duration,null,this.easing)}else{this.el.setSize(a.width,a.height,this.animate,this.duration,null,this.easing)}this.updateChildSize();if(!this.dynamic){this.proxy.hide()}if(this.draggable&&this.constrainTo){this.dd.resetConstraints();this.dd.constrainTo(this.constrainTo)}return a},constrain:function(b,c,a,d){if(b-cd){c=b-d}}return c},onMouseMove:function(v){if(this.enabled&&this.activeHandle){try{if(this.resizeRegion&&!this.resizeRegion.contains(v.getPoint())){return}var s=this.curSize||this.startBox,k=this.startBox.x,j=this.startBox.y,c=k,b=j,l=s.width,t=s.height,d=l,n=t,m=this.minWidth,z=this.minHeight,r=this.maxWidth,C=this.maxHeight,g=this.widthIncrement,a=this.heightIncrement,A=v.getXY(),q=-(this.startPoint[0]-Math.max(this.minX,A[0])),o=-(this.startPoint[1]-Math.max(this.minY,A[1])),i=this.activeHandle.position,D,f;switch(i){case"east":l+=q;l=Math.min(Math.max(m,l),r);break;case"south":t+=o;t=Math.min(Math.max(z,t),C);break;case"southeast":l+=q;t+=o;l=Math.min(Math.max(m,l),r);t=Math.min(Math.max(z,t),C);break;case"north":o=this.constrain(t,o,z,C);j+=o;t-=o;break;case"west":q=this.constrain(l,q,m,r);k+=q;l-=q;break;case"northeast":l+=q;l=Math.min(Math.max(m,l),r);o=this.constrain(t,o,z,C);j+=o;t-=o;break;case"northwest":q=this.constrain(l,q,m,r);o=this.constrain(t,o,z,C);j+=o;t-=o;k+=q;l-=q;break;case"southwest":q=this.constrain(l,q,m,r);t+=o;t=Math.min(Math.max(z,t),C);k+=q;l-=q;break}var p=this.snap(l,g,m);var B=this.snap(t,a,z);if(p!=l||B!=t){switch(i){case"northeast":j-=B-t;break;case"north":j-=B-t;break;case"southwest":k-=p-l;break;case"west":k-=p-l;break;case"northwest":k-=p-l;j-=B-t;break}l=p;t=B}if(this.preserveRatio){switch(i){case"southeast":case"east":t=n*(l/d);t=Math.min(Math.max(z,t),C);l=d*(t/n);break;case"south":l=d*(t/n);l=Math.min(Math.max(m,l),r);t=n*(l/d);break;case"northeast":l=d*(t/n);l=Math.min(Math.max(m,l),r);t=n*(l/d);break;case"north":D=l;l=d*(t/n);l=Math.min(Math.max(m,l),r);t=n*(l/d);k+=(D-l)/2;break;case"southwest":t=n*(l/d);t=Math.min(Math.max(z,t),C);D=l;l=d*(t/n);k+=D-l;break;case"west":f=t;t=n*(l/d);t=Math.min(Math.max(z,t),C);j+=(f-t)/2;D=l;l=d*(t/n);k+=D-l;break;case"northwest":D=l;f=t;t=n*(l/d);t=Math.min(Math.max(z,t),C);l=d*(t/n);j+=f-t;k+=D-l;break}}this.proxy.setBounds(k,j,l,t);if(this.dynamic){this.resizeElement()}}catch(u){}}},handleOver:function(){if(this.enabled){this.el.addClass("x-resizable-over")}},handleOut:function(){if(!this.resizing){this.el.removeClass("x-resizable-over")}},getEl:function(){return this.el},getResizeChild:function(){return this.resizeChild},destroy:function(b){Ext.destroy(this.dd,this.overlay,this.proxy);this.overlay=null;this.proxy=null;var c=Ext.Resizable.positions;for(var a in c){if(typeof c[a]!="function"&&this[c[a]]){this[c[a]].destroy()}}if(b){this.el.update("");Ext.destroy(this.el);this.el=null}this.purgeListeners()},syncHandleHeight:function(){var a=this.el.getHeight(true);if(this.west){this.west.el.setHeight(a)}if(this.east){this.east.el.setHeight(a)}}});Ext.Resizable.positions={n:"north",s:"south",e:"east",w:"west",se:"southeast",sw:"southwest",nw:"northwest",ne:"northeast"};Ext.Resizable.Handle=function(c,e,b,d){if(!this.tpl){var a=Ext.DomHelper.createTemplate({tag:"div",cls:"x-resizable-handle x-resizable-handle-{0}"});a.compile();Ext.Resizable.Handle.prototype.tpl=a}this.position=e;this.rz=c;this.el=this.tpl.append(c.el.dom,[this.position],true);this.el.unselectable();if(d){this.el.setOpacity(0)}this.el.on("mousedown",this.onMouseDown,this);if(!b){this.el.on({scope:this,mouseover:this.onMouseOver,mouseout:this.onMouseOut})}};Ext.Resizable.Handle.prototype={afterResize:function(a){},onMouseDown:function(a){this.rz.onMouseDown(this,a)},onMouseOver:function(a){this.rz.handleOver(this,a)},onMouseOut:function(a){this.rz.handleOut(this,a)},destroy:function(){Ext.destroy(this.el);this.el=null}}; \ No newline at end of file