diff --git a/css/pedigreejs.css b/css/pedigreejs.css
index a871565..0d1dd5f 100644
--- a/css/pedigreejs.css
+++ b/css/pedigreejs.css
@@ -8,3 +8,4 @@
.addsibling, .addchild {
cursor: default;
}
+svg {overflow:hidden}
diff --git a/dist/css/pedigreejs.min.css b/dist/css/pedigreejs.min.css
index 015b7fa..d4cd6a1 100644
--- a/dist/css/pedigreejs.min.css
+++ b/dist/css/pedigreejs.min.css
@@ -1 +1 @@
-.disabled{color:grey}.addparents,.addpartner,.delete,.popup_selection,.settings{cursor:pointer}.addchild,.addsibling{cursor:default}
\ No newline at end of file
+.disabled{color:grey}.addparents,.addpartner,.delete,.popup_selection,.settings{cursor:pointer}.addchild,.addsibling{cursor:default}svg{overflow:hidden}
\ No newline at end of file
diff --git a/dist/js/pedigreejs.min.js b/dist/js/pedigreejs.min.js
index a576a2e..00e7cfe 100644
--- a/dist/js/pedigreejs.min.js
+++ b/dist/js/pedigreejs.min.js
@@ -1,4 +1,4 @@
-/*! pedigreejs 2020-10-14 */
+/*! pedigreejs 2020-10-15 */
!function(a,b,c){a.isIE=function(){var a=navigator.userAgent;return a.indexOf("MSIE ")>-1||a.indexOf("Trident/")>-1},a.isEdge=function(){return navigator.userAgent.match(/Edge/g)},a.getFormattedDate=function(a){var b=new Date;return a?("0"+b.getHours()).slice(-2)+":"+("0"+b.getMinutes()).slice(-2)+":"+("0"+b.getSeconds()).slice(-2):b.getFullYear()+"-"+("0"+(b.getMonth()+1)).slice(-2)+"-"+("0"+b.getDate()).slice(-2)+" "+("0"+b.getHours()).slice(-2)+":"+("0"+b.getMinutes()).slice(-2)+":"+("0"+b.getSeconds()).slice(-2)},a.messages=function(a,c,d,e,f){d?b('
'+c+"
").dialog({modal:!0,title:a,width:350,buttons:{Yes:function(){b(this).dialog("close"),d(e,f)},No:function(){b(this).dialog("close")}}}):b(''+c+"
").dialog({title:a,width:350,buttons:[{text:"OK",click:function(){b(this).dialog("close")}}]})},a.validate_age_yob=function(a,b,c){var d=(new Date).getFullYear(),e=parseInt(a)+parseInt(b);return 1==c?d>=e:Math.abs(d-e)<=1&&d>=e},a.capitaliseFirstLetter=function(a){return a.charAt(0).toUpperCase()+a.slice(1)}}(window.utils=window.utils||{},jQuery),function(a,b,c){function d(a,c){return b.grep(a,function(a){return a&&a.name==c})[0]}function e(a){for(var b=0;b<2;b++)for(var c=0;cd&&(d=a[c].level);for(c=0;c-1&&a[e].mother&&(a[c].mother=a[e].mother,a[c].father=a[e].father),!a[c].mother)for(var b=0;b-1&&(a[c].mother="F"===a[b].sex?a[b].name:a[e].name,a[c].father="M"===a[b].sex?a[b].name:a[e].name)}else delete a[c].top_level;return a}function f(a,b){for(var c=0;c=0){var g=c[pedigree_util.getIdxByName(c,c[a].mother)],i=c[pedigree_util.getIdxByName(c,c[a].father)];(!c[f].level||c[f].level ";window.open().document.write(b)}else{var c=document.createElement("a");c.href=a.img,c.download="plot.png",c.target="_blank",document.body.appendChild(c),c.click(),document.body.removeChild(c)}})})},a.svg2png=function(a,c,d){var e,f=b.Deferred();void 0!==window.XMLSerializer?e=(new XMLSerializer).serializeToString(a.get(0)):void 0!==a.xml&&(e=a.get(0).xml);var g="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),h=document.createElement("canvas"),i=h.getContext("2d");h.width=a.width(),h.height=a.height();var j=document.createElement("img");return j.onload=function(){utils.isIE()||d?(e=e.replace(/ font-size="\d?.\d*em"/g,""),e=e.replace(/595||e.height>842){var g=e.width,h=e.height+100,i=1;if(e.width>595||e.height>842){e.width>595&&(g=595),e.height>842&&(h=842);var j=g/e.width,k=h/e.height;i=j"),svg=b("#"+a.targetDiv).find("svg").clone().appendTo(f),svg.attr("width",g),svg.attr("height",h);var l=1.5*-a.symbol_size*i;svg.find(".diagram").attr("transform","translate(0, "+l+") scale("+i+")")}return f},a.svg_download=function(a){var b=document.createElement("a");b.href="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a.html()))),b.download="plot.svg",b.target="_blank",document.body.appendChild(b),b.click(),document.body.removeChild(b)},a.print=function(a,c){a.constructor!==Array&&(a=[a]);for(var d=.9*b(window).width(),e=b(window).height()-10,f=["/static/css/canrisk.css","https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css"],g=window.open("","PrintMap","width="+d+",height="+e),h="",i=0;i';for(h+="",html="",i=0;i ');g.document.write(h),g.document.write(html),g.document.close(),g.focus(),setTimeout(function(){g.print(),g.close()},300)},a.save_file=function(a,b,c,d){a.DEBUG&&console.log(b),c||(c="ped.txt"),d||(d="text/plain");var e=new Blob([b],{type:d});if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(e,c);else{var f=document.createElement("a"),g=URL.createObjectURL(e);f.href=g,f.download=c,document.body.appendChild(f),f.click(),setTimeout(function(){document.body.removeChild(f),window.URL.revokeObjectURL(g)},0)}},a.save=function(b){var c=JSON.stringify(pedcache.current(b));a.save_file(b,c)},a.save_canrisk=function(b,c){a.save_file(b,run_prediction.get_non_anon_pedigree(pedcache.current(b),c),"canrisk.txt")},a.canrisk_validation=function(c){b.each(c.dataset,function(b,c){if(!c.hidden&&"M"===c.sex&&!pedigree_util.isProband(c)&&c[a.cancers.breast_cancer2]){var d="Male family member ("+c.display_name+") with contralateral breast cancer found. Please note that as the risk models do not take this into account the second breast cancer is ignored.";console.error(d),delete c[a.cancers.breast_cancer2],utils.messages("Warning",d)}})},a.load=function(d,e){var f=d.target.files[0];if(f){var g=new FileReader;g.onload=function(d){e.DEBUG&&console.log(d.target.result);try{if(d.target.result.startsWith("BOADICEA import pedigree file format 4.0"))e.dataset=a.readBoadiceaV4(d.target.result,4),a.canrisk_validation(e);else if(d.target.result.startsWith("BOADICEA import pedigree file format 2.0"))e.dataset=a.readBoadiceaV4(d.target.result,2),a.canrisk_validation(e);else if(d.target.result.startsWith("##")&&-1!==d.target.result.indexOf("CanRisk")){var f=a.readCanRiskV1(d.target.result),g=f[0];e.dataset=f[1],a.canrisk_validation(e)}else try{e.dataset=JSON.parse(d.target.result)}catch(b){e.dataset=a.readLinkage(d.target.result)}ptree.validate_pedigree(e)}catch(a){return console.error(a,d.target.result),void utils.messages("File Error",a.message?a.message:a)}console.log(e.dataset);try{ptree.rebuild(e),g!==c&&(console.log(g),b(document).trigger("riskfactorChange",[e,g])),b(document).trigger("fhChange",[e]);try{acc_FamHist_ticked(),acc_FamHist_Leave(),RESULT.FLAG_FAMILY_MODAL=!0}catch(a){}}catch(a){utils.messages("File Error",a.message?a.message:a)}},g.onerror=function(a){utils.messages("File Error","File could not be read! Code "+a.target.error.code)},g.readAsText(f)}else console.error("File could not be read!");b("#load")[0].value=""},a.readLinkage=function(a){for(var c,d=a.trim().split("\n"),f=[],g=0;g6){j.alleles="";for(var k=6;k-1)for(var j=i.split(";"),k=1;k1){var o={famid:n[0],display_name:n[1],name:n[3],sex:n[6],status:n[8]};1==n[2]&&(o.proband=!0),"0"!==n[4]&&(o.father=n[4]),"0"!==n[5]&&(o.mother=n[5]),"0"!==n[7]&&(o.mztwin=n[7]),"0"!==n[9]&&(o.age=n[9]),"0"!==n[10]&&(o.yob=n[10]);var p=11;b.each(a.cancers,function(a,b){"0"!==n[p]&&(o[b]=n[p]),p++}),"0"!==n[p++]&&(o.ashkenazi=1);for(var k=0;k1){var j={famid:i[0],display_name:i[1],name:i[3],sex:i[6],status:i[8]};1==i[2]&&(j.proband=!0),"0"!==i[4]&&(j.father=i[4]),"0"!==i[5]&&(j.mother=i[5]),"0"!==i[7]&&(j.mztwin=i[7]),"0"!==i[9]&&(j.age=i[9]),"0"!==i[10]&&(j.yob=i[10]);var k=11;if(b.each(a.cancers,function(a,b){"0"!==i[k]&&(j[b]=i[k]),k++}),4===d){"0"!==i[k++]&&(j.ashkenazi=1);for(var l=0;l<5;l++)k+=2,"0"!==i[k-2]&&("S"!==i[k-2]&&"T"!==i[k-2]||"P"!==i[k-1]&&"N"!==i[k-1]?console.warn("UNRECOGNISED GENE TEST ON LINE "+(h+1)+": "+i[k-2]+" "+i[k-1]):j[a.genetic_test[l]+"_gene_test"]={type:i[k-2],result:i[k-1]})}else 2===d&&(k+=2,"0"!==i[k-2]&&("S"===i[k-2]||"T"===i[k-2]?"N"===i[k-1]?(j.brca1_gene_test={type:i[k-2],result:"N"},j.brca2_gene_test={type:i[k-2],result:"N"}):"1"===i[k-1]?(j.brca1_gene_test={type:i[k-2],result:"P"},j.brca2_gene_test={type:i[k-2],result:"N"}):"2"===i[k-1]?(j.brca1_gene_test={type:i[k-2],result:"N"},j.brca2_gene_test={type:i[k-2],result:"P"}):"3"===i[k-1]&&(j.brca1_gene_test={type:i[k-2],result:"P"},j.brca2_gene_test={type:i[k-2],result:"P"}):console.warn("UNRECOGNISED GENE TEST ON LINE "+(h+1)+": "+i[k-2]+" "+i[k-1])),"0"!==i[k++]&&(j.ashkenazi=1));for(l=0;l=0&&("mother"in b[d]||b[d].top_level);)d=a.getIdxByName(b,b[d].mother),e++;return e},a.getIdxByName=function(a,c){var d=-1;return b.each(a,function(a,b){if(c===b.name)return d=a}),d},a.getNodesAtDepth=function(a,c,d){return b.map(a,function(a,e){return a.depth!=c||a.data.hidden||-1!=b.inArray(a.data.name,d)?null:a}).sort(function(a,b){return a.x-b.x})},a.linkNodes=function(b,c){for(var d=[],e=0;ei.x&&h.x>j.x)&&(h.x=k);else{h.x=k;var l=h.x-k;if(2==h.children.length&&(h.children[0].data.hidden||h.children[1].data.hidden)){if(!h.children[0].data.hidden||!h.children[1].data.hidden){var m=h.children[0].data.hidden?h.children[1]:h.children[0],n=h.children[0].data.hidden?h.children[0]:h.children[1];(m.xn.x&&k>n.x)&&!a.overlap(b,d.descendants(),k,m.depth,[m.data.name])&&(m.x=k)}}else if(1!=h.children.length||h.children[0].data.hidden){if(0!==l&&!g(b,h,l,d))if(1==h.children.length)h.children[0].x=k;else{var o=h.descendants();b.DEBUG&&console.log("ADJUSTING "+h.data.name+" NO. DESCENDANTS "+o.length+" diff="+l);for(var p=0;p");for(var d,e=0;e";for(d in a.dataset[e])"name"!==d&&("parent"===d?f+=""+d+":"+a.dataset[e][d].name+"; ":"children"===d?a.dataset[e][d][0]!==c&&(f+=""+d+":"+a.dataset[e][d][0].name+"; "):f+=""+d+":"+a.dataset[e][d]+"; ");b("#pedigree_data").append(f+"
")}b("#pedigree_data").append(" ");for(d in a)"dataset"!==d&&b("#pedigree_data").append(""+d+":"+a[d]+"; ")}}(window.pedigree_util=window.pedigree_util||{},jQuery),function(a,b,c){function d(a,c){var d=!1;return c&&b.each(c,function(b,c){if(0===b.indexOf(a+"_")||b===a)return d=!0}),d}function e(a,c,d){if(-1!=b.inArray(c.name,a)){f(a,i(d,c));var e=pedigree_util.getAllChildren(d,c);b.each(e,function(c,e){-1==b.inArray(e.name,a)&&(a.push(e.name),f(a,i(d,e)))})}}function f(a,c){for(var d=0;d0;--c)j.unshift(d[c-1]);return j}function k(a){var c=a.font_size;return c===parseInt(c,10)?c:c.indexOf("px")>-1?c.replace("px",""):-1===c.indexOf("em")?c:(c=parseFloat(c.replace("em","")),parseFloat(getComputedStyle(b("#"+a.targetDiv).get(0)).fontSize)*c-1)}function l(a,b,c,d,e,f,g){b.filter(function(b){return!(b.data.hidden&&!a.DEBUG)}).append("text").attr("class",g+" ped_label"||"ped_label").attr("x",d).attr("y",e).attr("font-family",a.font_family).attr("font-size",a.font_size).attr("font-weight",a.font_weight).text(f)}function m(a,b,c,d){return!(!b[d]&&(b[d]=n(a,d),!b[d]))&&(c[d]=b[d],b.yob&&(c.yob=b.yob),!b.age||0!=b.status&&b.status||(c.age=b.age),!0)}function n(a,b){for(var d=[1,2,3,4,5,6,7,8,9,"A"],e=0;e-1&&d.splice(f,1)}return d.length>0?d[0]:c}function o(a){for(var b=["mztwin","dztwin"],c=0;cb.x&&(e=f[g]);return[d,e]}a.roots={},a.build=function(e){function f(){var a=d3.event.transform;if(!(utils.isIE()&&a.x.toString().length>10)){var b=[a.x+parseInt(p),a.y+parseInt(q)];1==a.k?pedcache.setposition(i,b[0],b[1]):pedcache.setposition(i,b[0],b[1],a.k),s.attr("transform","translate("+b[0]+","+b[1]+") scale("+a.k+")")}}var i=b.extend({targetDiv:"pedigree_edit",dataset:[{name:"m21",display_name:"father",sex:"M",top_level:!0},{name:"f21",display_name:"mother",sex:"F",top_level:!0},{name:"ch1",display_name:"me",sex:"F",mother:"f21",father:"m21",proband:!0}],width:600,height:400,symbol_size:35,zoomIn:1,zoomOut:1,diseases:[{type:"breast_cancer",colour:"#F68F35"},{type:"breast_cancer2",colour:"pink"},{type:"ovarian_cancer",colour:"#4DAA4D"},{type:"pancreatic_cancer",colour:"#4289BA"},{type:"prostate_cancer",colour:"#D5494A"}],labels:["stillbirth","age","yob","alleles"],keep_proband_on_reset:!1,font_size:".75em",font_family:"Helvetica",font_weight:700,background:"#EEE",node_background:"#fdfdfd",validate:!0,DEBUG:!1},e);0===b("#fullscreen").length&&(pbuttons.add(i),io.add(i)),-1==pedcache.nstore(i)&&pedcache.add(i),pbuttons.updateButtons(i),a.validate_pedigree(i),i.dataset=j(i.dataset),i.DEBUG&&pedigree_util.print_opts(i);var m=h(i),n=d3.select("#"+i.targetDiv).append("svg:svg").attr("width",m.width).attr("height",m.height);n.append("rect").attr("width","100%").attr("height","100%").attr("rx",6).attr("ry",6).style("stroke","darkgrey").style("fill",i.background).style("stroke-width",1);var o=pedcache.getposition(i),p=o[0],q=o[1],r=1;3==o.length&&(r=o[2]),null!==p&&null!==q||(p=i.symbol_size/2,q=2.5*-i.symbol_size);var s=n.append("g").attr("class","diagram").attr("transform","translate("+p+","+q+") scale("+r+")"),t=b.map(i.dataset,function(a,b){return"top_level"in a&&a.top_level?a:null}),u={name:"hidden_root",id:0,hidden:!0,children:t},v=pedigree_util.buildTree(i,u,u)[0],w=d3.hierarchy(u);a.roots[i.targetDiv]=w;var x=a.get_tree_dimensions(i);i.DEBUG&&console.log("opts.width="+m.width+" width="+x.width+" opts.height="+m.height+" height="+x.height);var y=d3.tree().separation(function(a,b){return a.parent===b.parent||a.data.hidden||b.data.hidden?1.2:2.2}).size([x.width,x.height]),z=y(w.sort(function(a,b){return a.data.id-b.data.id})),A=z.descendants();if(b.map(i.dataset,function(a,b){return a.hidden?null:a}).length!=i.dataset.length)throw create_err("NUMBER OF VISIBLE NODES DIFFERENT TO NUMBER IN THE DATASET");pedigree_util.adjust_coords(i,z,A);var B=pedigree_util.linkNodes(A,v);g(i,B);var C=s.selectAll(".node").data(z.descendants()).enter().append("g").attr("transform",function(a,b){return"translate("+a.x+","+a.y+")"});C.append("path").filter(function(a){return!a.data.hidden}).attr("shape-rendering","geometricPrecision").attr("transform",function(a){return"U"!=a.data.sex||a.data.miscarriage||a.data.termination?"":"rotate(45)"}).attr("d",d3.symbol().size(function(a){return i.symbol_size*i.symbol_size+2}).type(function(a){return a.data.miscarriage||a.data.termination?d3.symbolTriangle:"F"==a.data.sex?d3.symbolCircle:d3.symbolSquare})).style("stroke",function(a){return a.data.age&&a.data.yob&&!a.data.exclude?"#303030":"grey"}).style("stroke-width",function(a){return a.data.age&&a.data.yob&&!a.data.exclude?".3em":".1em"}).style("stroke-dasharray",function(a){return a.data.exclude?"3, 3":null}).style("fill","none"),C.append("clipPath").attr("id",function(a){return a.data.name}).append("path").filter(function(a){return!(a.data.hidden&&!i.DEBUG)}).attr("class","node").attr("transform",function(a){return"U"!=a.data.sex||a.data.miscarriage||a.data.termination?"":"rotate(45)"}).attr("d",d3.symbol().size(function(a){return a.data.hidden?i.symbol_size*i.symbol_size/5:i.symbol_size*i.symbol_size}).type(function(a){return a.data.miscarriage||a.data.termination?d3.symbolTriangle:"F"==a.data.sex?d3.symbolCircle:d3.symbolSquare})),C.selectAll("pienode").data(function(a){var c=0,e=b.map(i.diseases,function(b,e){return d(i.diseases[e].type,a.data)?(c++,1):0});return 0===c&&(e=[1]),[b.map(e,function(b,d){return{cancer:b,ncancers:c,id:a.data.name,sex:a.data.sex,proband:a.data.proband,hidden:a.data.hidden,affected:a.data.affected,exclude:a.data.exclude}})]}).enter().append("g").selectAll("path").data(d3.pie().value(function(a){return a.cancer})).enter().append("path").attr("clip-path",function(a){return"url(#"+a.data.id+")"}).attr("class","pienode").attr("d",d3.arc().innerRadius(0).outerRadius(i.symbol_size)).style("fill",function(a,b){return a.data.exclude?"lightgrey":0===a.data.ncancers?a.data.affected?"darkgrey":i.node_background:i.diseases[b].colour}),C.append("path").filter(function(a){return!a.data.hidden&&(a.data.adopted_in||a.data.adopted_out)}).attr("d",function(a){function b(a,b,c){return"M"+(a+c)+","+b+"L"+a+" "+b+"L"+a+" "+(b+1.28*i.symbol_size)+"L"+a+" "+(b+1.28*i.symbol_size)+"L"+(a+c)+","+(b+1.28*i.symbol_size)}var c=-.66*i.symbol_size,d=-.64*i.symbol_size,e=i.symbol_size/4;return b(c,d,e)+b(-c,d,-e)}).style("stroke",function(a){return a.data.age&&a.data.yob&&!a.data.exclude?"#303030":"grey"}).style("stroke-width",function(a){return".1em"}).style("stroke-dasharray",function(a){return a.data.exclude?"3, 3":null}).style("fill","none");C.append("line").filter(function(a){return 1==a.data.status}).style("stroke","black").attr("x1",function(a,b){return-.6*i.symbol_size}).attr("y1",function(a,b){return.6*i.symbol_size}).attr("x2",function(a,b){return.6*i.symbol_size}).attr("y2",function(a,b){return-.6*i.symbol_size});l(i,C,".25em",-.4*i.symbol_size,-.1*i.symbol_size,function(a){return i.DEBUG?("display_name"in a.data?a.data.display_name:a.data.name)+" "+a.data.id:"display_name"in a.data?a.data.display_name:""});for(var D=parseInt(k(i))+4,E=0;Ej&&e.x.1)return"M"+h+","+k+"L"+j+","+s+"M"+h+","+(k-u)+"L"+j+","+(s-u);return"M"+h+","+k+m+"L"+j+","+k+"M"+h+","+(k-u)+(l?draw_path(l,n,k,s,r,u):"")+"L"+j+","+(k-u)+t}return"M"+h+","+k+m+"L"+j+","+k+t});var J=(s.selectAll(".link").data(w.links(z.descendants())).enter().filter(function(a){return i.DEBUG||a.target.data.noparents===c&&null!==a.source.parent&&!a.target.data.hidden}).insert("path","g").attr("fill","none").attr("stroke-width",function(a,b){return a.target.data.noparents!==c||null===a.source.parent||a.target.data.hidden?1:i.DEBUG?2:1}).attr("stroke",function(a,b){return a.target.data.noparents!==c||null===a.source.parent||a.target.data.hidden?"pink":"#000"}).attr("stroke-dasharray",function(a,c){if(!a.target.data.adopted_in)return null;var d=Math.abs(a.source.y-(a.source.y+a.target.y)/2),e=[d,0,Math.abs(a.source.x-a.target.x),0];pedigree_util.getTwins(i.dataset,a.target.data).length>=1&&(d*=3);for(var f=0;f=1){for(var d=0,e=a.target.x,f=a.target.x,g=0;gh&&(e=h),f-1)throw d("IndivID for family member "+h+" is not unique.");e.push(c.dataset[g].name),-1===b.inArray(c.dataset[g].famid,f)&&c.dataset[g].famid&&f.push(c.dataset[g].famid)}if(f.length>1)throw d("More than one family found: "+f.join(", ")+".");var m=a.unconnected(c.dataset);m.length>0&&console.warn("individuals unconnected to pedigree ",m)}},a.unconnected=function(a){var c=a[pedigree_util.getProbandIndex(a)];if(!c){if(console.warn("No target defined"),0==a.length)throw"empty pedigree data set";c=a[0]}for(var d=[c.name],f=!0,g=0;f&&g<200;){g++;var h=d.length;b.each(a,function(f,g){if(-1!=b.inArray(g.name,d)){for(var h=i(a,g),j=g.name===c.name||!g.noparents,k=0;ki&&a.x0?l:null},a.get_tree_dimensions=function(a){for(var b=h(a),c=0,d={},e=0;e0?.55+.25*g.length:0)+(a.dataset[e].father?.25:0);f in d?d[f]+=i:d[f]=i,d[f]>c&&(c=d[f])}var j=Object.keys(d).length*a.symbol_size*3.5;return{width:b.width-a.symbol_size>c*a.symbol_size*1.65?b.width-a.symbol_size:c*a.symbol_size*1.65,height:b.height-a.symbol_size>j?b.height-a.symbol_size:j}},a.rebuild=function(c){b("#"+c.targetDiv).empty(),pedcache.add(c);try{a.build(c)}catch(a){throw console.error(a),a}try{templates.update(c)}catch(a){}},a.copy_dataset=function(a){a[0].id&&a.sort(function(a,b){return a.id&&b.id?a.id>b.id?1:b.id>a.id?-1:0:0});for(var b=["id","parent_node"],c=[],d=0;d0&&i--:i++,c.splice(i,0,h),h},a.syncTwins=function(a,b){if(b.mztwin||b.dztwin)for(var c=b.mztwin?"mztwin":"dztwin",d=0;d0&&(g=n[0].mother==k.name?n[0].father:n[0].mother,m=pedigree_util.getNodeByName(i,g).data.id);var o;if(1==l)for(e={name:a.makeid(4),sex:"F",top_level:!0},f={name:a.makeid(4),sex:"M",top_level:!0},c.splice(0,0,e),c.splice(0,0,f),o=0;oj.data.id&&(s=u),u=j.data.id||m==t&&s<1e4;b.DEBUG&&console.log("lid="+t+" rid="+s+" nid="+j.data.id+" ADD_LHS="+v);var w;w=!v&&q.data.id>p.data.id||v&&q.data.idz){var A=c[y];c[y]=c[z],c[z]=A}var B=pedigree_util.getAdoptedSiblings(c,k),C=j.data.id;for(o=0;o0&&(v=pedigree_util.getNodeByName(d,w[0])),v&&v.mother!==u.mother)u.mother=v.mother,u.father=v.father;else if(v){var x=pedigree_util.getNodeByName(l,u.name),y=p(k,x,t);u.mother=y[0]?y[0].data.mother:y[1]?y[1].data.mother:null,u.father=y[0]?y[0].data.father:y[1]?y[1].data.father:null}else d.splice(pedigree_util.getIdxByName(d,u.name),1)}}}else d.splice(pedigree_util.getIdxByName(d,e.name),1);for(console.log(m),h=0;h0&&0===a.unconnected(f.dataset).length?(console.error("individuals unconnected to pedigree ",E),void utils.messages("Warning","Deleting this will split the pedigree. Continue?",g,f,d)):(g&&g(f,d),d)},a.makeid=function(a){for(var b="",c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",d=0;d'+"You are about to switch the index family member. Risk factor information (e.g. BMI etc) will be cleared for the current index. Ensure you have saved the pedigree file before continuing."+"").dialog({title:"WARNING - save before continuing",width:350,buttons:{Continue:function(){b(this).dialog("close");var a=pedcache.current(opts);opts.dataset=ptree.copy_dataset(a),pedigree_util.setProband(opts.dataset,c,!0),ptree.rebuild(opts),reset_n_sync(opts),b("#id_proband").prop("disabled",!0)},Cancel:function(){b(this).dialog("close"),b("#id_proband").prop("checked",!1),b("#id_proband").prop("disabled",!1)}}})}else if("id_exclude"===b(this).attr("id")){var d=pedcache.current(opts);opts.dataset=ptree.copy_dataset(d);var e=pedigree_util.getIdxByName(opts.dataset,c);b(this).is(":checked")?opts.dataset[e].exclude=!0:delete opts.dataset[e].exclude,ptree.rebuild(opts)}}),a.update=function(c){b(".node_save").click(function(){a.save(c)}),b("input[id$='_mut_sensitivity'], input[id$='_mut_frequency']").prop("disabled",!0),b("#id_use_custom_mutation_sensitivities").change(function(){b("input[id$='_mut_sensitivity']").prop("disabled",!b(this).is(":checked"))}),b("#id_mutation_frequencies").change(function(){if(b("input[id$='_mut_frequency']").prop("disabled","Custom"!==this.value),a.bc_mutation_frequencies&&"Custom"!==this.value){var d=a.bc_mutation_frequencies[this.value];for(var e in d)b("#id_"+e.toLowerCase()+"_bc_mut_frequency").val(d[e]);var f=a.oc_mutation_frequencies[this.value];for(var e in f)b("#id_"+e.toLowerCase()+"_oc_mut_frequency").val(f[e])}"Ashkenazi"===this.value?b("#orig_ashk").prop("checked",!0):b("#orig_unk").prop("checked",!0),a.save_ashkn(c)})},b(document).on("fhChange",function(a,d){try{var e=b("#id_name").val();pedigree_util.getNodeByName(pedcache.current(d),e)===c?b("form > fieldset").prop("disabled",!0):b("form > fieldset").prop("disabled",!1)}catch(a){console.warn(a)}}),a.updateStatus=function(a){b("#age_yob_lock").removeClass("fa-lock fa-unlock-alt"),1==a?b("#age_yob_lock").addClass("fa-unlock-alt"):b("#age_yob_lock").addClass("fa-lock"),b("#id_age_"+a).removeClass("hidden"),b("#id_age_"+(1==a?"0":"1")).addClass("hidden")},a.nodeclick=function(c){b("form > fieldset").prop("disabled",!1),b("#person_details").find("input[type=text], input[type=number]").val(""),b("#person_details select").val("").prop("selected",!0),"M"===c.sex||"F"===c.sex?b('input[name=sex][value="'+c.sex+'"]').prop("checked",!0):b("input[name=sex]").prop("checked",!1),e(c),"status"in c||(c.status=0),b('input[name=status][value="'+c.status+'"]').prop("checked",!0),a.updateStatus(c.status),"proband"in c?(b("#id_proband").prop("checked",c.proband),b("#id_proband").prop("disabled",!0)):(b("#id_proband").prop("checked",!1),b("#id_proband").prop("disabled",!("yob"in c))),"exclude"in c?b("#id_exclude").prop("checked",c.exclude):b("#id_exclude").prop("checked",!1),"yob"in c?b("#id_yob_0").val(c.yob):b("#id_yob_0").val("-"),b('select[name$="_bc_pathology"]').val("-"),b('select[name*="_gene_test"]').val("-"),b("input[id^='id_sex_']").prop("disabled",!(!c.parent_node||"U"===c.sex)),b("select[id$='_bc_pathology']").prop("disabled","M"===c.sex||!("F"!==c.sex||"breast_cancer_diagnosis_age"in c)),b("#id_approx").prop("checked",!!c.approx_diagnosis_age),a.update_diagnosis_age_widget();for(var d in c)"proband"!==d&&"sex"!==d&&(b("#id_"+d).length?-1!==d.indexOf("_gene_test")&&null!==c[d]&&"object"==typeof c[d]?(b("#id_"+d).val(c[d].type),b("#id_"+d+"_result").val(c[d].result)):b("#id_"+d).val(c[d]):-1!==d.indexOf("_diagnosis_age")&&(b("#id_approx").is(":checked")?b("#id_"+d+"_1").val(f(c[d])).prop("selected",!0):b("#id_"+d+"_0").val(c[d])));try{b("#person_details").find("form").valid()}catch(a){console.warn("valid() not found")}},a.save_ashkn=function(a){var b=pedcache.current(a),c=ptree.copy_dataset(b);d(c),a.dataset=c,ptree.rebuild(a)},a.save=function(a){var c=pedcache.current(a),g=b("#id_name").val(),h=ptree.copy_dataset(c),i=pedigree_util.getNodeByName(h,g);if(!i)return void console.warn("person not found when saving details");b("#"+a.targetDiv).empty();var j=b("#id_yob_0").val();j&&""!==j?i.yob=j:delete i.yob;var k=b("#id_status").find("input[type='radio']:checked");k.length>0&&(i.status=k.val());for(var l=["miscarriage","adopted_in","adopted_out","termination","stillbirth"],m=0;m0&&(console.log(o.is(":checked")),o.is(":checked")?i[n]=!0:delete i[n])}var p=b("#id_sex").find("input[type='radio']:checked");p.length>0&&(i.sex=p.val(),e(i)),d(h),b("#id_approx").is(":checked")?i.approx_diagnosis_age=!0:delete i.approx_diagnosis_age,b("#person_details select[name*='_diagnosis_age']:visible, #person_details input[type=text]:visible, #person_details input[type=number]:visible").each(function(){var a=this.name.indexOf("_diagnosis_age")>-1?this.name.substring(0,this.name.length-2):this.name;if(b(this).val()){var c=b(this).val();a.indexOf("_diagnosis_age")>-1&&b("#id_approx").is(":checked")&&(c=f(c)),i[a]=c}else delete i[a]}),b('#person_details input[type="checkbox"][name$="cancer"],input[type="checkbox"][name$="cancer2"]').each(function(){this.checked?i[b(this).attr("name")]=!0:delete i[b(this).attr("name")]}),b('#person_details select[name$="_bc_pathology"]').each(function(){"-"!==b(this).val()?i[b(this).attr("name")]=b(this).val():delete i[b(this).attr("name")]}),b('#person_details select[name$="_gene_test"]').each(function(){if("-"!==b(this).val()){var a=b('select[name="'+b(this).attr("name")+'_result"]');i[b(this).attr("name")]={type:b(this).val(),result:b(a).val()}}else delete i[b(this).attr("name")]});try{b("#person_details").find("form").valid()}catch(a){console.warn("valid() not found")}ptree.syncTwins(h,i),a.dataset=h,ptree.rebuild(a)},a.update_diagnosis_age_widget=function(){b("#id_approx").is(":checked")?(b("[id$='_diagnosis_age_0']").each(function(a){if(""!==b(this).val()){var c=this.name.substring(0,this.name.length-2);b("#id_"+c+"_1").val(f(b(this).val())).prop("selected",!0)}}),b("[id$='_diagnosis_age_0']").hide(),b("[id$='_diagnosis_age_1']").show()):(b("[id$='_diagnosis_age_1']").each(function(a){if(""!==b(this).val()){var c=this.name.substring(0,this.name.length-2);b("#id_"+c+"_0").val(b(this).val())}}),b("[id$='_diagnosis_age_0']").show(),b("[id$='_diagnosis_age_1']").hide())}}(window.pedigree_form=window.pedigree_form||{},jQuery),function(a,b,c){function d(d){b(document).on("webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange",function(a){var b=pedcache.current(d);b!==c&&null!==b&&(d.dataset=b),ptree.rebuild(d)}),b("#fullscreen").on("click",function(a){if(document.mozFullScreen||document.webkitFullScreen)document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen();else{var c=b("#"+d.targetDiv)[0];c.mozRequestFullScreen?c.mozRequestFullScreen():c.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}}),b("#"+d.btn_target).on("click",function(c){if(c.stopPropagation(),b(c.target).hasClass("disabled"))return!1;b(c.target).hasClass("fa-undo")?(d.dataset=pedcache.previous(d),b("#"+d.targetDiv).empty(),ptree.build(d)):b(c.target).hasClass("fa-repeat")?(d.dataset=pedcache.next(d),b("#"+d.targetDiv).empty(),ptree.build(d)):b(c.target).hasClass("fa-refresh")&&b('Resetting the pedigree may result in loss of some data.
').dialog({title:"Confirm Reset",resizable:!1,height:"auto",width:400,modal:!0,buttons:{Continue:function(){a.reset(d,d.keep_proband_on_reset),b(this).dialog("close")},Cancel:function(){b(this).dialog("close")}}}),b(document).trigger("fhChange",[d])})}a.add=function(a){for(var c=b.extend({btn_target:"pedigree_history"},a),e=[{fa:"fa-undo",title:"undo"},{fa:"fa-repeat",title:"redo"},{fa:"fa-refresh",title:"reset"},{fa:"fa-arrows-alt",title:"fullscreen"}],f="",g=0;g',f+=' ',f+="";b("#"+c.btn_target).append(f),d(c)},a.is_fullscreen=function(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement},a.reset=function(a,c){if(c){var d=pedcache.current(a),e=ptree.copy_dataset(d),f=e[pedigree_util.getProbandIndex(e)];f.name="ch1",f.mother="f21",f.father="m21",pedcache.clear_pedigree_data(a)}else{var f={name:"ch1",sex:"F",mother:"f21",father:"m21",proband:!0,status:"0",display_name:"me"};pedcache.clear(a)}delete a.dataset;var g=b("input[name='default_fam']:checked");g.length>0&&"extended2"==g.val()?a.dataset=[{name:"wZA",sex:"M",top_level:!0,status:"0",display_name:"paternal grandfather"},{name:"MAk",sex:"F",top_level:!0,status:"0",display_name:"paternal grandmother"},{name:"zwB",sex:"M",top_level:!0,status:"0",display_name:"maternal grandfather"},{name:"dOH",sex:"F",top_level:!0,status:"0",display_name:"maternal grandmother"},{name:"MKg",sex:"F",mother:"MAk",father:"wZA",status:"0",display_name:"paternal aunt"},{name:"xsm",sex:"M",mother:"MAk",father:"wZA",status:"0",display_name:"paternal uncle"},{name:"m21",sex:"M",mother:"MAk",father:"wZA",status:"0",display_name:"father"},{name:"f21",sex:"F",mother:"dOH",father:"zwB",status:"0",display_name:"mother"},{name:"aOH",sex:"F",mother:"f21",father:"m21",status:"0",display_name:"sister"},{name:"Vha",sex:"M",mother:"f21",father:"m21",status:"0",display_name:"brother"},{name:"Spj",sex:"M",mother:"f21",father:"m21",noparents:!0,status:"0",display_name:"partner"},f,{name:"zhk",sex:"F",mother:"ch1",father:"Spj",status:"0",display_name:"daughter"},{name:"Knx",display_name:"son",sex:"M",mother:"ch1",father:"Spj",status:"0"},{name:"uuc",display_name:"maternal aunt",sex:"F",mother:"dOH",father:"zwB",status:"0"},{name:"xIw",display_name:"maternal uncle",sex:"M",mother:"dOH",father:"zwB",status:"0"}]:g.length>0&&"extended1"==g.val()?a.dataset=[{name:"m21",sex:"M",mother:null,father:null,status:"0",display_name:"father",noparents:!0},{name:"f21",sex:"F",mother:null,father:null,status:"0",display_name:"mother",noparents:!0},{name:"aOH",sex:"F",mother:"f21",father:"m21",status:"0",display_name:"sister"},{name:"Vha",sex:"M",mother:"f21",father:"m21",status:"0",display_name:"brother"},{name:"Spj",sex:"M",mother:"f21",father:"m21",noparents:!0,status:"0",display_name:"partner"},f,{name:"zhk",sex:"F",mother:"ch1",father:"Spj",status:"0",display_name:"daughter"},{name:"Knx",display_name:"son",sex:"M",mother:"ch1",father:"Spj",status:"0"}]:a.dataset=[{name:"m21",display_name:"father",sex:"M",top_level:!0},{name:"f21",display_name:"mother",sex:"F",top_level:!0},f],ptree.rebuild(a)},a.updateButtons=function(a){var c=pedcache.get_count(a),d=pedcache.nstore(a),e="#"+a.btn_target;d<=c?b(e+" .fa-repeat").addClass("disabled"):b(e+" .fa-repeat").removeClass("disabled"),c>1?b(e+" .fa-undo").removeClass("disabled"):b(e+" .fa-undo").addClass("disabled")}}(window.pbuttons=window.pbuttons||{},jQuery),function(a,b,c){function d(a){try{if("array"===a.store_type)return!1;if("local"!==a.store_type&&"session"!==a.store_type&&a.store_type!==c)return!1;var b="test";return localStorage.setItem(b,b),localStorage.removeItem(b),!0}catch(a){return!1}}function e(a){return"PEDIGREE_"+a.btn_target+"_"}function f(a){return l[e(a)]}function g(a,b){return"local"===a.store_type?localStorage.getItem(b):sessionStorage.getItem(b)}function h(a,b,c){return"local"===a.store_type?localStorage.setItem(b,c):sessionStorage.setItem(b,c)}function i(a){return"local"===a.store_type?localStorage.clear():sessionStorage.clear()}function j(a,b){d(a)?h(a,e(a)+"COUNT",b):l[e(a)+"COUNT"]=b}var k=25,l={};a.clear_pedigree_data=function(a){for(var b=e(a),c="local"===a.store_type?localStorage:sessionStorage,d=[],f=0;f0?f(a).length:-1;for(var b=k;b>0;b--)if(null!==g(a,e(a)+(b-1)))return b;return-1},a.current=function(b){var c=a.get_count(b)-1;return-1==c&&(c=k),d(b)?JSON.parse(g(b,e(b)+c)):f(b)?JSON.parse(f(b)[c]):void 0},a.last=function(a){if(d(a))for(var b=k;b>0;b--){var h=g(a,e(a)+(b-1));if(null!==h)return j(a,b),JSON.parse(h)}else{var i=f(a);if(i)return JSON.parse(i(i.length-1))}return c},a.previous=function(b,h){if(h===c&&(h=a.get_count(b)-2),h<0){var i=a.nstore(b);h=i=k&&(h=0),j(b,parseInt(h)+1),d(b)?JSON.parse(g(b,e(b)+h)):JSON.parse(f(b)[h])},a.clear=function(a){d(a)&&i(a),l={}},a.setposition=function(a,b,c,f){d(a)&&(h(a,e(a)+"_X",b),h(a,e(a)+"_Y",c),f&&h(a,e(a)+"_ZOOM",f))},a.getposition=function(a){if(!d(a)||null===localStorage.getItem(e(a)+"_X")&&null===sessionStorage.getItem(e(a)+"_X"))return[null,null];var b=[parseInt(g(a,e(a)+"_X")),parseInt(g(a,e(a)+"_Y"))];return null!==g(e(a)+"_ZOOM")&&b.push(parseFloat(g(a,e(a)+"_ZOOM"))),b}}(window.pedcache=window.pedcache||{},jQuery),function(a,b,c){function d(a){function b(a){d3.event.sourceEvent.stopPropagation(),h=i,d3.selectAll(".line_drag_selection").attr("stroke","darkred")}function d(b){if(i&&h.data.name!==i.data.name&&h.data.sex!==i.data.sex){var d={name:ptree.makeid(4),sex:"U",mother:"F"===h.data.sex?h.data.name:i.data.name,father:"F"===h.data.sex?i.data.name:h.data.name};newdataset=ptree.copy_dataset(a.dataset),a.dataset=newdataset;var f=pedigree_util.getIdxByName(a.dataset,h.data.name)+1;a.dataset.splice(f,0,d),ptree.rebuild(a)}e(0,0,0,0),d3.selectAll(".line_drag_selection").attr("stroke","black"),h=c}function f(b){d3.event.sourceEvent.stopPropagation();var c=d3.event.dx,d=d3.event.dy,f=parseFloat(d3.select(this).attr("x2"))+c,g=parseFloat(d3.select(this).attr("y2"))+d;e(a.symbol_size-10,0,f,g)}d3.select(".diagram").append("line").attr("class","line_drag_selection").attr("stroke-width",6).style("stroke-dasharray","2, 1").attr("stroke","black").call(d3.drag().on("start",b).on("drag",f).on("end",d)).append("svg:title").text("drag to create consanguineous partners"),e(0,0,0,0)}function e(a,b,c,d,e){e&&d3.selectAll(".line_drag_selection").attr("transform","translate("+e+")"),d3.selectAll(".line_drag_selection").attr("x1",a).attr("y1",b).attr("x2",c).attr("y2",d)}function f(a){return a.charAt(0).toUpperCase()+a.slice(1)}function g(a,d){b("#node_properties").dialog({autoOpen:!1,title:d.data.display_name,width:b(window).width()>400?450:b(window).width()-30});var e="";e+="Unique ID ",e+="Name ",e+="Age ",e+="Year Of Birth ",e+=' Male Female Unknown ',e+=' Alive Deceased ",b("#id_status input[value='"+d.data.status+"']").prop("checked",!0);var g=["adopted_in","adopted_out","miscarriage","stillbirth","termination"];e+='Reproduction: ',e+='';for(var h=0;h '),e+=' "+f(i.replace("_"," "))+" "}e+=" ";var j=["children","name","parent_node","top_level","id","noparents","level","age","sex","status","display_name","mother","father","yob","mztwin","dztwin"];b.merge(j,g),e+='Age of Diagnosis: ',b.each(a.diseases,function(b,g){j.push(g.type+"_diagnosis_age");var h=' ',i=d.data[g.type+"_diagnosis_age"];e+=""+f(g.type.replace("_"," "))+h+" "}),e+=' ',b.each(d.data,function(a,c){if(-1==b.inArray(a,j)){var d=f(a);!0===c||!1===c?e+=""+d+" ":a.length>0&&(e+=""+d+" ")}}),e+="
",b("#node_properties").html(e),b("#node_properties").dialog("open"),b("#node_properties input[type=radio], #node_properties input[type=checkbox], #node_properties input[type=text], #node_properties input[type=number]").change(function(){pedigree_form.save(a)}),pedigree_form.update(a)}var h,i;a.addWidgets=function(a,f){var j=parseInt(b("body").css("font-size")),k=d3.select(".diagram");k.append("rect").attr("class","popup_selection").attr("rx",6).attr("ry",6).attr("transform","translate(-1000,-100)").style("opacity",0).attr("width",7.9*j).attr("height",2*j).style("stroke","darkgrey").attr("fill","white");var l=k.append("text").attr("font-family","FontAwesome").style("opacity",0).attr("font-size","1.em").attr("class","popup_selection fa-lg fa-square persontype").attr("transform","translate(-1000,-100)").attr("x",j/3).attr("y",1.5*j).text(" "),m=l.append("svg:title").text("add male"),n=k.append("text").attr("font-family","FontAwesome").style("opacity",0).attr("font-size","1.em").attr("class","popup_selection fa-lg fa-circle persontype").attr("transform","translate(-1000,-100)").attr("x",1.7*j).attr("y",1.5*j).text(" "),o=n.append("svg:title").text("add female"),p=k.append("text").attr("font-family","FontAwesome").style("opacity",0).attr("font-size","1.em").attr("transform","translate(-1000,-100)").attr("class","popup_selection fa-lg fa-unspecified popup_selection_rotate45 persontype").text(" "),q=(p.append("svg:title").text("add unspecified"),k.append("text").attr("font-family","FontAwesome").style("opacity",0).attr("transform","translate(-1000,-100)").attr("class","popup_selection fa-2x fa-angle-up persontype dztwin").attr("x",4.6*j).attr("y",1.5*j).text(" ")),r=(q.append("svg:title").text("add dizygotic/fraternal twins"),k.append("text").attr("font-family","FontAwesome").style("opacity",0).attr("transform","translate(-1000,-100)").attr("class","popup_selection fa-2x fa-caret-up persontype mztwin").attr("x",6.2*j).attr("y",1.5*j).text("")),s=(r.append("svg:title").text("add monozygotic/identical twins"),{});d3.selectAll(".persontype").on("click",function(){var b,c,d=ptree.copy_dataset(pedcache.current(a)),e=d3.select(this).classed("mztwin"),f=d3.select(this).classed("dztwin");if(e||f?(c=s.node.datum().data.sex,b=e?"mztwin":"dztwin"):c=d3.select(this).classed("fa-square")?"M":d3.select(this).classed("fa-circle")?"F":"U","addsibling"===s.type)ptree.addsibling(d,s.node.datum().data,c,!1,b);else{if("addchild"!==s.type)return;ptree.addchild(d,s.node.datum().data,b?"U":c,b?2:1,b)}a.dataset=d,ptree.rebuild(a),d3.selectAll(".popup_selection").style("opacity",0),s={}}).on("mouseover",function(){s.node&&s.node.select("rect").style("opacity",.2),d3.selectAll(".popup_selection").style("opacity",1),"addsibling"===s.type?d3.select(this).classed("fa-square")?m.text("add brother"):o.text("add sister"):"addchild"===s.type&&(d3.select(this).classed("fa-square")?m.text("add son"):o.text("add daughter"))}),d3.selectAll(".popup_selection").on("mouseout",function(){s.node!==c&&-1==A.indexOf(s.node.datum())&&s.node.select("rect").style("opacity",0),d3.selectAll(".popup_selection").style("opacity",0)}),d(a),f.append("rect").filter(function(b){return!(b.data.hidden&&!a.DEBUG)}).attr("class","indi_rect").attr("rx",6).attr("ry",6).attr("x",function(b){return-.75*a.symbol_size}).attr("y",function(b){return-a.symbol_size}).attr("width",1.5*a.symbol_size+"px").attr("height",2*a.symbol_size+"px").style("stroke","black").style("stroke-width",.7).style("opacity",0).attr("fill","lightgrey");var t=function(b){return v-.75*a.symbol_size},u=a.symbol_size-2,v=0,w={addchild:{text:"",title:"add child",fx:t,fy:u},addsibling:{text:"",title:"add sibling",fx:t,fy:u},addpartner:{text:"",title:"add partner",fx:t,fy:u},addparents:{text:"",title:"add parents",fx:-.75*a.symbol_size,fy:11-a.symbol_size},delete:{text:"X",title:"delete",fx:a.symbol_size/2-1,fy:12-a.symbol_size,styles:{"font-weight":"bold",fill:"darkred","font-family":"monospace"}}};a.edit&&(w.settings={text:"",title:"settings",fx:-j/2+2,fy:11-a.symbol_size});for(var x in w){var y=f.append("text").filter(function(b){return!(b.data.hidden&&!a.DEBUG||(b.data.mother===c||b.data.noparents)&&"addsibling"===x||b.data.parent_node!==c&&b.data.parent_node.length>1&&"addpartner"===x||b.data.parent_node===c&&"addchild"===x||b.data.noparents===c&&b.data.top_level===c&&"addparents"===x)}).attr("class",x).style("opacity",0).attr("font-family","FontAwesome").attr("xx",function(a){return a.x}).attr("yy",function(a){return a.y}).attr("x",w[x].fx).attr("y",w[x].fy).attr("font-size","0.9em").text(w[x].text);if("styles"in w[x])for(var z in w[x].styles)y.attr(z,w[x].styles[z]);y.append("svg:title").text(w[x].title),v+=17}d3.selectAll(".addsibling, .addchild").on("mouseover",function(){var a=d3.select(this).attr("class");d3.selectAll(".popup_selection").style("opacity",1),s={node:d3.select(this.parentNode),type:a};var b=parseInt(d3.select(this).attr("xx"))+parseInt(d3.select(this).attr("x")),c=parseInt(d3.select(this).attr("yy"))+parseInt(d3.select(this).attr("y"));d3.selectAll(".popup_selection").attr("transform","translate("+b+","+(c+2)+")"),d3.selectAll(".popup_selection_rotate45").attr("transform","translate("+(b+3*j)+","+(c+1.2*j)+") rotate(45)")}),d3.selectAll(".addchild, .addpartner, .addparents, .delete, .settings").on("click",function(){function c(a,b){a.dataset=b,ptree.rebuild(a)}d3.event.stopPropagation();var d=d3.select(this).attr("class"),e=d3.select(this.parentNode).datum();a.DEBUG&&console.log(d);var f;"settings"===d?"function"==typeof a.edit?a.edit(a,e):g(a,e):"delete"===d?(f=ptree.copy_dataset(pedcache.current(a)),ptree.delete_node_dataset(f,e.data,a,c)):"addparents"===d?(f=ptree.copy_dataset(pedcache.current(a)),a.dataset=f,ptree.addparents(a,f,e.data.name),ptree.rebuild(a)):"addpartner"===d&&(f=ptree.copy_dataset(pedcache.current(a)),ptree.addpartner(a,f,e.data.name),a.dataset=f,ptree.rebuild(a)),b(document).trigger("fhChange",[a])});var A=[];f.filter(function(a){return!a.data.hidden}).on("click",function(b){d3.event.ctrlKey?-1==A.indexOf(b)?A.push(b):A.splice(A.indexOf(b),1):A=[b],"nodeclick"in a&&(a.nodeclick(b.data),d3.selectAll(".indi_rect").style("opacity",0),d3.selectAll(".indi_rect").filter(function(a){return-1!=A.indexOf(a)}).style("opacity",.5))}).on("mouseover",function(b){if(d3.event.stopPropagation(),i=b,h)return void(h.data.name!==i.data.name&&h.data.sex!==i.data.sex&&d3.select(this).select("rect").style("opacity",.2));d3.select(this).select("rect").style("opacity",.2),d3.select(this).selectAll(".addchild, .addsibling, .addpartner, .addparents, .delete, .settings").style("opacity",1),d3.select(this).selectAll(".indi_details").style("opacity",0),e(a.symbol_size-10,0,a.symbol_size-2,0,b.x+","+(b.y+2))}).on("mouseout",function(b){h||(d3.select(this).selectAll(".addchild, .addsibling, .addpartner, .addparents, .delete, .settings").style("opacity",0),-1==A.indexOf(b)&&d3.select(this).select("rect").style("opacity",0),d3.select(this).selectAll(".indi_details").style("opacity",1),d3.mouse(this)[1]<.8*a.symbol_size&&d3.selectAll(".popup_selection").style("opacity",0),h||(Math.abs(d3.mouse(this)[1])>.25*a.symbol_size||Math.abs(d3.mouse(this)[1])<-.25*a.symbol_size||d3.mouse(this)[0]<.2*a.symbol_size)&&e(0,0,0,0))})}}(window.widgets=window.widgets||{},jQuery);
//# sourceMappingURL=pedigreejs.min.js.map
\ No newline at end of file