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