﻿function PXFileList($a,$b){this.element=$a;this.ID=$a.id;px_cm.readProperties(this,$b,PXFileList.properties);this.grid=px_all[this.ID+"_grd"];var me=this;if(this.grid!=null){this.grid.fileList=this;this.grid.events.addEventHandler("toolsButtonClick",PXFileList.$l);this.grid.events.addEventHandler("afterRefresh",PXFileList.$m);this.grid.events.addEventHandler("afterRowDelete",PXFileList.$n);var h=Function.createDelegate(this,this.$o);px.addEventHandler(window,"resize",h);setTimeout(function(){me.grid.adjustSize();},0);};this.callbacks=new Array();this.callbacks[0]=PXCallback.copyCommand("AttachFile",this.callBackMode);this.callbacks[1]=PXCallback.copyCommand("Download",this.callBackMode);this.callbacks[2]=PXCallback.copyCommand("PropertiesView",this.callBackMode);this.callbacks[3]=PXCallback.copyCommand("CheckOutFile",this.callBackMode);this.callbacks[4]=PXCallback.copyCommand("UndoCheckOutFile",this.callBackMode);if(this.isIELessThan8())this.intervalID=window.setInterval(function(){me.attachOnScrollForIELessThan8()},500);};PXFileList.properties=[["callBackMode",JSType.Object,PXCallback.commandDesc]];PXFileList.prototype.showUploader=function(){if(this.$p)this.$p.show();else PXCallback.execI(this,this.callbacks[0],"",PXFileList.$q);};PXFileList.prototype.downloadFile=function(){PXCallback.execI(this,this.callbacks[1],"");};PXFileList.prototype.viewProperties=function(){PXCallback.execI(this,this.callbacks[2],"");};PXFileList.prototype.checkOutFile=function(){PXCallback.execI(this,this.callbacks[3],"",PXFileList.$r);};PXFileList.prototype.undoCheckOutFile=function(){PXCallback.execI(this,this.callbacks[4],"",PXFileList.$r);};PXFileList.prototype.$s=function(){this.grid.refresh();};PXFileList.prototype.$o=function(){this.grid.adjustSize();this.grid.element.style.width="100%";this.grid.adjustColumns();if(this.isIELessThan8())this.element.style.height=this.grid.element.clientHeight+"px";};PXFileList.prototype.isIELessThan8=function(){if(!px.IsIE)return false;var ua=navigator.userAgent;var MSIEOffset=ua.indexOf("MSIE ");if(MSIEOffset==-1)return false;if(parseFloat(ua.substring(MSIEOffset+5,ua.indexOf(";",MSIEOffset)))==8)return false;return true;};PXFileList.prototype.attachOnScrollForIELessThan8=function(){this.grid.element.style.position="absolute";this.element.style.height=this.grid.element.clientHeight+"px";this.calculateGridPosition(this.element);var $a=this.grid.element.parentNode;var me=this;var $c=false;while($a.parentNode!=document){if($a.clientHeight<$a.scrollHeight){$a.onscroll=function(){me.calculateGridPosition(this)};$c=true;};$a=$a.parentNode;};if($c)window.clearInterval(this.intervalID);};PXFileList.prototype.calculateGridPosition=function($d){var $e=$d.scrollTop;this.grid.element.style.left=this.element.offsetLeft+"px";this.grid.element.style.top=(this.element.offsetTop-$e)+"px";};PXFileList.$l=function($f,ev){if(ev.button.key=="AddNew")$f.fileList.showUploader();else if(ev.button.key=="Download")$f.fileList.downloadFile();else if(ev.button.key=="Properties")$f.fileList.viewProperties();else if(ev.button.key=="CheckOut")$f.fileList.checkOutFile();else if(ev.button.key=="UndoCheckOut")$f.fileList.undoCheckOutFile();};PXFileList.$m=function($f,ev){$f.adjustSize();if($f.fileList.isIELessThan8())$f.fileList.element.style.height=$f.element.clientHeight+"px";};PXFileList.$n=function($f,ev){$f.adjustSize();};PXFileList.$q=function($g,$h){if($g){px_cm.processHtmlData($g);var $i=px_all[$h];setTimeout(function(){PXFileList.$t($i.ID);},0);}};PXFileList.$r=function($g,$h){var $i=px_all[$h];var $j=new PXXmlDoc("",$g);var $k=new Object();$k.id=$j.rootNode.nodeName;PXDataSource.$u($g,$k);$i.grid.refresh();};PXFileList.$t=function(id){var $i=px_all[id];if($i){$i.$p=px_all[$i.ID+"_upldr"];$i.$p.show();var h=Function.createDelegate($i,$i.$s);$i.$p.events.addEventHandler("hideAfterUpload",h);}}

