$(window).on("load",(function(){var t,e=d3.select("#collapsible-tree"),n={top:20,right:20,bottom:30,left:50},r=e.node().getBoundingClientRect().width-n.left-n.right,i=600-n.top-n.bottom,l=0,o=e.append("svg"),a=o.attr("width",r+n.left+n.right).attr("height",i+n.top+n.bottom).append("g").attr("transform","translate("+n.left+","+n.top+")"),c=d3.layout.tree().size([i,r-180]),d=d3.svg.diagonal().projection((function(t){return[t.y,t.x]}));function s(t){t.children?(t._children=t.children,t.children=null):(t.children=t._children,t._children=null)}d3.json("../../../app-assets/data/d3/tree/collapsible-tree.json",(function(f,u){(t=u).x0=i/2,t.y0=0,t.children.forEach((function t(e){e.children&&(e.children.forEach(t),s(e))})),s(t.children[1]),s(t.children[1].children[2]),s(t.children[9]),s(t.children[9].children[0]),function f(u){var h=d3.event&&d3.event.altKey?5e3:500,y=c.nodes(t).reverse(),p=a.selectAll(".d3-tree-node").data(y,(function(t){return t.id||(t.id=++l)})),g=p.enter().append("g").attr("class","d3-tree-node").attr("transform",(function(t){return"translate("+u.y0+","+u.x0+")"})).on("click",(function(t){s(t),f(t)}));g.append("circle").attr("r",1e-6).style("fill","#fff").style("stroke","#E84A5F").style("stroke-width",1.5).style("cursor","pointer").style("fill",(function(t){return t._children?"#E84A5F":"#fff"})),g.append("text").attr("x",(function(t){return t.children||t._children?-10:10})).attr("dy",".35em").style("text-anchor",(function(t){return t.children||t._children?"end":"start"})).style("font-size",12).style("fill-opacity",1e-6).text((function(t){return t.name}));var x=p.transition().duration(h).attr("transform",(function(t){return"translate("+t.y+","+t.x+")"}));x.select("circle").attr("r",4.5).style("fill",(function(t){return t._children?"#E84A5F":"#fff"})),x.select("text").style("fill-opacity",1);var v=p.exit().transition().duration(h).attr("transform",(function(t){return"translate("+u.y+","+u.x+")"})).remove();v.select("circle").attr("r",1e-6),v.select("text").style("fill-opacity",1e-6);var m=a.selectAll(".d3-tree-link").data(c.links(y),(function(t){return t.target.id}));function k(){r=e.node().getBoundingClientRect().width-n.left-n.right,y=c.nodes(t),links=c.links(y),o.attr("width",r+n.left+n.right),a.attr("width",r+n.left+n.right),c.size([i,r-180]),d.projection((function(t){return[t.y,t.x]})),a.selectAll(".d3-tree-link").attr("d",d),a.selectAll(".d3-tree-node").attr("transform",(function(t){return"translate("+t.y+","+t.x+")"}))}m.enter().insert("path","g").attr("class","d3-tree-link").style("fill","none").style("stroke","#e3e3e3").style("stroke-width",1.5).attr("d",(function(t){var e={x:u.x0,y:u.y0};return d({source:e,target:e})})).transition().duration(h).attr("d",d),m.transition().duration(h).attr("d",d),m.exit().transition().duration(h).attr("d",(function(t){var e={x:u.x,y:u.y};return d({source:e,target:e})})).remove(),y.forEach((function(t){t.x0=t.x,t.y0=t.y})),$(window).on("resize",k),$(".menu-toggle, .d3-tree-node circle").on("click",k)}(t)}))}));