annotate e2gallerypro/e2upload/Compressed/filemanager-yui-all.js @ 16:e902d48caadf judyates

added access.log and error.log
author Robert McIntyre <rlm@mit.edu>
date Tue, 22 Jun 2010 13:41:04 -0400
parents 3f6b44aa6b35
children
rev   line source
rlm@3 1 var FileManager=new Class({Implements:[Options,Events],Request:null,Directory:null,Current:null,options:{directory:"",url:null,assetBasePath:null,selectable:false,hideOnClick:false,language:"en"},hooks:{show:{},cleanup:{}},initialize:function(a){this.setOptions(a);this.options.assetBasePath=this.options.assetBasePath.replace(/(\/|\\)*$/,"/");this.droppables=[];this.Directory=this.options.directory;this.language=FileManager.Language[this.options.language]||FileManager.Language.en;this.container=new Element("div",{"class":"filemanager-container filemanager-engine-"+Browser.Engine.name+(Browser.Engine.trident?Browser.Engine.version:"")});this.el=new Element("div",{"class":"filemanager"}).inject(this.container);this.menu=new Element("div",{"class":"filemanager-menu"}).inject(this.el);this.loader=new Element("div",{"class":"loader",opacity:0,tween:{duration:200}}).inject(this.menu);this.browser=new Element("ul",{"class":"filemanager-browser"}).addEvents({click:(function(g){if(g.target.match("ul")){return this.deselect()}if(!g.target||!g.target.getParent("li")){return}var f=g.target.getParent("li").getElement("span");if(!f){return}g.stop();var d=f.retrieve("file");if(f.retrieve("block")){f.eliminate("block");return}else{if(d.mime=="text/directory"){f.addClass("selected");this.load(this.Directory+"/"+d.name);return}}this.fillInfo(d);if(this.Current){this.Current.removeClass("selected")}this.Current=f.addClass("selected");this.switchButton()}).bind(this)}).inject(this.el);if(this.options.selectable){this.addMenuButton("open")}this.addMenuButton("create");this.info=new Element("div",{"class":"filemanager-infos",opacity:0}).inject(this.el);var b=new Element("div",{"class":"filemanager-head"}).adopt([new Element("img",{"class":"filemanager-icon"}),new Element("h1")]);this.info.adopt([b,new Element("h2",{text:this.language.information})]);var c=new Element("dl").adopt([new Element("dt",{text:this.language.modified}),new Element("dd",{"class":"filemanager-modified"}),new Element("dt",{text:this.language.type}),new Element("dd",{"class":"filemanager-type"}),new Element("dt",{text:this.language.size}),new Element("dd",{"class":"filemanager-size"}),new Element("dt",{text:this.language.dir}),new Element("dd",{"class":"filemanager-dir"})]).inject(this.info);this.preview=new Element("div",{"class":"filemanager-preview"});this.info.adopt([new Element("h2",{"class":"filemanager-headline",text:this.language.preview}),this.preview]);this.closeIcon=new Element("div",{"class":"filemanager-close",title:this.language.close,events:{click:this.hide.bind(this)}}).adopt(new Asset.image(this.options.assetBasePath+"destroy.png")).inject(this.el);new FileManager.Tips(this.closeIcon.appearOn(this.closeIcon,[1,0.8]).appearOn(this.el,0.8));this.imageadd=new Asset.image(this.options.assetBasePath+"add.png",{"class":"browser-add"}).set("opacity",0).inject(this.container);this.container.inject(document.body);this.overlay=new Overlay(this.options.hideOnClick?{events:{click:this.hide.bind(this)}}:null);this.bound={keydown:(function(d){if(d.control){this.imageadd.fade(1)}}).bind(this),keyup:(function(){this.imageadd.fade(0)}).bind(this),keyesc:(function(d){if(d.key=="esc"){this.hide()}}).bind(this),scroll:(function(){this.el.center(this.offsets);this.fireEvent("scroll")}).bind(this)}},show:function(a){if(a){a.stop()}this.load(this.Directory);this.overlay.show();this.info.set("opacity",0);(function(){this.container.setStyles({opacity:0,display:"block"});this.el.center(this.offsets);this.fireEvent("show");this.container.set("opacity",1);this.fireHooks("show");window.addEvents({scroll:this.bound.scroll,resize:this.bound.scroll,keyup:this.bound.keyesc})}).delay(500,this)},hide:function(a){if(a){a.stop()}this.overlay.hide();this.browser.empty();this.container.setStyle("display","none");this.fireHooks("cleanup").fireEvent("hide");window.removeEvent("scroll",this.bound.scroll).removeEvent("resize",this.bound.scroll).removeEvent("keyup",this.bound.keyesc)},open:function(a){a.stop();if(!this.Current){return false}this.fireEvent("complete",[this.normalize(this.Directory+"/"+this.Current.retrieve("file").name),this.Current.retrieve("file")]);this.hide()},create:function(b){b.stop();var a=this;new Dialog(this.language.createdir,{language:{confirm:this.language.create,decline:this.language.cancel},content:[new Element("input",{"class":"createDirectory"})],onOpen:this.onDialogOpen.bind(this),onClose:this.onDialogClose.bind(this),onShow:function(){var c=this;this.el.getElement("input").addEvent("keyup",function(d){if(d.key=="enter"){c.el.getElement("button-confirm").fireEvent("click")}}).focus()},onConfirm:function(){new FileManager.Request({url:a.options.url+"?event=create",onSuccess:a.fill.bind(a),data:{file:this.el.getElement("input").get("value"),directory:a.Directory}},a).post()}})},deselect:function(a){if(a&&this.Current!=a){return}if(a){this.fillInfo()}if(this.Current){this.Current.removeClass("selected")}this.Current=null;this.switchButton()},load:function(a,b){this.deselect();if(!b){this.info.fade(0)}if(this.Request){this.Request.cancel()}this.Request=new FileManager.Request({url:this.options.url,onSuccess:(function(c){this.fill(c,b)}).bind(this),data:{directory:a}},this).post()},destroy:function(c,b){c.stop();var a=this;new Dialog(this.language.destroyfile,{language:{confirm:this.language.destroy,decline:this.language.cancel},onOpen:this.onDialogOpen.bind(this),onClose:this.onDialogClose.bind(this),onConfirm:function(){new FileManager.Request({url:a.options.url+"?event=destroy",data:{file:b.name,directory:a.Directory},onSuccess:function(d){if(!d||d.content!="destroyed"){new Dialog(a.language.nodestroy,{language:{confirm:a.language.ok},buttons:["confirm"]});return}a.fireEvent("modify",[$unlink(b)]);b.element.getParent().fade(0).get("tween").chain(function(){a.deselect(b.element);this.element.destroy()})}},a).post()}})},rename:function(d,c){d.stop();var b=c.name;if(c.mime!="text/directory"){b=b.replace(/\..*$/,"")}var a=this;new Dialog(this.language.renamefile,{language:{confirm:this.language.rename,decline:this.language.cancel},content:[new Element("input",{"class":"rename",value:b})],onOpen:this.onDialogOpen.bind(this),onClose:this.onDialogClose.bind(this),onShow:function(){var e=this;this.el.getElement("input").addEvent("keyup",function(f){if(f.key=="enter"){e.el.getElement("button-confirm").fireEvent("click")}}).focus()},onConfirm:function(){new FileManager.Request({url:a.options.url+"?event=move",onSuccess:(function(e){if(!e||!e.name){return}a.fireEvent("modify",[$unlink(c)]);c.element.getElement("span").set("text",e.name);c.name=e.name;a.fillInfo(c)}).bind(this),data:{file:c.name,name:this.el.getElement("input").get("value"),directory:a.Directory}},a).post()}})},fill:function(c,e){this.Directory=c.path;this.CurrentDir=c.dir;if(!e){this.fillInfo(c.dir)}this.browser.empty();if(!c.files){return}var d=[[],[]];$each(c.files,function(g){g.dir=c.path;var h=g.element=new Element("span",{"class":"fi",href:"#"}).adopt(new Asset.image(this.options.assetBasePath+"Icons/"+g.icon+".png"),new Element("span",{text:g.name})).store("file",g);var f=[];if(g.mime!="text/directory"){f.push(new Asset.image(this.options.assetBasePath+"disk.png",{title:this.language.download}).addClass("browser-icon").addEvent("click",(function(i){i.stop();window.open(this.normalize(this.Directory+"/"+g.name))}).bind(this)).inject(h,"top"))}if(g.name!=".."){["rename","destroy"].each(function(i){f.push(new Asset.image(this.options.assetBasePath+i+".png",{title:this.language[i]}).addClass("browser-icon").addEvent("click",this[i].bindWithEvent(this,[g])).injectTop(h))},this)}d[g.mime=="text/directory"?1:0].push(h);if(g.name==".."){h.set("opacity",0.7)}h.inject(new Element("li").inject(this.browser));f=$$(f.map(function(i){return i.appearOn(i,[1,0.7])})).appearOn(h.getParent("li"),0.7)},this);var b=this;$$(d[0]).makeDraggable({droppables:$$(this.droppables,d[1]),onDrag:function(f,g){b.imageadd.setStyles(Hash.getValues(g.page).map(function(h){return h+15}).associate(["left","top"]))},onBeforeStart:function(f){f.setStyles({left:"0",top:"0"})},onStart:function(f){b.onDragStart(f,this);f.set("opacity",0.7);document.addEvents({keydown:b.bound.keydown,keyup:b.bound.keyup})},onEnter:function(f,g){g.addClass("droppable")},onLeave:function(f,g){g.removeClass("droppable")},onDrop:function(h,j,i){document.removeEvents("keydown",b.bound.keydown).removeEvents("keyup",b.bound.keydown);b.imageadd.fade(0);h.set("opacity",1).store("block",true);if(i.control||!j){h.setStyles({left:"0",top:"0"})}if(!j&&!i.control){return}var f;if(j){j.addClass("selected");(function(){j.removeClass("droppable").removeClass("selected")}).delay(300);if(b.onDragComplete(h,j)){return}f=j.retrieve("file")}var g=h.retrieve("file");new FileManager.Request({url:b.options.url+"?event=move",data:{file:g.name,directory:b.Directory,newDirectory:f?f.dir+"/"+f.name:b.Directory,copy:i.control?1:0},onSuccess:function(){if(!f){b.load(b.Directory)}}},b).post();b.fireEvent("modify",[$unlink(g)]);if(!i.control){h.fade(0).get("tween").chain(function(){b.deselect(h);h.getParent().destroy()})}}});$$(d).setStyles({left:"0",top:"0"});var a=new FileManager.Tips(this.browser.getElements("img.browser-icon"));a.tip.removeClass("tip-base")},fillInfo:function(b,d){if(!b){b=this.CurrentDir}if(!d){d=this.Directory}if(!b){return}var a=this.size(b.size);this.info.fade(1).getElement("img").set({src:this.options.assetBasePath+"Icons/"+b.icon+".png",alt:b.mime});this.fireHooks("cleanup");this.preview.empty();this.info.getElement("h1").set("text",b.name);this.info.getElement("dd.filemanager-modified").set("text",b.date);this.info.getElement("dd.filemanager-type").set("text",b.mime);this.info.getElement("dd.filemanager-size").set("text",!a[0]&&a[1]=="Bytes"?"-":(a.join(" ")+(a[1]!="Bytes"?" ("+b.size+" Bytes)":"")));this.info.getElement("h2.filemanager-headline").setStyle("display",b.mime=="text/directory"?"none":"block");var e=[],c=[];d.split("/").each(function(f){if(!f){return}c.push(f);e.push(new Element("a",{"class":"icon",href:"#",text:f}).addEvent("click",(function(h,g){h.stop();this.load(g)}).bindWithEvent(this,[c.join("/")])));e.push(new Element("span",{text:" / "}))},this);e.pop();e[e.length-1].addClass("selected").removeEvents("click").addEvent("click",function(f){f.stop()});this.info.getElement("dd.filemanager-dir").empty().adopt(new Element("span",{text:"/ "}),e);if(b.mime=="text/directory"){return}if(this.Request){this.Request.cancel()}this.Request=new FileManager.Request({url:this.options.url+"?event=detail",onSuccess:(function(f){var h=this.preview.removeClass("filemanager-loading").set("html",f&&f.content?f.content.substitute(this.language,/\\?\$\{([^{}]+)\}/g):"").getElement("img.prev");if(h){h.addEvent("load",function(){this.setStyle("background","none")})}var g=this.preview.getElements("button");if(g){g.addEvent("click",function(i){i.stop();window.open(this.get("value"))})}}).bind(this),data:{directory:this.Directory,file:b.name}},this).post()},size:function(b){var c=["Bytes","KB","MB","GB","TB"];for(var a=0;b>1024;a++){b=b/1024}return[Math.round(b),c[a]]},normalize:function(a){return a.replace(/\/+/g,"/")},switchButton:function(){var a=!!this.Current;var b=this.menu.getElement("button.filemanager-open");if(b){b.set("disabled",!a)[(a?"remove":"add")+"Class"]("disabled")}},addMenuButton:function(a){var b=new Element("button",{"class":"filemanager-"+a,text:this.language[a]}).inject(this.menu);if(this[a]){b.addEvent("click",this[a].bind(this))}return b},fireHooks:function(c){var a=Array.slice(arguments,1);for(var b in this.hooks[c]){this.hooks[c][b].apply(this,a)}return this},onRequest:function(){this.loader.set("opacity",1)},onComplete:function(){this.loader.fade(0)},onDialogOpen:$empty,onDialogClose:$empty,onDragStart:$empty,onDragComplete:$lambda(false)});FileManager.Language={};if(!window.FileManager){var FileManager={}}FileManager.Tips=new Class({Extends:Tips,options:{offsets:{x:15,y:0},text:null,onShow:function(b,a){if(b.get("opacity")==0.8&&b.getStyle("visibility")=="visible"){return}b.get("tween").pause();b.set({opacity:0,tween:{duration:200,link:"cancel"}}).fade(0.8)},onHide:function(b,a){b.get("tween").pause().start("opacity",0).chain(function(){b.setStyle("left",0)})}},initialize:function(b,a){this.parent(b,a);this.tip.addClass("tip-filebrowser")}});FileManager.Request=new Class({Extends:Request.JSON,initialize:function(a,b){this.parent(a);if(b){this.addEvents({request:b.onRequest.bind(b),complete:b.onComplete.bind(b)})}}});Element.implement({appearOn:function(c,b,a){b=$type(b)=="array"?[b[0]||1,b[1]||0]:[b||1,0];this.set({opacity:b[1],tween:a||{duration:200}});$(c).addEvents({mouseenter:this.fade.bind(this,b[0]),mouseleave:this.fade.bind(this,b[1])});return this},center:function(e){var a=document.getScroll(),g=document.getSize(),c=this.getSize(),b={x:"left",y:"top"};if(!e){e={}}for(var f in b){var d=a[f]+(g[f]-c[f])/2+(e[f]||0);this.setStyle(b[f],d<10?10:d)}return this}});var Dialog=new Class({Implements:[Options,Events],options:{request:null,buttons:["confirm","decline"],language:{}},initialize:function(b,a){this.setOptions(a);this.el=new Element("div",{"class":"dialog dialog-engine-"+Browser.Engine.name+(Browser.Engine.trident?Browser.Engine.version:""),opacity:0,tween:{duration:250}}).adopt([$type(b)=="string"?new Element("div",{text:b}):b]);if(this.options.content){this.el.getElement("div").adopt(this.options.content)}Array.each(this.options.buttons,function(c){new Element("button",{"class":"dialog-"+c,text:this.options.language[c]}).addEvent("click",(function(d){if(d){d.stop()}this.fireEvent(c).fireEvent("close");this.overlay.hide();this.destroy()}).bind(this)).inject(this.el)},this);this.overlay=new Overlay({"class":"overlay overlay-dialog",events:{click:this.fireEvent.bind(this,["close"])},tween:{duration:250}});this.bound={scroll:(function(){if(!this.el){this.destroy()}else{this.el.center()}}).bind(this),keyesc:(function(c){if(c.key=="esc"){this.fireEvent("close").destroy()}}).bind(this)};this.show()},show:function(){this.overlay.show();var a=this.fireEvent("open");this.el.setStyle("display","block").inject(document.body).center().fade(1).get("tween").chain(function(){a.fireEvent("show")});window.addEvents({scroll:this.bound.scroll,resize:this.bound.scroll,keyup:this.bound.keyesc})},destroy:function(){if(this.el){this.el.fade(0).get("tween").chain((function(){this.overlay.destroy();this.el.destroy()}).bind(this))}window.removeEvent("scroll",this.bound.scroll).removeEvent("resize",this.bound.scroll).removeEvent("keyup",this.bound.keyesc)}}),Overlay=new Class({initialize:function(a){this.el=new Element("div",$extend({"class":"overlay"},a)).inject(document.body)},show:function(){this.objects=$$("object, select, embed").filter(function(a){return a.id=="SwiffFileManagerUpload"||a.style.visibility=="hidden"?false:!!(a.style.visibility="hidden")});this.resize=(function(){if(!this.el){this.destroy()}else{this.el.setStyles({width:document.getScrollWidth(),height:document.getScrollHeight()})}}).bind(this);this.resize();this.el.setStyles({opacity:0,display:"block"}).get("tween").pause().start("opacity",0.5);window.addEvent("resize",this.resize);return this},hide:function(){this.el.fade(0).get("tween").chain((function(){this.revertObjects();this.el.setStyle("display","none")}).bind(this));window.removeEvent("resize",this.resize);return this},destroy:function(){this.revertObjects().el.destroy()},revertObjects:function(){if(this.objects&&this.objects.length){this.objects.each(function(a){a.style.visibility="visible"})}return this}});FileManager.TinyMCE=function(a){return function(f,b,d,e){var c=new FileManager($extend({onComplete:function(g){if(!e.document){return}e.document.getElementById(f).value=g;if(e.ImageDialog){e.ImageDialog.showPreviewImage(g,1)}this.container.destroy()}},a(d)));c.el.setStyle("zIndex",400001);c.overlay.el.setStyle("zIndex",400000);c.show()}};FileManager.implement("SwiffZIndex",400002);var Dialog=new Class({Extends:Dialog,initialize:function(b,a){this.parent(b,a);this.el.setStyle("zIndex",400010);this.overlay.el.setStyle("zIndex",400009)}});Fx.ProgressBar=new Class({Extends:Fx,options:{text:null,url:null,transition:Fx.Transitions.Circ.easeOut,fit:true,link:"cancel"},initialize:function(c,b){this.element=$(c);this.parent(b);var a=this.options.url;if(a){this.element.setStyles({"background-image":"url("+a+")","background-repeat":"no-repeat"})}if(this.options.fit){a=a||this.element.getStyle("background-image").replace(/^url\(["']?|["']?\)$/g,"");if(a){var d=new Image();d.onload=function(){this.fill=d.width;d=d.onload=null;this.set(this.now||0)}.bind(this);d.src=a;if(!this.fill&&d.width){d.onload()}}}else{this.set(0)}},start:function(b,a){return this.parent(this.now,(arguments.length==1)?b.limit(0,100):b/a*100)},set:function(c){this.now=c;var a=(this.fill)?(((this.fill/-2)+(c/100)*(this.element.width||1)||0).round()+"px"):((100-c)+"%");this.element.setStyle("backgroundPosition",a+" 0px").title=Math.round(c)+"%";var b=$(this.options.text);if(b){b.set("text",Math.round(c)+"%")}return this}});Swiff.Uploader=new Class({Extends:Swiff,Implements:Events,options:{path:"Swiff.Uploader.swf",target:null,zIndex:9999,height:30,width:100,callBacks:null,params:{wMode:"opaque",menu:"false",allowScriptAccess:"always"},typeFilter:null,multiple:true,queued:true,verbose:false,url:null,method:null,data:null,mergeData:true,fieldName:null,fileSizeMin:1,fileSizeMax:null,allowDuplicates:false,buttonImage:null,fileListMax:0,fileListSizeMax:0,instantStart:false,appendCookieData:false,fileClass:null},initialize:function(b){this.addEvent("load",this.initializeSwiff,true).addEvent("select",this.processFiles,true).addEvent("complete",this.update,true).addEvent("fileRemove",function(d){this.fileList.erase(d)}.bind(this),true);this.setOptions(b);if(this.options.callBacks){Hash.each(this.options.callBacks,function(e,d){this.addEvent(d,e)},this)}this.options.callBacks={fireCallback:this.fireCallback.bind(this)};var c=this.options.path;if(!c.contains("?")){c+="?noCache="+$time()}this.options.container=this.box=new Element("span",{"class":"swiff-uploader-box"}).inject($(this.options.container)||document.body);this.target=$(this.options.target);if(this.target){var a=window.getScroll();this.box.setStyles({position:"absolute",visibility:"visible",zIndex:this.options.zIndex,overflow:"hidden",height:1,width:1,top:a.y,left:a.x});this.parent(c,{params:{wMode:"transparent"},height:"100%",width:"100%"});this.target.addEvent("mouseenter",this.reposition.bind(this,[]));this.addEvents({buttonEnter:this.targetRelay.bind(this,["mouseenter"]),buttonLeave:this.targetRelay.bind(this,["mouseleave"]),buttonDown:this.targetRelay.bind(this,["mousedown"]),buttonDisable:this.targetRelay.bind(this,["disable"])});this.reposition();window.addEvent("resize",this.reposition.bind(this,[]))}else{this.parent(c)}this.inject(this.box);this.fileList=[];this.size=this.uploading=this.bytesLoaded=this.percentLoaded=0;if(Browser.Plugins.Flash.version<9){this.fireEvent("fail",["flash"])}else{this.verifyLoad.delay(500,this)}},verifyLoad:function(){if(this.loaded){return}if(!this.object.parentNode){this.fireEvent("fail",["disabled"])}else{if(this.object.style.display=="none"){this.fireEvent("fail",["hidden"])}else{if(!this.object.offsetWidth){this.fireEvent("fail",["empty"])}}}},fireCallback:function(b,a){if(b.substr(0,4)=="file"){if(a.length>1){this.update(a[1])}var e=a[0];var c=this.findFile(e.id);this.fireEvent(b,c||e,5);if(c){var d=b.replace(/^file([A-Z])/,function(g,f){return f.toLowerCase()});c.update(e).fireEvent(d,[e],10)}}else{this.fireEvent(b,a,5)}},update:function(a){$extend(this,a);this.fireEvent("queue",[this],10);return this},findFile:function(b){for(var a=0;a<this.fileList.length;a++){if(this.fileList[a].id==b){return this.fileList[a]}}return null},initializeSwiff:function(){this.remote("initialize",{width:this.options.width,height:this.options.height,typeFilter:this.options.typeFilter,multiple:this.options.multiple,queued:this.options.queued,url:this.options.url,method:this.options.method,data:this.options.data,mergeData:this.options.mergeData,fieldName:this.options.fieldName,verbose:this.options.verbose,fileSizeMin:this.options.fileSizeMin,fileSizeMax:this.options.fileSizeMax,allowDuplicates:this.options.allowDuplicates,buttonImage:this.options.buttonImage});this.loaded=true;this.appendCookieData()},targetRelay:function(a){if(this.target){this.target.fireEvent(a)}},reposition:function(a){a=a||(this.target&&this.target.offsetHeight)?this.target.getCoordinates(this.box.getOffsetParent()):{top:window.getScrollTop(),left:0,width:40,height:40};this.box.setStyles(a);this.fireEvent("reposition",[a,this.box,this.target])},setOptions:function(a){if(a){if(a.url){a.url=Swiff.Uploader.qualifyPath(a.url)}if(a.buttonImage){a.buttonImage=Swiff.Uploader.qualifyPath(a.buttonImage)}this.parent(a);if(this.loaded){this.remote("setOptions",a)}}return this},setEnabled:function(a){this.remote("setEnabled",a)},start:function(){this.remote("start")},stop:function(){this.remote("stop")},remove:function(){this.remote("remove")},fileStart:function(a){this.remote("fileStart",a.id)},fileStop:function(a){this.remote("fileStop",a.id)},fileRemove:function(a){this.remote("fileRemove",a.id)},fileRequeue:function(a){this.remote("fileRequeue",a.id)},appendCookieData:function(){var a=this.options.appendCookieData;if(!a){return}var c={};document.cookie.split(/;\s*/).each(function(d){d=d.split("=");if(d.length==2){c[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}});var b=this.options.data||{};if($type(a)=="string"){b[a]=c}else{$extend(b,c)}this.setOptions({data:b})},processFiles:function(f,d,a){var c=this.options.fileClass||Swiff.Uploader.File;var b=[],e=[];if(f){f.each(function(h){var g=new c(this,h);if(!g.validate()){g.remove.delay(10,g);b.push(g)}else{this.size+=h.size;this.fileList.push(g);e.push(g);g.render()}},this);this.fireEvent("selectSuccess",[e],10)}if(d||b.length){b.extend((d)?d.map(function(g){return new c(this,g)},this):[]).each(function(g){g.invalidate().render()});this.fireEvent("selectFail",[b],10)}this.update(a);if(this.options.instantStart&&e.length){this.start()}}});$extend(Swiff.Uploader,{STATUS_QUEUED:0,STATUS_RUNNING:1,STATUS_ERROR:2,STATUS_COMPLETE:3,STATUS_STOPPED:4,log:function(){if(window.console&&console.info){console.info.apply(console,arguments)}},unitLabels:{b:[{min:1,unit:"B"},{min:1024,unit:"kB"},{min:1048576,unit:"MB"},{min:1073741824,unit:"GB"}],s:[{min:1,unit:"s"},{min:60,unit:"m"},{min:3600,unit:"h"},{min:86400,unit:"d"}]},formatUnit:function(a,h,b){var f=Swiff.Uploader.unitLabels[(h=="bps")?"b":h];var c=(h=="bps")?"/s":"";var e,d=f.length,j;if(a<1){return"0 "+f[0].unit+c}if(h=="s"){var g=[];for(e=d-1;e>=0;e--){j=Math.floor(a/f[e].min);if(j){g.push(j+" "+f[e].unit);a-=j*f[e].min;if(!a){break}}}return(b===false)?g:g.join(b||", ")}for(e=d-1;e>=0;e--){j=f[e].min;if(a>=j){break}}return(a/j).toFixed(1)+" "+f[e].unit+c}});Swiff.Uploader.qualifyPath=(function(){var a;return function(b){(a||(a=new Element("a"))).href=b;return a.href}})();Swiff.Uploader.File=new Class({Implements:Events,initialize:function(b,a){this.base=b;this.update(a)},update:function(a){return $extend(this,a)},validate:function(){var a=this.base.options;if(a.fileListMax&&this.base.fileList.length>=a.fileListMax){this.validationError="fileListMax";return false}if(a.fileListSizeMax&&(this.base.size+this.size)>a.fileListSizeMax){this.validationError="fileListSizeMax";return false}return true},invalidate:function(){this.invalid=true;this.base.fireEvent("fileInvalid",this,10);return this.fireEvent("invalid",this,10)},render:function(){return this},setOptions:function(a){if(a){if(a.url){a.url=Swiff.Uploader.qualifyPath(a.url)}this.base.remote("fileSetOptions",this.id,a);this.options=$merge(this.options,a)}return this},start:function(){this.base.fileStart(this);return this},stop:function(){this.base.fileStop(this);return this},remove:function(){this.base.fileRemove(this);return this},requeue:function(){this.base.fileRequeue(this)}});FileManager.implement({options:{resizeImages:true,upload:true,uploadAuthData:{}},hooks:{show:{upload:function(){this.startUpload()}},cleanup:{upload:function(){if(!this.options.upload||!this.upload){return}if(this.upload.uploader){this.upload.uploader.set("opacity",0).dispose()}}}},onDialogOpen:function(){if(this.swf&&this.swf.box){this.swf.box.setStyle("visibility","hidden")}},onDialogClose:function(){if(this.swf&&this.swf.box){this.swf.box.setStyle("visibility","visible")}},startUpload:function(){if(!this.options.upload||this.swf){return}var c=this;this.upload={button:this.addMenuButton("upload").addEvents({click:function(){return false},mouseenter:function(){this.addClass("hover")},mouseleave:function(){this.removeClass("hover");this.blur()},mousedown:function(){this.focus()}}),list:new Element("ul",{"class":"filemanager-uploader-list"}),uploader:new Element("div",{opacity:0}).adopt(new Element("h2",{text:this.language.upload}),new Element("div",{"class":"filemanager-uploader"}))};this.upload.uploader.getElement("div").adopt(this.upload.list);this.closeIcon.appearOn(this.upload.button,0.8);if(this.options.resizeImages){var d=new Element("div",{"class":"checkbox"}),b=(function(){this.toggleClass("checkboxChecked")}).bind(d);b();this.upload.label=new Element("label").adopt(d,new Element("span",{text:this.language.resizeImages})).addEvent("click",b).inject(this.menu)}var a=new Class({Extends:Swiff.Uploader.File,initialize:function(f,e){this.parent(f,e);this.setOptions({url:c.options.url+"?"+Hash.toQueryString($merge({},c.options.uploadAuthData,{event:"upload",directory:c.normalize(c.Directory),resize:c.options.resizeImages&&d.hasClass("checkboxChecked")?1:0}))})},render:function(){if(this.invalid){var i=c.language.uploader.unknown,h={name:this.name,size:Swiff.Uploader.formatUnit(this.size,"b")};if(c.language.uploader[this.validationError]){i=c.language.uploader[this.validationError]}if(this.validationError=="sizeLimitMin"){h.size_min=Swiff.Uploader.formatUnit(this.base.options.fileSizeMin,"b")}else{if(this.validationError=="sizeLimitMax"){h.size_max=Swiff.Uploader.formatUnit(this.base.options.fileSizeMax,"b")}}new Dialog(new Element("div",{html:i.substitute(h,/\\?\$\{([^{}]+)\}/g)}),{language:{confirm:c.language.ok},buttons:["confirm"]});return this}this.addEvents({open:this.onOpen,remove:this.onRemove,requeue:this.onRequeue,progress:this.onProgress,stop:this.onStop,complete:this.onComplete});this.ui={};this.ui.icon=new Asset.image(c.options.assetBasePath+"Icons/"+this.extension+".png",{onerror:function(){new Asset.image(c.options.assetBasePath+"Icons/default.png").replaces(this)}});this.ui.element=new Element("li",{"class":"file",id:"file-"+this.id});this.ui.title=new Element("span",{"class":"file-title",text:this.name});this.ui.size=new Element("span",{"class":"file-size",text:Swiff.Uploader.formatUnit(this.size,"b")});var e,g=this;this.ui.cancel=new Asset.image(c.options.assetBasePath+"cancel.png",{"class":"file-cancel",title:c.language.cancel}).addEvent("click",function(){g.remove();e.hide();e.detach(this)});e=new FileManager.Tips(this.ui.cancel);var f=new Element("img",{"class":"file-progress",src:c.options.assetBasePath+"bar.gif"});this.ui.element.adopt(this.ui.cancel,f,this.ui.icon,this.ui.title,this.ui.size).inject(c.upload.list).highlight();this.ui.progress=new Fx.ProgressBar(f).set(0);this.base.reposition();return this.parent()},onOpen:function(){this.ui.element.addClass("file-running")},onRemove:function(){this.ui=this.ui.element.destroy()},onProgress:function(){this.ui.progress.start(this.progress.percentLoaded)},onStop:function(){this.remove()},onComplete:function(){this.ui.progress=this.ui.progress.cancel().element.destroy();this.ui.cancel=this.ui.cancel.destroy();var e=JSON.decode(this.response.text);if(!e.status){new Dialog((""+e.error).substitute(c.language,/\\?\$\{([^{}]+)\}/g),{language:{confirm:c.language.ok},buttons:["confirm"]})}this.ui.element.set("tween",{duration:2000}).highlight(e.status?"#e6efc2":"#f0c2c2");(function(){this.ui.element.setStyle("overflow","hidden").morph({opacity:0,height:0}).get("morph").chain(function(){this.element.destroy();if(!c.upload.list.getElements("li").length){c.upload.uploader.fade(0).get("tween").chain(function(){c.fillInfo()})}})}).delay(5000,this)}});this.swf=new Swiff.Uploader({id:"SwiffFileManagerUpload",path:this.options.assetBasePath+"Swiff.Uploader.swf",queued:false,target:this.upload.button,allowDuplicates:true,instantStart:true,fileClass:a,fileSizeMax:25*1024*1024,onBrowse:function(){},onCancel:function(){},zIndex:this.SwiffZIndex||9999,onSelectSuccess:function(){c.fillInfo();c.info.getElement("h2.filemanager-headline").setStyle("display","none");c.preview.adopt(c.upload.uploader);c.upload.uploader.fade(1)},onComplete:function(){c.load(c.Directory,true)},onFail:function(e){$$(c.upload.button,c.upload.label).dispose();new Dialog(new Element("div",{html:c.language.flash[e]||c.language.flash.flash}),{language:{confirm:c.language.ok},buttons:["confirm"]})}})}});FileManager.Language.en={more:"Details",width:"Width:",height:"Height:",ok:"Ok",open:"Select file",upload:"Upload",create:"Create folder",createdir:"Please specify a folder name:",cancel:"Cancel",information:"Information",type:"Type:",size:"Size:",dir:"Path:",modified:"Last modified:",preview:"Preview",close:"Close",destroy:"Delete",destroyfile:"Are you sure to delete this file?",rename:"Rename",renamefile:"Please enter a new file name:",download:"Download",nopreview:"<i>No preview available</i>",title:"Title:",artist:"Artist:",album:"Album:",length:"Length:",bitrate:"Bitrate:",deselect:"Deselect",nodestroy:"Deleting files has been disabled on this Server.","upload.disabled":"Uploading has been disabled on this Server.","upload.authenticated":"You are not authenticated to upload files.","upload.path":"The specified Upload-Folder does not exist. Please contact the administrator of this Website.","upload.exists":"The specified Upload-Location does already exist. Please contact the administrator of this Website.","upload.mime":"The specified file-type is not allowed.","upload.extension":"The uploaded file has an unknown or forbidden file extension.","upload.size":"The size of the file you uploaded is too big to be processed on this server. Please upload a smaller file.","upload.partial":"The file you uploaded was only partially uploaded, please upload the file again.","upload.nofile":"There was no file specified to be uploaded.","upload.default":"Something went wrong with the File-Upload.",uploader:{unknown:"Unknown Error",sizeLimitMin:'You can not attach "<em>${name}</em>" (${size}), the file size minimum is <strong>${size_min}</strong>!',sizeLimitMax:'You can not attach "<em>${name}</em>" (${size}), the file size limit is <strong>${size_max}</strong>!'},flash:{hidden:"To enable the embedded uploader, unblock it in your browser and refresh (see Adblock).",disabled:"To enable the embedded uploader, enable the blocked Flash movie and refresh (see Flashblock).",flash:'In order to upload files you need to install <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Adobe Flash</a>.'},resizeImages:"Resize big images on upload"};