cfe.module.file=new Class({Extends:cfe.generic,type:"File",selector:"input[type=file]",options:{fileIcons:true,trimFilePath:true},getFilePath:function(){return this.v},getFull:function(){return[this.l,this.a,this.v]},initializeAdv:function(){if(!this.o.implicitLabel&&!Browser.Engine.webkit){this.a.addEvent("click",this.clicked.bindWithEvent(this))}if(this.isDisabled()){this.a.fireEvent("disable")}},build:function(){this.a.addEvent("mousemove",this.follow.bindWithEvent(this)).setStyle("overflow","hidden");this.o.inject(this.a);this.initO();this.v=new Element("div",{"class":"js"+this.type+"Path"}).inject(this.a,"after").addClass("hidden");if(this.options.fileIcons){this.fileIcon=new Element("img",{src:this.options.spacer,"class":"fileIcon"}).inject(this.v)}this.path=new Element("span",{"class":"filePath"}).inject(this.v);this.cross=new cfe.generic().addEvent("click",this.deleteCurrentFile.bind(this)).getAlias().addClass("delete").inject(this.v);this.update()},createOriginal:function(){return new Element("input",{type:"file"})},initO:function(){this.o.addEvent("mouseout",this.update.bind(this));this.o.addEvent("change",this.update.bind(this));this.o.setStyles({cursor:"pointer",opacity:"0",visibility:"visible",height:"100%",width:"auto",position:"relative"})},follow:function(b){var a=new Event(b);this.o.setStyle("left",(a.client.x-this.a.getLeft()-(this.o.getWidth()-30)));if(Browser.Engine.trident){if(a.client.x<this.a.getLeft()||a.client.x>this.a.getLeft()+this.a.getWidth()){this.o.setStyle("left",-999)}}},update:function(){if(this.o.value!=""){this.oldValue=this.o.getProperty("value");this.oldValue=this.options.trimFilePath?this.trimFilePath(this.oldValue):this.oldValue;this.path.set("html",this.oldValue);if(this.options.fileIcons){var a=this.oldValue.lastIndexOf(".");this.fileIcon.setProperty("class","fileIcon "+this.oldValue.substring(++a).toLowerCase())}this.v.removeClass("hidden")}else{this.path.set("html","");this.v.addClass("hidden")}this.parent()},deleteCurrentFile:function(){var a=this.createOriginal();a.addClass(this.o.getProperty("class")).setProperties({name:this.o.name,id:this.o.id});a.replaces(this.o);this.o=a;this.initO();this.update()},trimFilePath:function(b){var a=false;if(!(a=b.lastIndexOf("\\"))){if(!(a=b.lastIndexOf("/"))){a=0}}return b.substring(++a)}});
