(function(a){function c(d,f,c,e){function b(e){var c=a("<li/>").attr("id",this.id||"").html("<span>"+this.text+"</span>").appendTo(e);this.classes&&c.children("span").addClass(this.classes);this.expanded&&c.addClass("open");if(this.hasChildren||this.children&&this.children.length){var d=a("<ul/>").appendTo(c);if(this.hasChildren){c.addClass("hasChildren");b.call({classes:"placeholder",text:"&nbsp;",children:[]},d)}this.children&&this.children.length&&a.each(this.children,b,[d])}}a.ajax(a.extend(true,{url:d.url,dataType:"json",data:{root:f},afterload:function(){},success:function(d){c.empty();a.each(d,b,[c]);a(e).treeview({add:c});this.afterload()}},d.ajax))}var b=a.fn.treeview;a.fn.treeview=function(d){if(!d.url)return b.apply(this,arguments);var e=this;!e.children().size()&&c(d,"source",this,e);var f=d.toggle;return b.call(this,a.extend({},d,{collapsed:true,toggle:function(){var b=a(this);if(b.hasClass("hasChildren")){var g=b.removeClass("hasChildren").find("ul");c(d,this.id,g,e)}f&&f.apply(this,arguments)}}))}})(jQuery)