var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Selector=YAHOO.util.Selector;Alfresco.widget.DashletResizer=function DashletResizer_constructor(b,a){this.name="Alfresco.widget.DashletResizer";this.id=b;this.dashletId=a;Alfresco.util.YUILoaderHelper.require(["resize","selector"],this.onComponentsLoaded,this);this.widgets={};return this};Alfresco.widget.DashletResizer.prototype={options:{dashletHeight:-1,minDashletHeight:80,maxDashletHeight:1200},dashletId:"",widgets:null,dashlet:null,dashletBody:null,heightDelta:0,setOptions:function DashletResizer_setOptions(a){this.options=YAHOO.lang.merge(this.options,a);return this},onComponentsLoaded:function DashletResizer_onComponentsLoaded(){Event.onDOMReady(this.onReady,this,true)},onReady:function DashletResizer_onReady(){if(!Alfresco.constants.DASHLET_RESIZE){return}this.dashlet=Selector.query("div.dashlet",Dom.get(this.id),true);if(!this.dashlet){return}Dom.addClass(this.dashlet,"resizable");this.dashletBody=Selector.query("div.body",this.dashlet,true);if(!this.dashletBody){return}var a=Dom.getStyle(this.dashlet,"height");if(a=="auto"){a=this.dashlet.offsetHeight-parseInt(Dom.getStyle(this.dashlet,"padding-bottom"))}else{a=parseInt(a,10)}this.heightDelta=a-parseInt(Dom.getStyle(this.dashletBody,"height"),10);this.widgets.resizer=new YAHOO.util.Resize(this.dashlet,{handles:["b"],minHeight:this.options.minDashletHeight,maxHeight:this.options.maxDashletHeight});this.widgets.resizer.on("resize",function(){this.onResize()},this,true);this.widgets.resizer.on("endResize",function(b){this.onEndResize(b.height)},this,true);Dom.setStyle(this.dashlet,"width","")},onResize:function DashletResizer_onResize(){var a=parseInt(Dom.getStyle(this.dashlet,"height"),10)-this.heightDelta;Dom.setStyle(this.dashletBody,"height",a+"px")},onEndResize:function DashletResizer_onEndResize(a){Dom.setStyle(this.dashlet,"width","");Alfresco.util.Ajax.jsonRequest({method:"POST",url:Alfresco.constants.URL_SERVICECONTEXT+"modules/dashlet/config/"+this.dashletId,dataObj:{height:parseInt(Dom.getStyle(this.dashlet,"height"),10)-this.heightDelta},successCallback:function(){},successMessage:null,failureCallback:function(){},failureMessage:null})}};
