(function(){var a;a=(function(){function b(){this.root=$("#root");this.goDirectoryList()}b.prototype.replace_view=function(c){return this.root.html(c)};b.prototype.go=function(c,e){var d=this;return $.get("/media/ajax/"+c,function(f){d.replace_view(f);return e()})};b.prototype.goDirectory=function(d){var c=this;this.currentDirectoryId=d;this.goBrowse("/");return;return this.go("directory/"+d,function(){c.root.find("#go-back").click(function(){return c.goDirectoryList()});return c.root.find("#go-browse").click(function(){return c.goBrowse("/")})})};b.prototype.goDirectoryList=function(){var c=this;return this.go("directory-list",function(){return c.root.find("a").each(function(d,f){return $(f).click(function(){return c.goDirectory($(f).attr("data-id"))})})})};b.prototype.goBrowse=function(c){var d=this;return this.go("browse/"+this.currentDirectoryId+"/"+c,function(){d.root.find("#go-back").click(function(){return d.goDirectoryList()});if(c==="/"){d.root.find("#go-up").hide();c=""}else{d.root.find("#go-up").click(function(){var e;e=c.split("/");e=e.splice(0,e.length-1);c=e.join("/");return d.goBrowse(c)})}return d.root.find("a.browse-item").each(function(f,g){return $(g).click(function(){c=c+"/"+$(g).attr("data-id");return d.goBrowse(c)})})})};return b})();$(function(){return new a()})}).call(this);