From f5ef7ef3863516af7891b760c2307d352ae5d7d8 Mon Sep 17 00:00:00 2001 From: nglk Date: Tue, 27 Oct 2020 15:04:38 +0100 Subject: [PATCH] tryout to automate stop events on popups --- static/js/d3_map.js | 46 +++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/static/js/d3_map.js b/static/js/d3_map.js index 440dbe6..6071a8d 100644 --- a/static/js/d3_map.js +++ b/static/js/d3_map.js @@ -28,7 +28,7 @@ d3.json("/static/js/group1.json", function(error, json) { var node = svg.selectAll(".node") .data(json.nodes) - .enter().append("g") + .enter().append("g") .attr("class", "node ") // .node()classList.add(function(d){return d.group}); .attr("id", function(d){return d.id}) @@ -38,6 +38,12 @@ d3.json("/static/js/group1.json", function(error, json) { }) .call(force.drag); + d3.select("body").on("click",function(i){ + stop(i.id); + }); + + + node.append("image") .attr("xlink:href", "/static/images/squig2.png") .attr("x", -8) @@ -116,21 +122,33 @@ function popup(name,time) { //stop events when clicking somewhere else +// $(document).click(function (e) { +// if (!$(e.target).parents().andSelf().is('#dadaloglu')) { +// $("#showdadaloglu").fadeOut(); +// $("#audiodadaloglu").trigger('pause'); +// var textdada = document.getElementById("textdadaloglu"); +// textdada.classList.remove("active"); +// }; +// if (!$(e.target).parents().andSelf().is('#asikA')) { +// $("#showasikA").fadeOut(); +// $("#audioasikA").trigger('pause'); +// var textmuh = document.getElementById("textasikA"); +// textmuh.classList.remove("active"); +// }; +// +// }); + +function stop(name) { $(document).click(function (e) { - if (!$(e.target).parents().andSelf().is('#dadaloglu')) { - $("#showdadaloglu").fadeOut(); - $("#audiodadaloglu").trigger('pause'); - var textdada = document.getElementById("textdadaloglu"); + if (!$(e.target).parents().andSelf().is('#'+ name)) { + $("#show"+name).fadeOut(); + $("#audio"+name).trigger('pause'); + var textdada = document.getElementById("text"+name); textdada.classList.remove("active"); }; - if (!$(e.target).parents().andSelf().is('#asikA')) { - $("#showasikA").fadeOut(); - $("#audioasikA").trigger('pause'); - var textmuh = document.getElementById("textasikA"); - textmuh.classList.remove("active"); - }; - }); +}; - -}); +// +// +// });