var bind=function(a,b){return function(){return a.apply(b,arguments)}};(function(b,a){var c;c=(function(){function d(g,e,j){this.onEvent=bind(this.onEvent,this);var f,i,h;f=b(g);i=this;h={root:"/",script:"/files/filetree",folderEvent:"click",expandSpeed:500,collapseSpeed:500,expandEasing:"swing",collapseEasing:"swing",multiFolder:true,loadMessage:"Loading...",errorMessage:"Unable to get file tree information",multiSelect:false,onlyFolders:false,onlyFiles:false,preventLinkAction:false};this.jqft={container:f};this.options=b.extend(h,e);this.callback=j;this.data={};f.html('");i.showTree(f,escape(this.options.root),function(){return i._trigger("filetreeinitiated",{})});f.delegate("li a",this.options.folderEvent,i.onEvent)}d.prototype.onEvent=function(h){var f,k,j,i,e,g;f=b(h.target);e=this.options;i=this.jqft;k=this;j=this.callback;k.data={};k.data.li=f.closest("li");k.data.type=(g=k.data.li.hasClass("directory"))!=null?g:{directory:"file"};k.data.value=f.text();k.data.rel=f.prop("rel");k.data.container=i.container;if(e.preventLinkAction){h.preventDefault()}if(f.parent().hasClass("directory")){k.jqft.container.find("LI.directory").removeClass("selected");f.parent().addClass("selected");if(f.parent().hasClass("collapsed")){if(!e.multiFolder){f.parent().parent().find("UL").slideUp({duration:e.collapseSpeed,easing:e.collapseEasing});f.parent().parent().find("LI.directory").removeClass("expanded").addClass("collapsed")}f.parent().removeClass("collapsed").addClass("expanded");f.parent().find("UL").remove();return k.showTree(f.parent(),f.attr("rel"),function(){k._trigger("filetreeexpanded",k.data);return j!=null})}else{return f.parent().find("UL").slideUp({duration:e.collapseSpeed,easing:e.collapseEasing,start:function(){return k._trigger("filetreecollapse",k.data)},complete:function(){f.parent().removeClass("expanded").addClass("collapsed");k._trigger("filetreecollapsed",k.data);return j!=null}})}}else{if(!e.multiSelect){i.container.find("li").removeClass("selected");f.parent().addClass("selected")}else{if(f.parent().find("input").is(":checked")){f.parent().find("input").prop("checked",false);f.parent().removeClass("selected")}else{f.parent().find("input").prop("checked",true);f.parent().addClass("selected")}}k._trigger("filetreeclicked",k.data);return typeof j==="function"?j(f.attr("rel")):void 0}};d.prototype.showTree=function(f,g,n){var m,i,h,e,j,l,k;m=b(f);l=this.options;i=this;m.addClass("wait");b(".jqueryFileTree.start").remove();h={dir:g,onlyFolders:l.onlyFolders,onlyFiles:l.onlyFiles,multiSelect:l.multiSelect};j=function(p){var o;m.find(".start").html("");m.removeClass("wait").append(p);if(l.root===g){m.find("UL:hidden").show(typeof callback!=="undefined"&&callback!==null)}else{if(jQuery.easing[l.expandEasing]===void 0){console.log("Easing library not loaded. Include jQueryUI or 3rd party lib.");l.expandEasing="swing"}m.find("UL:hidden").slideDown({duration:l.expandSpeed,easing:l.expandEasing,start:function(){return i._trigger("filetreeexpand",i.data)},complete:n})}o=b('[rel="'+decodeURIComponent(g)+'"]').parent();if(l.multiSelect&&o.children("input").is(":checked")){o.find("ul li input").each(function(){b(this).prop("checked",true);return b(this).parent().addClass("selected")})}return false};e=function(){m.find(".start").html("");m.removeClass("wait").append("

"+l.errorMessage+"

");return false};if(typeof l.script==="function"){k=l.script(h);if(typeof k==="string"||k instanceof jQuery){return j(k)}else{return e()}}else{return b.ajax({url:l.script,type:"POST",dataType:"HTML",data:h}).done(function(o){return j(o)}).fail(function(){return e()})}};d.prototype._trigger=function(f,g){var e;e=this.jqft.container;return e.triggerHandler(f,g)};return d})();return b.fn.extend({fileTree:function(d,e){return this.each(function(){var g,f;g=b(this);f=g.data("fileTree");if(!f){g.data("fileTree",(f=new c(this,d,e)))}if(typeof d==="string"){return f[option].apply(f)}})}})})(window.jQuery,window);